Open
Description
Is the Select method not supported for linq query syntax for result?
As an example here is code that works with Maybe
Maybe<string> name = "John";
var upper = from x in name select x.ToUpper();`
But does not work with Result
This is the error:
CS1936 Could not find an implementation of the query pattern for source type 'Result'. 'Select' not found.
I see the that SelectMany operation is supported but it looks like there is no select. Is this something that you would be open to me adding?
It would help with workflows like this
Result<string> GetGreetingMessage(string userName)
{
var maybeGreeting =
from name in ValidateName(userName) // Bind the validated name
select CreateGreetingMessage(name); // Map to a greeting message
// Convert Maybe to Result
return maybeGreeting.ToResult("Invalid name provided");
}
Maybe<string> ValidateName(string name)
{
// Check if the name is valid, return Maybe.None if invalid
return string.IsNullOrWhiteSpace(name) ? Maybe<string>.None : Maybe<string>.From(name);
}
but for results.
Metadata
Metadata
Assignees
Labels
No labels