2 ms·
Extensible heterogeneous lists are hard in Haskell, but that's because Haskell chooses to encode extensibility through type-classes rather than data heterogenei
by eli_gottlieb 13y ago
Extensible heterogeneous lists are hard in Haskell, but that's because Haskell chooses to encode extensibility through type-classes rather than data heterogeneity.
It could very well be that most programmers just don't like programming that way, and thus Haskell sucks.
- chongli 13y agoNot 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?
- dschiptsov 13y agoGood 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.