Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Visualizing Types: Hussling Haskell types into Hasse diagrams (ezyang.com)
31 points by dons on Dec 6, 2010 | hide | past | favorite | 3 comments


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?


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 ;-)


Bottom is the type without values, a function with return type bottom is a function that not returns. Haskell has the term undefined, wich causes the program to abort when you try to evaluate it.




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: