## Monad tutorial, part 2

Building on the foundation of the Identity Decider from Part 1, I first introduce some notation to make a monadic computation look more like a `let`. Then I explain the Maybe monad and what it tells us about how monads are meant to be used. Finally, I show what the Sequence monad does as a teaser for Part 3.

March 10th, 2011 at 6:12 am

Thank you for posting these. It will help when I get to a later chapter in “7 languages in 7 weeks” (in about 6 months’ time…).

I have one remark: I don’t (yet) see why the final domonad example in this session used sequence-m instead of perhaps identity-decider. From the earlier explanation “take the result of a step, assign it do a variable, execute remaining steps” it seems that it indetity-decider would have worked.

What am I missing?

March 10th, 2011 at 6:13 am

…seems identity-decider would have worked.” Sorry.

March 10th, 2011 at 1:50 pm

Identity-decider would pass the whole list to the next step. Sequence-m passes each element separately (so many calls vs. one).

It’s called sequence-m because (as you’ll see), the sequence monad is composed of two functions: a decider function that looks like this:

(concat (map remaining-steps result-of-last-step))

… and a “patcher” function that’s needed to make that work. (I’ll say no more yet!)