September 2018
Intermediate to advanced
398 pages
9h 43m
English
Monad is a subclass of Applicative. It declares an additional function, flatMap, as follows:
@typeclass trait Monad[F[_]] extends FlatMap[F] with Applicative[F]@typeclass trait FlatMap[F[_]] extends Apply[F] { def flatMap[A, B](fa: F[A])(f: A => F[B]): F[B] }
This signature tells us that in order to produce F[B], flatMap will somehow have to extract A inside fa: F[A], and then call the function, f.
Previously, you saw that Applicative and mapN allow us to process several F[A] values in parallel, and combine them into a single F[B]. What Monad adds is the capability of processing F[] values in sequence: flatMap must process the F effect first, then call the f function.
Similar to Functor and map, many classes of the SDK already ...
Read now
Unlock full access