Pleasantly accessible! We need more articles like this in the ecosystem that explain scary-looking things like GHC extensions in terms of approachable and useful examples.
Author here, thanks for the kind words! To be honest, I wrote it merely because I kept forgetting what forall was about, so in part it was written for the future me :D. But I did try my best to make it readable.
Pleasantly accessible! We need more articles like this in the ecosystem that explain scary-looking things like GHC extensions in terms of approachable and useful examples.
Author here, thanks for the kind words! To be honest, I wrote it merely because I kept forgetting what forall was about, so in part it was written for the future me :D. But I did try my best to make it readable.
Haskell’s cousin PureScript requires explicit
forall
. As a bonus,∀
, the symbol (Vim digraphFA
), is supported by the compiler.As is often the case, “There’s an extension for that”.
So was the explicit forall, built-in is different from ‘needs extension’.
I don’t understand the motivation for the ScopedTypeVariable example, can you just not elide the type annotation for ys altogether in this case?
You could, but there’s some more advanced cases where a type signature will be required (often involving higher rank types).
There’s also cases where having the function signature visible helps with code readability a lot.
I mean it’s not that I don’t believe there are good uses for it, it’s just that this example doesn’t make any of them obvious to me.
In case it’s unclear from the title: Haskell does not have
forall
but there is a GHC extension which adds it.