Defaults for superclass methods

Dave Menendez dave at zednenem.com
Fri Apr 14 01:56:56 EDT 2006


John Meacham writes:

> On Tue, Apr 11, 2006 at 11:35:09AM +0100, Simon Marlow wrote:
> > On 11 April 2006 11:08, Ross Paterson wrote:
> > 
> > > On Tue, Apr 11, 2006 at 11:03:22AM +0100, Simon Marlow wrote:
> > >> This is a rather useful extension, and as far as I can tell it
> > >> doesn't have a ticket yet: 
> > >> 
> > >>
http://www.haskell.org//pipermail/libraries/2005-March/003494.html
> > >> 
> > >> should I create a ticket?  Is there any reason it might be hard
> > >> to implement?
> > > 
> > > There are a range of proposals, but none of them are implemented.
> > > Wouldn't that rule them out for Haskell'?
> > 
> > If it's not clear which is the right way to go, then yes I guess
> > that does rule it out.  Could you summarise the proposals?  If
> > there was a clear winner, and it was easy enough to implement,
> > perhaps we can knock up a prototype in time.
> 
> As I recall, this was brought up a few times during the class alias
> discussion and there were good technical reasons why it would be
> tricky to define a sane semantics for it. as in, it's harder than it
> first looks.

The tricky part is dealing with multiple subclasses.

For example,

    class Functor f where
        fmap :: (a -> b) -> f a -> f b
    
    class Functor f => Monad f where
        ...
        fmap = liftM
    
    class Functor f => Comonad f where
        ...
        fmap = liftW
    
    newtype Id a = Id a
    
    instance Functor Id
    instance Monad Id
    instance Comonad Id

Which default gets used for fmap?
-- 
David Menendez <zednenem at psualum.com> | "In this house, we obey the laws
<http://www.eyrie.org/~zednenem>      |        of thermodynamics!"


More information about the Haskell-prime mailing list