{-# 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 = String -> m a -> m a
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 :: ParseError s e -> StateT st m a
parseError ParseError s e
e = m a -> StateT st m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (ParseError s e -> m a
forall e s (m :: * -> *) a.
MonadParsec e s m =>
ParseError s e -> m a
parseError ParseError s e
e)
label :: String -> StateT st m a -> StateT st m a
label String
n (L.StateT st -> m (a, st)
m) = (st -> m (a, st)) -> StateT st m a
forall s (m :: * -> *) a. (s -> m (a, s)) -> StateT s m a
L.StateT ((st -> m (a, st)) -> StateT st m a)
-> (st -> m (a, st)) -> StateT st m a
forall a b. (a -> b) -> a -> b
$ String -> m (a, st) -> m (a, st)
forall e s (m :: * -> *) a.
MonadParsec e s m =>
String -> m a -> m a
label String
n (m (a, st) -> m (a, st)) -> (st -> m (a, st)) -> st -> m (a, st)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. st -> m (a, st)
m
try :: StateT st m a -> StateT st m a
try (L.StateT st -> m (a, st)
m) = (st -> m (a, st)) -> StateT st m a
forall s (m :: * -> *) a. (s -> m (a, s)) -> StateT s m a
L.StateT ((st -> m (a, st)) -> StateT st m a)
-> (st -> m (a, st)) -> StateT st m a
forall a b. (a -> b) -> a -> b
$ m (a, st) -> m (a, st)
forall e s (m :: * -> *) a. MonadParsec e s m => m a -> m a
try (m (a, st) -> m (a, st)) -> (st -> m (a, st)) -> st -> m (a, st)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. st -> m (a, st)
m
lookAhead :: StateT st m a -> StateT st m a
lookAhead (L.StateT st -> m (a, st)
m) = (st -> m (a, st)) -> StateT st m a
forall s (m :: * -> *) a. (s -> m (a, s)) -> StateT s m a
L.StateT ((st -> m (a, st)) -> StateT st m a)
-> (st -> m (a, st)) -> StateT st m a
forall a b. (a -> b) -> a -> b
$ \st
s ->
(,st
s) (a -> (a, st)) -> ((a, st) -> a) -> (a, st) -> (a, st)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a, st) -> a
forall a b. (a, b) -> a
fst ((a, st) -> (a, st)) -> m (a, st) -> m (a, st)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m (a, st) -> m (a, st)
forall e s (m :: * -> *) a. MonadParsec e s m => m a -> m a
lookAhead (st -> m (a, st)
m st
s)
notFollowedBy :: StateT st m a -> StateT st m ()
notFollowedBy (L.StateT st -> m (a, st)
m) = (st -> m ((), st)) -> StateT st m ()
forall s (m :: * -> *) a. (s -> m (a, s)) -> StateT s m a
L.StateT ((st -> m ((), st)) -> StateT st m ())
-> (st -> m ((), st)) -> StateT st m ()
forall a b. (a -> b) -> a -> b
$ \st
s ->
m a -> m ()
forall e s (m :: * -> *) a. MonadParsec e s m => m a -> m ()
notFollowedBy ((a, st) -> a
forall a b. (a, b) -> a
fst ((a, st) -> a) -> m (a, st) -> m a
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> st -> m (a, st)
m st
s) m () -> m ((), st) -> m ((), st)
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> ((), st) -> m ((), st)
forall (m :: * -> *) a. Monad m => a -> m a
return ((), st
s)
withRecovery :: (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) = (st -> m (a, st)) -> StateT st m a
forall s (m :: * -> *) a. (s -> m (a, s)) -> StateT s m a
L.StateT ((st -> m (a, st)) -> StateT st m a)
-> (st -> m (a, st)) -> StateT st m a
forall a b. (a -> b) -> a -> b
$ \st
s ->
(ParseError s e -> m (a, st)) -> m (a, st) -> m (a, st)
forall e s (m :: * -> *) a.
MonadParsec e s m =>
(ParseError s e -> m a) -> m a -> m a
withRecovery (\ParseError s e
e -> StateT st m a -> st -> m (a, st)
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 :: StateT st m a -> StateT st m (Either (ParseError s e) a)
observing (L.StateT st -> m (a, st)
m) = (st -> m (Either (ParseError s e) a, st))
-> StateT st m (Either (ParseError s e) a)
forall s (m :: * -> *) a. (s -> m (a, s)) -> StateT s m a
L.StateT ((st -> m (Either (ParseError s e) a, st))
-> StateT st m (Either (ParseError s e) a))
-> (st -> m (Either (ParseError s e) a, st))
-> StateT st m (Either (ParseError s e) a)
forall a b. (a -> b) -> a -> b
$ \st
s ->
st
-> Either (ParseError s e) (a, st)
-> (Either (ParseError s e) a, st)
forall s a b. s -> Either a (b, s) -> (Either a b, s)
fixs st
s (Either (ParseError s e) (a, st)
-> (Either (ParseError s e) a, st))
-> m (Either (ParseError s e) (a, st))
-> m (Either (ParseError s e) a, st)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m (a, st) -> m (Either (ParseError s e) (a, st))
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 = m () -> StateT st m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m ()
forall e s (m :: * -> *). MonadParsec e s m => m ()
eof
token :: (Token s -> Maybe a) -> Set (ErrorItem (Token s)) -> StateT st m a
token Token s -> Maybe a
test Set (ErrorItem (Token s))
mt = m a -> StateT st m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift ((Token s -> Maybe a) -> Set (ErrorItem (Token s)) -> m a
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 = m (Tokens s) -> StateT st m (Tokens s)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift ((Tokens s -> Tokens s -> Bool) -> Tokens s -> m (Tokens s)
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 = m (Tokens s) -> StateT st m (Tokens s)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (Maybe String -> (Token s -> Bool) -> m (Tokens s)
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 = m (Tokens s) -> StateT st m (Tokens s)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (Maybe String -> (Token s -> Bool) -> m (Tokens s)
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 = m (Tokens s) -> StateT st m (Tokens s)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (Maybe String -> Int -> m (Tokens s)
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 = m (State s e) -> StateT st m (State s e)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m (State s e)
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 = m () -> StateT st m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift ((State s e -> State s e) -> m ()
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 :: ParseError s e -> StateT st m a
parseError ParseError s e
e = m a -> StateT st m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (ParseError s e -> m a
forall e s (m :: * -> *) a.
MonadParsec e s m =>
ParseError s e -> m a
parseError ParseError s e
e)
label :: String -> StateT st m a -> StateT st m a
label String
n (S.StateT st -> m (a, st)
m) = (st -> m (a, st)) -> StateT st m a
forall s (m :: * -> *) a. (s -> m (a, s)) -> StateT s m a
S.StateT ((st -> m (a, st)) -> StateT st m a)
-> (st -> m (a, st)) -> StateT st m a
forall a b. (a -> b) -> a -> b
$ String -> m (a, st) -> m (a, st)
forall e s (m :: * -> *) a.
MonadParsec e s m =>
String -> m a -> m a
label String
n (m (a, st) -> m (a, st)) -> (st -> m (a, st)) -> st -> m (a, st)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. st -> m (a, st)
m
try :: StateT st m a -> StateT st m a
try (S.StateT st -> m (a, st)
m) = (st -> m (a, st)) -> StateT st m a
forall s (m :: * -> *) a. (s -> m (a, s)) -> StateT s m a
S.StateT ((st -> m (a, st)) -> StateT st m a)
-> (st -> m (a, st)) -> StateT st m a
forall a b. (a -> b) -> a -> b
$ m (a, st) -> m (a, st)
forall e s (m :: * -> *) a. MonadParsec e s m => m a -> m a
try (m (a, st) -> m (a, st)) -> (st -> m (a, st)) -> st -> m (a, st)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. st -> m (a, st)
m
lookAhead :: StateT st m a -> StateT st m a
lookAhead (S.StateT st -> m (a, st)
m) = (st -> m (a, st)) -> StateT st m a
forall s (m :: * -> *) a. (s -> m (a, s)) -> StateT s m a
S.StateT ((st -> m (a, st)) -> StateT st m a)
-> (st -> m (a, st)) -> StateT st m a
forall a b. (a -> b) -> a -> b
$ \st
s ->
(,st
s) (a -> (a, st)) -> ((a, st) -> a) -> (a, st) -> (a, st)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a, st) -> a
forall a b. (a, b) -> a
fst ((a, st) -> (a, st)) -> m (a, st) -> m (a, st)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m (a, st) -> m (a, st)
forall e s (m :: * -> *) a. MonadParsec e s m => m a -> m a
lookAhead (st -> m (a, st)
m st
s)
notFollowedBy :: StateT st m a -> StateT st m ()
notFollowedBy (S.StateT st -> m (a, st)
m) = (st -> m ((), st)) -> StateT st m ()
forall s (m :: * -> *) a. (s -> m (a, s)) -> StateT s m a
S.StateT ((st -> m ((), st)) -> StateT st m ())
-> (st -> m ((), st)) -> StateT st m ()
forall a b. (a -> b) -> a -> b
$ \st
s ->
m a -> m ()
forall e s (m :: * -> *) a. MonadParsec e s m => m a -> m ()
notFollowedBy ((a, st) -> a
forall a b. (a, b) -> a
fst ((a, st) -> a) -> m (a, st) -> m a
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> st -> m (a, st)
m st
s) m () -> m ((), st) -> m ((), st)
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> ((), st) -> m ((), st)
forall (m :: * -> *) a. Monad m => a -> m a
return ((), st
s)
withRecovery :: (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) = (st -> m (a, st)) -> StateT st m a
forall s (m :: * -> *) a. (s -> m (a, s)) -> StateT s m a
S.StateT ((st -> m (a, st)) -> StateT st m a)
-> (st -> m (a, st)) -> StateT st m a
forall a b. (a -> b) -> a -> b
$ \st
s ->
(ParseError s e -> m (a, st)) -> m (a, st) -> m (a, st)
forall e s (m :: * -> *) a.
MonadParsec e s m =>
(ParseError s e -> m a) -> m a -> m a
withRecovery (\ParseError s e
e -> StateT st m a -> st -> m (a, st)
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 :: StateT st m a -> StateT st m (Either (ParseError s e) a)
observing (S.StateT st -> m (a, st)
m) = (st -> m (Either (ParseError s e) a, st))
-> StateT st m (Either (ParseError s e) a)
forall s (m :: * -> *) a. (s -> m (a, s)) -> StateT s m a
S.StateT ((st -> m (Either (ParseError s e) a, st))
-> StateT st m (Either (ParseError s e) a))
-> (st -> m (Either (ParseError s e) a, st))
-> StateT st m (Either (ParseError s e) a)
forall a b. (a -> b) -> a -> b
$ \st
s ->
st
-> Either (ParseError s e) (a, st)
-> (Either (ParseError s e) a, st)
forall s a b. s -> Either a (b, s) -> (Either a b, s)
fixs st
s (Either (ParseError s e) (a, st)
-> (Either (ParseError s e) a, st))
-> m (Either (ParseError s e) (a, st))
-> m (Either (ParseError s e) a, st)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m (a, st) -> m (Either (ParseError s e) (a, st))
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 = m () -> StateT st m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m ()
forall e s (m :: * -> *). MonadParsec e s m => m ()
eof
token :: (Token s -> Maybe a) -> Set (ErrorItem (Token s)) -> StateT st m a
token Token s -> Maybe a
test Set (ErrorItem (Token s))
mt = m a -> StateT st m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift ((Token s -> Maybe a) -> Set (ErrorItem (Token s)) -> m a
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 = m (Tokens s) -> StateT st m (Tokens s)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift ((Tokens s -> Tokens s -> Bool) -> Tokens s -> m (Tokens s)
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 = m (Tokens s) -> StateT st m (Tokens s)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (Maybe String -> (Token s -> Bool) -> m (Tokens s)
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 = m (Tokens s) -> StateT st m (Tokens s)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (Maybe String -> (Token s -> Bool) -> m (Tokens s)
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 = m (Tokens s) -> StateT st m (Tokens s)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (Maybe String -> Int -> m (Tokens s)
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 = m (State s e) -> StateT st m (State s e)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m (State s e)
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 = m () -> StateT st m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift ((State s e -> State s e) -> m ()
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 :: ParseError s e -> ReaderT r m a
parseError ParseError s e
e = m a -> ReaderT r m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (ParseError s e -> m a
forall e s (m :: * -> *) a.
MonadParsec e s m =>
ParseError s e -> m a
parseError ParseError s e
e)
label :: String -> ReaderT r m a -> ReaderT r m a
label String
n (L.ReaderT r -> m a
m) = (r -> m a) -> ReaderT r m a
forall r (m :: * -> *) a. (r -> m a) -> ReaderT r m a
L.ReaderT ((r -> m a) -> ReaderT r m a) -> (r -> m a) -> ReaderT r m a
forall a b. (a -> b) -> a -> b
$ String -> m a -> m a
forall e s (m :: * -> *) a.
MonadParsec e s m =>
String -> m a -> m a
label String
n (m a -> m a) -> (r -> m a) -> r -> m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. r -> m a
m
try :: ReaderT r m a -> ReaderT r m a
try (L.ReaderT r -> m a
m) = (r -> m a) -> ReaderT r m a
forall r (m :: * -> *) a. (r -> m a) -> ReaderT r m a
L.ReaderT ((r -> m a) -> ReaderT r m a) -> (r -> m a) -> ReaderT r m a
forall a b. (a -> b) -> a -> b
$ m a -> m a
forall e s (m :: * -> *) a. MonadParsec e s m => m a -> m a
try (m a -> m a) -> (r -> m a) -> r -> m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. r -> m a
m
lookAhead :: ReaderT r m a -> ReaderT r m a
lookAhead (L.ReaderT r -> m a
m) = (r -> m a) -> ReaderT r m a
forall r (m :: * -> *) a. (r -> m a) -> ReaderT r m a
L.ReaderT ((r -> m a) -> ReaderT r m a) -> (r -> m a) -> ReaderT r m a
forall a b. (a -> b) -> a -> b
$ m a -> m a
forall e s (m :: * -> *) a. MonadParsec e s m => m a -> m a
lookAhead (m a -> m a) -> (r -> m a) -> r -> m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. r -> m a
m
notFollowedBy :: ReaderT r m a -> ReaderT r m ()
notFollowedBy (L.ReaderT r -> m a
m) = (r -> m ()) -> ReaderT r m ()
forall r (m :: * -> *) a. (r -> m a) -> ReaderT r m a
L.ReaderT ((r -> m ()) -> ReaderT r m ()) -> (r -> m ()) -> ReaderT r m ()
forall a b. (a -> b) -> a -> b
$ m a -> m ()
forall e s (m :: * -> *) a. MonadParsec e s m => m a -> m ()
notFollowedBy (m a -> m ()) -> (r -> m a) -> r -> m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. r -> m a
m
withRecovery :: (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) = (r -> m a) -> ReaderT r m a
forall r (m :: * -> *) a. (r -> m a) -> ReaderT r m a
L.ReaderT ((r -> m a) -> ReaderT r m a) -> (r -> m a) -> ReaderT r m a
forall a b. (a -> b) -> a -> b
$ \r
s ->
(ParseError s e -> m a) -> m a -> m a
forall e s (m :: * -> *) a.
MonadParsec e s m =>
(ParseError s e -> m a) -> m a -> m a
withRecovery (\ParseError s e
e -> ReaderT r m a -> r -> m a
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 :: ReaderT r m a -> ReaderT r m (Either (ParseError s e) a)
observing (L.ReaderT r -> m a
m) = (r -> m (Either (ParseError s e) a))
-> ReaderT r m (Either (ParseError s e) a)
forall r (m :: * -> *) a. (r -> m a) -> ReaderT r m a
L.ReaderT ((r -> m (Either (ParseError s e) a))
-> ReaderT r m (Either (ParseError s e) a))
-> (r -> m (Either (ParseError s e) a))
-> ReaderT r m (Either (ParseError s e) a)
forall a b. (a -> b) -> a -> b
$ m a -> m (Either (ParseError s e) a)
forall e s (m :: * -> *) a.
MonadParsec e s m =>
m a -> m (Either (ParseError s e) a)
observing (m a -> m (Either (ParseError s e) a))
-> (r -> m a) -> r -> m (Either (ParseError s e) a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. r -> m a
m
eof :: ReaderT r m ()
eof = m () -> ReaderT r m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m ()
forall e s (m :: * -> *). MonadParsec e s m => m ()
eof
token :: (Token s -> Maybe a) -> Set (ErrorItem (Token s)) -> ReaderT r m a
token Token s -> Maybe a
test Set (ErrorItem (Token s))
mt = m a -> ReaderT r m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift ((Token s -> Maybe a) -> Set (ErrorItem (Token s)) -> m a
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 = m (Tokens s) -> ReaderT r m (Tokens s)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift ((Tokens s -> Tokens s -> Bool) -> Tokens s -> m (Tokens s)
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 = m (Tokens s) -> ReaderT r m (Tokens s)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (Maybe String -> (Token s -> Bool) -> m (Tokens s)
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 = m (Tokens s) -> ReaderT r m (Tokens s)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (Maybe String -> (Token s -> Bool) -> m (Tokens s)
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 = m (Tokens s) -> ReaderT r m (Tokens s)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (Maybe String -> Int -> m (Tokens s)
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 = m (State s e) -> ReaderT r m (State s e)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m (State s e)
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 = m () -> ReaderT r m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift ((State s e -> State s e) -> m ()
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 :: ParseError s e -> WriterT w m a
parseError ParseError s e
e = m a -> WriterT w m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (ParseError s e -> m a
forall e s (m :: * -> *) a.
MonadParsec e s m =>
ParseError s e -> m a
parseError ParseError s e
e)
label :: String -> WriterT w m a -> WriterT w m a
label String
n (L.WriterT m (a, w)
m) = m (a, w) -> WriterT w m a
forall w (m :: * -> *) a. m (a, w) -> WriterT w m a
L.WriterT (m (a, w) -> WriterT w m a) -> m (a, w) -> WriterT w m a
forall a b. (a -> b) -> a -> b
$ String -> m (a, w) -> m (a, w)
forall e s (m :: * -> *) a.
MonadParsec e s m =>
String -> m a -> m a
label String
n m (a, w)
m
try :: WriterT w m a -> WriterT w m a
try (L.WriterT m (a, w)
m) = m (a, w) -> WriterT w m a
forall w (m :: * -> *) a. m (a, w) -> WriterT w m a
L.WriterT (m (a, w) -> WriterT w m a) -> m (a, w) -> WriterT w m a
forall a b. (a -> b) -> a -> b
$ m (a, w) -> m (a, w)
forall e s (m :: * -> *) a. MonadParsec e s m => m a -> m a
try m (a, w)
m
lookAhead :: WriterT w m a -> WriterT w m a
lookAhead (L.WriterT m (a, w)
m) =
m (a, w) -> WriterT w m a
forall w (m :: * -> *) a. m (a, w) -> WriterT w m a
L.WriterT (m (a, w) -> WriterT w m a) -> m (a, w) -> WriterT w m a
forall a b. (a -> b) -> a -> b
$
(,w
forall a. Monoid a => a
mempty) (a -> (a, w)) -> ((a, w) -> a) -> (a, w) -> (a, w)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a, w) -> a
forall a b. (a, b) -> a
fst ((a, w) -> (a, w)) -> m (a, w) -> m (a, w)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m (a, w) -> m (a, w)
forall e s (m :: * -> *) a. MonadParsec e s m => m a -> m a
lookAhead m (a, w)
m
notFollowedBy :: WriterT w m a -> WriterT w m ()
notFollowedBy (L.WriterT m (a, w)
m) =
m ((), w) -> WriterT w m ()
forall w (m :: * -> *) a. m (a, w) -> WriterT w m a
L.WriterT (m ((), w) -> WriterT w m ()) -> m ((), w) -> WriterT w m ()
forall a b. (a -> b) -> a -> b
$
(,w
forall a. Monoid a => a
mempty) (() -> ((), w)) -> m () -> m ((), w)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m a -> m ()
forall e s (m :: * -> *) a. MonadParsec e s m => m a -> m ()
notFollowedBy ((a, w) -> a
forall a b. (a, b) -> a
fst ((a, w) -> a) -> m (a, w) -> m a
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m (a, w)
m)
withRecovery :: (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) =
m (a, w) -> WriterT w m a
forall w (m :: * -> *) a. m (a, w) -> WriterT w m a
L.WriterT (m (a, w) -> WriterT w m a) -> m (a, w) -> WriterT w m a
forall a b. (a -> b) -> a -> b
$
(ParseError s e -> m (a, w)) -> m (a, w) -> m (a, w)
forall e s (m :: * -> *) a.
MonadParsec e s m =>
(ParseError s e -> m a) -> m a -> m a
withRecovery (WriterT w m a -> m (a, w)
forall w (m :: * -> *) a. WriterT w m a -> m (a, w)
L.runWriterT (WriterT w m a -> m (a, w))
-> (ParseError s e -> WriterT w m a) -> ParseError s e -> m (a, w)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ParseError s e -> WriterT w m a
r) m (a, w)
m
observing :: WriterT w m a -> WriterT w m (Either (ParseError s e) a)
observing (L.WriterT m (a, w)
m) =
m (Either (ParseError s e) a, w)
-> WriterT w m (Either (ParseError s e) a)
forall w (m :: * -> *) a. m (a, w) -> WriterT w m a
L.WriterT (m (Either (ParseError s e) a, w)
-> WriterT w m (Either (ParseError s e) a))
-> m (Either (ParseError s e) a, w)
-> WriterT w m (Either (ParseError s e) a)
forall a b. (a -> b) -> a -> b
$
w
-> Either (ParseError s e) (a, w) -> (Either (ParseError s e) a, w)
forall s a b. s -> Either a (b, s) -> (Either a b, s)
fixs w
forall a. Monoid a => a
mempty (Either (ParseError s e) (a, w) -> (Either (ParseError s e) a, w))
-> m (Either (ParseError s e) (a, w))
-> m (Either (ParseError s e) a, w)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m (a, w) -> m (Either (ParseError s e) (a, w))
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 = m () -> WriterT w m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m ()
forall e s (m :: * -> *). MonadParsec e s m => m ()
eof
token :: (Token s -> Maybe a) -> Set (ErrorItem (Token s)) -> WriterT w m a
token Token s -> Maybe a
test Set (ErrorItem (Token s))
mt = m a -> WriterT w m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift ((Token s -> Maybe a) -> Set (ErrorItem (Token s)) -> m a
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 = m (Tokens s) -> WriterT w m (Tokens s)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift ((Tokens s -> Tokens s -> Bool) -> Tokens s -> m (Tokens s)
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 = m (Tokens s) -> WriterT w m (Tokens s)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (Maybe String -> (Token s -> Bool) -> m (Tokens s)
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 = m (Tokens s) -> WriterT w m (Tokens s)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (Maybe String -> (Token s -> Bool) -> m (Tokens s)
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 = m (Tokens s) -> WriterT w m (Tokens s)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (Maybe String -> Int -> m (Tokens s)
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 = m (State s e) -> WriterT w m (State s e)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m (State s e)
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 = m () -> WriterT w m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift ((State s e -> State s e) -> m ()
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 :: ParseError s e -> WriterT w m a
parseError ParseError s e
e = m a -> WriterT w m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (ParseError s e -> m a
forall e s (m :: * -> *) a.
MonadParsec e s m =>
ParseError s e -> m a
parseError ParseError s e
e)
label :: String -> WriterT w m a -> WriterT w m a
label String
n (S.WriterT m (a, w)
m) = m (a, w) -> WriterT w m a
forall w (m :: * -> *) a. m (a, w) -> WriterT w m a
S.WriterT (m (a, w) -> WriterT w m a) -> m (a, w) -> WriterT w m a
forall a b. (a -> b) -> a -> b
$ String -> m (a, w) -> m (a, w)
forall e s (m :: * -> *) a.
MonadParsec e s m =>
String -> m a -> m a
label String
n m (a, w)
m
try :: WriterT w m a -> WriterT w m a
try (S.WriterT m (a, w)
m) = m (a, w) -> WriterT w m a
forall w (m :: * -> *) a. m (a, w) -> WriterT w m a
S.WriterT (m (a, w) -> WriterT w m a) -> m (a, w) -> WriterT w m a
forall a b. (a -> b) -> a -> b
$ m (a, w) -> m (a, w)
forall e s (m :: * -> *) a. MonadParsec e s m => m a -> m a
try m (a, w)
m
lookAhead :: WriterT w m a -> WriterT w m a
lookAhead (S.WriterT m (a, w)
m) =
m (a, w) -> WriterT w m a
forall w (m :: * -> *) a. m (a, w) -> WriterT w m a
S.WriterT (m (a, w) -> WriterT w m a) -> m (a, w) -> WriterT w m a
forall a b. (a -> b) -> a -> b
$
(,w
forall a. Monoid a => a
mempty) (a -> (a, w)) -> ((a, w) -> a) -> (a, w) -> (a, w)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a, w) -> a
forall a b. (a, b) -> a
fst ((a, w) -> (a, w)) -> m (a, w) -> m (a, w)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m (a, w) -> m (a, w)
forall e s (m :: * -> *) a. MonadParsec e s m => m a -> m a
lookAhead m (a, w)
m
notFollowedBy :: WriterT w m a -> WriterT w m ()
notFollowedBy (S.WriterT m (a, w)
m) =
m ((), w) -> WriterT w m ()
forall w (m :: * -> *) a. m (a, w) -> WriterT w m a
S.WriterT (m ((), w) -> WriterT w m ()) -> m ((), w) -> WriterT w m ()
forall a b. (a -> b) -> a -> b
$
(,w
forall a. Monoid a => a
mempty) (() -> ((), w)) -> m () -> m ((), w)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m a -> m ()
forall e s (m :: * -> *) a. MonadParsec e s m => m a -> m ()
notFollowedBy ((a, w) -> a
forall a b. (a, b) -> a
fst ((a, w) -> a) -> m (a, w) -> m a
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m (a, w)
m)
withRecovery :: (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) =
m (a, w) -> WriterT w m a
forall w (m :: * -> *) a. m (a, w) -> WriterT w m a
S.WriterT (m (a, w) -> WriterT w m a) -> m (a, w) -> WriterT w m a
forall a b. (a -> b) -> a -> b
$
(ParseError s e -> m (a, w)) -> m (a, w) -> m (a, w)
forall e s (m :: * -> *) a.
MonadParsec e s m =>
(ParseError s e -> m a) -> m a -> m a
withRecovery (WriterT w m a -> m (a, w)
forall w (m :: * -> *) a. WriterT w m a -> m (a, w)
S.runWriterT (WriterT w m a -> m (a, w))
-> (ParseError s e -> WriterT w m a) -> ParseError s e -> m (a, w)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ParseError s e -> WriterT w m a
r) m (a, w)
m
observing :: WriterT w m a -> WriterT w m (Either (ParseError s e) a)
observing (S.WriterT m (a, w)
m) =
m (Either (ParseError s e) a, w)
-> WriterT w m (Either (ParseError s e) a)
forall w (m :: * -> *) a. m (a, w) -> WriterT w m a
S.WriterT (m (Either (ParseError s e) a, w)
-> WriterT w m (Either (ParseError s e) a))
-> m (Either (ParseError s e) a, w)
-> WriterT w m (Either (ParseError s e) a)
forall a b. (a -> b) -> a -> b
$
w
-> Either (ParseError s e) (a, w) -> (Either (ParseError s e) a, w)
forall s a b. s -> Either a (b, s) -> (Either a b, s)
fixs w
forall a. Monoid a => a
mempty (Either (ParseError s e) (a, w) -> (Either (ParseError s e) a, w))
-> m (Either (ParseError s e) (a, w))
-> m (Either (ParseError s e) a, w)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m (a, w) -> m (Either (ParseError s e) (a, w))
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 = m () -> WriterT w m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m ()
forall e s (m :: * -> *). MonadParsec e s m => m ()
eof
token :: (Token s -> Maybe a) -> Set (ErrorItem (Token s)) -> WriterT w m a
token Token s -> Maybe a
test Set (ErrorItem (Token s))
mt = m a -> WriterT w m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift ((Token s -> Maybe a) -> Set (ErrorItem (Token s)) -> m a
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 = m (Tokens s) -> WriterT w m (Tokens s)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift ((Tokens s -> Tokens s -> Bool) -> Tokens s -> m (Tokens s)
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 = m (Tokens s) -> WriterT w m (Tokens s)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (Maybe String -> (Token s -> Bool) -> m (Tokens s)
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 = m (Tokens s) -> WriterT w m (Tokens s)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (Maybe String -> (Token s -> Bool) -> m (Tokens s)
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 = m (Tokens s) -> WriterT w m (Tokens s)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (Maybe String -> Int -> m (Tokens s)
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 = m (State s e) -> WriterT w m (State s e)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m (State s e)
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 = m () -> WriterT w m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift ((State s e -> State s e) -> m ()
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 :: ParseError s e -> RWST r w st m a
parseError ParseError s e
e = m a -> RWST r w st m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (ParseError s e -> m a
forall e s (m :: * -> *) a.
MonadParsec e s m =>
ParseError s e -> m a
parseError ParseError s e
e)
label :: 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) = (r -> st -> m (a, st, w)) -> RWST r w st m a
forall r w s (m :: * -> *) a.
(r -> s -> m (a, s, w)) -> RWST r w s m a
L.RWST ((r -> st -> m (a, st, w)) -> RWST r w st m a)
-> (r -> st -> m (a, st, w)) -> RWST r w st m a
forall a b. (a -> b) -> a -> b
$ \r
r st
s -> String -> m (a, st, w) -> m (a, st, w)
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 :: RWST r w st m a -> RWST r w st m a
try (L.RWST r -> st -> m (a, st, w)
m) = (r -> st -> m (a, st, w)) -> RWST r w st m a
forall r w s (m :: * -> *) a.
(r -> s -> m (a, s, w)) -> RWST r w s m a
L.RWST ((r -> st -> m (a, st, w)) -> RWST r w st m a)
-> (r -> st -> m (a, st, w)) -> RWST r w st m a
forall a b. (a -> b) -> a -> b
$ \r
r st
s -> m (a, st, w) -> m (a, st, w)
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 :: RWST r w st m a -> RWST r w st m a
lookAhead (L.RWST r -> st -> m (a, st, w)
m) = (r -> st -> m (a, st, w)) -> RWST r w st m a
forall r w s (m :: * -> *) a.
(r -> s -> m (a, s, w)) -> RWST r w s m a
L.RWST ((r -> st -> m (a, st, w)) -> RWST r w st m a)
-> (r -> st -> m (a, st, w)) -> RWST r w st m a
forall a b. (a -> b) -> a -> b
$ \r
r st
s -> do
(a
x, st
_, w
_) <- m (a, st, w) -> m (a, 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)
(a, st, w) -> m (a, st, w)
forall (m :: * -> *) a. Monad m => a -> m a
return (a
x, st
s, w
forall a. Monoid a => a
mempty)
notFollowedBy :: RWST r w st m a -> RWST r w st m ()
notFollowedBy (L.RWST r -> st -> m (a, st, w)
m) = (r -> st -> m ((), st, w)) -> RWST r w st m ()
forall r w s (m :: * -> *) a.
(r -> s -> m (a, s, w)) -> RWST r w s m a
L.RWST ((r -> st -> m ((), st, w)) -> RWST r w st m ())
-> (r -> st -> m ((), st, w)) -> RWST r w st m ()
forall a b. (a -> b) -> a -> b
$ \r
r st
s -> do
m () -> m ()
forall e s (m :: * -> *) a. MonadParsec e s m => m a -> m ()
notFollowedBy (m (a, st, w) -> m ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (m (a, st, w) -> m ()) -> m (a, st, w) -> m ()
forall a b. (a -> b) -> a -> b
$ r -> st -> m (a, st, w)
m r
r st
s)
((), st, w) -> m ((), st, w)
forall (m :: * -> *) a. Monad m => a -> m a
return ((), st
s, w
forall a. Monoid a => a
mempty)
withRecovery :: (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) = (r -> st -> m (a, st, w)) -> RWST r w st m a
forall r w s (m :: * -> *) a.
(r -> s -> m (a, s, w)) -> RWST r w s m a
L.RWST ((r -> st -> m (a, st, w)) -> RWST r w st m a)
-> (r -> st -> m (a, st, w)) -> RWST r w st m a
forall a b. (a -> b) -> a -> b
$ \r
r st
s ->
(ParseError s e -> m (a, st, w)) -> m (a, st, w) -> m (a, st, w)
forall e s (m :: * -> *) a.
MonadParsec e s m =>
(ParseError s e -> m a) -> m a -> m a
withRecovery (\ParseError s e
e -> RWST r w st m a -> r -> st -> m (a, st, w)
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 :: 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) = (r -> st -> m (Either (ParseError s e) a, st, w))
-> RWST r w st m (Either (ParseError s e) a)
forall r w s (m :: * -> *) a.
(r -> s -> m (a, s, w)) -> RWST r w s m a
L.RWST ((r -> st -> m (Either (ParseError s e) a, st, w))
-> RWST r w st m (Either (ParseError s e) a))
-> (r -> st -> m (Either (ParseError s e) a, st, w))
-> RWST r w st m (Either (ParseError s e) a)
forall a b. (a -> b) -> a -> b
$ \r
r st
s ->
st
-> Either (ParseError s e) (a, st, w)
-> (Either (ParseError s e) a, st, w)
forall w s a b.
Monoid w =>
s -> Either a (b, s, w) -> (Either a b, s, w)
fixs' st
s (Either (ParseError s e) (a, st, w)
-> (Either (ParseError s e) a, st, w))
-> m (Either (ParseError s e) (a, st, w))
-> m (Either (ParseError s e) a, st, w)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m (a, st, w) -> m (Either (ParseError s e) (a, st, w))
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 = m () -> RWST r w st m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m ()
forall e s (m :: * -> *). MonadParsec e s m => m ()
eof
token :: (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 = m a -> RWST r w st m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift ((Token s -> Maybe a) -> Set (ErrorItem (Token s)) -> m a
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 = m (Tokens s) -> RWST r w st m (Tokens s)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift ((Tokens s -> Tokens s -> Bool) -> Tokens s -> m (Tokens s)
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 = m (Tokens s) -> RWST r w st m (Tokens s)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (Maybe String -> (Token s -> Bool) -> m (Tokens s)
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 = m (Tokens s) -> RWST r w st m (Tokens s)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (Maybe String -> (Token s -> Bool) -> m (Tokens s)
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 = m (Tokens s) -> RWST r w st m (Tokens s)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (Maybe String -> Int -> m (Tokens s)
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 = m (State s e) -> RWST r w st m (State s e)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m (State s e)
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 = m () -> RWST r w st m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift ((State s e -> State s e) -> m ()
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 :: ParseError s e -> RWST r w st m a
parseError ParseError s e
e = m a -> RWST r w st m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (ParseError s e -> m a
forall e s (m :: * -> *) a.
MonadParsec e s m =>
ParseError s e -> m a
parseError ParseError s e
e)
label :: 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) = (r -> st -> m (a, st, w)) -> RWST r w st m a
forall r w s (m :: * -> *) a.
(r -> s -> m (a, s, w)) -> RWST r w s m a
S.RWST ((r -> st -> m (a, st, w)) -> RWST r w st m a)
-> (r -> st -> m (a, st, w)) -> RWST r w st m a
forall a b. (a -> b) -> a -> b
$ \r
r st
s -> String -> m (a, st, w) -> m (a, st, w)
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 :: RWST r w st m a -> RWST r w st m a
try (S.RWST r -> st -> m (a, st, w)
m) = (r -> st -> m (a, st, w)) -> RWST r w st m a
forall r w s (m :: * -> *) a.
(r -> s -> m (a, s, w)) -> RWST r w s m a
S.RWST ((r -> st -> m (a, st, w)) -> RWST r w st m a)
-> (r -> st -> m (a, st, w)) -> RWST r w st m a
forall a b. (a -> b) -> a -> b
$ \r
r st
s -> m (a, st, w) -> m (a, st, w)
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 :: RWST r w st m a -> RWST r w st m a
lookAhead (S.RWST r -> st -> m (a, st, w)
m) = (r -> st -> m (a, st, w)) -> RWST r w st m a
forall r w s (m :: * -> *) a.
(r -> s -> m (a, s, w)) -> RWST r w s m a
S.RWST ((r -> st -> m (a, st, w)) -> RWST r w st m a)
-> (r -> st -> m (a, st, w)) -> RWST r w st m a
forall a b. (a -> b) -> a -> b
$ \r
r st
s -> do
(a
x, st
_, w
_) <- m (a, st, w) -> m (a, 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)
(a, st, w) -> m (a, st, w)
forall (m :: * -> *) a. Monad m => a -> m a
return (a
x, st
s, w
forall a. Monoid a => a
mempty)
notFollowedBy :: RWST r w st m a -> RWST r w st m ()
notFollowedBy (S.RWST r -> st -> m (a, st, w)
m) = (r -> st -> m ((), st, w)) -> RWST r w st m ()
forall r w s (m :: * -> *) a.
(r -> s -> m (a, s, w)) -> RWST r w s m a
S.RWST ((r -> st -> m ((), st, w)) -> RWST r w st m ())
-> (r -> st -> m ((), st, w)) -> RWST r w st m ()
forall a b. (a -> b) -> a -> b
$ \r
r st
s -> do
m () -> m ()
forall e s (m :: * -> *) a. MonadParsec e s m => m a -> m ()
notFollowedBy (m (a, st, w) -> m ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (m (a, st, w) -> m ()) -> m (a, st, w) -> m ()
forall a b. (a -> b) -> a -> b
$ r -> st -> m (a, st, w)
m r
r st
s)
((), st, w) -> m ((), st, w)
forall (m :: * -> *) a. Monad m => a -> m a
return ((), st
s, w
forall a. Monoid a => a
mempty)
withRecovery :: (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) = (r -> st -> m (a, st, w)) -> RWST r w st m a
forall r w s (m :: * -> *) a.
(r -> s -> m (a, s, w)) -> RWST r w s m a
S.RWST ((r -> st -> m (a, st, w)) -> RWST r w st m a)
-> (r -> st -> m (a, st, w)) -> RWST r w st m a
forall a b. (a -> b) -> a -> b
$ \r
r st
s ->
(ParseError s e -> m (a, st, w)) -> m (a, st, w) -> m (a, st, w)
forall e s (m :: * -> *) a.
MonadParsec e s m =>
(ParseError s e -> m a) -> m a -> m a
withRecovery (\ParseError s e
e -> RWST r w st m a -> r -> st -> m (a, st, w)
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 :: 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) = (r -> st -> m (Either (ParseError s e) a, st, w))
-> RWST r w st m (Either (ParseError s e) a)
forall r w s (m :: * -> *) a.
(r -> s -> m (a, s, w)) -> RWST r w s m a
S.RWST ((r -> st -> m (Either (ParseError s e) a, st, w))
-> RWST r w st m (Either (ParseError s e) a))
-> (r -> st -> m (Either (ParseError s e) a, st, w))
-> RWST r w st m (Either (ParseError s e) a)
forall a b. (a -> b) -> a -> b
$ \r
r st
s ->
st
-> Either (ParseError s e) (a, st, w)
-> (Either (ParseError s e) a, st, w)
forall w s a b.
Monoid w =>
s -> Either a (b, s, w) -> (Either a b, s, w)
fixs' st
s (Either (ParseError s e) (a, st, w)
-> (Either (ParseError s e) a, st, w))
-> m (Either (ParseError s e) (a, st, w))
-> m (Either (ParseError s e) a, st, w)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m (a, st, w) -> m (Either (ParseError s e) (a, st, w))
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 = m () -> RWST r w st m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m ()
forall e s (m :: * -> *). MonadParsec e s m => m ()
eof
token :: (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 = m a -> RWST r w st m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift ((Token s -> Maybe a) -> Set (ErrorItem (Token s)) -> m a
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 = m (Tokens s) -> RWST r w st m (Tokens s)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift ((Tokens s -> Tokens s -> Bool) -> Tokens s -> m (Tokens s)
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 = m (Tokens s) -> RWST r w st m (Tokens s)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (Maybe String -> (Token s -> Bool) -> m (Tokens s)
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 = m (Tokens s) -> RWST r w st m (Tokens s)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (Maybe String -> (Token s -> Bool) -> m (Tokens s)
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 = m (Tokens s) -> RWST r w st m (Tokens s)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (Maybe String -> Int -> m (Tokens s)
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 = m (State s e) -> RWST r w st m (State s e)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m (State s e)
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 = m () -> RWST r w st m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift ((State s e -> State s e) -> m ()
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 :: ParseError s e -> IdentityT m a
parseError ParseError s e
e = m a -> IdentityT m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (ParseError s e -> m a
forall e s (m :: * -> *) a.
MonadParsec e s m =>
ParseError s e -> m a
parseError ParseError s e
e)
label :: String -> IdentityT m a -> IdentityT m a
label String
n (IdentityT m a
m) = m a -> IdentityT m a
forall k (f :: k -> *) (a :: k). f a -> IdentityT f a
IdentityT (m a -> IdentityT m a) -> m a -> IdentityT m a
forall a b. (a -> b) -> a -> b
$ String -> m a -> m a
forall e s (m :: * -> *) a.
MonadParsec e s m =>
String -> m a -> m a
label String
n m a
m
try :: IdentityT m a -> IdentityT m a
try = m a -> IdentityT m a
forall k (f :: k -> *) (a :: k). f a -> IdentityT f a
IdentityT (m a -> IdentityT m a)
-> (IdentityT m a -> m a) -> IdentityT m a -> IdentityT m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. m a -> m a
forall e s (m :: * -> *) a. MonadParsec e s m => m a -> m a
try (m a -> m a) -> (IdentityT m a -> m a) -> IdentityT m a -> m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. IdentityT m a -> m a
forall k (f :: k -> *) (a :: k). IdentityT f a -> f a
runIdentityT
lookAhead :: IdentityT m a -> IdentityT m a
lookAhead (IdentityT m a
m) = m a -> IdentityT m a
forall k (f :: k -> *) (a :: k). f a -> IdentityT f a
IdentityT (m a -> IdentityT m a) -> m a -> IdentityT m a
forall a b. (a -> b) -> a -> b
$ m a -> m a
forall e s (m :: * -> *) a. MonadParsec e s m => m a -> m a
lookAhead m a
m
notFollowedBy :: IdentityT m a -> IdentityT m ()
notFollowedBy (IdentityT m a
m) = m () -> IdentityT m ()
forall k (f :: k -> *) (a :: k). f a -> IdentityT f a
IdentityT (m () -> IdentityT m ()) -> m () -> IdentityT m ()
forall a b. (a -> b) -> a -> b
$ m a -> m ()
forall e s (m :: * -> *) a. MonadParsec e s m => m a -> m ()
notFollowedBy m a
m
withRecovery :: (ParseError s e -> IdentityT m a) -> IdentityT m a -> IdentityT m a
withRecovery ParseError s e -> IdentityT m a
r (IdentityT m a
m) =
m a -> IdentityT m a
forall k (f :: k -> *) (a :: k). f a -> IdentityT f a
IdentityT (m a -> IdentityT m a) -> m a -> IdentityT m a
forall a b. (a -> b) -> a -> b
$
(ParseError s e -> m a) -> m a -> m a
forall e s (m :: * -> *) a.
MonadParsec e s m =>
(ParseError s e -> m a) -> m a -> m a
withRecovery (IdentityT m a -> m a
forall k (f :: k -> *) (a :: k). IdentityT f a -> f a
runIdentityT (IdentityT m a -> m a)
-> (ParseError s e -> IdentityT m a) -> ParseError s e -> m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ParseError s e -> IdentityT m a
r) m a
m
observing :: IdentityT m a -> IdentityT m (Either (ParseError s e) a)
observing (IdentityT m a
m) = m (Either (ParseError s e) a)
-> IdentityT m (Either (ParseError s e) a)
forall k (f :: k -> *) (a :: k). f a -> IdentityT f a
IdentityT (m (Either (ParseError s e) a)
-> IdentityT m (Either (ParseError s e) a))
-> m (Either (ParseError s e) a)
-> IdentityT m (Either (ParseError s e) a)
forall a b. (a -> b) -> a -> b
$ m a -> m (Either (ParseError s e) a)
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 = m () -> IdentityT m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m ()
forall e s (m :: * -> *). MonadParsec e s m => m ()
eof
token :: (Token s -> Maybe a) -> Set (ErrorItem (Token s)) -> IdentityT m a
token Token s -> Maybe a
test Set (ErrorItem (Token s))
mt = m a -> IdentityT m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift ((Token s -> Maybe a) -> Set (ErrorItem (Token s)) -> m a
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 = m (Tokens s) -> IdentityT m (Tokens s)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (Tokens s) -> IdentityT m (Tokens s))
-> m (Tokens s) -> IdentityT m (Tokens s)
forall a b. (a -> b) -> a -> b
$ (Tokens s -> Tokens s -> Bool) -> Tokens s -> m (Tokens s)
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 = m (Tokens s) -> IdentityT m (Tokens s)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (Maybe String -> (Token s -> Bool) -> m (Tokens s)
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 = m (Tokens s) -> IdentityT m (Tokens s)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (Maybe String -> (Token s -> Bool) -> m (Tokens s)
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 = m (Tokens s) -> IdentityT m (Tokens s)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (Maybe String -> Int -> m (Tokens s)
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 = m (State s e) -> IdentityT m (State s e)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m (State s e)
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 = m () -> IdentityT m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> IdentityT m ()) -> m () -> IdentityT m ()
forall a b. (a -> b) -> a -> b
$ (State s e -> State s e) -> m ()
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 :: s -> Either a (b, s) -> (Either a b, s)
fixs s
s (Left a
a) = (a -> Either a b
forall a b. a -> Either a b
Left a
a, s
s)
fixs s
_ (Right (b
b, s
s)) = (b -> Either a b
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' :: s -> Either a (b, s, w) -> (Either a b, s, w)
fixs' s
s (Left a
a) = (a -> Either a b
forall a b. a -> Either a b
Left a
a, s
s, w
forall a. Monoid a => a
mempty)
fixs' s
_ (Right (b
b, s
s, w
w)) = (b -> Either a b
forall a b. b -> Either a b
Right b
b, s
s, w
w)
{-# INLINE fixs' #-}