

Visualizing Types: Hussling Haskell types into Hasse diagrams - dons
http://blog.ezyang.com/2010/12/hussling-haskell-types-into-hasse-diagrams/

======
lmkg
This post makes some sense in the context of Common Lisp as well, because it
also has the bottom value NIL, of type NULL, which is always a subtype of all
types (type T is also a supertype of all types, making the type system a
complete lattice). Lisp's type system isn't as rigid, or as flexible, but the
construction of lists follows a similar pattern, and the AND and OR type
constructors make the relation between types and partial orders pretty
explicit.

But, the one thing that sticks out to me is that NIL is a full-fledged value
in Lisp, and I've never seen an equivalent bottom type in any Haskell
tutorial. In fact, it would seem to violate the strictness of the type system
(given that I don't fully understand said type system). Does Haskell have a
"real" (reifiable?) bottom type, i.e. can your functions actually return
bottom in a valid program, or is the bottom value only something that appears
when you're doing theoretical analysis of the type system? I know that Bottom
sometimes represents uncaught exceptions or infinite loops in type theory,
does Haskell use it in the same way?

~~~
ezyang
Yes! In fact, the usual way to define bottom in a programming language with a
fixpoint operator is 'fix id'.

It's not appropriate to call NIL/NULL bottom, because it is a real value and
we can always do computation on it (if var == NIL). Because always detecting
bottom is equivalent to the halting problem, we lose. Of course, GHC will
sometimes raise a NonTermination exception ;-)

