Changes to Typeable

Robin KAY komadori at
Wed Oct 3 22:26:37 CEST 2012

On 03/10/12 14:20, Edward Kmett wrote:
> I don't think anyone has proposed weakening parametricity in this way.

I don't think so either, but is there any reason it shouldn't be done? 
If you give every type a Typeable instance automatically, then it's not 
effective as a constraint. The compiler would be free to either still 
use the type-class mechanism behind the scenes or "simply" replace it 
with magic:-

typeOf :: a -> TypeRep
typeOf = rtsInternalGetTypeOf

Simon's comment that it "would save tons of lookup in the massive 
Typeable-instance table" seemed to me to imply that there was some kind 
of optimisation you could make if Typeable wasn't really a type-class 
internally anyway.


Robin KAY

More information about the Libraries mailing list