[Haskell-beginners] fmap Maybe
Shishir Srivastava
shishir.srivastava at gmail.com
Mon Apr 27 10:02:01 UTC 2015
Hi,
Please can someone explain why these two expression behave differently -
----
fmap (\x -> x) Just 2
Just 2
-----
fmap (\x -> x+2) Just 2
*No instance for (Num (Maybe a0)) arising from a use of `it'*
*In a stmt of an interactive GHCi command: print it*
----
The first expression evaluates fine whereas the second one fails. However
if I do -
----
fmap (\x -> x+2) $ Just 2
Just 4
----
Then the second expression also returns the Maybe value. Why is $ needed in
second expression but not in the first one ?
Thanks,
Shishir
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/beginners/attachments/20150427/d79e46f6/attachment-0001.html>
More information about the Beginners
mailing list