[Haskell] The FunctorM library

Keean Schupke k.schupke at imperial.ac.uk
Thu Mar 24 06:09:19 EST 2005

Why not just have the new definition with a different import path, so 
that legacy code continues to do:

import Control.Monad

And new code could do:

import Control.Category.Monad (or something)

And we could take this opportunity to incorporate premonads...

class Functor f -- defines fmap
class Functor p => Premonad p -- defines return
class Premonad m = Monad m -- defines bind


Simon Peyton-Jones wrote:

>| > Yes, I think this should be fixed, and perhaps it could be done in a
>| > backward compatible way? If classes were allowed to declare default
>| > methods for superclasses, then you could have
>| >
>| >     class Functor f where fmap :: ...
>| >     class Functor m => Monad m where
>| >        ...the usual stuff...
>| >        fmap = liftM
>| >
>| > Then declaring
>| >
>| >     instance Monad T where ...
>| >
>| > for some T, would implicitly introduce an instance Functor T, if it
>| > not defined explicitly...
>It seems overkill to have a whole new language feature to deal with one
>library issue.  It would take a bit of implementing too, and it's not
>clear to me what the specification is.  For example, what if Functor T
>*is* defined explicitly, but in a later module?
>The idea comes up very occasionally, but I wouldn't say it's been a hot
>Haskell mailing list
>Haskell at haskell.org

More information about the Haskell mailing list