
On Mon, Mar 10, 2014 at 6:35 AM, Roman Cheplyaka
Ok, one reason is that the TypeRep won't be cached in the Dynamic value. Even in GHC 7.8 Typeable is defined as
class Typeable a where typeRep# :: Proxy# a -> TypeRep
instead of
class Typeable a where typeRep :: Tagged a TypeRep
Why? Is this an oversight?
I talked with Ed about this, and he noted that this might be a false problem. Certainly, the Proxy# is never actually used, so as long as the generated instances are of the form: typeRep# = let tr = ... in \_ -> tr the TypeReps are shared, and are at most a bit of indirection away. Also, how different are (Tagged tr :: Tagged a TypeRep) and ((\_ -> tr) :: Proxy# a -> TypeRep) at a low level? I know the constructor of the former disappears in core, but don't know what specifically happens with 0-width fields like Proxy#. Is the latter slightly less efficient? If so, can the optimizer eliminate the difference for cases like this? -- Dan