News for hackers. Stuff that matters.
Re:Mental models around Ok-Wrapping by bcheung on Friday April 10, 2020 @12:26PM (#22834587)
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...

Re:Mental models around Ok-Wrapping by whelming_wave on Friday April 10, 2020 @07:50PM (#22838553)
I'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

[2]: https://crates.io/crates/thiserror