In a comment to one of my answers, SO user sdcwc essentially pointed out that the following code:

comb 0 = [[]]

comb n =
    let rest = comb (n-1)
    in  map ('0':) rest
     ++ map ('1':) rest

could be replaced by:

comb n = replicateM n "01"

which had me completely stunned.

Now I am looking for a tutorial, book or PDF that teaches these advanced concepts. I am not looking for a "what's a monad" tutorial aimed at beginners or online references explaining the type of replicateM. I want to learn how to think in monads and use them effectively, monadic "patterns" if you will.

Edit
Report