atom feed35 messages in org.haskell.haskell[Haskell] PROPOSAL: class aliases
FromSent OnAttachments
John MeachamOct 12, 2005 7:41 pm 
Philippa CowderoyOct 12, 2005 7:55 pm 
John MeachamOct 12, 2005 8:16 pm 
Wolfgang JeltschOct 13, 2005 5:48 am 
John MeachamOct 13, 2005 6:03 am 
Malcolm WallaceOct 13, 2005 6:15 am 
Andres LoehOct 13, 2005 6:23 am 
Malcolm WallaceOct 13, 2005 6:29 am 
John MeachamOct 13, 2005 6:37 am 
John MeachamOct 13, 2005 6:39 am 
Simon Peyton-JonesOct 13, 2005 7:02 am 
Benjamin FranksenOct 13, 2005 7:26 am 
Benjamin FranksenOct 13, 2005 7:33 am 
S.M.KahrsOct 13, 2005 7:37 am 
John MeachamOct 13, 2005 8:32 am 
Simon Peyton-JonesOct 13, 2005 9:23 am 
Udo StenzelOct 13, 2005 9:46 am 
Jan-Willem MaessenOct 13, 2005 9:58 am 
Paul GovereauOct 13, 2005 1:21 pm 
Jacques CaretteOct 13, 2005 1:52 pm 
John MeachamOct 13, 2005 4:45 pm 
John MeachamOct 13, 2005 6:13 pm 
John MeachamOct 13, 2005 6:21 pm 
David MenendezOct 13, 2005 6:49 pm 
John MeachamOct 13, 2005 8:33 pm 
aj...@spamcop.netOct 13, 2005 11:25 pm 
Ashley YakeleyOct 14, 2005 6:20 am 
Ashley YakeleyOct 14, 2005 6:31 am 
Wolfgang JeltschOct 14, 2005 9:46 am 
Wolfgang JeltschOct 14, 2005 11:44 am 
Wolfgang JeltschOct 14, 2005 11:47 am 
Remi TurkOct 14, 2005 2:05 pm 
Udo StenzelOct 15, 2005 6:15 am 
Ross PatersonOct 27, 2005 6:58 am 
Wolfgang JeltschOct 28, 2005 7:05 am 
Subject:[Haskell] PROPOSAL: class aliases
From:David Menendez (zedn@psualum.com)
Date:Oct 13, 2005 6:49:27 pm
List:org.haskell.haskell

Udo Stenzel writes:

Simon Peyton-Jones wrote:

I've considered this before, but never done anything about it because superclasses are so close. Specifically, what is the difference between

(i) class (C a, D a) => CD a and (ii) class alias CD a = (C a, D a)

Note that (i) is Haskell 98.

I was about to suggest almost exactly the same. In particular, John's proposal could be decomposed into three parts:

1. Allow instance declarations to define methods of superclasses. These are simply converted into the appropriate instance declarations for the superclasses.

2. Allow class declarations to give defaults for methods in superclasses. Together with (1) they are used in the obvious way.

3. Allow empty instance declarations to be implicitly generated.

As a nice side effect, (1) and (2) together would allow us to cleanly get rid of the fmap/liftM annoyance:

*> class Functor f where { fmap :: ... } *> class Functor m => Monad m where { fmap = liftM }

This can also get us into trouble. Consider,

class Functor f where fmap :: ... class Functor m => Monad m where { fmap = liftM; ... } class Functor d => Comonad d where { fmap = liftD; ... }

The Id functor is an instance of Monad and Comonad; what happens to the fmap definition?

If the instance for every type were allowed, Foo and Bar would be indistinguishable from true synonyms. Further, if classes with no methods have no use currently, this "universal instance" could be compiler generated whenever a class without methods is declared. Or the empty class may be treated as a synonym, if that's simpler. Does this make any sense?

I don't know that method-less classes have *no* value. You could use them to make additional claims about a type. For example,

class Monoid m where { ... }

class CommutativeMonoid m where {}

The idea being that instances of CommutativeMonoid satisfy additional laws.