首页 > 解决方案 > 使用 optparse-applicative 的程序的(键入)参数列表

问题描述

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

我正在 +/- 寻找一些类型的功能ParserInfo a -> [(String,TypeRep)]

标签: haskelloptparse-applicative

解决方案


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

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)
  | -- ...

由于 和 的sx是存在量化的并且不带有约束,因此有关在树的叶子上使用的类型的信息在运行时会丢失。MultPBindPTypeableParser a


推荐阅读