With Scalaz Task I make this with scalaz.Nondeterminism.both
:
Nondeterminism[Task]
.both(
Task.now("Hello"),
Task.now("world")
)
or with Nondeterminism[Task].gatherUnordered()
.
How can I do the same thing with fs2 0.9.x version tasks?
I'm assuming you're on fs2 version 0.9.x. To execute several Tasks in parallel, you can simply call
Task.start
. Here's an example from the docs:So in your case it would look like this:
Note that in the future it might be possible to do something like this with much less boilerplate. There's a PR in the works to add a
Parallel
type class, which would allow us to write something like this: