streaming-bytestring
has been undergoing some updates lately, and we’re wondering about the deeper difference between liftM
and fmap
(for IO
, in this case).
Here are the relevant definitions:
instance Functor IO where
fmap f x = x >>= (pure . f)
instance Monad IO where
{-# INLINE (>>) #-}
{-# INLINE (>>=) #-}
(>>) = (*>)
(>>=) = bindIO
liftM :: (Monad m) => (a1 -> r) -> m a1 -> m r
liftM f m1 = do { x1 <- m1; return (f x1) }
hlint
unilaterally suggests that liftM
be replaced with fmap
:
Char8.hs:203:27-31: Warning: Use fmap
Found:
liftM
Perhaps:
fmap
But we’re curious: would there ever be a reason not to?