-
-
Notifications
You must be signed in to change notification settings - Fork 95
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mapping the left side of an Either #98
Comments
Nice suggestions! In Haskell Data.Either is an instance of Data.Bifunctor. Which would give us |
I'm going to go ahead and take a crack at |
Are you still interested in working on this, @benperez? If not, I'm happy to investigate these options. |
I can check it out this weekend after I submit my ramda PR. |
That would be wonderful! |
@blperez is an imposter, I'll take a look when if I get a chance this weekend. |
any news on this side? |
I think we should implement Either#bimap :: Either a b ~> (a -> c) -> (b -> d) -> Either c d I'm preparing to move to a different continent in a couple of days, but I should be able to devote significant time to Sanctuary once I'm in Europe. If you'd like to contribute a pull request for this addition, though, please do so. :) |
Examples: S.Right(1).extract();
// => 1
S.Left("NaN").extract();
// => ?
S.Right(1).orElse(2);
// => 1
S.Left("NaN").orElse(2);
// => 2
S.Right(1).orElseGet(() => 2);
// => 1
S.Left("NaN").orElseGet(() => 2);
// => 2
S.Right(1).orElseThrow(() => new Error("fatal: because reasons");
// => 1
S.Left("NaN").orElseThrow(() => new Error("fatal: because reasons");
// => throws Error With |
In other words, |
Basically. Hence the |
Static versions come in handy when going through a map as well rather than having to purge all the lefts/nothings/failures. |
Thanks to #229 we have |
Let's explore if these functions in
data.either
would be useful in Sanctuary:orElse
bimap
leftMap
The text was updated successfully, but these errors were encountered: