8 ms·
> My point with this arguments is not that "polymorphic instances" are as powerful as functors (they aren't!). Rather in this (and similar examples) it's higher
by catnaroek 11y ago
> My point with this arguments is not that "polymorphic instances" are as powerful as functors (they aren't!). Rather in this (and similar examples) it's higher-kinded types vs modules, no type classes involved.
This paper disagrees: http://www.cse.unsw.edu.au/~chak/papers/modules-classes.pdf http://www.cse.unsw.edu.au/~chak/papers/modules-classes.pdf . See below.
> The Haskell equivalent is just a plane[sic] function, not a polymorphic instance, and there is things that can be done in the term language but not the module language.
A plain function can't return fresh new types. A functor can.
> SML/OCaml with higher-kinded types would annihilate this argument
As I said above, OCaml's higher-order modules let you encode arbitrarily higher-kinded types. Even if OCaml didn't have parametric polymorphism in the core language, you can express it in the module language with applicative functors (although the result would be a lot more verbose). If you don't believe me, give me an arbitrary higher-kinded type, and I'll tell you how to encode it in OCaml.
- Ericson2314 11y agoI don't have time to read the paper for a few days, but I meant while functors can do things functions cannot do, functions can do things functors cannot do too.
- catnaroek 11y agoAnd records can do things functions can't do. And vice versa. That alone doesn't mean records in one language are the counterpart of functions in another.
- Ericson2314 11y agoHow is that relevant? I'm claiming that their exists functions in Haskell that cannot be encoded either as functor or functions in ML. (If you want, I'll try to come up with an example, but my guess would be some funny polymorphic recursion + higher-kinded types)