
On 2006-08-15 at 16:25CDT Taral wrote:
On 8/15/06, Bulat Ziganshin
wrote: in this case we lose "class Functor a => Monad a" base class declaration. so what will be the meaning of this:
I don't see why that is the case.
class Functor m => Monad m where return :: a -> m a (>>=) :: m a -> (a -> m b) -> m b instance Functor m where fmap f = (>>= return . f)
What's wrong with this? All Monads are Functors. If you don't provide a Functor, it gets defined for you. The problem is working out whether to use the default Functor or an external Functor.
It seems obvious to me that we always use an external definition if one exists, so I suppose the problem is knowing whether an external instance exists -- so this proposal would rely on doing something about scoping for instances, I suppose. -- Jón Fairbairn Jon.Fairbairn at cl.cam.ac.uk