Re: [Haskell-cafe] Re: Small displeasure with associated type synonyms

2008-03-07 Thread David Roundy
On Fri, Mar 07, 2008 at 08:07:57AM +0100, Tom Schrijvers wrote: Am I correct in thinking this would have worked if it were an associated type instead of an associated type synonym? ie, class C a where data T a val :: T a Yes, you are. Associate data type constructors (as well as

[Haskell-cafe] Re: Small displeasure with associated type synonyms

2008-03-06 Thread Tom Schrijvers
Stefan, I tried lexically scoped type variables, but to no avail: instance forall a b. (C a, C b) = C (a, b) where type T (a, b) = (T a, T b) val = (val :: T a, val :: T b) The problem is ambiguity. The type checker can't determine which val function to use, i.e. which

[Haskell-cafe] Re: Small displeasure with associated type synonyms

2008-03-06 Thread ChrisK
Tom Schrijvers wrote: Stefan, I tried lexically scoped type variables, but to no avail: instance forall a b. (C a, C b) = C (a, b) where type T (a, b) = (T a, T b) val = (val :: T a, val :: T b) The problem is ambiguity. The type checker can't determine which val function to

Re: [Haskell-cafe] Re: Small displeasure with associated type synonyms

2008-03-06 Thread Tom Schrijvers
I don't see how your example explains this particular error. I agree Int cannot be generalized to (T Int) or (T Bool). Generalized is not the right word here. In my example T Int, T Bool and Int are all equivalent. I see Stefan's local type signature is not (val :: a) like your (val ::Int)

[Haskell-cafe] Re: Small displeasure with associated type synonyms

2008-03-06 Thread ChrisK
Okay, I get the difference. The T a annotation in val :: T a)and val :: T a does not help choose the C a dictionary. But the val :: a- T a and val (undefined :: a) allows a to successfully choose the C a dictionary. val :: T a fixes T a but does not imply C a. (undefined :: a) fixes a and

[Haskell-cafe] Re: Small displeasure with associated type synonyms

2008-03-06 Thread Stefan Holdermans
Tom, Thanks for your quick answer. The problem is ambiguity. The type checker can't determine which val function to use, i.e. which dictionary to pass to val. I see. Still, maybe a type-error message in terms of good old unresolved top-level overloading would be a bit more useful

Re: [Haskell-cafe] Re: Small displeasure with associated type synonyms

2008-03-06 Thread Manuel M T Chakravarty
Stefan Holdermans: The problem is ambiguity. The type checker can't determine which val function to use, i.e. which dictionary to pass to val. I see. Still, maybe a type-error message in terms of good old unresolved top-level overloading would be a bit more useful here... ;-) I agree

Re: [Haskell-cafe] Re: Small displeasure with associated type synonyms

2008-03-06 Thread David Menendez
On Thu, Mar 6, 2008 at 3:57 PM, ChrisK [EMAIL PROTECTED] wrote: Okay, I get the difference. The T a annotation in val :: T a)and val :: T a does not help choose the C a dictionary. But the val :: a- T a and val (undefined :: a) allows a to successfully choose the C a dictionary.

Re: [Haskell-cafe] Re: Small displeasure with associated type synonyms

2008-03-06 Thread Tom Schrijvers
Am I correct in thinking this would have worked if it were an associated type instead of an associated type synonym? ie, class C a where data T a val :: T a Yes, you are. Associate data type constructors (as well as ordinary algebraic data constructors) are injective. So we have: