[Haskell-cafe] A beginners question
chaddai.fouche at gmail.com
Sat Feb 23 11:45:05 EST 2008
2008/2/23, Harri Kiiskinen <harkiisk at utu.fi>:
> Dear All,
> banging my head against Haskell, but liking the feeling of hurting
> brains. Just a simple question:
> fmap (^4) [1,2,3] >>= \i -> shows i " "
> "1 16 81 "
In the List Monad, (>>=) is defined as concatMap, so this code can be
translated by :
> concatMap (\i -> shows i " ") (fmap (^4) [1,2,3])
shows is applied to each elements of the list, then the strings are concatened.
> let xs = fmap (^4) [1,2,3] in shows xs " "
shows is applied to the whole list.
More information about the Haskell-Cafe