4 ms·
If you're representing error conditions as part of a mathematical type, you're definitely doing it wrong. The correct way to do this is to have a type that exp
by wyager 12y ago
If you're representing error conditions as part of a mathematical type, you're definitely doing it wrong.
The correct way to do this is to have a type that explicitly deals with errors, and use this to wrap the mathematical type.
This type is usually called Maybe or Option. For example, in Rust, you can have a `Option<bool>`, which can have one of three values: `None` (which might represent an error), `Some(true)`, or `Some(false)`.
The important thing is that you're not making some weird, poorly thought out kludge type. You're composing two clean and simple types in an obvious way.