Proposal: Applicative => Monad: Call for consensus

Jan Behrens public at
Fri Jan 28 15:13:44 CET 2011

On Sunday 02 January 2011 13:04:30 you wrote:
> The patches attached to
> make Applicative a superclass of Monad. Default definitions are provided
> for backwards compatibility.

I looked at the Prelude of the referenced documentation in the ticket:

Would it be useful to include liftM and ap in the Prelude, so that you can use 
it as a default implementation for fmap, when defining Functor instances?

Then you can write...

instance Functor Something where
  fmap = liftM

instance Applicative Something where
  pure x = ...
  (<*>)  = ap

instance Monad Something where
  (>>=) = ...

This way you don't need to write explicit implementations of fmap and <*> for 
every monad you define.

An alternative name for liftM would be fmapMonad...

There is a similar approach in Data.Traversable:

fmapDefault :: Traversable t => (a -> b) -> t a -> t b

However as Functor, Applicative and Monad are part of the Prelude, it might be 
useful, to include a default implementation for fmap in the Prelude.


More information about the Libraries mailing list