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

Hugo Pacheco hpacheco at gmail.com
Mon Mar 3 12:35:06 EST 2008


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 variable k is not in scope.

However, if we extract the type family from the class

type family S a (k :: * -> *) :: *
type instance S [a] k = (a, k a)
class C a

it compiles correctly.
According to [3], the difference is purely syntactic sugar, does that mean
that both examples should compile and behave the same or is there some
subtlety that justifies the class example not to compile?

Another issue is that data kinds (used in both [2] and [3]) do not seem to
be supported at all by the compiler, are they already implemented in GHC?

Simple examples such as

datakind Nat = Zero
or
datakind Nat = Zero | Succ Nat

fail to compile.

Perhaps some of these should be submitted to the GHC Bug Tracker. I have
tested both GHC 6.8.2 and 6.9.20080218.


References:

   1. Associated Types with
Class.<http://www.cse.unsw.edu.au/~chak/papers/CKPM05.html> Manuel
   M. T. Chakravarty, Gabriele Keller, Simon Peyton Jones, and Simon Marlow.
   In *Proceedings of The 32nd Annual ACM SIGPLAN-SIGACT Symposium on
   Principles of Programming Languages (POPL'05)*, pages 1-13, ACM Press,
   2005.
   2. Associated Type
Synonyms.<http://www.cse.unsw.edu.au/~chak/papers/CKP05.html> Manuel
   M. T. Chakravarty, Gabriele Keller, and Simon Peyton Jones. In *Proceedings
   of The Tenth ACM SIGPLAN International Conference on Functional Programming
   *, ACM Press, pages 241-253, 2005.
   3. Towards Open Type Functions for
Haskell.<http://www.cse.unsw.edu.au/~chak/papers/SSPC07.html> Tom
   Schrijvers, Martin Sulzmann, Simon Peyton-Jones, and Manuel M. T.
   Chakravarty. Unpublished manuscript, 2007.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080303/30db966f/attachment.htm


More information about the Haskell-Cafe mailing list