News for hackers. Stuff that matters.
Re:Bottom Type in F# by mlex on Wednesday September 23, 2020 @04:31AM (#24564493)
Swift has Never, which is the return type of functions that don't terminate, such as fatalError().

https://developer.apple.com/documentation/swift/never

It's currently not implemented as a bottom type in the sense that it's not the subtype of all types (discussed in https://nshipster.com/never/).

Re:Bottom Type in F# by Latty on Wednesday September 23, 2020 @10:28AM (#24567470)
As a use case other than the bottom type or "doesn't terminate", some pure languages use it to mean "this code path is impossible". I always liked the way Elm (and I assume many other pure functional languages) define(s) `Never`:

    type Never = JustOneMore Never
As the only constructor takes an instance of itself as an argument, any attempt to construct one would become infinite.

This very naturally allows for a function to obtain any value you want:

    never : Never -> a
    never (JustOneMore nvr) =
      never nvr
If you can get a `Never` instance that can't possibly exist, you must be in a code path that can't happen, so you can get any value you want to short circuit early and make impossible return values. That makes it very useful in a language with no runtime exceptions to handle impossible cases. (E.g: you can go from a `Result Never a` to an `a` where normally you'd have to handle the error case).

[1]: https://github.com/elm/core/blob/1.0.5/src/Basics.elm#L948