[Haskell-cafe] Re: type families and type signatures

2008-04-11 Thread apfelmus
Tom Schrijvers wrote: apfelmus wrote: However, I have this feeling that bar :: forall a . Id a - String with a type family Id *is* parametric in the sense that no matter what a is, the result always has to be the same. Intuitively, that's because we may not pattern match on the branch

Re: [Haskell-cafe] Re: type families and type signatures

2008-04-09 Thread Tom Schrijvers
However, I have this feeling that bar :: forall a . Id a - String with a type family Id *is* parametric in the sense that no matter what a is, the result always has to be the same. Intuitively, that's because we may not pattern match on the branch of a definition like type instance Id

[Haskell-cafe] Re: type families and type signatures

2008-04-09 Thread apfelmus
Manuel M T Chakravarty wrote: apfelmus: Manuel M T Chakravarty wrote: Let's alpha-rename the signatures and use explicit foralls for clarity: foo :: forall a. Id a - Id a foo' :: forall b. Id b - Id b GHC will try to match (Id a) against (Id b). As Id is a type synonym family, it would

Re: [Haskell-cafe] Re: type families and type signatures

2008-04-09 Thread Manuel M T Chakravarty
apfelmus: Manuel M T Chakravarty wrote: apfelmus: Manuel M T Chakravarty wrote: Let's alpha-rename the signatures and use explicit foralls for clarity: foo :: forall a. Id a - Id a foo' :: forall b. Id b - Id b GHC will try to match (Id a) against (Id b). As Id is a type synonym family,

Re: [Haskell-cafe] Re: type families and type signatures

2008-04-08 Thread Tom Schrijvers
Hi Tom, It seems we are thinking of different things. I was referring to the characterization of a type of the form P = t as being ambiguous if there is a type variable in P that is not determined by the variables in t; this condition is used in Haskell to establish coherence (i.e., to show

Re: [Haskell-cafe] Re: type families and type signatures

2008-04-08 Thread Martin Sulzmann
The point is that Mark proposes a *pessimistic* ambiguity check whereas Tom (as well as GHC) favors an *optimistic* ambiguity check. By pessimistic I mean that we immediately reject a program/type if there's a potential unambiguity. For example, class Foo a b forall a b. Foo a b = b - b

[Haskell-cafe] Re: type families and type signatures

2008-04-07 Thread apfelmus
Manuel M T Chakravarty wrote: Ganesh Sittampalam: The following program doesn't compile in latest GHC HEAD, although it does if I remove the signature on foo'. {-# LANGUAGE TypeFamilies #-} module Test7 where type family Id a type instance Id Int = Int foo :: Id a - Id a foo = id foo' ::

Re: [Haskell-cafe] Re: type families and type signatures

2008-04-07 Thread Tom Schrijvers
type instance Id Int = Int foo :: Id a - Id a foo = id foo' :: Id a - Id a foo' = foo Is this expected? Yes, unfortunately, this is expected, although it is very unintuitive. This is for the following reason. Huh? This sounds very wrong to me, simply because foo and foo' have the

Re: [Haskell-cafe] Re: type families and type signatures

2008-04-07 Thread Mark P Jones
The surprising thing about this example is the fact that the definition of foo is accepted, and not the fact that the definition of foo' is rejected. At least in Manuel's equivalent program using functional dependencies, both functions have ambiguous types, and hence both would be rejected. It

Re: [Haskell-cafe] Re: type families and type signatures

2008-04-07 Thread Tom Schrijvers
On Mon, 7 Apr 2008, Mark P Jones wrote: The surprising thing about this example is the fact that the definition of foo is accepted, and not the fact that the definition of foo' is rejected. At least in Manuel's equivalent program using functional dependencies, both functions have ambiguous

[Haskell-cafe] Re: type families and type signatures

2008-04-07 Thread Stefan Monnier
Id is an operation over types yielding a type, as such it doesn't make much sense to me to have (Id a - Id a) but rather something like (a - Id a). Actually, it can make perfect sense: e.g. if the `Id' function acts as a constraint. Stefan

Re: [Haskell-cafe] Re: type families and type signatures

2008-04-07 Thread Mark P Jones
Hi Tom, It seems we are thinking of different things. I was referring to the characterization of a type of the form P = t as being ambiguous if there is a type variable in P that is not determined by the variables in t; this condition is used in Haskell to establish coherence (i.e., to show

Re: [Haskell-cafe] Re: type families and type signatures

2008-04-07 Thread Manuel M T Chakravarty
Hi Mark, I don't know if you have defined/studied corresponding notions of ambiguity/coherence in your framework. Instead, I was referring to what Manuel described as the equivalent problem using FDs: class IdC a b | a - b instance IdC Int Int bar :: IdC a b = b - b bar = id bar' ::

Re: [Haskell-cafe] Re: type families and type signatures

2008-04-07 Thread Manuel M T Chakravarty
apfelmus: Manuel M T Chakravarty wrote: Ganesh Sittampalam: Let's alpha-rename the signatures and use explicit foralls for clarity: foo :: forall a. Id a - Id a foo' :: forall b. Id b - Id b GHC will try to match (Id a) against (Id b). As Id is a type synonym family, it would *not* be