[Haskell-cafe] fmap vs. liftM

Felipe Lessa felipe.lessa at gmail.com
Mon Feb 4 09:22:04 EST 2008


Hi there,

Reading http://www.haskell.org/haskellwiki/Things_to_avoid I found an
interesting saying:

"By the way, in the case of IO monad the Functor class method fmap and
the Monad based function liftM are the same."

I always tought that

prop :: (Functor m, Monad m, Eq (m b)) => (a -> b) -> m a -> Bool
prop f x = fmap f x == liftM f x

was True regardless of 'm'. Is there any exception? If so, why? I've
even done s/fmap/liftM/g and s/liftM/fmap/g in the past for
consistency =).

Thanks!

-- 
Felipe.


More information about the Haskell-Cafe mailing list