Chain effects with Haskell Functor, Applicative and Monad

8 steps · about 3 h 8 min · Intermediate

  1. Map over values in a context with fmap and <*> (tutorial, Learn You a Haskell, 40 min)

    Builds intuition for Functor and Applicative with Maybe, lists and IO.

  2. Chain failing steps with >>= on Maybe (tutorial, Learn You a Haskell, 35 min)

    The tightrope-walker example shows why bind removes nested checks.

  3. Combine independent effects with Applicative style (tutorial, Wikibooks, 25 min)

    Shows when <*> is enough and you do not need a monad.

  4. Understand the Monad class and its laws (tutorial, Wikibooks, 25 min)

    Defines return and >>= and why the laws matter.

  5. Rewrite bind chains with do notation (tutorial, Wikibooks, 15 min)

    Translates do blocks to >>= so you know what you are writing.

  6. See how the classes relate in the Typeclassopedia (article, HaskellWiki, 30 min)

    Maps Functor, Applicative, Monad and their laws in one place.

  7. Look up <$>, <$ and void (reference, Hackage (base), 8 min)

    The Functor helpers you will use every day.

  8. Use mapM, when, forM and foldM (reference, Hackage (base), 10 min)

    Ready-made combinators for looping and branching inside a monad.