3 ms·
`Result<T, E>` comes from Haskell's `Either a b` type. F# also has a `Result<'T, 'E>` type. It's funny how often functional programming languages lead the way,
by munchler 11mo ago
`Result<T, E>` comes from Haskell's `Either a b` type. F# also has a `Result<'T, 'E>` type.
It's funny how often functional programming languages lead the way, but imperative languages end up with the credit.
- raincole 11mo agoActually (insert nerd emoji) this is a direct descendant from tagged union type, which existed in ALGLO 68, an imperative language. Java's checked exception is just an (very anti-ergonomic) implementation of tagged union type.
- munchler 11mo agoOK, but it wasn't until functional programming came along that tagged unions were recognized as a natural way to implement sum types, which is how they are used in modern programming. The old idea of a "variant" has pretty much faded away.
- paulddraper 11mo agoAlgebraic types, immutable structures, lambdas, higher-order functions. I think FP receives a lot of "credit." Albeit the "pure" FP languages aren't popular, because 99% FP is really hard.