
Hi all,
On Mon, May 2, 2011 at 9:56 PM, Sean Perry
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)".
I'm trying to understand this example and I can't get the types to line up. Can you provide the "real" types for ds and (applyOp op x y)? This is what I'm working out: fmap ((:) ds) (applyOp op x y) == fmap (ds :) (applyOp op x y) == fmap (\dss -> ds : dss) (applyOp op x y) (applyOp op x y) >>= (flip (:) ds) == (applyOp op x y) >>= (: ds) == (applyOp op x y) >>= (\d -> d : ds) To my untrained eyes is doesn't even look like the code is doing the same thing... What am I missing here (or more probably where is my mistake)? Patrick
_______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners
-- ===================== Patrick LeBoutillier Rosemère, Québec, Canada