[Haskell-cafe] Implementation of "Dynamic" datatype

Stefan O'Rear stefanor at cox.net
Fri Mar 2 19:17:53 EST 2007


On Fri, Mar 02, 2007 at 07:10:32PM -0500, Isaac Dupree wrote:
> Stefan O'Rear wrote:
> > the current type:
> > 
> > data Dynamic = Dynamic TypeRep Obj
> > 
> > the new type, if lucky:
> 
> Meaning the one with "Typeable a =>" instead of TypeRep?

Yes
 
> > data Dynamic = Dynamic !(a -> TypeRep) a
> > 
> > if unlucky:
> > 
> > data TypeableD a = TypeableD (a -> TypeRep)
> > data Dynamic = Dynamic (TypeableD a) a
> > 
> > either way, the typeclass approach gives a lot more boxing.
> 
> Yes, that's why I don't really propose that, because it's probably
> inefficient (for dictionary-passing-based implementations anyway), just
> that the "Obj" in Dynamic's constructor should be, type-system-wise, an
> existential instead (which I don't think will change the runtime
> representation, but I don't know how to test that).

-ddump-cmm, and a 10x magnifying glass.

Stefan


More information about the Haskell-Cafe mailing list