3 ms·
I think a better example is needed. The example's solution to the Haskell heterogeneous list "problem" could be implemented in other statically typed languages
by zwieback 13y ago
I think a better example is needed. The example's solution to the Haskell heterogeneous list "problem" could be implemented in other statically typed languages (C++, Java) although it wouldn't be necessary to do so.
I don't see how the Haskell type system is safer in this example but I feel there's something interesting there which I don't understand. Can someone explain the advantage of type classes over what could be done with interfaces and templates in C++?
- mcguire 13y ago"...although it wouldn't be necessary to do so." That's actually the point. (Have you read the "wearing the hair shirt" paper?) One of the hardest problems in moving from other languages to Haskell is that many of the solutions that you would immediately default to rely on run-time information or behavior, like the heterogeneous list. Those don't translate well, if at all. Instead, you need to step back and change the problem, by relying more on compile-time, type-level information.