3

I have the following Haskell code using optparse-applicative which hangs at runtime.

main :: IO ()
main = do
  printf "Start...\n"
  args <- execParser $ info args fullDesc
  printf "Cmdline args: %s\n" (show args)

args :: Parser [Integer]
args = many (option auto
         (short 'x'
           <> value 1))

The problem is related to the use of many combinator because once I remove it the code runs fine.

Is this a bug or am I doing something wrong?

Thanks!

vidi
  • 2,056
  • 16
  • 34

1 Answers1

5

I think, the problem here is with the default value. Just remove value 1 from parser modifiers.

From docs on value:

Note: Because this modifier means the parser will never fail, do not use it with combinators such as some or many, as these combinators continue until a failure occurs. Careless use will thus result in a hang.

freestyle
  • 3,692
  • 11
  • 21