Re: [Haskell-cafe] Issues(Bugs?) with GHC Type Families

2008-03-09 Thread Manuel M T Chakravarty
Hugo Pacheco: If the equality does not hold, you should get a type error because your program is not type correct. So, what is it that you would like different? I would simply like the compiler not to use that instance if the equality constraint does not hold, like some another instance

Re: [Haskell-cafe] Issues(Bugs?) with GHC Type Families

2008-03-07 Thread David Menendez
On Fri, Mar 7, 2008 at 2:10 AM, Ryan Ingram [EMAIL PROTECTED] wrote: I don't think the cost is that great; the compiler can easily flag polymorphic functions that require type information for some or all arguments and in many cases the type evidence can be passed just-in-time when calling

Re: [Haskell-cafe] Issues(Bugs?) with GHC Type Families

2008-03-06 Thread Manuel M T Chakravarty
Hugo Pacheco: Just something I have been wondering. I would like to implement somehting like: type family F a :: * - * ... class C a b where ... instance (F a ~ F b) = C a b where ... But apparently type equality coercions can not be used as a single context. If I enable

Re: [Haskell-cafe] Issues(Bugs?) with GHC Type Families

2008-03-06 Thread Hugo Pacheco
If the equality does not hold, you should get a type error because your program is not type correct. So, what is it that you would like different? I would simply like the compiler not to use that instance if the equality constraint does not hold, like some another instance dependency

Re: [Haskell-cafe] Issues(Bugs?) with GHC Type Families

2008-03-06 Thread Hugo Pacheco
What I said is not true since overlapping instances are not that much decidable. Btw, in previous versions of GHC this worked well, but now I suppose order does not suffices to define instances overlapping How could I compile such an example, assuming that I want to use the instance C String for

Re: [Haskell-cafe] Issues(Bugs?) with GHC Type Families

2008-03-06 Thread Ryan Ingram
2008/3/6 Hugo Pacheco [EMAIL PROTECTED]: How could I compile such an example, assuming that I want to use the instance C String for Strings only and the more general instance for the rest? class C a where c :: a instance C Char where c = 'a' instance C a = C [a] where c = [c

Re: [Haskell-cafe] Issues(Bugs?) with GHC Type Families

2008-03-06 Thread Luke Palmer
On Thu, Mar 6, 2008 at 7:52 PM, Ryan Ingram [EMAIL PROTECTED] wrote: I wish there was some form of instance declaration that let you do case analysis; something similar to the following: instances C [a] where instance C String where c = a instance C a = C [a] where

Re: [Haskell-cafe] Issues(Bugs?) with GHC Type Families

2008-03-06 Thread David Menendez
On Thu, Mar 6, 2008 at 9:52 PM, Ryan Ingram [EMAIL PROTECTED] wrote: This is actually a general issue with the way typeclasses are defined in Haskell; the accepted solution is what the Show typeclass does: class C a where c :: a cList :: [a] cList = [c,c] instance C

Re: [Haskell-cafe] Issues(Bugs?) with GHC Type Families

2008-03-06 Thread Ryan Ingram
On Thu, Mar 6, 2008 at 7:16 PM, Luke Palmer [EMAIL PROTECTED] wrote: I agree that this would be nice. But I think that the situation is stickier than it looks on the surface. Consider this: instances GShow [a] where instance [Char] where gShow = id instance [a] where

Re: [Haskell-cafe] Issues(Bugs?) with GHC Type Families

2008-03-05 Thread Hugo Pacheco
Just something I have been wondering. I would like to implement somehting like: type family F a :: * - * ... class C a b where ... instance (F a ~ F b) = C a b where ... But apparently type equality coercions can not be used as a single context. If I enable -fallow-undecidable-instances,

[Haskell-cafe] Issues(Bugs?) with GHC Type Families

2008-03-03 Thread Hugo Pacheco
Hi all, I have recently tried to replicate some examples from in the articles about type families but found some possible bugs. In [2], the example class C a where type S a (k :: * - *) :: * instance C [a] where type S [a] k = (a,k a) does not compile under the claim that the type

Re: [Haskell-cafe] Issues(Bugs?) with GHC Type Families

2008-03-03 Thread Ryan Ingram
2008/3/3 Hugo Pacheco [EMAIL PROTECTED]: class C a where type S a (k :: * - *) :: * instance C [a] where type S [a] k = (a,k a) does not compile under the claim that the type variable k is not in scope. It's not entirely syntactical sugar; I believe that when a type family is a

Re: [Haskell-cafe] Issues(Bugs?) with GHC Type Families

2008-03-03 Thread Manuel M T Chakravarty
Hugo Pacheco: I have recently tried to replicate some examples from in the articles about type families but found some possible bugs. In [2], the example class C a where type S a (k :: * - *) :: * instance C [a] where type S [a] k = (a,k a) does not compile under the claim that the