Data.Dynamic: Any vs existential

Nikita Volkov nikita.y.volkov at gmail.com
Mon Mar 10 12:08:16 UTC 2014


What about the memory footprint? I recall making measurements using
"ghc-datasize" package and the existential appeared to occupy much more
space.


2014-03-10 15:26 GMT+04:00 Simon Peyton Jones <simonpj at microsoft.com>:

> Dear Core Libraries committee
>
> I think Roman is right here. Moreover we have known this for at least I
> think seven years
> http://comments.gmane.org/gmane.comp.lang.haskell.cafe/20097, where I
> wrote:
>
> | Yes, Dynamic preceded the Typeable class, I think.
> | Were we to do it today, I think we'd have
> |
> | data Dynamic = forall a . (Typeable a) => Dynamic a
> |
> | Whether it's worth changing, I'm not sure.  It's a library so,
> | if a change desirable, anyone could take a lead.
>
> The new representation for Dynamic would be good because it's less
> insecure than all this "Obj" nonsense, instead relying on Typeable, which
> is pretty good these days.
>
> Pedro is the most recent visitor to this territory and may have views.
>
> Roman's point about the method for the Typeable class is a good one too,
> and not one I've seen discussed.
>
> Over to you
>
> Simon
>
> | -----Original Message-----
> | From: Libraries [mailto:libraries-bounces at haskell.org] On Behalf Of
> | Roman Cheplyaka
> | Sent: 10 March 2014 10:35
> | To: libraries at haskell.org
> | Subject: Re: Data.Dynamic: Any vs existential
> |
> | 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?
> |
> | * Roman Cheplyaka <roma at ro-che.info> [2014-03-10 12:11:27+0200]
> | > In Data.Dynamic, Dynamic is defined as
> | >
> | >   data Dynamic = Dynamic TypeRep Any
> | >
> | > Does this have any advantage over a safer
> | >
> | >   data Dynamic = forall a. Typeable a => Dynamic a
> | >
> | > ?
> | >
> | > Roman
> _______________________________________________
> Libraries mailing list
> Libraries at haskell.org
> http://www.haskell.org/mailman/listinfo/libraries
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/libraries/attachments/20140310/ce2ed4a6/attachment.html>


More information about the Libraries mailing list