    -- |
    -- Module      :  Text.Megaparsec.Class
    -- Copyright   :  © 2015–present Megaparsec contributors
    --                © 2007 Paolo Martini
    --                © 1999–2001 Daan Leijen
    -- License     :  FreeBSD
    --
    -- Maintainer  :  Mark Karpov <markkarpov92@gmail.com>
    -- Stability   :  experimental
    -- Portability :  portable
    --
    -- Definition of 'MonadParsec'—type class describing monads that implement
    -- the full set of primitive parsers.
    --
    -- @since 6.5.0

    {-# LANGUAGE FlexibleInstances      #-}
    {-# LANGUAGE FunctionalDependencies #-}
    {-# LANGUAGE MultiParamTypeClasses  #-}
    {-# LANGUAGE TupleSections          #-}
    {-# LANGUAGE UndecidableInstances   #-}

    module Text.Megaparsec.Class
      ( MonadParsec (..) )
    where

    import Control.Monad
    import Control.Monad.Identity
    import Control.Monad.Trans
    import Data.Set (Set)
    import Text.Megaparsec.Error
    import Text.Megaparsec.State
    import Text.Megaparsec.Stream
    import qualified Control.Monad.RWS.Lazy            as L
    import qualified Control.Monad.RWS.Strict          as S
    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

    -- | Type class describing monads that implement the full set of primitive
    -- parsers.
    --
    -- __Note__ that the following primitives are “fast” and should be taken
    -- advantage of as much as possible if your aim is a fast parser: 'tokens',
    -- 'takeWhileP', 'takeWhile1P', and 'takeP'.

    class (Stream s, MonadPlus m) => MonadParsec e s m | m -> e s where

      -- | Stop parsing and report the 'ParseError'. This is the only way to
      -- control position of the error without manipulating parser state
      -- manually.
      --
      -- @since 8.0.0

      parseError :: ParseError s e -> m a

      -- | The parser @'label' name p@ behaves as parser @p@, but whenever the
      -- parser @p@ fails /without consuming any input/, it replaces names of
      -- “expected” tokens with the name @name@.

      label :: String -> m a -> m a

      -- | @'hidden' p@ behaves just like parser @p@, but it doesn't show any
      -- “expected” tokens in error message when @p@ fails.
      --
      -- Please use 'hidden' instead of the old @'label' ""@ idiom.

      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 ""

      -- | The parser @'try' p@ behaves like parser @p@, except that it
      -- backtracks the parser state when @p@ fails (either consuming input or
      -- not).
      --
      -- This combinator is used whenever arbitrary look ahead is needed. Since
      -- it pretends that it hasn't consumed any input when @p@ fails, the
      -- ('A.<|>') combinator will try its second alternative even if the first
      -- parser failed while consuming input.
      --
      -- For example, here is a parser that is supposed to parse the word “let”
      -- or the word “lexical”:
      --
      -- >>> parseTest (string "let" <|> string "lexical") "lexical"
      -- 1:1:
      -- unexpected "lex"
      -- expecting "let"
      --
      -- What happens here? The first parser consumes “le” and fails (because it
      -- doesn't see a “t”). The second parser, however, isn't tried, since the
      -- first parser has already consumed some input! 'try' fixes this behavior
      -- and allows backtracking to work:
      --
      -- >>> parseTest (try (string "let") <|> string "lexical") "lexical"
      -- "lexical"
      --
      -- 'try' also improves error messages in case of overlapping alternatives,
      -- because Megaparsec's hint system can be used:
      --
      -- >>> parseTest (try (string "let") <|> string "lexical") "le"
      -- 1:1:
      -- unexpected "le"
      -- expecting "let" or "lexical"
      --
      -- __Note__ that as of Megaparsec 4.4.0, 'Text.Megaparsec.Char.string'
      -- backtracks automatically (see 'tokens'), so it does not need 'try'.
      -- However, the examples above demonstrate the idea behind 'try' so well
      -- that it was decided to keep them. You still need to use 'try' when your
      -- alternatives are complex, composite parsers.

      try :: m a -> m a

      -- | If @p@ in @'lookAhead' p@ succeeds (either consuming input or not)
      -- the whole parser behaves like @p@ succeeded without consuming anything
      -- (parser state is not updated as well). If @p@ fails, 'lookAhead' has no
      -- effect, i.e. it will fail consuming input if @p@ fails consuming input.
      -- Combine with 'try' if this is undesirable.

      lookAhead :: m a -> m a

      -- | @'notFollowedBy' p@ only succeeds when the parser @p@ fails. This
      -- parser /never consumes/ any input and /never modifies/ parser state. It
      -- can be used to implement the “longest match” rule.

      notFollowedBy :: m a -> m ()

      -- | @'withRecovery' r p@ allows continue parsing even if parser @p@
      -- fails. In this case @r@ is called with the actual 'ParseError' as its
      -- argument. Typical usage is to return a value signifying failure to
      -- parse this particular object and to consume some part of the input up
      -- to the point where the next object starts.
      --
      -- Note that if @r@ fails, original error message is reported as if
      -- without 'withRecovery'. In no way recovering parser @r@ can influence
      -- error messages.
      --
      -- @since 4.4.0

      withRecovery
        :: (ParseError s e -> m a) -- ^ How to recover from failure
        -> m a             -- ^ Original parser
        -> m a             -- ^ Parser that can recover from failures

      -- | @'observing' p@ allows to “observe” failure of the @p@ parser, should
      -- it happen, without actually ending parsing but instead getting the
      -- 'ParseError' in 'Left'. On success parsed value is returned in 'Right'
      -- as usual. Note that this primitive just allows you to observe parse
      -- errors as they happen, it does not backtrack or change how the @p@
      -- parser works in any way.
      --
      -- @since 5.1.0

      observing
        :: m a             -- ^ The parser to run
        -> m (Either (ParseError s e) a)

      -- | This parser only succeeds at the end of input.

      eof :: m ()

      -- | The parser @'token' test expected@ accepts a token @t@ with result
      -- @x@ when the function @test t@ returns @'Just' x@. @expected@ specifies
      -- the collection of expected items to report in error messages.
      --
      -- This is the most primitive combinator for accepting tokens. For
      -- example, the 'Text.Megaparsec.satisfy' parser is implemented as:
      --
      -- > satisfy f = token testToken E.empty
      -- >   where
      -- >     testToken x = if f x then Just x else Nothing
      --
      -- __Note__: type signature of this primitive was changed in the version
      -- /7.0.0/.

      token
        :: (Token s -> Maybe a)
           -- ^ Matching function for the token to parse
        -> Set (ErrorItem (Token s))
           -- ^ Expected items (in case of an error)
        -> m a

      -- | The parser @'tokens' test chk@ parses a chunk of input @chk@ and
      -- returns it. The supplied predicate @test@ is used to check equality of
      -- given and parsed chunks after a candidate chunk of correct length is
      -- fetched from the stream.
      --
      -- This can be used for example to write 'Text.Megaparsec.chunk':
      --
      -- > chunk = tokens (==)
      --
      -- Note that beginning from Megaparsec 4.4.0, this is an auto-backtracking
      -- primitive, which means that if it fails, it never consumes any input.
      -- This is done to make its consumption model match how error messages for
      -- this primitive are reported (which becomes an important thing as user
      -- gets more control with primitives like 'withRecovery'):
      --
      -- >>> parseTest (string "abc") "abd"
      -- 1:1:
      -- unexpected "abd"
      -- expecting "abc"
      --
      -- This means, in particular, that it's no longer necessary to use 'try'
      -- with 'tokens'-based parsers, such as 'Text.Megaparsec.Char.string' and
      -- 'Text.Megaparsec.Char.string''. This feature /does not/ affect
      -- performance in any way.

      tokens
        :: (Tokens s -> Tokens s -> Bool)
           -- ^ Predicate to check equality of chunks
        -> Tokens s
           -- ^ Chunk of input to match against
        -> m (Tokens s)

      -- | Parse /zero/ or more tokens for which the supplied predicate holds.
      -- Try to use this as much as possible because for many streams the
      -- combinator is much faster than parsers built with
      -- 'Control.Monad.Combinators.many' and 'Text.Megaparsec.satisfy'.
      --
      -- The following equations should clarify the behavior:
      --
      -- > takeWhileP (Just "foo") f = many (satisfy f <?> "foo")
      -- > takeWhileP Nothing      f = many (satisfy f)
      --
      -- The combinator never fails, although it may parse the empty chunk.
      --
      -- @since 6.0.0

      takeWhileP
        :: Maybe String    -- ^ Name for a single token in the row
        -> (Token s -> Bool) -- ^ Predicate to use to test tokens
        -> m (Tokens s)    -- ^ A chunk of matching tokens

      -- | Similar to 'takeWhileP', but fails if it can't parse at least one
      -- token. Note that the combinator either succeeds or fails without
      -- consuming any input, so 'try' is not necessary with it.
      --
      -- @since 6.0.0

      takeWhile1P
        :: Maybe String    -- ^ Name for a single token in the row
        -> (Token s -> Bool) -- ^ Predicate to use to test tokens
        -> m (Tokens s)    -- ^ A chunk of matching tokens

      -- | Extract the specified number of tokens from the input stream and
      -- return them packed as a chunk of stream. If there is not enough tokens
      -- in the stream, a parse error will be signaled. It's guaranteed that if
      -- the parser succeeds, the requested number of tokens will be returned.
      --
      -- The parser is roughly equivalent to:
      --
      -- > takeP (Just "foo") n = count n (anyChar <?> "foo")
      -- > takeP Nothing      n = count n anyChar
      --
      -- Note that if the combinator fails due to insufficient number of tokens
      -- in the input stream, it backtracks automatically. No 'try' is necessary
      -- with 'takeP'.
      --
      -- @since 6.0.0

      takeP
        :: Maybe String    -- ^ Name for a single token in the row
        -> Int             -- ^ How many tokens to extract
        -> m (Tokens s)    -- ^ A chunk of matching tokens

      -- | Return the full parser state as a 'State' record.

      getParserState :: m (State s e)

      -- | @'updateParserState' f@ applies the function @f@ to the parser state.

      updateParserState :: (State s e -> State s e) -> m ()

    ----------------------------------------------------------------------------
    -- Lifting through MTL

    instance MonadParsec e s m => MonadParsec e s (L.StateT st m) where
      parseError :: ParseError s e -> StateT st m a
    parseError e :: 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 n :: String
    n       (L.StateT m :: 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 m :: 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 m :: 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
    $ \s :: 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 m :: 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
    $ \s :: 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 r :: ParseError s e -> StateT st m a
    r (L.StateT m :: 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
    $ \s :: 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 (\e :: 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 m :: 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
    $ \s :: 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 test :: Token s -> Maybe a
    test mt :: 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 e :: Tokens s -> Tokens s -> Bool
    e ts :: 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 l :: Maybe String
    l f :: 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 l :: Maybe String
    l f :: 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 l :: Maybe String
    l n :: 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 f :: 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 e :: 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 n :: String
    n       (S.StateT m :: 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 m :: 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 m :: 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
    $ \s :: 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 m :: 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
    $ \s :: 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 r :: ParseError s e -> StateT st m a
    r (S.StateT m :: 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
    $ \s :: 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 (\e :: 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 m :: 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
    $ \s :: 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 test :: Token s -> Maybe a
    test mt :: 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 e :: Tokens s -> Tokens s -> Bool
    e ts :: 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 l :: Maybe String
    l f :: 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 l :: Maybe String
    l f :: 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 l :: Maybe String
    l n :: 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 f :: 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 e :: 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 n :: String
    n       (L.ReaderT m :: 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 m :: 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 m :: 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 m :: 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 r :: ParseError s e -> ReaderT r m a
    r (L.ReaderT m :: 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
    $ \s :: 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 (\e :: 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 m :: 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 test :: Token s -> Maybe a
    test mt :: 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 e :: Tokens s -> Tokens s -> Bool
    e ts :: 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 l :: Maybe String
    l f :: 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 l :: Maybe String
    l f :: 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 l :: Maybe String
    l n :: 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 f :: 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 e :: 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 n :: String
    n       (L.WriterT m :: 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 :: 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 :: 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 :: 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 r :: ParseError s e -> WriterT w m a
    r (L.WriterT m :: 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 :: 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 test :: Token s -> Maybe a
    test mt :: 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 e :: Tokens s -> Tokens s -> Bool
    e ts :: 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 l :: Maybe String
    l f :: 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 l :: Maybe String
    l f :: 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 l :: Maybe String
    l n :: 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 f :: 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 e :: 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 n :: String
    n       (S.WriterT m :: 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 :: 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 :: 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 :: 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 r :: ParseError s e -> WriterT w m a
    r (S.WriterT m :: 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 :: 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 test :: Token s -> Maybe a
    test mt :: 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 e :: Tokens s -> Tokens s -> Bool
    e ts :: 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 l :: Maybe String
    l f :: 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 l :: Maybe String
    l f :: 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 l :: Maybe String
    l n :: 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 f :: 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)

    -- | @since 5.2.0

    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 e :: 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 n :: String
    n          (L.RWST m :: 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
    r s :: 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 m :: 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
    r s :: 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 m :: 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
    r s :: st
    s -> do
        (x :: a
    x,_,_) <- 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 m :: 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
    r s :: 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   n :: ParseError s e -> RWST r w st m a
    n (L.RWST m :: 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
    r s :: 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 (\e :: 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 m :: 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
    r s :: 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 test :: Token s -> Maybe a
    test mt :: 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 e :: Tokens s -> Tokens s -> Bool
    e ts :: 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 l :: Maybe String
    l f :: 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 l :: Maybe String
    l f :: 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 l :: Maybe String
    l n :: 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 f :: 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)

    -- | @since 5.2.0

    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 e :: 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 n :: String
    n          (S.RWST m :: 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
    r s :: 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 m :: 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
    r s :: 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 m :: 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
    r s :: st
    s -> do
        (x :: a
    x,_,_) <- 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 m :: 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
    r s :: 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   n :: ParseError s e -> RWST r w st m a
    n (S.RWST m :: 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
    r s :: 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 (\e :: 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 m :: 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
    r s :: 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 test :: Token s -> Maybe a
    test mt :: 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 e :: Tokens s -> Tokens s -> Bool
    e ts :: 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 l :: Maybe String
    l f :: 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 l :: Maybe String
    l f :: 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 l :: Maybe String
    l n :: 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 f :: 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 e :: 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 n :: String
    n       (IdentityT m :: 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 :: 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 :: 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 r :: ParseError s e -> IdentityT m a
    r (IdentityT m :: 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 :: 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 test :: Token s -> Maybe a
    test mt :: 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 e :: Tokens s -> Tokens s -> Bool
    e ts :: 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 l :: Maybe String
    l f :: 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 l :: Maybe String
    l f :: 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 l :: Maybe String
    l n :: 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 f :: 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
    s (Left a :: a
    a)       = (a -> Either a b
    forall a b. a -> Either a b
    Left a
    a, s
    s)
    fixs _ (Right (b :: b
    b, s :: 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
    s (Left a :: 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' _ (Right (b :: b
    b,s :: s
    s,w :: w
    w)) = (b -> Either a b
    forall a b. b -> Either a b
    Right b
    b, s
    s, w
    w)
    {-# INLINE fixs' #-}