commandlineparser / commandlineparser/commandline

Question - can f# matching handle verbs?

Ouverte
#774 1 commentaire 0 réactions 0 personnes assignées Voir sur GitHub
Langage dominant
C#
Étoiles
4.8k
Forks
478
Métriques de merge des PR
Aucune PR mergée en 30 j

Description

Sorry for question as issue, googled a bit and had no luck.

Is the F# matching support meant to work with verbs? I'm trying

```fs
[]
type UploadOptions = {
[] FileName: string;
[] RootUrl: string;
}

[]
type OtherOptions = {
[] Opt: string;
}

let getOpts argv : CLIOptions =
let result = CommandLine.Parser.Default.ParseArguments(argv)
match result with
| :? Parsed as p -> p.Value // <-- compile error here
| :? Parsed as p -> p.Value
| :? NotParsed as e ->
let errs = e.Errors |> Seq.map string |> Seq.toList
failwith <| String.Join("\n", errs)
| _ -> failwith "bang"
```

But this fails to compile:
```
Type constraint mismatch. The type
'Parsed'
is not compatible with type
'ParserResult'
```

I don't have a good understanding of how C# types map to F# sorry, so apologies if I'm missing something obvious.

EDIT: Never mind, found the readme. Consider this a feature request to not need to double match against `obj`. :)

Guide de contribution

Aucun guide de contribution indexé pour ce dépôt

Évaluation

Cette issue n'a pas encore été évaluée.

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.