Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Not really. Just make your types instances of Typeable and then store them in a list of Dynamics. This gives you dynamic typing for those exceptionally rare occasions when you really need it.

Frankly, from my experience with dynamically typed languages such as Clojure few people actually make heterogeneous lists and vectors beyond a handful of elements; a use case which is covered nicely by Haskell's tuples. Long hetereogeneous lists and vectors are not particularly useful because they cannot be reduced/folded -- unless your reducing function accounts for all the different types but then why not use an algebraic data type with pattern matching?



Good points about folding and pattern matching on algebraic types. Thanks.

Of course, there is TYPECASE in CL and some similar macro in Clojure, but Haskell's pattern-matching syntax is more concise.




Consider applying for YC's Fall 2026 batch! Applications are open till July 27.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: