module Main where data Position t = Position t deriving (Show) stagger (Position d) = Position (d + 2) crawl (Position d) = Position (d + 1) rtn x = x x >>== f = f x treasureMap pos = pos >>== stagger >>== stagger >>== crawl >>== rtn

The function treasureMap uses the monad without syntactic sugar. I think I understand it, and it's a lot less magical than I was expecting. >>== is an operator that lets me pipe functions together via currying. (Please correct me if I am wrong.)

Next the book explains there is the "do" notation that adds syntactic sugar to monads, and it gives an example using IO. This doesn't satisfy me because I can't see how the sugar relates to the core syntax. To help me get to the bottom of it, I'm trying to rewrite the treadureMap function to use the "do" syntax. This is the best I have come up with.

treasureMap2 pos = do let { x = stagger pos } ; let { y = stagger x } ; let { z = crawl y } ; rtn z

This seems considerably worse than the first incarnation. In fact, it is considerably worse than the equivalent monad-free implementation:

treasureMap3 pos = let x = stagger pos y = stagger x z = crawl y in z

Any help or advice would be very much appreciated.