Ticket #531 (closed enhancement: invalid)

Opened 4 years ago

Last modified 17 months ago

Text.Parsec.Combinators.notFollowedBy too restrictive

Reported by: nzeh Owned by:
Priority: normal Milestone: _|_
Component: Cabal library Version: 1.6.0.1
Severity: minor Keywords:
Cc: Difficulty: unknown
GHC Version: Platform:

Description

Say, you want to write something like

aParser :: Parser String
aParser = many1 $ noneOf "a" <|>
                  ( char 'a' >>
                    notFollowedBy $ string "rrgh" >>
                    return 'a'
                  )

This fails because, according to the type signature of notFollowedBy, since the parser parses a stream characters, the parser given to notFollowedBy must have return type Char, which it doesn't. The same happens for something a little more meaningful such as

nonFinalA :: Parser ()
nonFinalA = char 'a' >> notFollowedBy eof

because eof has return type (). This is a request to change the type signature of notFollowedBy to accept a parser with arbitrary return type.

Rationale:

  • The return type is ignored anyway.
  • The return type has only a loose connection with what part of the input stream the parser consumes.

Change History

in reply to: ↑ description   Changed 4 years ago by duncan

  • status changed from new to closed
  • resolution set to invalid

Replying to nzeh:

Say, you want to write something like

Looks like you've opened this ticket in the wrong trac. I'm not quite sure where one should report bugs in parsec but it's certainly not here. Sorry. The parsec.cabal file lists a maintainer, you could try emailing them.

  Changed 17 months ago by elga

Note: See TracTickets for help on using tickets.