Re: [Haskell-cafe] Equality constraints in type families

2008-03-30 Thread Manuel M T Chakravarty
Hugo Pacheco: Yes, but doesn't the confluence problem only occur for type synonyms that ignore one or more of the parameters? If so, this could be checked... You can't check this easily (for the general case). Given type family G a b type FList a x = G a x type instance F [a] =

Re: [Haskell-cafe] Equality constraints in type families

2008-03-30 Thread Hugo Pacheco
On Sun, Mar 30, 2008 at 3:54 AM, Manuel M T Chakravarty [EMAIL PROTECTED] wrote: Hugo Pacheco: Yes, but doesn't the confluence problem only occur for type synonyms that ignore one or more of the parameters? If so, this could be checked... You can't check this easily (for the general

Re: [Haskell-cafe] Equality constraints in type families

2008-03-30 Thread Hugo Pacheco
Anyway, do you think it is feasible to have a flag such as -fallow-unsafe-type-families for users to use at their own risk? (supposing we know how to guarantee these constraints). I speak for my own, there are currently some nice thinks that I can only accomplish with partially applied type

Re: [Haskell-cafe] Equality constraints in type families

2008-03-30 Thread Manuel M T Chakravarty
Hugo Pacheco: Anyway, do you think it is feasible to have a flag such as -fallow- unsafe-type-families for users to use at their own risk? (supposing we know how to guarantee these constraints). Sorry, but it doesn't seem like a good idea to enable an unsound type system even by an

Re: [Haskell-cafe] Equality constraints in type families

2008-03-27 Thread Hugo Pacheco
The current implementation is wrong, as it permits type S a b = a type family F a :: * - * type instance F a = S a Why do we need to forbid this type instance? Because it breaks the confluence of equality constraint normalisation. Here are two diverging normalisations: (1)

Re: [Haskell-cafe] Equality constraints in type families

2008-03-27 Thread Hugo Pacheco
Sorry, I meant type FList a x = Either One (a,x) type instance F [a] = FList a On Thu, Mar 27, 2008 at 4:45 PM, Hugo Pacheco [EMAIL PROTECTED] wrote: The current implementation is wrong, as it permits type S a b = a type family F a :: * - * type instance F a = S a Why do

Re: [Haskell-cafe] Equality constraints in type families

2008-03-27 Thread Wolfgang Jeltsch
Am Mittwoch, 26. März 2008 03:07 schrieb Hugo Pacheco: The extra syntax has its advantages (more local information) and disadvantages (more clutter). We weren't convinced that we need the extra syntax, so left it out for the moment. However, this is something that can always be changed if

Re: [Haskell-cafe] Equality constraints in type families

2008-03-27 Thread Wolfgang Jeltsch
Am Donnerstag, 27. März 2008 22:43 schrieb Wolfgang Jeltsch: Am Mittwoch, 26. März 2008 03:07 schrieb Hugo Pacheco: The extra syntax has its advantages (more local information) and disadvantages (more clutter). We weren't convinced that we need the extra syntax, so left it out for the

Re: [Haskell-cafe] Equality constraints in type families

2008-03-27 Thread Hugo Pacheco
The reason for the braces in type families is because type indices are treated differently than normal parameters. I don't think this should be adopted for type synonyms either. Cheers, hugo On Thu, Mar 27, 2008 at 9:48 PM, Wolfgang Jeltsch [EMAIL PROTECTED] wrote: Am Donnerstag, 27. März

Re: [Haskell-cafe] Equality constraints in type families

2008-03-27 Thread Manuel M T Chakravarty
Hugo Pacheco: Sorry, I meant type FList a x = Either One (a,x) type instance F [a] = FList a We should not allow such programs. Manuel On Thu, Mar 27, 2008 at 4:45 PM, Hugo Pacheco [EMAIL PROTECTED] wrote: The current implementation is wrong, as it permits type S a b = a type

Re: [Haskell-cafe] Equality constraints in type families

2008-03-27 Thread Hugo Pacheco
Yes, but doesn't the confluence problem only occur for type synonyms that ignore one or more of the parameters? If so, this could be checked... On Fri, Mar 28, 2008 at 12:04 AM, Manuel M T Chakravarty [EMAIL PROTECTED] wrote: Hugo Pacheco: Sorry, I meant type FList a x = Either One (a,x)

Re: [Haskell-cafe] Equality constraints in type families

2008-03-27 Thread Wolfgang Jeltsch
Am Donnerstag, 27. März 2008 23:12 schrieben Sie: The reason for the braces in type families is because type indices are treated differently than normal parameters. I don't think this should be adopted for type synonyms either. Cheers, hugo In a way, there is also different treatment in the

RE: [Haskell-cafe] Equality constraints in type families

2008-03-26 Thread Simon Peyton-Jones
| * GHC says that these constraints must be obeyed only | *after* the programmer-written type has been normalised | by expanding saturated type synonyms | ... | I regard this as a kind of pre-pass, before serious type checking | takes place, so I don't think it should interact

Re: [Haskell-cafe] Equality constraints in type families

2008-03-26 Thread Manuel M T Chakravarty
Hugo Pacheco: Since I was the one to start this thread, I have managed to implement what I initially wanted as F a :: *-* with F a x::*, and the cost of not having partially applied type synonyms was not much apart from some more equality coercions that I wasn't expecting. [..] Generally,

Re: [Haskell-cafe] Equality constraints in type families

2008-03-26 Thread Claus Reinke
Well, we still need normal subject reduction (i.e., types don't change under value term reduction), and we have established that for System FC (in the TLDI paper). In addition, type term normalisation (much like value term normalisation) needs to be confluent; otherwise, you won't get a

Re: [Haskell-cafe] Equality constraints in type families

2008-03-26 Thread Manuel M T Chakravarty
Simon Peyton-Jones: | * GHC says that these constraints must be obeyed only | *after* the programmer-written type has been normalised | by expanding saturated type synonyms | ... | I regard this as a kind of pre-pass, before serious type checking | takes place, so I don't

RE: [Haskell-cafe] Equality constraints in type families

2008-03-26 Thread Simon Peyton-Jones
| Why not quite? | | Maybe I was thinking too much in terms of GHC's implementation, but | due to the lazy expansion type synonyms, the expansion is interleaved | with all the rest of type checking. But I think I now know what you | meant: the outcome should be *as if* type synonym expansion

Re: [Haskell-cafe] Equality constraints in type families

2008-03-25 Thread Manuel M T Chakravarty
Manuel M T Chakravarty: again, i gave a concrete example of how ghc behaves as i would expect, not as that decomposition rule would suggest. Maybe you can explain why you think so. I didn't understand why you think the example is not following the decomposition rule. Actually, see

Re: [Haskell-cafe] Equality constraints in type families

2008-03-25 Thread Claus Reinke
again, i gave a concrete example of how ghc behaves as i would expect, not as that decomposition rule would suggest. Maybe you can explain why you think so. I didn't understand why you think the example is not following the decomposition rule. Actually, see

Re: [Haskell-cafe] Equality constraints in type families

2008-03-25 Thread Claus Reinke
type family F a :: * - * F x y ~ F u v = F x ~ F u /\ y ~ v why would F x and F u have to be the same functions? shouldn't it be sufficient for them to have the same result, when applied to y and v, respectively? Oh, yes, that is sufficient and exactly what is meant by F x ~ F u. It means,

Re: [Haskell-cafe] Equality constraints in type families

2008-03-25 Thread Claus Reinke
was hoping for. in fact, the decomposition rule seems to be saying that type function results cannot matter, only the structure of type family applications does: F x y ~ F u v = F x ~ F u /\ y ~ v or do you have a specific type rule application order in mind where all type-level reductions

RE: [Haskell-cafe] Equality constraints in type families

2008-03-25 Thread Simon Peyton-Jones
| | However, I think I now understand what you are worried about. It is the | | interaction of type families and GHC's generalised type synonyms (i.e., | | type synonyms that may be partially applied). I agree that it does lead | | to an odd interaction, because the outcome may depend on the

Re: [Haskell-cafe] Equality constraints in type families

2008-03-25 Thread Dan Doel
On Tuesday 11 March 2008, Tom Schrijvers wrote: I think you've uncovered a bug in the type checker. We made the design choice that type functions with a higher-kinded result type must be injective with respect to the additional paramters. I.e. in your case: F x y ~ F u v = F x ~

Re: [Haskell-cafe] Equality constraints in type families

2008-03-25 Thread David Menendez
On Mon, Mar 24, 2008 at 12:14 AM, Manuel M T Chakravarty [EMAIL PROTECTED] wrote: One difference between type families and (value-level) functions is that not all parameters of a type family are treated the same. A type family has a fixed number of type indicies. We call the number of

Re: [Haskell-cafe] Equality constraints in type families

2008-03-25 Thread Manuel M T Chakravarty
Simon Peyton-Jones: | | However, I think I now understand what you are worried about. It is the | | interaction of type families and GHC's generalised type synonyms (i.e., | | type synonyms that may be partially applied). I agree that it does lead | | to an odd interaction, because the

Re: [Haskell-cafe] Equality constraints in type families

2008-03-25 Thread Manuel M T Chakravarty
Claus Reinke: one might say that the central point of example two were two partially applied type synonym families in the same position (rhs of a type synonym family instance definition). usually, when reduction meets typing, there is a subject reduction theorem, stating that types do not

Re: [Haskell-cafe] Equality constraints in type families

2008-03-25 Thread Manuel M T Chakravarty
Claus Reinke wrote, given that type families are never meant to be partially applied, perhaps a different notation, avoiding confusion with type constructor applications in favour of something resembling products, could make that clearer? something simple, like braces to group families and

Re: [Haskell-cafe] Equality constraints in type families

2008-03-25 Thread Hugo Pacheco
The extra syntax has its advantages (more local information) and disadvantages (more clutter). We weren't convinced that we need the extra syntax, so left it out for the moment. However, this is something that can always be changed if experience shows that programs are easier to understand

Re: [Haskell-cafe] Equality constraints in type families

2008-03-25 Thread Manuel M T Chakravarty
Dan Doel: On Tuesday 11 March 2008, Tom Schrijvers wrote: I think you've uncovered a bug in the type checker. We made the design choice that type functions with a higher-kinded result type must be injective with respect to the additional paramters. I.e. in your case: F x y

Re: [Haskell-cafe] Equality constraints in type families

2008-03-24 Thread Claus Reinke
type family F a :: * - * F x y ~ F u v = F x ~ F u /\ y ~ v words, in a type term like (F Int Bool), the two parameters Int and Bool are treated differently. Int is treated like a parameter to a function (which is what you where expecting), whereas Bool is treated like a parameter to a

Re: [Haskell-cafe] Equality constraints in type families

2008-03-24 Thread Claus Reinke
type family F a :: * - * F x y ~ F u v = F x ~ F u /\ y ~ v why would F x and F u have to be the same functions? shouldn't it be sufficient for them to have the same result, when applied to y and v, respectively? Oh, yes, that is sufficient and exactly what is meant by F x ~ F u. It

Re: [Haskell-cafe] Equality constraints in type families

2008-03-24 Thread Manuel M T Chakravarty
Claus Reinke: type family F a :: * - * F x y ~ F u v = F x ~ F u /\ y ~ v words, in a type term like (F Int Bool), the two parameters Int and Bool are treated differently. Int is treated like a parameter to a function (which is what you where expecting), whereas Bool is treated like

Re: [Haskell-cafe] Equality constraints in type families

2008-03-24 Thread Manuel M T Chakravarty
Claus Reinke: type family F a :: * - * F x y ~ F u v = F x ~ F u /\ y ~ v why would F x and F u have to be the same functions? shouldn't it be sufficient for them to have the same result, when applied to y and v, respectively? Oh, yes, that is sufficient and exactly what is meant by F x ~ F

Re: [Haskell-cafe] Equality constraints in type families

2008-03-23 Thread Manuel M T Chakravarty
Claus Reinke: type family F a :: * - * .. We made the design choice that type functions with a higher-kinded result type must be injective with respect to the additional paramters. I.e. in your case: F x y ~ F u v = F x ~ F u /\ y ~ v i'm still trying to understand this remark: - if we

Re: [Haskell-cafe] Equality constraints in type families

2008-03-23 Thread Manuel M T Chakravarty
Tom Schrijvers: could you please help me to clear up this confusion?-) Let me summarize :-) The current design for type functions with result kinds other than * (e.g. * - *) has not gotten very far yet. We are currently stabilizing the ordinary * type functions, and writing the story up.

Re: [Haskell-cafe] Equality constraints in type families

2008-03-23 Thread Manuel M T Chakravarty
Claus Reinke: type family F a :: * - * .. We made the design choice that type functions with a higher-kinded result type must be injective with respect to the additional paramters. I.e. in your case: F x y ~ F u v = F x ~ F u /\ y ~ v actually, i don't even understand the first part of

Re: [Haskell-cafe] Equality constraints in type families

2008-03-19 Thread Claus Reinke
type family F a :: * - * .. We made the design choice that type functions with a higher-kinded result type must be injective with respect to the additional paramters. I.e. in your case: F x y ~ F u v = F x ~ F u /\ y ~ v i'm still trying to understand this remark: - if we are talking

Re: [Haskell-cafe] Equality constraints in type families

2008-03-19 Thread Tom Schrijvers
could you please help me to clear up this confusion?-) Let me summarize :-) The current design for type functions with result kinds other than * (e.g. * - *) has not gotten very far yet. We are currently stabilizing the ordinary * type functions, and writing the story up. When that's done we

Re: [Haskell-cafe] Equality constraints in type families

2008-03-19 Thread Claus Reinke
type family F a :: * - * .. We made the design choice that type functions with a higher-kinded result type must be injective with respect to the additional paramters. I.e. in your case: F x y ~ F u v = F x ~ F u /\ y ~ v actually, i don't even understand the first part of that:-( why

Re: [Haskell-cafe] Equality constraints in type families

2008-03-19 Thread Claus Reinke
Let me summarize :-) The current design for type functions with result kinds other than * (e.g. * - *) has not gotten very far yet. We are currently stabilizing the ordinary * type functions, and writing the story up. When that's done we can properly focus on this issue and consider different

Re: [Haskell-cafe] Equality constraints in type families

2008-03-12 Thread Tom Schrijvers
On Tue, 11 Mar 2008, Hugo Pacheco wrote: Yes, I have tried both implementations at the start and solved it by choosing for the following: type family F a :: * - * type FList a x = Either () (a,x) type instance F [a] = FList a instance (Functor (F [a])) where fmap _ (Left _) = Left () fmap f

Re: [Haskell-cafe] Equality constraints in type families

2008-03-12 Thread Hugo Pacheco
That's simple Tom. Imagine the factorial function for Int written as a paramorphism: type instance F Int = Either One instance (Mu Int) where inn (Left _) = 0 inn (Right n) = succ n out 0 = Left () out n = Right (pred n) instance Functor (F Int) where fmap _ (Left ()) = Left

Re: [Haskell-cafe] Equality constraints in type families

2008-03-11 Thread Tom Schrijvers
Hi Hugo, I have encoded a type family such that: type family F a :: * - * and a function (I know it is complicated, but I think the problem is self explanatory): hyloPara :: (Functor (F a), Functor (F d), F d a ~ F a (a,a), F d c ~ F a (c,a)) = d - (F d c - c) - (a - F d a) - a - c hyloPara

Re: [Haskell-cafe] Equality constraints in type families

2008-03-11 Thread Hugo Pacheco
I know I do not need these constraints, it was just the simplest way I found to explain the problem. I have fought about that: I was not expecting F d c ~ F a (c,a) not mean that F d ~F a /\ c ~(c,a), I thought the whole family was parameterized. If I encoded the family type family F a x :: *

Re: [Haskell-cafe] Equality constraints in type families

2008-03-11 Thread Tom Schrijvers
On Tue, 11 Mar 2008, Hugo Pacheco wrote: I know I do not need these constraints, it was just the simplest way I found to explain the problem. I have fought about that: I was not expecting F d c ~ F a (c,a) not mean that F d ~F a /\ c ~(c,a), I thought the whole family was parameterized. If I

Re: [Haskell-cafe] Equality constraints in type families

2008-03-11 Thread Hugo Pacheco
Yes, I have tried both implementations at the start and solved it by choosing for the following: type family F a :: * - * type FList a x = Either () (a,x) type instance F [a] = FList a instance (Functor (F [a])) where fmap _ (Left _) = Left () fmap f (Right (a,x)) = Right (a,f x) The option was:

[Haskell-cafe] Equality constraints in type families

2008-03-10 Thread Hugo Pacheco
Hi all, I have encoded a type family such that: type family F a :: * - * and a function (I know it is complicated, but I think the problem is self explanatory): hyloPara :: (Functor (F a), Functor (F d), F d a ~ F a (a,a), F d c ~ F a (c,a)) = d - (F d c - c) - (a - F d a) - a - c hyloPara d g