On Wed, Oct 3, 2012 at 4:26 PM, Robin KAY <komadori@gekkou.co.uk> wrote:
On 03/10/12 14:20, Edward Kmett wrote:[snip]
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.