SamuelSchlesinger / commander-cli

A simple library I wrote to allow me to quickly and easily construct command line interfaces.
MIT License
29 stars 2 forks source link

right is usually tried first #11

Closed BebeSparkelSparkel closed 1 year ago

BebeSparkelSparkel commented 3 years ago

Maybe I am mistaken but isn't usual to have the right be tried first?

https://github.com/SamuelSchlesinger/commander-cli/blob/51116f5e9b4f40cb8ba3eacf45cf801fab102180/src/Options/Commander.hs#L185

SamuelSchlesinger commented 3 years ago

That might be true. I was thinking we try the left branch then the right, cause that's the way humans read and the function reads well as leftCase x <|> rightCase x cause that's on the left. Honestly open to changes here, but it would be a breaking change and would require a potentially unpleasant to reason about major version bump.

SamuelSchlesinger commented 3 years ago

After a thought, I think a nice change would be to change to it not being Either but being a new data type, something like:

data Alternate a b = Alternate b | Primary a

This makes the change explicit in the types, so as long as people understand the current behavior (though, per your comment, they might not...), they will understand how to migrate. I'd be open to a PR of this sort, if you want another way to contribute, but I would also get around to it sometime.

BebeSparkelSparkel commented 3 years ago

Perhaps it would be better to have Alternate functor capable with data Alternate a b = Alternate a | Primary b for moving forward but have a compatibility type like type AltEither a b = Alternate b a and a conversion function altEither :: AltEither a b -> Either a b.

SamuelSchlesinger commented 3 years ago

Looking now.