deriving Typeable

oleg at oleg at
Tue Apr 4 23:38:35 EDT 2006

John Meacham wrote:
> things like DeepSeq and Typeable will most likely have optimized
> versions on various compilers which is why I'd like to see the
> restriction that the only way to create instances for these two
> classes is via the "deriving" mechanism of the compiler.

Please make it so! Allowing users to create their own instances of
Typeable is tantamount to allowing them to define the _total_ function

	unsafeCoerce :: (Typable a, Typeable b) => a -> b

That function always succeeds; you don't want to trust its result in
general though. If we add -fallow-incoherent-instances, then the
Typeable constraint disappears and we obtain the total function of the
type a->b. The fact these functions are expressible in Haskell at all
is quite disconcerting.

More information about the Haskell-prime mailing list