fmap seems oddly named because no "mapping" takes place, except in the fourth
example, where the map is "passed in." Just sayin'.
Michael
1)
Prelude Control.Monad Control.Applicative> fmap (++ "abc") getLine
xyz
"xyzabc"
2)
Prelude Control.Monad Control.Applicative Data.Char Data.String> fmap (splitAt
3) getLine
qwertyuio
("qwe","rtyuio")
3)
Prelude Control.Monad Control.Applicative Data.Char> fmap toUpper getLine
<interactive>:1:13:
Couldn't match expected type `Char' against inferred type `[Char]'
Expected type: IO Char
Inferred type: IO String
In the second argument of `fmap', namely `getLine'
In the expression: fmap toUpper getLine
4)
Prelude Control.Monad Control.Applicative Data.Char Data.String> fmap (map
toUpper) getLine
qwertyuio
"QWERTYUIO"
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe