pure :: a -> List a flatten :: List (List a) -> List a map :: (a -> b) -> List a -> List b
For lists, the implementation is as follows:
pure x = [x] flatten [] = [] flatten (x:xs) = x ++ flatten xs map f [] = [] map f (x:xs) = f x : map f xs
flatMap f m = flatten (map f m)
m >>= f = flatMap f m
For lists, the implementation is as follows:
A flatMap method can be defined once for all monads: This method is sometimes called "bind" and is written ">>=" in Haskell (where pure is also called "return" and flatten is also called "join"): The methods are related by the monad laws - you can look them up if you're interested, but they're not required to gain an intuition.