4
Defeating Return Type Polymorphism
(philipphagenlocher.de)
**The Haskell programming language community.** Daily news and info about all things Haskell related: practical stuff, theory, types, libraries, jobs, patches, releases, events and conferences and more... ### Links - Get Started with Haskell
I put this together this evening.
You can swap out
x
fory
to see the behavior is the same.You can drop the
GADT
pragma, GADT definition,f
, existential,g
, andx
(but keep all the Scott versions, includeingy
) to reveal code that works "simply" withRankNTypes
.Higher-rank types and parametricity is quite powerful.
BTW, this isn't new / doesn't require the bleeding edge compiler. I'm on "The Glorious Glasgow Haskell Compilation System, version 9.0.2" from the Debian repositories.
The Lemmy->Kbin conversion has inserted a lot of
<span>
elements into your code making it unreadable. For people reading this from the Kbin side, here's the code:I think the spans are all syntax highlighting/coloring. Your comment seems to have a dangling
```/span
at the end to me, but that might just be the KBin->Lemmy translation.EDIT: Also, Lemmy seems to be munging this post between the preview and the submit, due to me wanting to include some text that appears to be a dangling xml/html end tag (angle brackets removed in edit for "readability") inside backticks.
Ah, that's interesting. Although I can imagine not many people would want to write code in that style. And I also wonder how many languages support higher rank polymorphism in the first place.
Yeah, I generally prefer pattern matching and constructor calls, but often languages don't have GADTs or existentials. Even in GHC, existentials are still a bit "wonky", though still generally nicer to use than CPS/Codensity.