Skip to content

Conversation

@mrboring
Copy link
Contributor

@mrboring mrboring commented Aug 4, 2025

Add other types of ArgumentArity.

@mrboring
Copy link
Contributor Author

mrboring commented Aug 5, 2025

I've been thinking and I'm not sure this is needed. The current implementation allows access to all the types of arity.

let x =
    option<string array> "--test"
    |> arity (ArgumentArity(1, 3))
    |> arity ArgumentArity.ExactlyOne
    |> arity ArgumentArity.OneOrMore
    |> arity ArgumentArity.Zero
    |> arity ArgumentArity.ZeroOrMore
    |> arity ArgumentArity.ZeroOrOne

Also MaximumNumberOfValues and MinimumNumberOfValues have Get only.

My code (minus the previous two) just removes the need to prefix with ArgumentArity, making it a bit more F# like.

let x =
    option<string array> "--test"
    |> arity (ArgumentArity (1, 3))
    |> arity ExactlyOne
    |> arity OneOrMore
    |> arity Zero
    |> arity ZeroOrMore
    |> arity ZeroOrOne

What do you think?

@JordanMarr
Copy link
Owner

JordanMarr commented Aug 5, 2025

I was going back and forth on it earlier and am still undecided.

As you said, using the built-in properties like ArgumentArity.ExactlyOne already works using the established ArgumentArity type.

OTOH, the DU is a bit more F# like.

@mrboring
Copy link
Contributor Author

mrboring commented Aug 5, 2025

I do prefer the F# style using the DU.

The original method is a mix of F# and direct calls to S.CL. Though it works well, it smells a bit.

@JordanMarr JordanMarr merged commit e20df56 into JordanMarr:main Aug 7, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants