[Haskell-cafe] fmap vs. liftM
miguelimo38 at yandex.ru
Mon Feb 4 12:55:50 EST 2008
> Problem is that from the idea Functor is a superclass of Monad, with
> property that "fmap == liftM".
> The second relation can even not be expressed in Haskell 98.
class Functor f where
fmap :: (a -> b) -> f a -> f b
class Functor m => Monad m where
return :: a -> m a
join :: m (m a) -> m a
bind :: Monad m => m a -> (a -> m b) -> m b
bind mx f = join $ fmap f mx
Now liftM must be exactly equal to fmap.
More information about the Haskell-Cafe