JasonShin / fp-core.rs

A library for functional programming in Rust
MIT License
1.34k stars 65 forks source link

Support Result<T,_> in a way similar to Option<T>. #44

Closed massimiliano-mantione closed 4 years ago

massimiliano-mantione commented 4 years ago

On similar "functional programming adaptation projects" I have seen Option types where the None branch actually carries a value and is used to describe errors.

An example is fp-ts for Typescript.

This is exactly what the Rust Result type does, so I added support for it handling it just like Option.

This can be useful to chain computations on the "happy path", like when chaining and_then calls.

JasonShin commented 4 years ago

amazing!! thanks for this! i will review it tonight

JasonShin commented 4 years ago

Looks fine to me!