3 ms·
Null and exceptions. (in Haskell, Maybe and Try/Either)
by bedobi 6y ago
Null and exceptions. (in Haskell, Maybe and Try/Either)
- dmix 6y agoNothing beats pattern matching on Maybe for exception or null handling, or variations of such (Rust's Option). It's just so clean syntactically.
- mirekrusin 6y agoI’d argue that nullable type with refinements as in flow for example beats Maybe most of the time. You can’t make it simpler (one letter ? overhead) without special unwrapping constructs (refinements) just normal code with same guarantees.
- lmm 6y agoRefinement typing is too complicated IME. Haskell guarantees that you can always pull out an expression into a function without changing anything, and vice versa, whereas with refinement types you can extract a function and find your code no longer compiles.
- js8 6y agoYes, null is, as it turns out, an incorrect abstraction. It's like saying that all your types are Maybe a, and you cannot get create a type that is not (with few exceptions of base types, which confuses it even more). I would also add Enums to the list, sum types are superior in all respects.