Hacker News new | ask | show | jobs
by GrantMoyer 353 days ago
Haskell has `bottom`[1] (see also [2]), which acts like Rust's `return` from a type checking perspective.

I wouldn't call using a uninhabited type for the type of a return expression theoretically inelegant. On the contrary, I find it quite pleasing.

[1]: https://wiki.haskell.org/Bottom

[2]: https://en.wikipedia.org/wiki/Bottom_type

1 comments

On the more mainstream side of things, Typescript also has a bottom type called `never` which is used to type unreachable/exceptional code.