[Haskell-cafe] Implementation of "Dynamic" datatype

John Meacham john at repetae.net
Fri Mar 9 15:16:41 EST 2007


On Fri, Mar 09, 2007 at 03:40:07PM +0000, Simon Peyton-Jones 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.

I think

data Dynamic where
        Dynamic :: a -> TypeRep -> Dynamic

would be better, as it would cache the TypeRep for fast equality, while
the 'Typeable' version would perhaps have to go through a dictionary
lookup to get at it.

        John


-- 
John Meacham - ⑆repetae.net⑆john⑈


More information about the Haskell-Cafe mailing list