module Text.ParserCombinators.Poly.State
(
Parser(P)
, Result(..)
, runParser
, next
, eof
, satisfy
, onFail
, stUpdate
, stQuery
, stGet
, reparse
, module Text.ParserCombinators.Poly.Base
, module Control.Applicative
) where
import Text.ParserCombinators.Poly.Base
import Text.ParserCombinators.Poly.Result
import Text.ParserCombinators.Poly.StateParser
import Control.Applicative
runParser :: Parser s t a -> s -> [t] -> (Either String a, s, [t])
runParser (P p) = \s-> reTuple . resultToEither . p s
where
reTuple (either, (z,s)) = (either, s, z)
instance Applicative (Parser s t) where
pure f = return f
pf <*> px = do { f <- pf; x <- px; return (f x) }
#if defined(GLASGOW_HASKELL) && GLASGOW_HASKELL > 610
p <* q = p `discard` q
#endif
instance Alternative (Parser s t) where
empty = fail "no parse"
p <|> q = p `onFail` q
instance PolyParse (Parser s t)