[Haskell-beginners] Natural functions versus existential types

Darren Grant therealkludgy at gmail.com
Mon Jan 7 08:22:51 CET 2013


I've seen some cases where Haskell examples dive into existential types
instead of using natural higher order functions. For instance, the
"Existential type" wiki page [1] section 2.2 proposes existentials as the
solution to a heterogeneous list problem where a ray-tracer must evaluate a
trace function for different types of objects. Is there a good reason for
this, or is it just a case of prior language assumptions leading to
unnatural code? Why could I not just make the list homogeneous by supplying
a list of partially evaluated trace functions instead?

Sometimes I read an argument that existentials are required due to unknown
constraints at compile time, but do not have an intuition for this
situation yet.  For instance, I read that IO requires existentials. Still
working on that one. :)

Cheers,
Darren



[1] http://www.haskell.org/haskellwiki/Existential_type
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20130106/44b0360e/attachment.htm>


More information about the Beginners mailing list