Hacker News new | past | comments | ask | show | jobs | submit login

I think an easier to understand definition uses fmap and join. Example:

    f x = [x, x*2]

    f =<< [5, 3, 4]
    join (fmap f [5, 3, 4])
    join ([[5, 10], [3, 6], [4, 8]])
    [5, 10, 3, 6, 4, 8]
So the pattern is fmap a function `a -> f b`; this leaves us with `f (f b)` so we flatten. You might notice that we could bind as often as we want since we always get a list of integers!



I think if you already know fmap, join and Haskell syntax, you also already know monads, so I'm not sure whom this is easier for :P




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: