Data.Dynamic: Any vs existential
Dan Doel
dan.doel at gmail.com
Mon Mar 10 18:01:47 UTC 2014
On Mon, Mar 10, 2014 at 6:35 AM, Roman Cheplyaka <roma at ro-che.info> wrote:
> 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/libraries/attachments/20140310/81b065e6/attachment.html>
More information about the Libraries
mailing list