Result to Maybe
See original GitHub issueHi Vladimir, thanks for that great library and your premium stuff on Pluralsight. I was wondering why there is no Extension on Result<T> to convert it to a Maybe<T> like the following:
public static class ResultToMaybeExtensions { public static Maybe<T> ToMaybe<T>(this Result<T> result) { return result.IsFailure ? Maybe<T>.None : Maybe.From(result.Value); } }
Do I misunderstande these two concepts so that this is not a valid use case? For example I would like to offer the value object Address on an Entity Customer as a get-only Maybe. Therefore I would use Address.Create(…) and later in the process I need to transform it to a Maybe monade.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Result to Maybe Conversion - Vladimir Khorikov
Result and Maybe. First off, what are Result and Maybe ? Result is a class that represents a result of an operation.
Read more >Brief beginners guide to Maybe and Result types in Elm
Two of them are the concepts of Result and Maybe. ... So, to deal with situation that can bring error, there are three...
Read more >vkhorikov/CSharpFunctionalExtensions: Functional ...
Use case: Procedurally checking if the Maybe has a value, usually before accessing the value directly. void Response(string fruit) { Console.
Read more >Extensions — csharp-functional-docs 1.0.0 documentation
In the NuGet packages there are extensions that mutate from Maybe monad to Result, Result<T>, Result<TValue,TError>; as well as many others that mutate...
Read more >Functional C#: Handling failures, input errors
Introducing the Result class helps to show if the method can fail or not. OnSuccess, OnFailure, and OnBoth methods, on the other hand,...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Yes, it is planned, just didn’t have time yet to implement it. Feel free to submit a PR.
Thanks Vladimir for explanation. 👍 I would really enjoy seeing your Pluralsight course EF Core Encapsulation updated to the new possibilities of EF Core 6. ✌️ Maybe I can contribute to or support you with Code Samples