[Haskell-beginners] Re: Encapsulation and Polymorphism

Stephen Tetley stephen.tetley at gmail.com
Fri Aug 27 03:23:06 EDT 2010

Hello Michael

I think I put my point forward with too little nuance, my point wasn't
that existentials aren't useful[*] (I did call them inert rather then
useless...), but that they aren't the rosetta stone for getting to
flexible designs. They do solve the original posters problem of
putting objects different types in a list, but with the expense that
they need heavy use of classes afterwards to be able to manipulate

For the original problem, dynamic typing with Data.Typeable would
probably be a better solution as it avoids annotating the existential
Obj type with every class the simulation needs.

Best wishes


[*] I think with just existentials you can get dynamic types -
Data.Typeable itself use a couple of other tricks (unsafe coerce), see
"Typing Dynamic Typing" Arthur I. Baars and S. Doaitse Swierstra or "A
Lightweight Implementation of Generics and Dynamics" James Cheney and
Ralf Hinze.

More information about the Beginners mailing list