For haskell it will give you a warning. For Rust it will actually not compile. The key here is that you MUST use pattern matching.
For haskell it will give you a warning. For Rust it will actually not compile. The key here is that you MUST use pattern matching.
Having to wrap every division call in a maybe monad or rust result enum is bad from a usability standpoint and potentially unacceptable from a performance standpoint.
Exhaustive pattern matching is great. But not a replacement for other types of error handling.
There are languages that employ this philosophy everywhere. Such languages are actually incapable of having a runtime error outside of edge cases like ffi.
Just so you know, you don't have to wrap every type in an enum. Types and enums share a bijective relationship. A type IS an enum and vice versa. You CAN in fact define an Int in terms of an enum (and an enum in terms of an int, in C). The mechanisms behind an Int and a bool are roughly the same, it's just the cardinality and mappings that are different. Pattern matching implementations usually check types based off of cardinality and do not differentiate between enums and other built in types like floats or ints.