Open
Description
It would be nice to have F# parser like this Haskell library https://github.com/pcapriotti/optparse-applicative . I like that you can just pattern match the result. And it looks cool.
In F# it might look like the following when use (almost real code). Using notion from https://github.com/fsprojects/FSharpPlus
type Sample =
{ hello : string
quiet : bool
enthusiasm : int }
let currySample (hello : string) (quiet : bool) (enthusiasm : int) =
{ hello = hello
quiet = quiet
enthusiasm = enthusiasm }
let parser =
currySample
<!> Option(Aliases [ "--hello"; "-h" ]
+ HelpDetail "description"
+ Argument ExactlyOne "TARGET")
<*> Option(Aliases [ "-q" ]
+ HelpDetail "description"
+ Argument Zero)
<*> Option(Aliases [ "--enthusiasm" ]
+ HelpDetail "description"
+ Argument ExactlyOne "INT")
let result : Sample = runParser parser "--hello Bob -q --enthusiasm 3"
To add in subcommand, Sample need to be a union and it should use alternative to combine parser https://github.com/pcapriotti/optparse-applicative#alternative
Problems:
- Is there a genetic way to curry Record type? Or we may need to use Tuple.
- How to fit Argument? Just by position could be fine. During config, the name of the Record field is not used.
...
...