[Haskell-cafe] Trying to make a Typeable instance

Adrian Hey ahey at iee.org
Sun Jul 8 10:59:38 EDT 2007

Benja Fallenstein wrote:
> Hi Adrian,
> 2007/7/8, Adrian Hey <ahey at iee.org>:
>> So it seems ghc doesn't like kinds (* -> *) either :-(
>> Actually, AFAICT the problem seems to be with Data.Typeable
>> itself rather than ghc. There is no proper TypeRep for
>> (ListGT map k a) because map is not a type.
> Have you tried using (Typeable1 map) as the constraint?

Yes, see my earlier post. This seems to "work" in that the code
compiles and showing the resulting TypeRep at least terminates
in the tests I did so far.

But I don't see how it can be regarded correct as AFAICT types like
this just aren't properly representable as a TypeRep (as provided
by Data.Typeable).

But I might be wrong. As is often the case, the documentation for
Data.Typeable is somewhat terse and inadequate IMO, so it's not at all
clear to me how it should be used or what other users can reasonably
expect from "sane" instances.

Typeable1 etc.. seem problematic in that although the typeOf methods
apparently return TypeReps, I don't see how they can possibly be
correct. Surely they must be returning a representation of a
type constructor that's masquerading as a TypeRep?

In fact that's exactly what the macros in Typeable.h seem to do so
I guess this is generally accepted as correct, but it seems wrong to
me :-(

AFAICT it's unsafe to assume that a TypeRep represents an actual
proper type (I.E. the type that a monomorphic expression may have).
Maybe that's intentional, I dunno. It'd be nice if the Data.Typeable
Haddock made it clear exactly what a "TypeRep" is supposed to be
a representation of :-)

Adrian Hey

More information about the Haskell-Cafe mailing list