Hacker News new | ask | show | jobs
by stuffihavemade 4847 days ago
What do each of these equal?

  1) Just 1 >>= \_ -> Just 2

  2) Just 1 >>= \_ -> Nothing

  3) Just 1 >>= \_ -> Nothing >>= \_ -> Just 2

  4) Just 1 >>= \x -> Just(x+1)

  5) Nothing >>= \x -> Just(x+1)

  6) Just 1 >>= \x -> Just(x+1) >>= \x -> Just(x+1)

  7) Just 1 >>= \x -> Just(x+1) >>= \y -> Just(x)
If you can answer all of those correctly, you should have a decent understanding of monads.

answers:

  1) Just 2

  2) Nothing

  3) Nothing

  4) Just 2

  5) Nothing

  6) Just 3

  7) Just 1