
23 Feb
2008
23 Feb
'08
11:45 a.m.
2008/2/23, Harri Kiiskinen
Dear All,
banging my head against Haskell, but liking the feeling of hurting brains. Just a simple question:
If
fmap (^4) [1,2,3] >>= \i -> shows i " "
gives
"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. Whereas in
let xs = fmap (^4) [1,2,3] in shows xs " " shows is applied to the whole list.
-- Jedaï