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

A sighting of sequence function in Practical FP...

Sponsored · Your Podcast. Everywhere. Effortlessly. Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.

A sighting of sequence function in Practical FP inย Scala

Avatar for Philip Schwarz

Philip Schwarz PRO

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