Parsec State Monad Question

John Knottenbelt jak97 at
Fri Mar 5 10:57:07 EST 2004


I was wondering if it was possible to write a function that allows changing 
the state type of the Parser monad from Parsec.

The full parser type is: GenParser p s a, where p is the token type, s is the 
state type and a is the return type of the monad. However, I mostly use 
CharParser s a which is a synonym for GenParser Char s a.

What I would like is a function that allows me to combine CharParsers with 
differing state types. Something like:

runParser' :: CharParser t a -> t -> CharParser s (t,a)

So that I can use parsers written to work with different state types together 
on the same input stream.

Does anybody know if this is possible, or how one might do it with Parsec?



More information about the Glasgow-haskell-users mailing list