typescript-monads icon indicating copy to clipboard operation
typescript-monads copied to clipboard

Add reducer funcationality to `Result`

Open chughes-pika opened this issue 3 years ago • 1 comments

Rather frequently, I'm collapsing collections of Result and needing a way to easily collapse values together in Ok, or toggle the Result to Fail if it exists. Using Rust as an example, there's a good abstraction with having the and and or functions built into the result class to allow for this behavior (reference to Boolean Operators in https://doc.rust-lang.org/std/result/).

I'd like to request this type reducer functionality be added to the Result type.

chughes-pika avatar Sep 15 '22 16:09 chughes-pika

@chughes-pika ok I will check this out. Just read your comment today.

patrickmichalina avatar Oct 14 '22 05:10 patrickmichalina

@chughes-pika can you post an example here?

patrickmichalina avatar Nov 03 '22 14:11 patrickmichalina

I think my request here isn't fully formed. I'll close this issue though I might reopen it at a latter date when I have a more concrete description of how I'm hoping to solve my problem. At its root I'm wanting a simple way to do the follow Result<T, E>[] => Result<T[], E[]>, but that feels like something that would be built on top of this library and not built into it. Thank you for your time and sorry for the malformed request.

ghost avatar Nov 14 '22 18:11 ghost