-
Notifications
You must be signed in to change notification settings - Fork 4
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
Simpler Monad Constructors #809
Comments
I have thought about the The either version looks really cool, I gotta experiment with that. Maybe it's possible to do it with a static function instead of an extension method instead for symmetry? |
It's a discussion opener, I do not have strong opinions yet, except that I really want that |
An alternative for It can easily co-exist with the specify-value-first approach. Either<string, int> a = Either.WithLeft<string>.Return(10);
Either<string, int> b = Either.Right(10).WithLeft<string>();
Either<int, string> c = Either.WithRight<string>.Return(10);
Either<int, string> d = Either.Left(10).WithRight<string>();
enumerable.Select(Either.WithRight<string>.Return);
public static class Either
{
public static RightBuilder<TRight> Right<TRight>(TRight right) => ...;
public static LeftBuilder<TLeft> Left<TLeft>(TLeft left) => ...;
public static class WithLeft<TLeft>
where TLeft : notnull
{
public static Either<TLeft, TRight> Return<TRight>(TRight right)
where TRight : notnull
=> Either<TLeft, TRight>.Right(right);
}
public static class WithRight<TRight>
where TRight : notnull
{
public static Either<TLeft, TRight> Return<TLeft>(TLeft left)
where TLeft : notnull
=> Either<TLeft, TRight>.Left(left);
}
} |
Looks actually pretty good, what would we do with the old Return which works at the moment like this: Either<string, int> either = Either<string>.Return(42); I found an old user story: #760 I think if we go this way we can close the idea to use |
lang-ext has something like this
Marc Seeman has one for Either: https://blog.ploeh.dk/2024/12/16/a-restaurant-sandwich/
We already have a simplified one as the Return function, but none for Left.
Consistency should be key here, probably needs some thinking what we exactly want.
Funcky.Functional
would probably the Prelude Object for us, if we go that route.The text was updated successfully, but these errors were encountered: