Open StefanHoutzager opened 3 years ago
Yeah, I have learned Haskell and Rust, but haven't seen the article above before.
To be honest, I tend to confuse errors and exceptions at work,but I think they are very different
@uinz Maybe thinking with the inhabitants of type can help.
zero
inhabitants type like Void
or never
or panic
, means halt, no program can run.1 + a
inhabitants type like Maybe
in Haskell
, or Option
in Rust
, encode the empty or defaults with a specific typea + b
inhabitants types like Either
in Haskell
, or Result
in Rust
, encode the union of two types.Choice the appropriate one to model the problem we are facing in some domains.
Interesting work. Have you looked into "type safe errorhandling"? For example https://dev.to/_gdelgado/type-safe-error-handling-in-typescript-1p4n explains it a bit.