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:Simon Peyton-Jones (simo@microsoft.com)
Date:Oct 13, 2005 9:23:38 am
List:org.haskell.haskell

John

Replying just to you to avoid spamming everyone.

| in particular, | | (CD a) => a and (C a,D a) => a are distinct types. this means that | you cannot use the aliases as abreviations or alternate names, which is | a very nice side effect. with fine grained class hierarchies, type | signatures get big fast. having a shorthand is very nice.

I don't agree. What do you mean by "distinct types"? In H98 both of these are ok:

f :: CD a => ty f = ...code...

g :: (C a, D a) => ty g = f and f :: (C a, D a) => ty f = ...code...

g :: (CD a) => ty g = f

That is, the two types are interchangeable.

| Another illustrative example is one that combines aliases with | superclasses. | | class alias Num a = Show a => (Additive a, Multiplicative a) | | now, Show is a superclass, but Num is an alias for Additive and | Multiplicative.

Yes, this part really confused me. I didn't understand what it meant. Here's my attempt to summarise what I think you are proposing. (This summary might be useful to add to your note.)

(1a) If I have f :: Num a => ... then I can use any of the class ops of Show, Additive, Multiplicative in the body of f.

(1b) Dually, a call of f can be satisfied if (Show, Additive, Multiplicative) are all available (or Num of course).

(2a) I can declare an instance of Num * either by giving separate instances for Show, Additive, Multiplicative; * or by giving a separate instance for Show, and an instance for Num itself

(2b) If a type T is an instance of Additive, then it's an error to also give a Num instance, even if the instance only gives the methods for Multiplicative.

(3) In the class decl for Num I can override the default methods for Additive, Multiplicative. These new default methods will be used (only) if I give an instance decl for Num.

Here, (1a,b) are satisfied by H98 superclasses, whereas (2a) and (3) are not. Are there any points I've missed in this list?

Simon