The Parsec documentation has an example of using makeTokenParser to build a lexer:
module Main where
import Text.Parsec
import qualified Text.Parsec.Token as P
import Text.Parsec.Language (haskellDef)
-- The parser
...
expr = parens expr
<|> identifier
<|> ...
-- The lexer
lexer = P.makeTokenParser haskellDef
parens = P.parens lexer
braces = P.braces lexer
identifier = P.identifier lexer
reserved = P.reserved lexer
...
In "The lexer" block, every P.* is applied to lexer so that one can avoid repeating that in "The parser" block. However repeating that for every token is still tedious. Is there some way to avoid the repetition even more? I was thinking to implicitly apply lexer everywhere in "The parser", but am at lost how to.