Recommendation: Non-Generic Maybe.From Factory Method
seangwright opened this issue · 1 comments
seangwright commented
Sometimes I combine the use of Result<T>
and Maybe<T>
:
Result<Maybe<string>> stringOperation = // ...
Sometimes C#'s type inference isn't as smart as I would like it to be and the implicit conversions don't flow through my code.
I propose creating a static class that would create Maybe<T>
without having to specify the type parameter:
public static class Maybe
{
public static Maybe<T? From<T>(T value) => Maybe<T>.From(value);
}
It would be used like:
var result1 = Result.Success(Maybe.From("name"));
// vs
var result2 = Result.Success(Maybe<string>.From("name"));
I'd be happy to make a PR if you think this is a helpful addition.
vkhorikov commented
Yep, sounds good. Please go ahead with the PR.