4 ms·
I created a Result style interface in Typescript and made the decisions to fix the Error to a single type for this very reason. Result<T> instead of Result<T,E
by bcheung 7y ago
I created a Result style interface in Typescript and made the decisions to fix the Error to a single type for this very reason.
Result<T> instead of Result<T,E> so that it was easier to compose.
This made Kleisli composition easier since I don't have to worry about mismatched types on the Error.
You can see the code at https://github.com/brennancheung/wasmtalk/blob/master/src/fp/Result.ts https://github.com/brennancheung/wasmtalk/blob/master/src/fp...
- whelming_wave 6y agoI've found this kind of pattern much nicer in an application context. Rust sort of has this going on with anyhow[1] for applications and thiserror[2] for libraries (or just writing your own Error type). [1]: https://crates.io/crates/anyhow https://crates.io/crates/anyhow [2]: https://crates.io/crates/thiserror https://crates.io/crates/thiserror