
27 Apr
2015
27 Apr
'15
6:02 a.m.
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