$30 off During Our Annual Pro Sale. View Details »

A sighting of sequence function in Practical FP in Scala

A sighting of sequence function in Practical FP in Scala

Philip Schwarz
PRO

September 24, 2023
Tweet

More Decks by Philip Schwarz

Other Decks in Programming

Transcript

  1. sequence
    a sighting of
    in
    @philip_schwarz
    slides by http://fpilluminated.com/
    by

    View Slide

  2. View Slide

  3. ^⇧P Type Info
    ^⇧P Type Info

    View Slide

  4. @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

    View Slide