[Haskell-cafe] Why the reluctance to introduce the Functor requirement on Monad?

Sebastien Zany sebastien at chaoticresearch.com
Mon Jul 25 05:50:57 CEST 2011


I was thinking the reverse. We can already give default implementations of class operations that can be overridden by giving them explicitly when we declare instances, so why shouldn't we be able to give default implementations of operations of more general classes, which could be overridden by a separate instance declaration for these?

Then I could say something like "a monad is also automatically a functor with fmap by default given by..." and if I wanted to give a more efficient fmap for a particular monad I would just instantiate it as a functor explicitly.


On Jul 23, 2011, at 3:19 PM, Ivan Lazar Miljenovic <ivan.miljenovic at gmail.com> wrote:

> On 24 July 2011 00:49, Sebastien Zany <sebastien at chaoticresearch.com> wrote:
>> Would it be theoretically possible/convenient to be able to put boilerplate
>> like this in class definitions?
> 
> Not really: what happens for Functors that aren't Monads?  Also, for
> some Monads there may be a more efficient definition of fmap than
> using liftM, so even an automatic reverse instance wouldn't always be
> wanted.
> 
> -- 
> Ivan Lazar Miljenovic
> Ivan.Miljenovic at gmail.com
> IvanMiljenovic.wordpress.com



More information about the Haskell-Cafe mailing list