[Haskell-cafe] Implementation of "Dynamic" datatype

Isaac Dupree isaacdupree at charter.net
Fri Mar 2 19:10:32 EST 2007


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

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?

> 
> 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).

Isaac
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFF6Lz4HgcxvIWYTTURAggEAKCdexJu4irOk2CiIfLfyatJfzIrgACgzokb
kTlzxONc+tL+i5IJIkShMqk=
=H/tO
-----END PGP SIGNATURE-----


More information about the Haskell-Cafe mailing list