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
In a previous project I used fp-ts which has match and a less strict matchW (short for widening).
I'm not necessarily suggesting to add this (though it would be nice to have), but how would we implement this ourselves? I especially had trouble coming up with an implementation that supports both the data-first and data-last functionality.
function matchW<A, B, R, R2>(result: Result<A, B>, okFn: (value: A) => R, errorFn: (value: B) => R2): R | R2
function matchW<A, B, R, R2>(okFn: (value: A) => R, errorFn: (value: B) => R2): (result: Result<A, B>) => R | R2
The first one was pretty trivial to write, but did not manage to have one (at least clean) implementation supporting both. Is there an easy way to implement using match? Seeing an example would help me (and maybe others) understand how to implement similar helpers.
The text was updated successfully, but these errors were encountered:
In a previous project I used
fp-ts
which hasmatch
and a less strictmatchW
(short for widening).I'm not necessarily suggesting to add this (though it would be nice to have), but how would we implement this ourselves? I especially had trouble coming up with an implementation that supports both the data-first and data-last functionality.
The first one was pretty trivial to write, but did not manage to have one (at least clean) implementation supporting both. Is there an easy way to implement using
match
? Seeing an example would help me (and maybe others) understand how to implement similar helpers.The text was updated successfully, but these errors were encountered: