lexeme<A> function

Parser<ParseError, A> lexeme<A>(
  1. Parser<ParseError, A> parser
)

Wraps parser to consume trailing whitespace.

Every atom in a grammar should consume its own trailing whitespace (either via lexeme or a manual whitespace parser). If an atom doesn't, downstream combinators like chainl1 will fail to match the operator between terms.

Implementation

Parser<ParseError, A> lexeme<A>(Parser<ParseError, A> parser) =>
    Mapped<ParseError, (A, List<String>), A>(
      Zip<ParseError, A, List<String>>(parser, spaces()),
      ((A, List<String>) pair) => pair.$1,
    );