3 ms·
I'm pretty sure that Haskell typeclasses are also resolved at compile time. That's why you can't have a list containing different ordered types, for example (un
by klipt 17y ago
I'm pretty sure that Haskell typeclasses are also resolved at compile time. That's why you can't have a list containing different ordered types, for example (unless they can all be coerced to the same type).
- jemfinch 17y agoNo, you can't have a list containing different ordered types because the signature for comparison only permits two values of the same exact type, not any arbitrary member of class `Ord`. As I said before, Haskell passes [runtime dictionaries](http://www.haskell.org/haskellwiki/OOP_vs_type_classes http://www.haskell.org/haskellwiki/OOP_vs_type_classes). The compiler can perhaps infer many cases statically, but the core implementation is to pass around runtime dictionaries for typeclasses.