loading...

re: What the heck is polymorphism? VIEW POST

TOP OF THREAD FULL DISCUSSION
re: Nice article! It helps me a lot on contemplating about the design of my programming language. I kind of understand every category of polymorphism ...
 

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:

withHook: (forall a. IsApiData a => a -> IO ()) -> IO ()

This allows withHook to send any data to the callback that implements the IsApiData type class

 

I'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?

code of conduct - report abuse