<div dir="ltr"><div>Hi, Shishir,</div><div><br></div>It's because Haskell uses juxtaposition for argument passing. So the first case <div><br></div><div>fmap (\x -> x) Just 2</div><div><br></div><div>is equal to</div><div><br></div><div>(fmap (\x -> x) Just) 2</div><div><br></div><div>While</div><div><br></div><div>fmap (\x -> x+2) $ Just 2</div><div><br></div><div>is</div><div><br></div><div>fmap (\x -> x + 2) (Just 2)</div><div><br></div><div>I believe you want the latter.</div><div><br></div><div>Basically, the first example works because ((->) r) is an instance of Functor.</div><div><br></div><div><div>instance Functor ((->) r) where</div><div>    fmap = (.)</div><div><br></div><div>So basically first example is:</div><div>((\x -> x) . Just) 2</div></div><div><br></div><div>Now you should see why it behaves this way.</div><div><br></div><div>Have a nice day!</div><div>Alexey Shmalko</div></div>