Nice article! It helps me a lot on contemplating about the design of my programming language.
I kind of understand every category of polymorphism you mentioned, but I still couldn’t understand how can higher-rank polymorphism is useful.
So, do you mind to provide any practical example of higher rank polymorphism (It would be better if the example you provided is actually used in industrial code, not just in the academia)
Nice article! It helps me a lot on contemplating about the design of my programming language.
I kind of understand every category of polymorphism you mentioned, but I still couldn’t understand how can higher-rank polymorphism is useful.
So, do you mind to provide any practical example of higher rank polymorphism (It would be better if the example you provided is actually used in industrial code, not just in the academia)
Yes, I've added a paragraph about the ST trick there. Another possible use case would be callback functions that receive data from your API:
This allows
withHook
to send any data to the callback that implements theIsApiData
type classI'm confused, isn't this ad-hoc (or 'first-rank' I guess) as it only quantifies over
a
?No, as you can see the forall is in the parenthesis, the scope does not go until the return type
herp derp, realized it myself just now,
∀x(P(x))->Q ≠ ∀x(P(x)->Q)
.So this would require an an ad-hoc polymorphic function as argument, yes?
Correct 👍