[Haskell] PROPOSAL: class aliases

John Meacham john at repetae.net
Thu Oct 13 18:40:32 EDT 2005

On Thu, Oct 13, 2005 at 10:18:24AM -0400, Jan-Willem Maessen wrote:
> >* incidental but not earth-shattering benefits include being able to
> >  declare an instance for a class and all its superclasses at once,
> >  smarter defaults when you are combining related classes, and much
> >  nicer type signatures by being able to create your own aliases for
> >  common combinations of classes.
> >
> It seems to me this is a simpler extension here which might serve at  
> least as a conceptual stepping-stone to full class aliases---the  
> ability to declare an instance for a class and all its superclasses  
> at once.  Given that ability, class aliases actually look like a  
> relatively simple extension.

Yeah, see my response to SPJ for why this doesn't quite solve all the
problems mentioned.

the gist of the main one is how do you control which instances you are
creating? surely you don't want someone declaring an instance of Num to
fill in Eq and Show with defaults (bottom and a different kind of bottom
respectivly), but there are often cases where you _do_ want the
defaults. if you only have it fill in non-existing instances then
importing a module could silently change the behavior of code as it
might bring in an instance for something you wanted to use the default
methods for. All in all, it seems like a can of worms and implementing
full class aliases is of roughly the same amount of work.

there are a few other issues mentioned in my other reply.

> One final thing which would be nice is the ability to define  
> instances of superclass methods in a subclass declaration.  But this  
> takes things in a different direction entirely.

I am not sure what you mean by this?

John Meacham - ⑆repetae.net⑆john⑈ 

More information about the Haskell mailing list