class default method proposal
jon.fairbairn at cl.cam.ac.uk
Thu Dec 13 04:48:40 EST 2007
Duncan Coutts <duncan.coutts at worc.ox.ac.uk> writes:
> We all know that Functor should have been a superclass of Monad, and
> indeed we now know that Applicative should be too. Making such a change
> would break lots of things however so the change does not happen.
> However in this case the Monad operations can be used to implement the
> Functor and Applicative class methods. So it would be nice if we could
> get them for free if the author did not choose to write the Functor and
> Applicative instances.
> Does this proposal have any unintended consequences? I'm not sure.
> Please discuss :-)
I started a discussion on these lines on the Haskell prime
mailing list a while ago. Apart from the objections others
have posted, I think just supplying methods a bit
I suggested instead that such defaults should be instance
declarations. It gives much the same effect (and with
similar problems), but makes it clear to which class the
methods being declared belong. If you were to find a middle
ground (say using the syntax I suggest there but with the
interpretation that it supplies default methods for the
superclass, and use Simons suggestion of requiring explicit
empty instance declarations when you want to use them, we
might get somewhere sensible.
Jón Fairbairn Jon.Fairbairn at cl.cam.ac.uk
More information about the Glasgow-haskell-users