| > Notice that this part *is* exactly true of a superclass with no
| > methods
| >
| >         class (S a, C1 a, C2 a) => A a where {}
|
| No, this isn't true. imagine
|
| > f :: (S a, C1 a, C2 a) => a -> Int
| > f x = g x
|
| > g :: A a => a -> Int
| > g x = ....
|
| If A is a class alias, then this compiles just fine, if A is a
| concrete class with superclasses, then it doesn't necessarily.

Excellent point.  I'll think about that -- meanwhile can you describe this 
difference explicitly in your writeup?

| > =============== Desugaring instanc decls =================
| > | now for instance declarations
| > |
| > | > instance A a where
| > | >         f2 = bf2
| > |
| > | expands to
| > |
| > | > instance (S a) => C1 a where
| > | >         f1 = nd1
| > |
| > | > instance (S a) => C2 a where
| > | >         f2 = bf2
| > | >         f3 = d3
| >
| > Do you really mean that? Presumably 'a' is not a type variable here?
| > Furthermore, instance decls typically have a context.  Unless I have
| > profoundly misunderstood, I think you mean this:
|
| Yeah, a is likely not a type variable, so it will be of form 'S Foo' for
| some concrete type 'Foo'.

Can you give a more general example, like I did, in which we make an instance 
for A (a,b), where there is a type constructor (your Foo) but also type 
variables. Perhpas pairs are confusing; try

        instance ... => A (Foo a b)

That's when the context matters!

| No, the 'S a' as appended to whatever instance context you provide. so
|
| >   instance (Foo a, Bar b) => A (a,b) where f1 = bf1
|
| expands to
|
| >   instance (S (a,b), Foo a, Bar b) => C1 (a,b) where f1 = nd1
| >   instance (S (a,b), Foo a, Bar b) => C2 (a,b) where f2 = bf2 f2 = d3
|
| If 'S (a,b)' is not entailed by the environment in scope then the
| declaration produces an error.

I don't understand why.  To be concrete, what goes wrong if you omit the (S 
(a,b))?

| of Num.  The 'class alias context' vs 'class alias expansion' is there
| to make that distinction clear and unambigous, the expansion is what you
| declare with an instance, the context is a prerequisite for creating an
| instance.

I'm not against making such a distinction -- I'm just trying to understand what 
the distinction is.


OK, this is progress.  Perhaps rather than responding in detail the next step 
is to write the proposal up in the light of where we've got to?

S
_______________________________________________
Haskell-prime mailing list
Haskell-prime@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-prime

Reply via email to