You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I'm new to neverthrow (and functional programming) and I can't understand how to reuse a former value in a pipeline
functionrun(){returnfromPromise(getData(),()=>newError('error getting data')).andThen((fetched)=>ok(add(fetched,5))).andThen((added)=>ok(multiply(added,2))).andThen((multiplied)=>ok(substract(multiplied,3))).andThen((substracted,fetched)=>ok(add(substracted,fetched)))// fetched is not accessible here.match((value)=>value,(error)=>error)}
The text was updated successfully, but these errors were encountered:
unfortunately, there is no way to reuse a former value. you basically have 2 options here, either "pause" a pipeline mid-way, unwrap the value you need and then start a new one where later you can refer to it. alternatively you may introduce a more complex value in your result to carry the value you need, the approach is similar to the state monad in haskell
Hi, I'm new to neverthrow (and functional programming) and I can't understand how to reuse a former value in a pipeline
The text was updated successfully, but these errors were encountered: