{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE Safe #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE UndecidableInstances #-}
module Text.Megaparsec.Class
( MonadParsec (..),
)
where
import Control.Monad
import Control.Monad.Identity
import qualified Control.Monad.RWS.Lazy as L
import qualified Control.Monad.RWS.Strict as S
import Control.Monad.Trans
import qualified Control.Monad.Trans.Reader as L
import qualified Control.Monad.Trans.State.Lazy as L
import qualified Control.Monad.Trans.State.Strict as S
import qualified Control.Monad.Trans.Writer.Lazy as L
import qualified Control.Monad.Trans.Writer.Strict as S
import Data.Set (Set)
import Text.Megaparsec.Error
import Text.Megaparsec.State
import Text.Megaparsec.Stream
class (Stream s, MonadPlus m) => MonadParsec e s m | m -> e s where
parseError :: ParseError s e -> m a
label :: String -> m a -> m a
hidden :: m a -> m a
hidden = forall e s (m :: * -> *) a.
MonadParsec e s m =>
String -> m a -> m a
label String
""
try :: m a -> m a
lookAhead :: m a -> m a
notFollowedBy :: m a -> m ()
withRecovery ::
(ParseError s e -> m a) ->
m a ->
m a
observing ::
m a ->
m (Either (ParseError s e) a)
eof :: m ()
token ::
(Token s -> Maybe a) ->
Set (ErrorItem (Token s)) ->
m a
tokens ::
(Tokens s -> Tokens s -> Bool) ->
Tokens s ->
m (Tokens s)
takeWhileP ::
Maybe String ->
(Token s -> Bool) ->
m (Tokens s)
takeWhile1P ::
Maybe String ->
(Token s -> Bool) ->
m (Tokens s)
takeP ::
Maybe String ->
Int ->
m (Tokens s)
getParserState :: m (State s e)
updateParserState :: (State s e -> State s e) -> m ()
instance MonadParsec e s m => MonadParsec e s (L.StateT st m) where
parseError :: forall a. ParseError s e -> StateT st m a
parseError ParseError s e
e = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (forall e s (m :: * -> *) a.
MonadParsec e s m =>
ParseError s e -> m a
parseError ParseError s e
e)
label :: forall a. String -> StateT st m a -> StateT st m a
label String
n (L.StateT st -> m (a, st)
m) = forall s (m :: * -> *) a. (s -> m (a, s)) -> StateT s m a
L.StateT forall a b. (a -> b) -> a -> b
$ forall e s (m :: * -> *) a.
MonadParsec e s m =>
String -> m a -> m a
label String
n forall b c a. (b -> c) -> (a -> b) -> a -> c
. st -> m (a, st)
m
try :: forall a. StateT st m a -> StateT st m a
try (L.StateT st -> m (a, st)
m) = forall s (m :: * -> *) a. (s -> m (a, s)) -> StateT s m a
L.StateT forall a b. (a -> b) -> a -> b
$ forall e s (m :: * -> *) a. MonadParsec e s m => m a -> m a
try forall b c a. (b -> c) -> (a -> b) -> a -> c
. st -> m (a, st)
m
lookAhead :: forall a. StateT st m a -> StateT st m a
lookAhead (L.StateT st -> m (a, st)
m) = forall s (m :: * -> *) a. (s -> m (a, s)) -> StateT s m a
L.StateT forall a b. (a -> b) -> a -> b
$ \st
s ->
(,st
s) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. (a, b) -> a
fst forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall e s (m :: * -> *) a. MonadParsec e s m => m a -> m a
lookAhead (st -> m (a, st)
m st
s)
notFollowedBy :: forall a. StateT st m a -> StateT st m ()
notFollowedBy (L.StateT st -> m (a, st)
m) = forall s (m :: * -> *) a. (s -> m (a, s)) -> StateT s m a
L.StateT forall a b. (a -> b) -> a -> b
$ \st
s ->
forall e s (m :: * -> *) a. MonadParsec e s m => m a -> m ()
notFollowedBy (forall a b. (a, b) -> a
fst forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> st -> m (a, st)
m st
s) forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall (m :: * -> *) a. Monad m => a -> m a
return ((), st
s)
withRecovery :: forall a.
(ParseError s e -> StateT st m a) -> StateT st m a -> StateT st m a
withRecovery ParseError s e -> StateT st m a
r (L.StateT st -> m (a, st)
m) = forall s (m :: * -> *) a. (s -> m (a, s)) -> StateT s m a
L.StateT forall a b. (a -> b) -> a -> b
$ \st
s ->
forall e s (m :: * -> *) a.
MonadParsec e s m =>
(ParseError s e -> m a) -> m a -> m a
withRecovery (\ParseError s e
e -> forall s (m :: * -> *) a. StateT s m a -> s -> m (a, s)
L.runStateT (ParseError s e -> StateT st m a
r ParseError s e
e) st
s) (st -> m (a, st)
m st
s)
observing :: forall a. StateT st m a -> StateT st m (Either (ParseError s e) a)
observing (L.StateT st -> m (a, st)
m) = forall s (m :: * -> *) a. (s -> m (a, s)) -> StateT s m a
L.StateT forall a b. (a -> b) -> a -> b
$ \st
s ->
forall s a b. s -> Either a (b, s) -> (Either a b, s)
fixs st
s forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall e s (m :: * -> *) a.
MonadParsec e s m =>
m a -> m (Either (ParseError s e) a)
observing (st -> m (a, st)
m st
s)
eof :: StateT st m ()
eof = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall e s (m :: * -> *). MonadParsec e s m => m ()
eof
token :: forall a.
(Token s -> Maybe a) -> Set (ErrorItem (Token s)) -> StateT st m a
token Token s -> Maybe a
test Set (ErrorItem (Token s))
mt = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (forall e s (m :: * -> *) a.
MonadParsec e s m =>
(Token s -> Maybe a) -> Set (ErrorItem (Token s)) -> m a
token Token s -> Maybe a
test Set (ErrorItem (Token s))
mt)
tokens :: (Tokens s -> Tokens s -> Bool)
-> Tokens s -> StateT st m (Tokens s)
tokens Tokens s -> Tokens s -> Bool
e Tokens s
ts = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (forall e s (m :: * -> *).
MonadParsec e s m =>
(Tokens s -> Tokens s -> Bool) -> Tokens s -> m (Tokens s)
tokens Tokens s -> Tokens s -> Bool
e Tokens s
ts)
takeWhileP :: Maybe String -> (Token s -> Bool) -> StateT st m (Tokens s)
takeWhileP Maybe String
l Token s -> Bool
f = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (forall e s (m :: * -> *).
MonadParsec e s m =>
Maybe String -> (Token s -> Bool) -> m (Tokens s)
takeWhileP Maybe String
l Token s -> Bool
f)
takeWhile1P :: Maybe String -> (Token s -> Bool) -> StateT st m (Tokens s)
takeWhile1P Maybe String
l Token s -> Bool
f = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (forall e s (m :: * -> *).
MonadParsec e s m =>
Maybe String -> (Token s -> Bool) -> m (Tokens s)
takeWhile1P Maybe String
l Token s -> Bool
f)
takeP :: Maybe String -> Int -> StateT st m (Tokens s)
takeP Maybe String
l Int
n = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (forall e s (m :: * -> *).
MonadParsec e s m =>
Maybe String -> Int -> m (Tokens s)
takeP Maybe String
l Int
n)
getParserState :: StateT st m (State s e)
getParserState = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall e s (m :: * -> *). MonadParsec e s m => m (State s e)
getParserState
updateParserState :: (State s e -> State s e) -> StateT st m ()
updateParserState State s e -> State s e
f = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (forall e s (m :: * -> *).
MonadParsec e s m =>
(State s e -> State s e) -> m ()
updateParserState State s e -> State s e
f)
instance MonadParsec e s m => MonadParsec e s (S.StateT st m) where
parseError :: forall a. ParseError s e -> StateT st m a
parseError ParseError s e
e = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (forall e s (m :: * -> *) a.
MonadParsec e s m =>
ParseError s e -> m a
parseError ParseError s e
e)
label :: forall a. String -> StateT st m a -> StateT st m a
label String
n (S.StateT st -> m (a, st)
m) = forall s (m :: * -> *) a. (s -> m (a, s)) -> StateT s m a
S.StateT forall a b. (a -> b) -> a -> b
$ forall e s (m :: * -> *) a.
MonadParsec e s m =>
String -> m a -> m a
label String
n forall b c a. (b -> c) -> (a -> b) -> a -> c
. st -> m (a, st)
m
try :: forall a. StateT st m a -> StateT st m a
try (S.StateT st -> m (a, st)
m) = forall s (m :: * -> *) a. (s -> m (a, s)) -> StateT s m a
S.StateT forall a b. (a -> b) -> a -> b
$ forall e s (m :: * -> *) a. MonadParsec e s m => m a -> m a
try forall b c a. (b -> c) -> (a -> b) -> a -> c
. st -> m (a, st)
m
lookAhead :: forall a. StateT st m a -> StateT st m a
lookAhead (S.StateT st -> m (a, st)
m) = forall s (m :: * -> *) a. (s -> m (a, s)) -> StateT s m a
S.StateT forall a b. (a -> b) -> a -> b
$ \st
s ->
(,st
s) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. (a, b) -> a
fst forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall e s (m :: * -> *) a. MonadParsec e s m => m a -> m a
lookAhead (st -> m (a, st)
m st
s)
notFollowedBy :: forall a. StateT st m a -> StateT st m ()
notFollowedBy (S.StateT st -> m (a, st)
m) = forall s (m :: * -> *) a. (s -> m (a, s)) -> StateT s m a
S.StateT forall a b. (a -> b) -> a -> b
$ \st
s ->
forall e s (m :: * -> *) a. MonadParsec e s m => m a -> m ()
notFollowedBy (forall a b. (a, b) -> a
fst forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> st -> m (a, st)
m st
s) forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall (m :: * -> *) a. Monad m => a -> m a
return ((), st
s)
withRecovery :: forall a.
(ParseError s e -> StateT st m a) -> StateT st m a -> StateT st m a
withRecovery ParseError s e -> StateT st m a
r (S.StateT st -> m (a, st)
m) = forall s (m :: * -> *) a. (s -> m (a, s)) -> StateT s m a
S.StateT forall a b. (a -> b) -> a -> b
$ \st
s ->
forall e s (m :: * -> *) a.
MonadParsec e s m =>
(ParseError s e -> m a) -> m a -> m a
withRecovery (\ParseError s e
e -> forall s (m :: * -> *) a. StateT s m a -> s -> m (a, s)
S.runStateT (ParseError s e -> StateT st m a
r ParseError s e
e) st
s) (st -> m (a, st)
m st
s)
observing :: forall a. StateT st m a -> StateT st m (Either (ParseError s e) a)
observing (S.StateT st -> m (a, st)
m) = forall s (m :: * -> *) a. (s -> m (a, s)) -> StateT s m a
S.StateT forall a b. (a -> b) -> a -> b
$ \st
s ->
forall s a b. s -> Either a (b, s) -> (Either a b, s)
fixs st
s forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall e s (m :: * -> *) a.
MonadParsec e s m =>
m a -> m (Either (ParseError s e) a)
observing (st -> m (a, st)
m st
s)
eof :: StateT st m ()
eof = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall e s (m :: * -> *). MonadParsec e s m => m ()
eof
token :: forall a.
(Token s -> Maybe a) -> Set (ErrorItem (Token s)) -> StateT st m a
token Token s -> Maybe a
test Set (ErrorItem (Token s))
mt = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (forall e s (m :: * -> *) a.
MonadParsec e s m =>
(Token s -> Maybe a) -> Set (ErrorItem (Token s)) -> m a
token Token s -> Maybe a
test Set (ErrorItem (Token s))
mt)
tokens :: (Tokens s -> Tokens s -> Bool)
-> Tokens s -> StateT st m (Tokens s)
tokens Tokens s -> Tokens s -> Bool
e Tokens s
ts = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (forall e s (m :: * -> *).
MonadParsec e s m =>
(Tokens s -> Tokens s -> Bool) -> Tokens s -> m (Tokens s)
tokens Tokens s -> Tokens s -> Bool
e Tokens s
ts)
takeWhileP :: Maybe String -> (Token s -> Bool) -> StateT st m (Tokens s)
takeWhileP Maybe String
l Token s -> Bool
f = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (forall e s (m :: * -> *).
MonadParsec e s m =>
Maybe String -> (Token s -> Bool) -> m (Tokens s)
takeWhileP Maybe String
l Token s -> Bool
f)
takeWhile1P :: Maybe String -> (Token s -> Bool) -> StateT st m (Tokens s)
takeWhile1P Maybe String
l Token s -> Bool
f = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (forall e s (m :: * -> *).
MonadParsec e s m =>
Maybe String -> (Token s -> Bool) -> m (Tokens s)
takeWhile1P Maybe String
l Token s -> Bool
f)
takeP :: Maybe String -> Int -> StateT st m (Tokens s)
takeP Maybe String
l Int
n = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (forall e s (m :: * -> *).
MonadParsec e s m =>
Maybe String -> Int -> m (Tokens s)
takeP Maybe String
l Int
n)
getParserState :: StateT st m (State s e)
getParserState = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall e s (m :: * -> *). MonadParsec e s m => m (State s e)
getParserState
updateParserState :: (State s e -> State s e) -> StateT st m ()
updateParserState State s e -> State s e
f = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (forall e s (m :: * -> *).
MonadParsec e s m =>
(State s e -> State s e) -> m ()
updateParserState State s e -> State s e
f)
instance MonadParsec e s m => MonadParsec e s (L.ReaderT r m) where
parseError :: forall a. ParseError s e -> ReaderT r m a
parseError ParseError s e
e = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (forall e s (m :: * -> *) a.
MonadParsec e s m =>
ParseError s e -> m a
parseError ParseError s e
e)
label :: forall a. String -> ReaderT r m a -> ReaderT r m a
label String
n (L.ReaderT r -> m a
m) = forall r (m :: * -> *) a. (r -> m a) -> ReaderT r m a
L.ReaderT forall a b. (a -> b) -> a -> b
$ forall e s (m :: * -> *) a.
MonadParsec e s m =>
String -> m a -> m a
label String
n forall b c a. (b -> c) -> (a -> b) -> a -> c
. r -> m a
m
try :: forall a. ReaderT r m a -> ReaderT r m a
try (L.ReaderT r -> m a
m) = forall r (m :: * -> *) a. (r -> m a) -> ReaderT r m a
L.ReaderT forall a b. (a -> b) -> a -> b
$ forall e s (m :: * -> *) a. MonadParsec e s m => m a -> m a
try forall b c a. (b -> c) -> (a -> b) -> a -> c
. r -> m a
m
lookAhead :: forall a. ReaderT r m a -> ReaderT r m a
lookAhead (L.ReaderT r -> m a
m) = forall r (m :: * -> *) a. (r -> m a) -> ReaderT r m a
L.ReaderT forall a b. (a -> b) -> a -> b
$ forall e s (m :: * -> *) a. MonadParsec e s m => m a -> m a
lookAhead forall b c a. (b -> c) -> (a -> b) -> a -> c
. r -> m a
m
notFollowedBy :: forall a. ReaderT r m a -> ReaderT r m ()
notFollowedBy (L.ReaderT r -> m a
m) = forall r (m :: * -> *) a. (r -> m a) -> ReaderT r m a
L.ReaderT forall a b. (a -> b) -> a -> b
$ forall e s (m :: * -> *) a. MonadParsec e s m => m a -> m ()
notFollowedBy forall b c a. (b -> c) -> (a -> b) -> a -> c
. r -> m a
m
withRecovery :: forall a.
(ParseError s e -> ReaderT r m a) -> ReaderT r m a -> ReaderT r m a
withRecovery ParseError s e -> ReaderT r m a
r (L.ReaderT r -> m a
m) = forall r (m :: * -> *) a. (r -> m a) -> ReaderT r m a
L.ReaderT forall a b. (a -> b) -> a -> b
$ \r
s ->
forall e s (m :: * -> *) a.
MonadParsec e s m =>
(ParseError s e -> m a) -> m a -> m a
withRecovery (\ParseError s e
e -> forall r (m :: * -> *) a. ReaderT r m a -> r -> m a
L.runReaderT (ParseError s e -> ReaderT r m a
r ParseError s e
e) r
s) (r -> m a
m r
s)
observing :: forall a. ReaderT r m a -> ReaderT r m (Either (ParseError s e) a)
observing (L.ReaderT r -> m a
m) = forall r (m :: * -> *) a. (r -> m a) -> ReaderT r m a
L.ReaderT forall a b. (a -> b) -> a -> b
$ forall e s (m :: * -> *) a.
MonadParsec e s m =>
m a -> m (Either (ParseError s e) a)
observing forall b c a. (b -> c) -> (a -> b) -> a -> c
. r -> m a
m
eof :: ReaderT r m ()
eof = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall e s (m :: * -> *). MonadParsec e s m => m ()
eof
token :: forall a.
(Token s -> Maybe a) -> Set (ErrorItem (Token s)) -> ReaderT r m a
token Token s -> Maybe a
test Set (ErrorItem (Token s))
mt = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (forall e s (m :: * -> *) a.
MonadParsec e s m =>
(Token s -> Maybe a) -> Set (ErrorItem (Token s)) -> m a
token Token s -> Maybe a
test Set (ErrorItem (Token s))
mt)
tokens :: (Tokens s -> Tokens s -> Bool)
-> Tokens s -> ReaderT r m (Tokens s)
tokens Tokens s -> Tokens s -> Bool
e Tokens s
ts = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (forall e s (m :: * -> *).
MonadParsec e s m =>
(Tokens s -> Tokens s -> Bool) -> Tokens s -> m (Tokens s)
tokens Tokens s -> Tokens s -> Bool
e Tokens s
ts)
takeWhileP :: Maybe String -> (Token s -> Bool) -> ReaderT r m (Tokens s)
takeWhileP Maybe String
l Token s -> Bool
f = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (forall e s (m :: * -> *).
MonadParsec e s m =>
Maybe String -> (Token s -> Bool) -> m (Tokens s)
takeWhileP Maybe String
l Token s -> Bool
f)
takeWhile1P :: Maybe String -> (Token s -> Bool) -> ReaderT r m (Tokens s)
takeWhile1P Maybe String
l Token s -> Bool
f = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (forall e s (m :: * -> *).
MonadParsec e s m =>
Maybe String -> (Token s -> Bool) -> m (Tokens s)
takeWhile1P Maybe String
l Token s -> Bool
f)
takeP :: Maybe String -> Int -> ReaderT r m (Tokens s)
takeP Maybe String
l Int
n = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (forall e s (m :: * -> *).
MonadParsec e s m =>
Maybe String -> Int -> m (Tokens s)
takeP Maybe String
l Int
n)
getParserState :: ReaderT r m (State s e)
getParserState = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall e s (m :: * -> *). MonadParsec e s m => m (State s e)
getParserState
updateParserState :: (State s e -> State s e) -> ReaderT r m ()
updateParserState State s e -> State s e
f = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (forall e s (m :: * -> *).
MonadParsec e s m =>
(State s e -> State s e) -> m ()
updateParserState State s e -> State s e
f)
instance (Monoid w, MonadParsec e s m) => MonadParsec e s (L.WriterT w m) where
parseError :: forall a. ParseError s e -> WriterT w m a
parseError ParseError s e
e = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (forall e s (m :: * -> *) a.
MonadParsec e s m =>
ParseError s e -> m a
parseError ParseError s e
e)
label :: forall a. String -> WriterT w m a -> WriterT w m a
label String
n (L.WriterT m (a, w)
m) = forall w (m :: * -> *) a. m (a, w) -> WriterT w m a
L.WriterT forall a b. (a -> b) -> a -> b
$ forall e s (m :: * -> *) a.
MonadParsec e s m =>
String -> m a -> m a
label String
n m (a, w)
m
try :: forall a. WriterT w m a -> WriterT w m a
try (L.WriterT m (a, w)
m) = forall w (m :: * -> *) a. m (a, w) -> WriterT w m a
L.WriterT forall a b. (a -> b) -> a -> b
$ forall e s (m :: * -> *) a. MonadParsec e s m => m a -> m a
try m (a, w)
m
lookAhead :: forall a. WriterT w m a -> WriterT w m a
lookAhead (L.WriterT m (a, w)
m) =
forall w (m :: * -> *) a. m (a, w) -> WriterT w m a
L.WriterT forall a b. (a -> b) -> a -> b
$
(,forall a. Monoid a => a
mempty) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. (a, b) -> a
fst forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall e s (m :: * -> *) a. MonadParsec e s m => m a -> m a
lookAhead m (a, w)
m
notFollowedBy :: forall a. WriterT w m a -> WriterT w m ()
notFollowedBy (L.WriterT m (a, w)
m) =
forall w (m :: * -> *) a. m (a, w) -> WriterT w m a
L.WriterT forall a b. (a -> b) -> a -> b
$
(,forall a. Monoid a => a
mempty) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall e s (m :: * -> *) a. MonadParsec e s m => m a -> m ()
notFollowedBy (forall a b. (a, b) -> a
fst forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m (a, w)
m)
withRecovery :: forall a.
(ParseError s e -> WriterT w m a) -> WriterT w m a -> WriterT w m a
withRecovery ParseError s e -> WriterT w m a
r (L.WriterT m (a, w)
m) =
forall w (m :: * -> *) a. m (a, w) -> WriterT w m a
L.WriterT forall a b. (a -> b) -> a -> b
$
forall e s (m :: * -> *) a.
MonadParsec e s m =>
(ParseError s e -> m a) -> m a -> m a
withRecovery (forall w (m :: * -> *) a. WriterT w m a -> m (a, w)
L.runWriterT forall b c a. (b -> c) -> (a -> b) -> a -> c
. ParseError s e -> WriterT w m a
r) m (a, w)
m
observing :: forall a. WriterT w m a -> WriterT w m (Either (ParseError s e) a)
observing (L.WriterT m (a, w)
m) =
forall w (m :: * -> *) a. m (a, w) -> WriterT w m a
L.WriterT forall a b. (a -> b) -> a -> b
$
forall s a b. s -> Either a (b, s) -> (Either a b, s)
fixs forall a. Monoid a => a
mempty forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall e s (m :: * -> *) a.
MonadParsec e s m =>
m a -> m (Either (ParseError s e) a)
observing m (a, w)
m
eof :: WriterT w m ()
eof = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall e s (m :: * -> *). MonadParsec e s m => m ()
eof
token :: forall a.
(Token s -> Maybe a) -> Set (ErrorItem (Token s)) -> WriterT w m a
token Token s -> Maybe a
test Set (ErrorItem (Token s))
mt = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (forall e s (m :: * -> *) a.
MonadParsec e s m =>
(Token s -> Maybe a) -> Set (ErrorItem (Token s)) -> m a
token Token s -> Maybe a
test Set (ErrorItem (Token s))
mt)
tokens :: (Tokens s -> Tokens s -> Bool)
-> Tokens s -> WriterT w m (Tokens s)
tokens Tokens s -> Tokens s -> Bool
e Tokens s
ts = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (forall e s (m :: * -> *).
MonadParsec e s m =>
(Tokens s -> Tokens s -> Bool) -> Tokens s -> m (Tokens s)
tokens Tokens s -> Tokens s -> Bool
e Tokens s
ts)
takeWhileP :: Maybe String -> (Token s -> Bool) -> WriterT w m (Tokens s)
takeWhileP Maybe String
l Token s -> Bool
f = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (forall e s (m :: * -> *).
MonadParsec e s m =>
Maybe String -> (Token s -> Bool) -> m (Tokens s)
takeWhileP Maybe String
l Token s -> Bool
f)
takeWhile1P :: Maybe String -> (Token s -> Bool) -> WriterT w m (Tokens s)
takeWhile1P Maybe String
l Token s -> Bool
f = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (forall e s (m :: * -> *).
MonadParsec e s m =>
Maybe String -> (Token s -> Bool) -> m (Tokens s)
takeWhile1P Maybe String
l Token s -> Bool
f)
takeP :: Maybe String -> Int -> WriterT w m (Tokens s)
takeP Maybe String
l Int
n = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (forall e s (m :: * -> *).
MonadParsec e s m =>
Maybe String -> Int -> m (Tokens s)
takeP Maybe String
l Int
n)
getParserState :: WriterT w m (State s e)
getParserState = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall e s (m :: * -> *). MonadParsec e s m => m (State s e)
getParserState
updateParserState :: (State s e -> State s e) -> WriterT w m ()
updateParserState State s e -> State s e
f = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (forall e s (m :: * -> *).
MonadParsec e s m =>
(State s e -> State s e) -> m ()
updateParserState State s e -> State s e
f)
instance (Monoid w, MonadParsec e s m) => MonadParsec e s (S.WriterT w m) where
parseError :: forall a. ParseError s e -> WriterT w m a
parseError ParseError s e
e = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (forall e s (m :: * -> *) a.
MonadParsec e s m =>
ParseError s e -> m a
parseError ParseError s e
e)
label :: forall a. String -> WriterT w m a -> WriterT w m a
label String
n (S.WriterT m (a, w)
m) = forall w (m :: * -> *) a. m (a, w) -> WriterT w m a
S.WriterT forall a b. (a -> b) -> a -> b
$ forall e s (m :: * -> *) a.
MonadParsec e s m =>
String -> m a -> m a
label String
n m (a, w)
m
try :: forall a. WriterT w m a -> WriterT w m a
try (S.WriterT m (a, w)
m) = forall w (m :: * -> *) a. m (a, w) -> WriterT w m a
S.WriterT forall a b. (a -> b) -> a -> b
$ forall e s (m :: * -> *) a. MonadParsec e s m => m a -> m a
try m (a, w)
m
lookAhead :: forall a. WriterT w m a -> WriterT w m a
lookAhead (S.WriterT m (a, w)
m) =
forall w (m :: * -> *) a. m (a, w) -> WriterT w m a
S.WriterT forall a b. (a -> b) -> a -> b
$
(,forall a. Monoid a => a
mempty) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. (a, b) -> a
fst forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall e s (m :: * -> *) a. MonadParsec e s m => m a -> m a
lookAhead m (a, w)
m
notFollowedBy :: forall a. WriterT w m a -> WriterT w m ()
notFollowedBy (S.WriterT m (a, w)
m) =
forall w (m :: * -> *) a. m (a, w) -> WriterT w m a
S.WriterT forall a b. (a -> b) -> a -> b
$
(,forall a. Monoid a => a
mempty) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall e s (m :: * -> *) a. MonadParsec e s m => m a -> m ()
notFollowedBy (forall a b. (a, b) -> a
fst forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m (a, w)
m)
withRecovery :: forall a.
(ParseError s e -> WriterT w m a) -> WriterT w m a -> WriterT w m a
withRecovery ParseError s e -> WriterT w m a
r (S.WriterT m (a, w)
m) =
forall w (m :: * -> *) a. m (a, w) -> WriterT w m a
S.WriterT forall a b. (a -> b) -> a -> b
$
forall e s (m :: * -> *) a.
MonadParsec e s m =>
(ParseError s e -> m a) -> m a -> m a
withRecovery (forall w (m :: * -> *) a. WriterT w m a -> m (a, w)
S.runWriterT forall b c a. (b -> c) -> (a -> b) -> a -> c
. ParseError s e -> WriterT w m a
r) m (a, w)
m
observing :: forall a. WriterT w m a -> WriterT w m (Either (ParseError s e) a)
observing (S.WriterT m (a, w)
m) =
forall w (m :: * -> *) a. m (a, w) -> WriterT w m a
S.WriterT forall a b. (a -> b) -> a -> b
$
forall s a b. s -> Either a (b, s) -> (Either a b, s)
fixs forall a. Monoid a => a
mempty forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall e s (m :: * -> *) a.
MonadParsec e s m =>
m a -> m (Either (ParseError s e) a)
observing m (a, w)
m
eof :: WriterT w m ()
eof = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall e s (m :: * -> *). MonadParsec e s m => m ()
eof
token :: forall a.
(Token s -> Maybe a) -> Set (ErrorItem (Token s)) -> WriterT w m a
token Token s -> Maybe a
test Set (ErrorItem (Token s))
mt = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (forall e s (m :: * -> *) a.
MonadParsec e s m =>
(Token s -> Maybe a) -> Set (ErrorItem (Token s)) -> m a
token Token s -> Maybe a
test Set (ErrorItem (Token s))
mt)
tokens :: (Tokens s -> Tokens s -> Bool)
-> Tokens s -> WriterT w m (Tokens s)
tokens Tokens s -> Tokens s -> Bool
e Tokens s
ts = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (forall e s (m :: * -> *).
MonadParsec e s m =>
(Tokens s -> Tokens s -> Bool) -> Tokens s -> m (Tokens s)
tokens Tokens s -> Tokens s -> Bool
e Tokens s
ts)
takeWhileP :: Maybe String -> (Token s -> Bool) -> WriterT w m (Tokens s)
takeWhileP Maybe String
l Token s -> Bool
f = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (forall e s (m :: * -> *).
MonadParsec e s m =>
Maybe String -> (Token s -> Bool) -> m (Tokens s)
takeWhileP Maybe String
l Token s -> Bool
f)
takeWhile1P :: Maybe String -> (Token s -> Bool) -> WriterT w m (Tokens s)
takeWhile1P Maybe String
l Token s -> Bool
f = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (forall e s (m :: * -> *).
MonadParsec e s m =>
Maybe String -> (Token s -> Bool) -> m (Tokens s)
takeWhile1P Maybe String
l Token s -> Bool
f)
takeP :: Maybe String -> Int -> WriterT w m (Tokens s)
takeP Maybe String
l Int
n = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (forall e s (m :: * -> *).
MonadParsec e s m =>
Maybe String -> Int -> m (Tokens s)
takeP Maybe String
l Int
n)
getParserState :: WriterT w m (State s e)
getParserState = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall e s (m :: * -> *). MonadParsec e s m => m (State s e)
getParserState
updateParserState :: (State s e -> State s e) -> WriterT w m ()
updateParserState State s e -> State s e
f = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (forall e s (m :: * -> *).
MonadParsec e s m =>
(State s e -> State s e) -> m ()
updateParserState State s e -> State s e
f)
instance (Monoid w, MonadParsec e s m) => MonadParsec e s (L.RWST r w st m) where
parseError :: forall a. ParseError s e -> RWST r w st m a
parseError ParseError s e
e = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (forall e s (m :: * -> *) a.
MonadParsec e s m =>
ParseError s e -> m a
parseError ParseError s e
e)
label :: forall a. String -> RWST r w st m a -> RWST r w st m a
label String
n (L.RWST r -> st -> m (a, st, w)
m) = forall r w s (m :: * -> *) a.
(r -> s -> m (a, s, w)) -> RWST r w s m a
L.RWST forall a b. (a -> b) -> a -> b
$ \r
r st
s -> forall e s (m :: * -> *) a.
MonadParsec e s m =>
String -> m a -> m a
label String
n (r -> st -> m (a, st, w)
m r
r st
s)
try :: forall a. RWST r w st m a -> RWST r w st m a
try (L.RWST r -> st -> m (a, st, w)
m) = forall r w s (m :: * -> *) a.
(r -> s -> m (a, s, w)) -> RWST r w s m a
L.RWST forall a b. (a -> b) -> a -> b
$ \r
r st
s -> forall e s (m :: * -> *) a. MonadParsec e s m => m a -> m a
try (r -> st -> m (a, st, w)
m r
r st
s)
lookAhead :: forall a. RWST r w st m a -> RWST r w st m a
lookAhead (L.RWST r -> st -> m (a, st, w)
m) = forall r w s (m :: * -> *) a.
(r -> s -> m (a, s, w)) -> RWST r w s m a
L.RWST forall a b. (a -> b) -> a -> b
$ \r
r st
s -> do
(a
x, st
_, w
_) <- forall e s (m :: * -> *) a. MonadParsec e s m => m a -> m a
lookAhead (r -> st -> m (a, st, w)
m r
r st
s)
forall (m :: * -> *) a. Monad m => a -> m a
return (a
x, st
s, forall a. Monoid a => a
mempty)
notFollowedBy :: forall a. RWST r w st m a -> RWST r w st m ()
notFollowedBy (L.RWST r -> st -> m (a, st, w)
m) = forall r w s (m :: * -> *) a.
(r -> s -> m (a, s, w)) -> RWST r w s m a
L.RWST forall a b. (a -> b) -> a -> b
$ \r
r st
s -> do
forall e s (m :: * -> *) a. MonadParsec e s m => m a -> m ()
notFollowedBy (forall (f :: * -> *) a. Functor f => f a -> f ()
void forall a b. (a -> b) -> a -> b
$ r -> st -> m (a, st, w)
m r
r st
s)
forall (m :: * -> *) a. Monad m => a -> m a
return ((), st
s, forall a. Monoid a => a
mempty)
withRecovery :: forall a.
(ParseError s e -> RWST r w st m a)
-> RWST r w st m a -> RWST r w st m a
withRecovery ParseError s e -> RWST r w st m a
n (L.RWST r -> st -> m (a, st, w)
m) = forall r w s (m :: * -> *) a.
(r -> s -> m (a, s, w)) -> RWST r w s m a
L.RWST forall a b. (a -> b) -> a -> b
$ \r
r st
s ->
forall e s (m :: * -> *) a.
MonadParsec e s m =>
(ParseError s e -> m a) -> m a -> m a
withRecovery (\ParseError s e
e -> forall r w s (m :: * -> *) a.
RWST r w s m a -> r -> s -> m (a, s, w)
L.runRWST (ParseError s e -> RWST r w st m a
n ParseError s e
e) r
r st
s) (r -> st -> m (a, st, w)
m r
r st
s)
observing :: forall a.
RWST r w st m a -> RWST r w st m (Either (ParseError s e) a)
observing (L.RWST r -> st -> m (a, st, w)
m) = forall r w s (m :: * -> *) a.
(r -> s -> m (a, s, w)) -> RWST r w s m a
L.RWST forall a b. (a -> b) -> a -> b
$ \r
r st
s ->
forall w s a b.
Monoid w =>
s -> Either a (b, s, w) -> (Either a b, s, w)
fixs' st
s forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall e s (m :: * -> *) a.
MonadParsec e s m =>
m a -> m (Either (ParseError s e) a)
observing (r -> st -> m (a, st, w)
m r
r st
s)
eof :: RWST r w st m ()
eof = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall e s (m :: * -> *). MonadParsec e s m => m ()
eof
token :: forall a.
(Token s -> Maybe a)
-> Set (ErrorItem (Token s)) -> RWST r w st m a
token Token s -> Maybe a
test Set (ErrorItem (Token s))
mt = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (forall e s (m :: * -> *) a.
MonadParsec e s m =>
(Token s -> Maybe a) -> Set (ErrorItem (Token s)) -> m a
token Token s -> Maybe a
test Set (ErrorItem (Token s))
mt)
tokens :: (Tokens s -> Tokens s -> Bool)
-> Tokens s -> RWST r w st m (Tokens s)
tokens Tokens s -> Tokens s -> Bool
e Tokens s
ts = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (forall e s (m :: * -> *).
MonadParsec e s m =>
(Tokens s -> Tokens s -> Bool) -> Tokens s -> m (Tokens s)
tokens Tokens s -> Tokens s -> Bool
e Tokens s
ts)
takeWhileP :: Maybe String -> (Token s -> Bool) -> RWST r w st m (Tokens s)
takeWhileP Maybe String
l Token s -> Bool
f = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (forall e s (m :: * -> *).
MonadParsec e s m =>
Maybe String -> (Token s -> Bool) -> m (Tokens s)
takeWhileP Maybe String
l Token s -> Bool
f)
takeWhile1P :: Maybe String -> (Token s -> Bool) -> RWST r w st m (Tokens s)
takeWhile1P Maybe String
l Token s -> Bool
f = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (forall e s (m :: * -> *).
MonadParsec e s m =>
Maybe String -> (Token s -> Bool) -> m (Tokens s)
takeWhile1P Maybe String
l Token s -> Bool
f)
takeP :: Maybe String -> Int -> RWST r w st m (Tokens s)
takeP Maybe String
l Int
n = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (forall e s (m :: * -> *).
MonadParsec e s m =>
Maybe String -> Int -> m (Tokens s)
takeP Maybe String
l Int
n)
getParserState :: RWST r w st m (State s e)
getParserState = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall e s (m :: * -> *). MonadParsec e s m => m (State s e)
getParserState
updateParserState :: (State s e -> State s e) -> RWST r w st m ()
updateParserState State s e -> State s e
f = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (forall e s (m :: * -> *).
MonadParsec e s m =>
(State s e -> State s e) -> m ()
updateParserState State s e -> State s e
f)
instance (Monoid w, MonadParsec e s m) => MonadParsec e s (S.RWST r w st m) where
parseError :: forall a. ParseError s e -> RWST r w st m a
parseError ParseError s e
e = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (forall e s (m :: * -> *) a.
MonadParsec e s m =>
ParseError s e -> m a
parseError ParseError s e
e)
label :: forall a. String -> RWST r w st m a -> RWST r w st m a
label String
n (S.RWST r -> st -> m (a, st, w)
m) = forall r w s (m :: * -> *) a.
(r -> s -> m (a, s, w)) -> RWST r w s m a
S.RWST forall a b. (a -> b) -> a -> b
$ \r
r st
s -> forall e s (m :: * -> *) a.
MonadParsec e s m =>
String -> m a -> m a
label String
n (r -> st -> m (a, st, w)
m r
r st
s)
try :: forall a. RWST r w st m a -> RWST r w st m a
try (S.RWST r -> st -> m (a, st, w)
m) = forall r w s (m :: * -> *) a.
(r -> s -> m (a, s, w)) -> RWST r w s m a
S.RWST forall a b. (a -> b) -> a -> b
$ \r
r st
s -> forall e s (m :: * -> *) a. MonadParsec e s m => m a -> m a
try (r -> st -> m (a, st, w)
m r
r st
s)
lookAhead :: forall a. RWST r w st m a -> RWST r w st m a
lookAhead (S.RWST r -> st -> m (a, st, w)
m) = forall r w s (m :: * -> *) a.
(r -> s -> m (a, s, w)) -> RWST r w s m a
S.RWST forall a b. (a -> b) -> a -> b
$ \r
r st
s -> do
(a
x, st
_, w
_) <- forall e s (m :: * -> *) a. MonadParsec e s m => m a -> m a
lookAhead (r -> st -> m (a, st, w)
m r
r st
s)
forall (m :: * -> *) a. Monad m => a -> m a
return (a
x, st
s, forall a. Monoid a => a
mempty)
notFollowedBy :: forall a. RWST r w st m a -> RWST r w st m ()
notFollowedBy (S.RWST r -> st -> m (a, st, w)
m) = forall r w s (m :: * -> *) a.
(r -> s -> m (a, s, w)) -> RWST r w s m a
S.RWST forall a b. (a -> b) -> a -> b
$ \r
r st
s -> do
forall e s (m :: * -> *) a. MonadParsec e s m => m a -> m ()
notFollowedBy (forall (f :: * -> *) a. Functor f => f a -> f ()
void forall a b. (a -> b) -> a -> b
$ r -> st -> m (a, st, w)
m r
r st
s)
forall (m :: * -> *) a. Monad m => a -> m a
return ((), st
s, forall a. Monoid a => a
mempty)
withRecovery :: forall a.
(ParseError s e -> RWST r w st m a)
-> RWST r w st m a -> RWST r w st m a
withRecovery ParseError s e -> RWST r w st m a
n (S.RWST r -> st -> m (a, st, w)
m) = forall r w s (m :: * -> *) a.
(r -> s -> m (a, s, w)) -> RWST r w s m a
S.RWST forall a b. (a -> b) -> a -> b
$ \r
r st
s ->
forall e s (m :: * -> *) a.
MonadParsec e s m =>
(ParseError s e -> m a) -> m a -> m a
withRecovery (\ParseError s e
e -> forall r w s (m :: * -> *) a.
RWST r w s m a -> r -> s -> m (a, s, w)
S.runRWST (ParseError s e -> RWST r w st m a
n ParseError s e
e) r
r st
s) (r -> st -> m (a, st, w)
m r
r st
s)
observing :: forall a.
RWST r w st m a -> RWST r w st m (Either (ParseError s e) a)
observing (S.RWST r -> st -> m (a, st, w)
m) = forall r w s (m :: * -> *) a.
(r -> s -> m (a, s, w)) -> RWST r w s m a
S.RWST forall a b. (a -> b) -> a -> b
$ \r
r st
s ->
forall w s a b.
Monoid w =>
s -> Either a (b, s, w) -> (Either a b, s, w)
fixs' st
s forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall e s (m :: * -> *) a.
MonadParsec e s m =>
m a -> m (Either (ParseError s e) a)
observing (r -> st -> m (a, st, w)
m r
r st
s)
eof :: RWST r w st m ()
eof = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall e s (m :: * -> *). MonadParsec e s m => m ()
eof
token :: forall a.
(Token s -> Maybe a)
-> Set (ErrorItem (Token s)) -> RWST r w st m a
token Token s -> Maybe a
test Set (ErrorItem (Token s))
mt = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (forall e s (m :: * -> *) a.
MonadParsec e s m =>
(Token s -> Maybe a) -> Set (ErrorItem (Token s)) -> m a
token Token s -> Maybe a
test Set (ErrorItem (Token s))
mt)
tokens :: (Tokens s -> Tokens s -> Bool)
-> Tokens s -> RWST r w st m (Tokens s)
tokens Tokens s -> Tokens s -> Bool
e Tokens s
ts = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (forall e s (m :: * -> *).
MonadParsec e s m =>
(Tokens s -> Tokens s -> Bool) -> Tokens s -> m (Tokens s)
tokens Tokens s -> Tokens s -> Bool
e Tokens s
ts)
takeWhileP :: Maybe String -> (Token s -> Bool) -> RWST r w st m (Tokens s)
takeWhileP Maybe String
l Token s -> Bool
f = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (forall e s (m :: * -> *).
MonadParsec e s m =>
Maybe String -> (Token s -> Bool) -> m (Tokens s)
takeWhileP Maybe String
l Token s -> Bool
f)
takeWhile1P :: Maybe String -> (Token s -> Bool) -> RWST r w st m (Tokens s)
takeWhile1P Maybe String
l Token s -> Bool
f = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (forall e s (m :: * -> *).
MonadParsec e s m =>
Maybe String -> (Token s -> Bool) -> m (Tokens s)
takeWhile1P Maybe String
l Token s -> Bool
f)
takeP :: Maybe String -> Int -> RWST r w st m (Tokens s)
takeP Maybe String
l Int
n = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (forall e s (m :: * -> *).
MonadParsec e s m =>
Maybe String -> Int -> m (Tokens s)
takeP Maybe String
l Int
n)
getParserState :: RWST r w st m (State s e)
getParserState = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall e s (m :: * -> *). MonadParsec e s m => m (State s e)
getParserState
updateParserState :: (State s e -> State s e) -> RWST r w st m ()
updateParserState State s e -> State s e
f = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (forall e s (m :: * -> *).
MonadParsec e s m =>
(State s e -> State s e) -> m ()
updateParserState State s e -> State s e
f)
instance MonadParsec e s m => MonadParsec e s (IdentityT m) where
parseError :: forall a. ParseError s e -> IdentityT m a
parseError ParseError s e
e = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (forall e s (m :: * -> *) a.
MonadParsec e s m =>
ParseError s e -> m a
parseError ParseError s e
e)
label :: forall a. String -> IdentityT m a -> IdentityT m a
label String
n (IdentityT m a
m) = forall {k} (f :: k -> *) (a :: k). f a -> IdentityT f a
IdentityT forall a b. (a -> b) -> a -> b
$ forall e s (m :: * -> *) a.
MonadParsec e s m =>
String -> m a -> m a
label String
n m a
m
try :: forall a. IdentityT m a -> IdentityT m a
try = forall {k} (f :: k -> *) (a :: k). f a -> IdentityT f a
IdentityT forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall e s (m :: * -> *) a. MonadParsec e s m => m a -> m a
try forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall {k} (f :: k -> *) (a :: k). IdentityT f a -> f a
runIdentityT
lookAhead :: forall a. IdentityT m a -> IdentityT m a
lookAhead (IdentityT m a
m) = forall {k} (f :: k -> *) (a :: k). f a -> IdentityT f a
IdentityT forall a b. (a -> b) -> a -> b
$ forall e s (m :: * -> *) a. MonadParsec e s m => m a -> m a
lookAhead m a
m
notFollowedBy :: forall a. IdentityT m a -> IdentityT m ()
notFollowedBy (IdentityT m a
m) = forall {k} (f :: k -> *) (a :: k). f a -> IdentityT f a
IdentityT forall a b. (a -> b) -> a -> b
$ forall e s (m :: * -> *) a. MonadParsec e s m => m a -> m ()
notFollowedBy m a
m
withRecovery :: forall a.
(ParseError s e -> IdentityT m a) -> IdentityT m a -> IdentityT m a
withRecovery ParseError s e -> IdentityT m a
r (IdentityT m a
m) =
forall {k} (f :: k -> *) (a :: k). f a -> IdentityT f a
IdentityT forall a b. (a -> b) -> a -> b
$
forall e s (m :: * -> *) a.
MonadParsec e s m =>
(ParseError s e -> m a) -> m a -> m a
withRecovery (forall {k} (f :: k -> *) (a :: k). IdentityT f a -> f a
runIdentityT forall b c a. (b -> c) -> (a -> b) -> a -> c
. ParseError s e -> IdentityT m a
r) m a
m
observing :: forall a. IdentityT m a -> IdentityT m (Either (ParseError s e) a)
observing (IdentityT m a
m) = forall {k} (f :: k -> *) (a :: k). f a -> IdentityT f a
IdentityT forall a b. (a -> b) -> a -> b
$ forall e s (m :: * -> *) a.
MonadParsec e s m =>
m a -> m (Either (ParseError s e) a)
observing m a
m
eof :: IdentityT m ()
eof = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall e s (m :: * -> *). MonadParsec e s m => m ()
eof
token :: forall a.
(Token s -> Maybe a) -> Set (ErrorItem (Token s)) -> IdentityT m a
token Token s -> Maybe a
test Set (ErrorItem (Token s))
mt = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (forall e s (m :: * -> *) a.
MonadParsec e s m =>
(Token s -> Maybe a) -> Set (ErrorItem (Token s)) -> m a
token Token s -> Maybe a
test Set (ErrorItem (Token s))
mt)
tokens :: (Tokens s -> Tokens s -> Bool)
-> Tokens s -> IdentityT m (Tokens s)
tokens Tokens s -> Tokens s -> Bool
e Tokens s
ts = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall e s (m :: * -> *).
MonadParsec e s m =>
(Tokens s -> Tokens s -> Bool) -> Tokens s -> m (Tokens s)
tokens Tokens s -> Tokens s -> Bool
e Tokens s
ts
takeWhileP :: Maybe String -> (Token s -> Bool) -> IdentityT m (Tokens s)
takeWhileP Maybe String
l Token s -> Bool
f = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (forall e s (m :: * -> *).
MonadParsec e s m =>
Maybe String -> (Token s -> Bool) -> m (Tokens s)
takeWhileP Maybe String
l Token s -> Bool
f)
takeWhile1P :: Maybe String -> (Token s -> Bool) -> IdentityT m (Tokens s)
takeWhile1P Maybe String
l Token s -> Bool
f = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (forall e s (m :: * -> *).
MonadParsec e s m =>
Maybe String -> (Token s -> Bool) -> m (Tokens s)
takeWhile1P Maybe String
l Token s -> Bool
f)
takeP :: Maybe String -> Int -> IdentityT m (Tokens s)
takeP Maybe String
l Int
n = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (forall e s (m :: * -> *).
MonadParsec e s m =>
Maybe String -> Int -> m (Tokens s)
takeP Maybe String
l Int
n)
getParserState :: IdentityT m (State s e)
getParserState = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall e s (m :: * -> *). MonadParsec e s m => m (State s e)
getParserState
updateParserState :: (State s e -> State s e) -> IdentityT m ()
updateParserState State s e -> State s e
f = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall e s (m :: * -> *).
MonadParsec e s m =>
(State s e -> State s e) -> m ()
updateParserState State s e -> State s e
f
fixs :: s -> Either a (b, s) -> (Either a b, s)
fixs :: forall s a b. s -> Either a (b, s) -> (Either a b, s)
fixs s
s (Left a
a) = (forall a b. a -> Either a b
Left a
a, s
s)
fixs s
_ (Right (b
b, s
s)) = (forall a b. b -> Either a b
Right b
b, s
s)
{-# INLINE fixs #-}
fixs' :: Monoid w => s -> Either a (b, s, w) -> (Either a b, s, w)
fixs' :: forall w s a b.
Monoid w =>
s -> Either a (b, s, w) -> (Either a b, s, w)
fixs' s
s (Left a
a) = (forall a b. a -> Either a b
Left a
a, s
s, forall a. Monoid a => a
mempty)
fixs' s
_ (Right (b
b, s
s, w
w)) = (forall a b. b -> Either a b
Right b
b, s
s, w
w)
{-# INLINE fixs' #-}