-
-
Notifications
You must be signed in to change notification settings - Fork 417
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
Replace current Result<T>.Match syntax #1141
Comments
Even tho this post is a bit older, I'm gonna answer it out of my knowledge for anyone reading this and asking this himself, too.
When you use monads you rather want to produce so called railroaded code: Stay in the monads by using map and bind functions, lift pure values up to them and keep this up until you reach the end of the application. Monads aren't supposed to be unwrapped after every operation |
@MrWuffels You've got the job ;) |
Maybe a little irrelevant to this, but may I ask why in the |
@wxxedu Which If you mean the It is however good practice to use named parameters when using var result = either.Match(
Left: l => ...,
Right: r => ...); This labelling of parameters is more declarative and makes code easier to read for others (with no cost overhead). In var result = either switch
{
Either.Left<L, R> l => ...,
Either.Right<L, R> r => ...,
}; |
Hi @louthy, thanks so much for the quick and detailed reply. Yes I was meaning the |
Why not create something like the following? Your current
Result<T>.Match
/IfSucc
syntax looks a bit weird and so is the nameIfSucc
.instead of
I assume the reason you didn't is because you were not aware of the
MemberNotNullWhen
/NotNullWhen
attributes.The text was updated successfully, but these errors were encountered: