Sbt 0.13 the scale equivalent of flatMap

I am updating my assembly to use the new macro syntax as far as I can and have come across flatMap , which I do not know how to deal with.

Say I had a task like this

 myTask <<= (foo, bar) flatMap { (x, y) => someFunctionProducingATask(x, y, 5) } 

Now Def.taskDyn looks skeptical promising, but not quite suitable. Translating it to a naive thing does not work:

 myTask <<= Def.taskDyn { val x = foo.value val y = bar.value someFunctionProducingATask(x, y, 5) // ERROR: we need an Initialize[Task[...]], but have a Task[...] } 

Initialize feels monadic, but I can’t find pure for it, so I don’t know how to include my task in it, or even if it is desirable. The docs don't seem to say anything, except that I use taskDyn . Does anyone have any ideas?

+6
source share
1 answer

In most user-oriented documentation, "task" means Initialize[Task[T]] . A "task" , since assemblies and plugins usually use them, are really a setting whose value is the task.

someFunctionProducatATask should return Initialize[Task[T]] .

pure for Initialize - Def.value (accepts => T ) or Def.pure (accepts () => T ).

However, usually use Def.task (for Initialize[Task[T]] ) and Def.setting (for Initialize[T] ). They allow you to use the same syntax as the argument := , += and ++= .

+4
source

Source: https://habr.com/ru/post/950385/


All Articles