hello,
 
i have a parser which is a state transformer monad, and i need to implement a lookahead function, which applies a given parser but does not change the parser state. so i wrote a function which reads the state, applies the parser and restores the state (the State monad is derived from the paper "Monadic parser combinators" by Hutton/Meijer):
 
 
type Parser a = State String Maybe a
lookahead  :: Parser a -> Parser a
lookahead p = do { s <- fetch
                 ; x <- p
                 ; set s
                 ; return x
                 }
now i am curious if it is possible to run the given parser (state transformer) in a context of a state reader somehow, so as the state gets preserved automatically. something that would let me omit the calls to fetch and set methods.
 
i would appreciate any advise
 
thanks
konst