[Haskell-beginners] fmap versus bind

Sean Perry shaleh at speakeasy.net
Tue May 3 03:56:31 CEST 2011


i came across hlint today and ran it on my experiments. It pointed out places where I was overly cautious with parens or used a $ and forget to remove it later. But one suggestion it made I was curious about.

Why does it recommend using fmap over >>=? Idiomatically does fmap make more sense when the Monad is more like a collection?

For instance I had "(applyOp op x y) >>= (flip (:) ds)". This seems more clear than "fmap ((:) ds) (applyOp op x y)".


More information about the Beginners mailing list