使用 optparse-applicative 的程序的(类型化)参数列表

(typed) list of argument from a program using optparse-appplicative

有没有办法从使用 optparse-applicative 制作的命令行程序中提取名称和类型列表?

我正在 +/- 寻找 ParserInfo a -> [(String,TypeRep)]

类型的函数

不行,没办法。相关位是:

data ParserInfo a = ParserInfo   
    { infoParser :: Parser a
    , -- ...
    }

data Parser a
  = forall x . MultP (Parser (x -> a)) (Parser x)
  | forall x . BindP (Parser x) (x -> Parser a)
  | -- ...

由于 MultPBindPx 是存在量化的并且不带有 Typeable 约束,关于在叶子上使用的类型的信息Parser a 树在运行时丢失。