Upgrade to Pro — share decks privately, control downloads, hide ads and more …

A sighting of sequence function in Practical FP in Scala

A sighting of sequence function in Practical FP in Scala

Philip Schwarz

September 24, 2023
Tweet

More Decks by Philip Schwarz

Other Decks in Programming

Transcript

  1. @typeclass trait Traverse[F[_]] extends Functor[F] with Foldable[F] with … …

    Thread all the G effects through the F structure to invert the structure from F[G[A]] to G[F[A]]. def sequence[G[_]: Applicative, A](fga: F[G[A]]): G[F[A]] = traverse(fga)(ga => ga) List[F[Unit]] => F[List[Unit]] case class CartRoutes[F[_]: JsonDecoder: Monad] Applicative Monad Functor Traverse Foldable