
Forbidden Haskell Types - lelf
https://semantic.org/post/forbidden-haskell-types/
======
siraben
If anyone is confused by how the author uses "proof" in this article, they are
referring to the Curry-Howard isomorphism that types represent propositions in
a constructive logic and well-typed terms inhabiting those types can be
considered as proofs. a :~: b is the type that a and b are "equal", i.e. they
are the same type. the functions convert1 and convert2 witness the isomorphism
between a and b.

The core reason why GHC didn't allow the naïve recursive definition in the
first place is because the definition failed the occurs check[0], so using
type families and explicitly labeling the types circumvents the problem.

[0]
[https://en.wikipedia.org/wiki/Occurs_check](https://en.wikipedia.org/wiki/Occurs_check)

------
batterseapower
For another approach to making this work in Haskell, see this thread of mine
from 2010: [https://mail.haskell.org/pipermail/haskell-
cafe/2010-October...](https://mail.haskell.org/pipermail/haskell-
cafe/2010-October/085307.html)

The relevant keyword if you want to learn more here is "equirecursive types".

~~~
carterschonwald
Zomg it’s max!

(For those who don’t know, the parent poster wrote and maintained a lot of
nice Haskell Libs at one point)

~~~
batterseapower
Thanks for remembering :P

------
netko_netkovic
Thank you for the article, it is great read. I'm trying to follow haskell-
oriented blogs, some of them are cool to read, while more deeper ones are
harder to follow (probably it is about me, not about author!).

Anyway, I often struggle to understand "what problem is author solving
exactly", in terms "what is the benefit if we create such recursive type (or
whatever else is the theme)" ? Somehow, there are lot of articles making some
magic and showing "how can this be done in haskell", but at the end it is hard
to understand "what is the benefit here, which real-life problem can I solve
by using this technique, how to relate this with real world".

Please do not get me wrong, this not only about this post, but somehow very
often in haskell - related posts. Or is it only me ?

~~~
twic
Jon Harrop, who is a troll, but on occasion quite funny, once wrote:

 _Haskell is best at solving problems that Haskell invented and other
languages do not have._

~~~
centimeter
This is very true, but I think there’s a good reason for it - using Haskell
forces you to first address many fundamental issues that most languages just
let you paper over. The issues still exist in other languages, but you can
ignore them, and then years later wonder why so much software is ad-hoc and
full of complicated, but preventable, bugs.

E.g. haskell’s laziness forced early haskellers to think about denotational
ways of managing effects, and ended up forcing them to invent modern monadic
effect systems. Now, there are a lot of people who actually prefer explicit
effect management over freely mixing effects and logic, and not just because
they have stockholm syndrome.

------
OscarCunningham
Now do 'T = T -> Bool'!

~~~
cvoss
Curry's Paradox [0], for anyone wondering why this suggestion is entertaining
and deserves its exclamation point.

[0]
[https://en.wikipedia.org/wiki/Curry%27s_paradox](https://en.wikipedia.org/wiki/Curry%27s_paradox)

------
sonofgod
There was a part of me hoping that this would be "forbidden" in the sense of
"forbidden knowledge".

I was, surprisingly, not disappointed.

~~~
twic
Ah, you wish to learn of the category which is not a category,
H̦̻̺̮̝̹̲a̶̶̳͉͚̕ͅs̷͏̷̻͙͚̥͚̟̣ͅk͞͏̼̭ͅͅ.

