Skip to content
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

Pure Value Matches #758

Open
FreeApophis opened this issue Feb 8, 2023 · 0 comments
Open

Pure Value Matches #758

FreeApophis opened this issue Feb 8, 2023 · 0 comments
Labels
area: DiscriminatedUnion Issues for Funcky.DiscriminateUnion

Comments

@FreeApophis
Copy link
Member

Idea to think about:

  • currently you always have to provide a Func even in simple cases where you return only a value in each case:

Example:

        => validationResult
            .Match(notValidated: _ => HttpStatusCode.BadRequest, valid: _ => HttpStatusCode.OK, invalid: _ => HttpStatusCode.BadRequest);

And this would allow code like this:

    private static HttpStatusCode ToStatusCode(this DataValidationResult validationResult)
        => validationResult
            .Match(notValidated: HttpStatusCode.BadRequest, valid: HttpStatusCode.OK, invalid: HttpStatusCode.BadRequest);

Possible Strategies:

  • Either everything is a func or everything is a value. (Above)
  • Allow Values only in cases where there is an empty class provided. (Like Option)

Pro:

  • simpler code in a few cases
  • Similarity to Option

Contra:

  • could lead to overload problems
@bash bash transferred this issue from polyadic/funcky-discriminated-union Nov 7, 2023
@bash bash added the area: DiscriminatedUnion Issues for Funcky.DiscriminateUnion label Nov 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: DiscriminatedUnion Issues for Funcky.DiscriminateUnion
Projects
None yet
Development

No branches or pull requests

2 participants