| data T a b c d e f g h = T a b c d e f g h
|   deriving Typeable
| 
| fails in ghc-6.4 with the message:
|     Can't make a derived instance of `Typeable (T a b c d e f g h)'
|     (`T' has too many arguments)
|     When deriving instances for type `T'
| 
| In ghc 6.2.2, it was no problem to derive Typeable instances for type
| constructors of higher (arbitrary?) arities.

Yes, this was a change, I'm afraid, and not a documented one.  I've
updated the documentation (see below for the diff, and the explanation).

| If it is not possible to provide deriving Typeable for arbitrary arity
| of type constructors anymore, would it be possible to extend deriving
to
| at least type constructors of arity 20? We are using Haskell as a
target
| language of a compiler and here type constructors with many arguments
occur.

I'm not against this, although you can work around the problem by adding
a library that defines the missing type classes (Typeable8, Typeable9
etc), and making your compiler generate the instance itself.  There is
nothing magic about 'deriving'; it's just convenient.

The Read and Show instances for tuples go up to arity 15, and since we
have some arbitrary numbers in GHC we might as well have as few as
possible.  So would arity 15 do?  If you really want 20 maybe we should
do the same for Read/Show on tuples.

If someone likes to volunteer to do the actual work on the library
Data.Typeable, I think we could adopt it.  It's simple but boring to
follow the recipe for Typable1..Typeable7.  I'm a bit tied up right now.

Simon

+ <para>An instance of <literal>Typeable</literal> can only be derived
if the
+ data type has seven or fewer type parameters, all of kind
<literal>*</literal>.
+ The reason for this is that the <literal>Typeable</literal> class is
derived using the scheme
+ described in
+ <ulink
url="http://research.microsoft.com/%7Esimonpj/papers/hmap/gmap2.ps";>
+ Scrap More Boilerplate: Reflection, Zips, and Generalised Casts
+ </ulink>.
+ (Section 7.4 of the paper describes the multiple
<literal>Typeable</literal> classes that
+ are used, and only <literal>Typeable1</literal> up to
+ <literal>Typeable7</literal> are provided in the library.)
+ In other cases, there is nothing to stop the programmer writing a
<literal>TypableX</literal>
+ class, whose kind suits that of the data type constructor, and
+ then writing the data type instance by hand.
+ </para>


| -----Original Message-----
| From: [EMAIL PROTECTED]
[mailto:glasgow-haskell-bugs-
| [EMAIL PROTECTED] On Behalf Of Frank Huch
| Sent: 04 August 2005 18:00
| To: glasgow-haskell-bugs@haskell.org
| Subject: Deriving Typeable instances
| 
| Hi,
| 
| we have a problem with deriving Typeable instances in ghc-6.4. The
| following code
| 
| data T a b c d e f g h = T a b c d e f g h
|   deriving Typeable
| 
| fails in ghc-6.4 with the message:
|     Can't make a derived instance of `Typeable (T a b c d e f g h)'
|     (`T' has too many arguments)
|     When deriving instances for type `T'
| 
| In ghc 6.2.2, it was no problem to derive Typeable instances for type
| constructors of higher (arbitrary?) arities.
| 
| If it is not possible to provide deriving Typeable for arbitrary arity
| of type constructors anymore, would it be possible to extend deriving
to
| at least type constructors of arity 20? We are using Haskell as a
target
| language of a compiler and here type constructors with many arguments
occur.
| 
| Regards,
| Frank
| _______________________________________________
| Glasgow-haskell-bugs mailing list
| Glasgow-haskell-bugs@haskell.org
| http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
_______________________________________________
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs

Reply via email to