Some types don't have `pure`
What's the order of operations here?
Could be anything
Inherently sequential
What's the order of operations here?
Sequential (left to right)
We'll get to that
Parallel applicatives can't have FlatMap
flatMapValidatedZipListcats.effect.IO.Parcats.Parallel
/**
* Some types that form a FlatMap,
* are also capable of forming an Apply
* that supports parallel composition.
*/
Parallel[M, F]?Monad[M], Applicative[F]How it's used
How it works
How Parallel.parProduct works
M[_] to parallel F[_]product using the Apply[F]M[_]
Two type parameters :(
cats-par"io.chrisdavenport" %% "cats-par" % "0.2.0"
import cats.temp.par._
IO has an instance: Parallel[IO, IO.Par]
Requires implicit cats.effect.ContextShift[IO]
Purely functional Executor
Getting an instance
Usage
Happens only after asynchronous boundaries*, which can be achieved by:
IO.cancelable, IO.async, IO.bracket (!)IO.cancelBoundary or IO.shift* - plus runtime-inserted cancel boundaries every n steps in the run loop (as of 1.1.0)
start
Fiber - pure "green thread"
Unless you're creating async boundaries, the same one all the time
ContextShift/Async/Timer/start/parMapN insert async boundaries
Slides: https://git.io/fp1Ag
Code: https://git.io/fp01Ao
Get in touch