I find myself unable to reason about an error that `optional` in a parser err out instead of return Nothing, I asked the question at StackOverflow, and would like to seek your help here as well.
$ cabal run dcp:dcp < samples/basic.txt
Up to date
dcp: 10:1:
|
10 | method doXXX() pass
| ^
unexpected 'm'
expecting ';'
CallStack (from HasCallStack):
error, called at src/Parser.hs:149:14 in main:Parser
$
I believe it's optionalSemicolon
causing the failure:
findIt = do
nbsc >> optionalSemicolon >> nbsc
getIt >>= \case
optionalSemicolon :: Parser Bool
optionalSemicolon = fromMaybe False <$> optional (True <$ symbol ";")
I can't reason about why it can fail like this.