Custom whiteSpace using Haskell Parsec

Posted by fryguybob on Stack Overflow See other posts from Stack Overflow or by fryguybob
Published on 2010-04-14T23:25:00Z Indexed on 2010/04/15 0:43 UTC
Read the original article Hit count: 469

Filed under:
|
|
|

I would like to use Parsec's makeTokenParser to build my parser, but I want to use my own definition of whiteSpace. Doing the following replaces whiteSpace with my definition, but all the lexeme parsers still use the old definition (e.g. P.identifier lexer will use the old whiteSpace).

...
lexer :: P.TokenParser ()
lexer      = l { P.whiteSpace = myWhiteSpace }
   where l = P.makeTokenParser myLanguageDef
...

Looking at the code for makeTokenParser I think I understand why it works this way. I want to know if there are any workarounds to avoid completely duplicating the code for makeTokenParser?

© Stack Overflow or respective owner

Related posts about haskell

Related posts about parsec