<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;">fmap seems oddly named because no "mapping" takes place, except in the fourth example, where the map is "passed in." Just sayin'.<br><br>Michael<br><br>1)<br>Prelude Control.Monad Control.Applicative> fmap (++ "abc") getLine<br>xyz<br>"xyzabc"<br><br>2)<br>Prelude Control.Monad Control.Applicative Data.Char Data.String> fmap (splitAt 3) getLine<br>qwertyuio<br>("qwe","rtyuio")<br><br>3)<br>Prelude Control.Monad Control.Applicative Data.Char> fmap toUpper getLine<br><br><interactive>:1:13:<br> Couldn't match expected type `Char' against inferred type `[Char]'<br> Expected type: IO Char<br> Inferred type: IO String<br> In the second argument of `fmap', namely `getLine'<br> In the expression: fmap toUpper getLine<br><br>4)<br>Prelude
Control.Monad Control.Applicative Data.Char Data.String> fmap (map toUpper) getLine<br>qwertyuio<br>"QWERTYUIO"<br><br><br><br></td></tr></table><br>