I have
type Month = Int
parseMonths :: OP.Parser (Month, Month)
parseMonths =
liftA2 (,)
(OP.option
(OP.eitherReader $
parseNumber "month" (\n -> 1<=n && n<=12) "month")
(OP.metavar "MONTH" <>
OP.long "from-month" <>
OP.value 1))
(OP.option
(OP.eitherReader $
parseNumber "month" (\n -> 1<=n && n<=12) "month")
(OP.metavar "MONTH" <>
OP.long "to-month" <>
OP.value 12))
I want to add a check, that the first month is not after the second month. Obviously I cannot do that in OP.ReadM
. Can I perform the check in OP.Parser
? Or do I have to perform the check after parsing with parserFailure
like here:
Optparse-applicative: consecutive parsing (ReadM)
?