fluture-js / Fluture

🦋 Fantasy Land compliant (monadic) alternative to Promises

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add a bichain function

Avaq opened this issue · comments

bichain :: (a -> Future x y) -> (b -> Future x y) -> Future a b -> Future x y

Currently the only way to bichain is like this:

compose (chain (x => x)) (coalesce (f) (g))

It's not straightforward and one might be inclined to do something like this instead:

compose (chainRej (f)) (chain (g))

However, this solution behaves different from how bichain would, in that if g returns a rejected Future, its rejection is handled by f.