{-# LANGUAGE CPP #-}
{-# LANGUAGE DefaultSignatures #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}

#if defined (__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ < 802
{-# LANGUAGE TypeSynonymInstances #-}
#endif

-- | Parsers that can consume and return a prefix of their input.

module Text.Parser.Input (InputParsing(..), InputCharParsing(..), ConsumedInputParsing(..),
                          Lazy(..), Strict(..)) where

import Control.Applicative (Alternative ((<|>), empty))
import Control.Monad (MonadPlus, void)
import Control.Monad.Trans.Class (lift)
import Control.Monad.Trans.Identity (IdentityT(..))
import Control.Monad.Trans.Reader (ReaderT(..), mapReaderT)
import qualified Control.Monad.Trans.Writer.Lazy as Lazy (WriterT)
import qualified Control.Monad.Trans.Writer.Strict as Strict (WriterT)
import qualified Control.Monad.Trans.State.Lazy as Lazy (StateT)
import qualified Control.Monad.Trans.State.Strict as Strict (StateT)
import qualified Control.Monad.Trans.RWS.Lazy as Lazy (RWST)
import qualified Control.Monad.Trans.RWS.Strict as Strict (RWST)
import Data.ByteString (ByteString)
import qualified Data.ByteString as ByteString
import qualified Data.ByteString.Lazy as Lazy
import Data.Ord (Down)
import Text.ParserCombinators.ReadP (ReadP)
import qualified Text.ParserCombinators.ReadP as ReadP

import Text.Parser.Char (CharParsing)
import Text.Parser.Combinators (count, eof, notFollowedBy, try, unexpected)
import Text.Parser.LookAhead (LookAheadParsing, lookAhead)
import qualified Text.Parser.Char as Char

import qualified Data.Monoid.Factorial as Factorial
import qualified Data.Monoid.Null as Null
import qualified Data.Monoid.Textual as Textual
import qualified Data.Semigroup.Cancellative as Cancellative
import Data.Monoid.Factorial (FactorialMonoid)
import Data.Monoid.Textual (TextualMonoid)
import Data.Semigroup.Cancellative (LeftReductive)

#ifdef MIN_VERSION_attoparsec
import Data.Text (Text)
import qualified Data.ByteString.Char8 as ByteString.Char8
import qualified Data.Text as Text

import qualified Data.Attoparsec.ByteString as Attoparsec
import qualified Data.Attoparsec.ByteString.Char8 as Attoparsec.Char8
import qualified Data.Attoparsec.Text as Attoparsec.Text
#endif

#ifdef MIN_VERSION_parsec
import Text.Parsec (ParsecT)
import qualified Text.Parsec as Parsec
#endif

#ifdef MIN_VERSION_binary
import qualified Data.Binary.Get as Binary
#endif

import Text.Parser.Input.Position (fromEnd, fromStart)
import Text.Parser.Internal (mapLazyWriterT, mapStrictWriterT,
                             mapLazyStateT, mapStrictStateT,
                             mapLazyRWST, mapStrictRWST)
import Text.Parser.Wrapper (Lazy(..), Strict(..))

import Prelude hiding (take, takeWhile)

-- | Methods for parsing monoidal inputs
class LookAheadParsing m => InputParsing m where
   -- | The type of the input stream that the parser @m@ expects to parse.
   type ParserInput m
   type ParserPosition m
   -- | Always sucessful parser that returns the entire remaining input without consuming it.
   getInput :: m (ParserInput m)
   -- | Retrieve the 'Position' reached by the parser in the input source.
   getSourcePos :: m (ParserPosition m)

   -- | A parser that accepts any single atomic prefix of the input stream.
   --
   -- > anyToken == satisfy (const True)
   -- > anyToken == take 1
   anyToken :: m (ParserInput m)
   -- | A parser that accepts exactly the given number of input atoms.
   --
   -- > take n == count n anyToken
   take :: Int -> m (ParserInput m)
   -- | A parser that accepts an input atom only if it satisfies the given predicate.
   satisfy :: (ParserInput m -> Bool) -> m (ParserInput m)
   -- | A parser that succeeds exactly when satisfy doesn't, equivalent to
   -- 'Text.Parser.Combinators.notFollowedBy' @.@ 'satisfy'
   notSatisfy :: (ParserInput m -> Bool) -> m ()

   -- | A stateful scanner. The predicate modifies a state argument, and each transformed state is passed to successive
   -- invocations of the predicate on each token of the input until one returns 'Nothing' or the input ends.
   --
   -- This parser does not fail.  It will return an empty string if the predicate returns 'Nothing' on the first
   -- character.
   --
   -- /Note/: Because this parser does not fail, do not use it with combinators such as 'Control.Applicative.many',
   -- because such parsers loop until a failure occurs.  Careless use will thus result in an infinite loop.
   scan :: state -> (state -> ParserInput m -> Maybe state) -> m (ParserInput m)
   -- | A parser that consumes and returns the given prefix of the input.
   string :: ParserInput m -> m (ParserInput m)

   -- | A parser accepting the longest sequence of input atoms that match the given predicate; an optimized version of
   -- 'concat' @.@ 'Control.Applicative.many' @.@ 'satisfy'.
   --
   -- /Note/: Because this parser does not fail, do not use it with combinators such as 'Control.Applicative.many',
   -- because such parsers loop until a failure occurs.  Careless use will thus result in an infinite loop.
   takeWhile :: (ParserInput m -> Bool) -> m (ParserInput m)
   -- | A parser accepting the longest non-empty sequence of input atoms that match the given predicate; an optimized
   -- version of 'concat' @.@ 'Control.Applicative.some' @.@ 'satisfy'.
   takeWhile1 :: (ParserInput m -> Bool) -> m (ParserInput m)

   type ParserPosition m = Down Int
   default getSourcePos :: (FactorialMonoid (ParserInput m), Functor m, ParserPosition m ~ Down Int)
                        => m (ParserPosition m)
   getSourcePos = Int -> Down Int
fromEnd forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall m. Factorial m => m -> Int
Factorial.length forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (m :: * -> *). InputParsing m => m (ParserInput m)
getInput
   anyToken = forall (m :: * -> *). InputParsing m => Int -> m (ParserInput m)
take Int
1
   default satisfy :: Monad m => (ParserInput m -> Bool) -> m (ParserInput m)
   satisfy ParserInput m -> Bool
predicate = forall (m :: * -> *). InputParsing m => m (ParserInput m)
anyToken forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \ParserInput m
x-> if ParserInput m -> Bool
predicate ParserInput m
x then forall (f :: * -> *) a. Applicative f => a -> f a
pure ParserInput m
x else forall (f :: * -> *) a. Alternative f => f a
empty
   notSatisfy ParserInput m -> Bool
predicate = forall (m :: * -> *) a. Parsing m => m a -> m a
try (forall (f :: * -> *) a. Functor f => f a -> f ()
void forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *).
InputParsing m =>
(ParserInput m -> Bool) -> m (ParserInput m)
satisfy forall a b. (a -> b) -> a -> b
$ Bool -> Bool
not forall b c a. (b -> c) -> (a -> b) -> a -> c
. ParserInput m -> Bool
predicate) forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> forall (m :: * -> *). Parsing m => m ()
eof
   default string :: (Monad m, LeftReductive (ParserInput m), FactorialMonoid (ParserInput m), Show (ParserInput m))
                  => ParserInput m -> m (ParserInput m)
   string ParserInput m
s = do ParserInput m
i <- forall (m :: * -> *). InputParsing m => m (ParserInput m)
getInput
                 if ParserInput m
s forall m. LeftReductive m => m -> m -> Bool
`Cancellative.isPrefixOf` ParserInput m
i
                    then forall (m :: * -> *). InputParsing m => Int -> m (ParserInput m)
take (forall m. Factorial m => m -> Int
Factorial.length ParserInput m
s)
                    else forall (m :: * -> *) a. Parsing m => String -> m a
unexpected (String
"string " forall a. Semigroup a => a -> a -> a
<> forall a. Show a => a -> String
show ParserInput m
s)
   default scan :: (Monad m, FactorialMonoid (ParserInput m)) =>
                   state -> (state -> ParserInput m -> Maybe state) -> m (ParserInput m)
   scan state
state state -> ParserInput m -> Maybe state
f = do ParserInput m
i <- forall (m :: * -> *). InputParsing m => m (ParserInput m)
getInput
                     let (ParserInput m
prefix, ParserInput m
_suffix, state
_state) = forall m s.
FactorialMonoid m =>
s -> (s -> m -> Maybe s) -> m -> (m, m, s)
Factorial.spanMaybe' state
state state -> ParserInput m -> Maybe state
f ParserInput m
i
                     forall (m :: * -> *). InputParsing m => Int -> m (ParserInput m)
take (forall m. Factorial m => m -> Int
Factorial.length ParserInput m
prefix)
   default takeWhile :: (Monad m, FactorialMonoid (ParserInput m)) => (ParserInput m -> Bool) -> m (ParserInput m)
   takeWhile ParserInput m -> Bool
predicate = do ParserInput m
i <- forall (m :: * -> *). InputParsing m => m (ParserInput m)
getInput
                            forall (m :: * -> *). InputParsing m => Int -> m (ParserInput m)
take (forall m. Factorial m => m -> Int
Factorial.length forall a b. (a -> b) -> a -> b
$ forall m. FactorialMonoid m => (m -> Bool) -> m -> m
Factorial.takeWhile ParserInput m -> Bool
predicate ParserInput m
i)
   default takeWhile1 :: (Monad m, FactorialMonoid (ParserInput m)) => (ParserInput m -> Bool) -> m (ParserInput m)
   takeWhile1 ParserInput m -> Bool
predicate = do ParserInput m
x <- forall (m :: * -> *).
InputParsing m =>
(ParserInput m -> Bool) -> m (ParserInput m)
takeWhile ParserInput m -> Bool
predicate
                             if forall m. MonoidNull m => m -> Bool
Null.null ParserInput m
x then forall (m :: * -> *) a. Parsing m => String -> m a
unexpected String
"takeWhile1" else forall (f :: * -> *) a. Applicative f => a -> f a
pure ParserInput m
x


-- | Methods for parsing textual monoid inputs
class (CharParsing m, InputParsing m) => InputCharParsing m where
   -- | Specialization of 'satisfy' on textual inputs, accepting an input character only if it satisfies the given
   -- predicate, and returning the input atom that represents the character. Equivalent to @fmap singleton
   -- . Char.satisfy@
   satisfyCharInput :: (Char -> Bool) -> m (ParserInput m)
   -- | A parser that succeeds exactly when satisfy doesn't, equivalent to @notFollowedBy . Char.satisfy@
   notSatisfyChar :: (Char -> Bool) -> m ()

   -- | Stateful scanner like `scan`, but specialized for 'TextualMonoid' inputs.
   scanChars :: state -> (state -> Char -> Maybe state) -> m (ParserInput m)

   -- | Specialization of 'takeWhile' on 'TextualMonoid' inputs, accepting the longest sequence of input characters that
   -- match the given predicate; an optimized version of @fmap fromString  . many . Char.satisfy@.
   --
   -- /Note/: Because this parser does not fail, do not use it with combinators such as 'Control.Applicative.many',
   -- because such parsers loop until a failure occurs.  Careless use will thus result in an infinite loop.
   takeCharsWhile :: (Char -> Bool) -> m (ParserInput m)
   -- | Specialization of 'takeWhile1' on 'TextualMonoid' inputs, accepting the longest sequence of input characters
   -- that match the given predicate; an optimized version of @fmap fromString  . some . Char.satisfy@.
   takeCharsWhile1 :: (Char -> Bool) -> m (ParserInput m)

   notSatisfyChar = forall (m :: * -> *) a. (Parsing m, Show a) => m a -> m ()
notFollowedBy forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *). CharParsing m => (Char -> Bool) -> m Char
Char.satisfy
   default scanChars :: (Monad m, TextualMonoid (ParserInput m)) =>
                        state -> (state -> Char -> Maybe state) -> m (ParserInput m)
   scanChars state
state state -> Char -> Maybe state
f = do ParserInput m
i <- forall (m :: * -> *). InputParsing m => m (ParserInput m)
getInput
                          let (ParserInput m
prefix, ParserInput m
_suffix, state
_state) = forall t s.
TextualMonoid t =>
s
-> (s -> t -> Maybe s) -> (s -> Char -> Maybe s) -> t -> (t, t, s)
Textual.spanMaybe' state
state (forall a b. a -> b -> a
const forall a b. (a -> b) -> a -> b
$ forall a b. a -> b -> a
const forall a. Maybe a
Nothing) state -> Char -> Maybe state
f ParserInput m
i
                          forall (m :: * -> *). InputParsing m => Int -> m (ParserInput m)
take (forall m. Factorial m => m -> Int
Factorial.length ParserInput m
prefix)
   default takeCharsWhile :: (Monad m, TextualMonoid (ParserInput m)) => (Char -> Bool) -> m (ParserInput m)
   takeCharsWhile Char -> Bool
predicate = do ParserInput m
i <- forall (m :: * -> *). InputParsing m => m (ParserInput m)
getInput
                                 forall (m :: * -> *). InputParsing m => Int -> m (ParserInput m)
take (forall m. Factorial m => m -> Int
Factorial.length forall a b. (a -> b) -> a -> b
$ forall t. TextualMonoid t => Bool -> (Char -> Bool) -> t -> t
Textual.takeWhile_ Bool
False Char -> Bool
predicate ParserInput m
i)
   default takeCharsWhile1 :: (Monad m, TextualMonoid (ParserInput m)) => (Char -> Bool) -> m (ParserInput m)
   takeCharsWhile1 Char -> Bool
predicate = do ParserInput m
x <- forall (m :: * -> *).
InputCharParsing m =>
(Char -> Bool) -> m (ParserInput m)
takeCharsWhile Char -> Bool
predicate
                                  if forall m. MonoidNull m => m -> Bool
Null.null ParserInput m
x then forall (m :: * -> *) a. Parsing m => String -> m a
unexpected String
"takeCharsWhile1" else forall (f :: * -> *) a. Applicative f => a -> f a
pure ParserInput m
x

-- | Parsers that keep track of the consumed input.
class InputParsing m => ConsumedInputParsing m where
   -- | Return both the result of a parse and the portion of the input that the argument parser consumed.
   match :: m a -> m (ParserInput m, a)

instance InputParsing ReadP where
   type ParserInput ReadP = String
   getInput :: ReadP (ParserInput ReadP)
getInput = ReadP String
ReadP.look
   take :: Int -> ReadP (ParserInput ReadP)
take Int
n = forall (m :: * -> *) a. Applicative m => Int -> m a -> m [a]
count Int
n ReadP Char
ReadP.get
   anyToken :: ReadP (ParserInput ReadP)
anyToken = forall (f :: * -> *) a. Applicative f => a -> f a
pure forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ReadP Char
ReadP.get
   satisfy :: (ParserInput ReadP -> Bool) -> ReadP (ParserInput ReadP)
satisfy ParserInput ReadP -> Bool
predicate = forall (f :: * -> *) a. Applicative f => a -> f a
pure forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Char -> Bool) -> ReadP Char
ReadP.satisfy (ParserInput ReadP -> Bool
predicate forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (f :: * -> *) a. Applicative f => a -> f a
pure)
   string :: ParserInput ReadP -> ReadP (ParserInput ReadP)
string = String -> ReadP String
ReadP.string

instance InputCharParsing ReadP where
   satisfyCharInput :: (Char -> Bool) -> ReadP (ParserInput ReadP)
satisfyCharInput Char -> Bool
predicate = forall (f :: * -> *) a. Applicative f => a -> f a
pure forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Char -> Bool) -> ReadP Char
ReadP.satisfy Char -> Bool
predicate

instance ConsumedInputParsing ReadP where
   match :: forall a. ReadP a -> ReadP (ParserInput ReadP, a)
match = forall a. ReadP a -> ReadP (String, a)
ReadP.gather

instance (Monad m, InputParsing m) => InputParsing (IdentityT m) where
   type ParserInput (IdentityT m) = ParserInput m
   type ParserPosition (IdentityT m) = ParserPosition m
   getInput :: IdentityT m (ParserInput (IdentityT m))
getInput = forall {k} (f :: k -> *) (a :: k). f a -> IdentityT f a
IdentityT forall (m :: * -> *). InputParsing m => m (ParserInput m)
getInput
   getSourcePos :: IdentityT m (ParserPosition (IdentityT m))
getSourcePos = forall {k} (f :: k -> *) (a :: k). f a -> IdentityT f a
IdentityT forall (m :: * -> *). InputParsing m => m (ParserPosition m)
getSourcePos
   anyToken :: IdentityT m (ParserInput (IdentityT m))
anyToken = forall {k} (f :: k -> *) (a :: k). f a -> IdentityT f a
IdentityT forall (m :: * -> *). InputParsing m => m (ParserInput m)
anyToken
   take :: Int -> IdentityT m (ParserInput (IdentityT m))
take = forall {k} (f :: k -> *) (a :: k). f a -> IdentityT f a
IdentityT forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *). InputParsing m => Int -> m (ParserInput m)
take
   satisfy :: (ParserInput (IdentityT m) -> Bool)
-> IdentityT m (ParserInput (IdentityT m))
satisfy = forall {k} (f :: k -> *) (a :: k). f a -> IdentityT f a
IdentityT forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *).
InputParsing m =>
(ParserInput m -> Bool) -> m (ParserInput m)
satisfy
   notSatisfy :: (ParserInput (IdentityT m) -> Bool) -> IdentityT m ()
notSatisfy = forall {k} (f :: k -> *) (a :: k). f a -> IdentityT f a
IdentityT forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *).
InputParsing m =>
(ParserInput m -> Bool) -> m ()
notSatisfy
   scan :: forall state.
state
-> (state -> ParserInput (IdentityT m) -> Maybe state)
-> IdentityT m (ParserInput (IdentityT m))
scan state
state state -> ParserInput (IdentityT m) -> Maybe state
f = forall {k} (f :: k -> *) (a :: k). f a -> IdentityT f a
IdentityT (forall (m :: * -> *) state.
InputParsing m =>
state
-> (state -> ParserInput m -> Maybe state) -> m (ParserInput m)
scan state
state state -> ParserInput (IdentityT m) -> Maybe state
f)
   string :: ParserInput (IdentityT m)
-> IdentityT m (ParserInput (IdentityT m))
string = forall {k} (f :: k -> *) (a :: k). f a -> IdentityT f a
IdentityT forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *).
InputParsing m =>
ParserInput m -> m (ParserInput m)
string
   takeWhile :: (ParserInput (IdentityT m) -> Bool)
-> IdentityT m (ParserInput (IdentityT m))
takeWhile = forall {k} (f :: k -> *) (a :: k). f a -> IdentityT f a
IdentityT forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *).
InputParsing m =>
(ParserInput m -> Bool) -> m (ParserInput m)
takeWhile
   takeWhile1 :: (ParserInput (IdentityT m) -> Bool)
-> IdentityT m (ParserInput (IdentityT m))
takeWhile1 = forall {k} (f :: k -> *) (a :: k). f a -> IdentityT f a
IdentityT forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *).
InputParsing m =>
(ParserInput m -> Bool) -> m (ParserInput m)
takeWhile1

instance (MonadPlus m, InputCharParsing m) => InputCharParsing (IdentityT m) where
   satisfyCharInput :: (Char -> Bool) -> IdentityT m (ParserInput (IdentityT m))
satisfyCharInput = forall {k} (f :: k -> *) (a :: k). f a -> IdentityT f a
IdentityT forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *).
InputCharParsing m =>
(Char -> Bool) -> m (ParserInput m)
satisfyCharInput
   notSatisfyChar :: (Char -> Bool) -> IdentityT m ()
notSatisfyChar = forall {k} (f :: k -> *) (a :: k). f a -> IdentityT f a
IdentityT forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *). InputCharParsing m => (Char -> Bool) -> m ()
notSatisfyChar
   scanChars :: forall state.
state
-> (state -> Char -> Maybe state)
-> IdentityT m (ParserInput (IdentityT m))
scanChars state
state state -> Char -> Maybe state
f = forall {k} (f :: k -> *) (a :: k). f a -> IdentityT f a
IdentityT (forall (m :: * -> *) state.
InputCharParsing m =>
state -> (state -> Char -> Maybe state) -> m (ParserInput m)
scanChars state
state state -> Char -> Maybe state
f)
   takeCharsWhile :: (Char -> Bool) -> IdentityT m (ParserInput (IdentityT m))
takeCharsWhile = forall {k} (f :: k -> *) (a :: k). f a -> IdentityT f a
IdentityT forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *).
InputCharParsing m =>
(Char -> Bool) -> m (ParserInput m)
takeCharsWhile
   takeCharsWhile1 :: (Char -> Bool) -> IdentityT m (ParserInput (IdentityT m))
takeCharsWhile1 = forall {k} (f :: k -> *) (a :: k). f a -> IdentityT f a
IdentityT forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *).
InputCharParsing m =>
(Char -> Bool) -> m (ParserInput m)
takeCharsWhile1

instance (Monad m, ConsumedInputParsing m) => ConsumedInputParsing (IdentityT m) where
  match :: forall a.
IdentityT m a -> IdentityT m (ParserInput (IdentityT m), a)
match (IdentityT m a
p) = forall {k} (f :: k -> *) (a :: k). f a -> IdentityT f a
IdentityT (forall (m :: * -> *) a.
ConsumedInputParsing m =>
m a -> m (ParserInput m, a)
match m a
p)

instance (MonadPlus m, InputParsing m) => InputParsing (ReaderT e m) where
   type ParserInput (ReaderT e m) = ParserInput m
   type ParserPosition (ReaderT e m) = ParserPosition m
   getInput :: ReaderT e m (ParserInput (ReaderT e m))
getInput = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall (m :: * -> *). InputParsing m => m (ParserInput m)
getInput
   getSourcePos :: ReaderT e m (ParserPosition (ReaderT e m))
getSourcePos = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall (m :: * -> *). InputParsing m => m (ParserPosition m)
getSourcePos
   anyToken :: ReaderT e m (ParserInput (ReaderT e m))
anyToken = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall (m :: * -> *). InputParsing m => m (ParserInput m)
anyToken
   take :: Int -> ReaderT e m (ParserInput (ReaderT e m))
take = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *). InputParsing m => Int -> m (ParserInput m)
take
   satisfy :: (ParserInput (ReaderT e m) -> Bool)
-> ReaderT e m (ParserInput (ReaderT e m))
satisfy = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *).
InputParsing m =>
(ParserInput m -> Bool) -> m (ParserInput m)
satisfy
   notSatisfy :: (ParserInput (ReaderT e m) -> Bool) -> ReaderT e m ()
notSatisfy = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *).
InputParsing m =>
(ParserInput m -> Bool) -> m ()
notSatisfy
   scan :: forall state.
state
-> (state -> ParserInput (ReaderT e m) -> Maybe state)
-> ReaderT e m (ParserInput (ReaderT e m))
scan state
state state -> ParserInput (ReaderT e m) -> Maybe state
f = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (forall (m :: * -> *) state.
InputParsing m =>
state
-> (state -> ParserInput m -> Maybe state) -> m (ParserInput m)
scan state
state state -> ParserInput (ReaderT e m) -> Maybe state
f)
   string :: ParserInput (ReaderT e m)
-> ReaderT e m (ParserInput (ReaderT e m))
string = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *).
InputParsing m =>
ParserInput m -> m (ParserInput m)
string
   takeWhile :: (ParserInput (ReaderT e m) -> Bool)
-> ReaderT e m (ParserInput (ReaderT e m))
takeWhile = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *).
InputParsing m =>
(ParserInput m -> Bool) -> m (ParserInput m)
takeWhile
   takeWhile1 :: (ParserInput (ReaderT e m) -> Bool)
-> ReaderT e m (ParserInput (ReaderT e m))
takeWhile1 = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *).
InputParsing m =>
(ParserInput m -> Bool) -> m (ParserInput m)
takeWhile1

instance (MonadPlus m, InputCharParsing m) => InputCharParsing (ReaderT e m) where
   satisfyCharInput :: (Char -> Bool) -> ReaderT e m (ParserInput (ReaderT e m))
satisfyCharInput = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *).
InputCharParsing m =>
(Char -> Bool) -> m (ParserInput m)
satisfyCharInput
   notSatisfyChar :: (Char -> Bool) -> ReaderT e m ()
notSatisfyChar = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *). InputCharParsing m => (Char -> Bool) -> m ()
notSatisfyChar
   scanChars :: forall state.
state
-> (state -> Char -> Maybe state)
-> ReaderT e m (ParserInput (ReaderT e m))
scanChars state
state state -> Char -> Maybe state
f = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (forall (m :: * -> *) state.
InputCharParsing m =>
state -> (state -> Char -> Maybe state) -> m (ParserInput m)
scanChars state
state state -> Char -> Maybe state
f)
   takeCharsWhile :: (Char -> Bool) -> ReaderT e m (ParserInput (ReaderT e m))
takeCharsWhile = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *).
InputCharParsing m =>
(Char -> Bool) -> m (ParserInput m)
takeCharsWhile
   takeCharsWhile1 :: (Char -> Bool) -> ReaderT e m (ParserInput (ReaderT e m))
takeCharsWhile1 = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *).
InputCharParsing m =>
(Char -> Bool) -> m (ParserInput m)
takeCharsWhile1

instance (MonadPlus m, ConsumedInputParsing m) => ConsumedInputParsing (ReaderT e m) where
  match :: forall a.
ReaderT e m a -> ReaderT e m (ParserInput (ReaderT e m), a)
match = forall (m :: * -> *) a (n :: * -> *) b r.
(m a -> n b) -> ReaderT r m a -> ReaderT r n b
mapReaderT forall (m :: * -> *) a.
ConsumedInputParsing m =>
m a -> m (ParserInput m, a)
match

instance (MonadPlus m, InputParsing m, Monoid w) => InputParsing (Lazy.WriterT w m) where
   type ParserInput (Lazy.WriterT w m) = ParserInput m
   type ParserPosition (Lazy.WriterT w m) = ParserPosition m
   getInput :: WriterT w m (ParserInput (WriterT w m))
getInput = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall (m :: * -> *). InputParsing m => m (ParserInput m)
getInput
   getSourcePos :: WriterT w m (ParserPosition (WriterT w m))
getSourcePos = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall (m :: * -> *). InputParsing m => m (ParserPosition m)
getSourcePos
   anyToken :: WriterT w m (ParserInput (WriterT w m))
anyToken = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall (m :: * -> *). InputParsing m => m (ParserInput m)
anyToken
   take :: Int -> WriterT w m (ParserInput (WriterT w m))
take = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *). InputParsing m => Int -> m (ParserInput m)
take
   satisfy :: (ParserInput (WriterT w m) -> Bool)
-> WriterT w m (ParserInput (WriterT w m))
satisfy = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *).
InputParsing m =>
(ParserInput m -> Bool) -> m (ParserInput m)
satisfy
   notSatisfy :: (ParserInput (WriterT w m) -> Bool) -> WriterT w m ()
notSatisfy = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *).
InputParsing m =>
(ParserInput m -> Bool) -> m ()
notSatisfy
   scan :: forall state.
state
-> (state -> ParserInput (WriterT w m) -> Maybe state)
-> WriterT w m (ParserInput (WriterT w m))
scan state
state state -> ParserInput (WriterT w m) -> Maybe state
f = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (forall (m :: * -> *) state.
InputParsing m =>
state
-> (state -> ParserInput m -> Maybe state) -> m (ParserInput m)
scan state
state state -> ParserInput (WriterT w m) -> Maybe state
f)
   string :: ParserInput (WriterT w m)
-> WriterT w m (ParserInput (WriterT w m))
string = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *).
InputParsing m =>
ParserInput m -> m (ParserInput m)
string
   takeWhile :: (ParserInput (WriterT w m) -> Bool)
-> WriterT w m (ParserInput (WriterT w m))
takeWhile = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *).
InputParsing m =>
(ParserInput m -> Bool) -> m (ParserInput m)
takeWhile
   takeWhile1 :: (ParserInput (WriterT w m) -> Bool)
-> WriterT w m (ParserInput (WriterT w m))
takeWhile1 = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *).
InputParsing m =>
(ParserInput m -> Bool) -> m (ParserInput m)
takeWhile1

instance (MonadPlus m, InputCharParsing m, Monoid w) => InputCharParsing (Lazy.WriterT w m) where
   satisfyCharInput :: (Char -> Bool) -> WriterT w m (ParserInput (WriterT w m))
satisfyCharInput = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *).
InputCharParsing m =>
(Char -> Bool) -> m (ParserInput m)
satisfyCharInput
   notSatisfyChar :: (Char -> Bool) -> WriterT w m ()
notSatisfyChar = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *). InputCharParsing m => (Char -> Bool) -> m ()
notSatisfyChar
   scanChars :: forall state.
state
-> (state -> Char -> Maybe state)
-> WriterT w m (ParserInput (WriterT w m))
scanChars state
state state -> Char -> Maybe state
f = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (forall (m :: * -> *) state.
InputCharParsing m =>
state -> (state -> Char -> Maybe state) -> m (ParserInput m)
scanChars state
state state -> Char -> Maybe state
f)
   takeCharsWhile :: (Char -> Bool) -> WriterT w m (ParserInput (WriterT w m))
takeCharsWhile = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *).
InputCharParsing m =>
(Char -> Bool) -> m (ParserInput m)
takeCharsWhile
   takeCharsWhile1 :: (Char -> Bool) -> WriterT w m (ParserInput (WriterT w m))
takeCharsWhile1 = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *).
InputCharParsing m =>
(Char -> Bool) -> m (ParserInput m)
takeCharsWhile1

instance (MonadPlus m, ConsumedInputParsing m, Monoid w) => ConsumedInputParsing (Lazy.WriterT w m) where
  match :: forall a.
WriterT w m a -> WriterT w m (ParserInput (WriterT w m), a)
match = forall (m :: * -> *) a b w.
Applicative m =>
(m a -> m b) -> WriterT w m a -> WriterT w m b
mapLazyWriterT forall (m :: * -> *) a.
ConsumedInputParsing m =>
m a -> m (ParserInput m, a)
match

instance (MonadPlus m, InputParsing m, Monoid w) => InputParsing (Strict.WriterT w m) where
   type ParserInput (Strict.WriterT w m) = ParserInput m
   type ParserPosition (Strict.WriterT w m) = ParserPosition m
   getInput :: WriterT w m (ParserInput (WriterT w m))
getInput = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall (m :: * -> *). InputParsing m => m (ParserInput m)
getInput
   getSourcePos :: WriterT w m (ParserPosition (WriterT w m))
getSourcePos = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall (m :: * -> *). InputParsing m => m (ParserPosition m)
getSourcePos
   anyToken :: WriterT w m (ParserInput (WriterT w m))
anyToken = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall (m :: * -> *). InputParsing m => m (ParserInput m)
anyToken
   take :: Int -> WriterT w m (ParserInput (WriterT w m))
take = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *). InputParsing m => Int -> m (ParserInput m)
take
   satisfy :: (ParserInput (WriterT w m) -> Bool)
-> WriterT w m (ParserInput (WriterT w m))
satisfy = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *).
InputParsing m =>
(ParserInput m -> Bool) -> m (ParserInput m)
satisfy
   notSatisfy :: (ParserInput (WriterT w m) -> Bool) -> WriterT w m ()
notSatisfy = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *).
InputParsing m =>
(ParserInput m -> Bool) -> m ()
notSatisfy
   scan :: forall state.
state
-> (state -> ParserInput (WriterT w m) -> Maybe state)
-> WriterT w m (ParserInput (WriterT w m))
scan state
state state -> ParserInput (WriterT w m) -> Maybe state
f = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (forall (m :: * -> *) state.
InputParsing m =>
state
-> (state -> ParserInput m -> Maybe state) -> m (ParserInput m)
scan state
state state -> ParserInput (WriterT w m) -> Maybe state
f)
   string :: ParserInput (WriterT w m)
-> WriterT w m (ParserInput (WriterT w m))
string = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *).
InputParsing m =>
ParserInput m -> m (ParserInput m)
string
   takeWhile :: (ParserInput (WriterT w m) -> Bool)
-> WriterT w m (ParserInput (WriterT w m))
takeWhile = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *).
InputParsing m =>
(ParserInput m -> Bool) -> m (ParserInput m)
takeWhile
   takeWhile1 :: (ParserInput (WriterT w m) -> Bool)
-> WriterT w m (ParserInput (WriterT w m))
takeWhile1 = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *).
InputParsing m =>
(ParserInput m -> Bool) -> m (ParserInput m)
takeWhile1

instance (MonadPlus m, InputCharParsing m, Monoid w) => InputCharParsing (Strict.WriterT w m) where
   satisfyCharInput :: (Char -> Bool) -> WriterT w m (ParserInput (WriterT w m))
satisfyCharInput = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *).
InputCharParsing m =>
(Char -> Bool) -> m (ParserInput m)
satisfyCharInput
   notSatisfyChar :: (Char -> Bool) -> WriterT w m ()
notSatisfyChar = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *). InputCharParsing m => (Char -> Bool) -> m ()
notSatisfyChar
   scanChars :: forall state.
state
-> (state -> Char -> Maybe state)
-> WriterT w m (ParserInput (WriterT w m))
scanChars state
state state -> Char -> Maybe state
f = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (forall (m :: * -> *) state.
InputCharParsing m =>
state -> (state -> Char -> Maybe state) -> m (ParserInput m)
scanChars state
state state -> Char -> Maybe state
f)
   takeCharsWhile :: (Char -> Bool) -> WriterT w m (ParserInput (WriterT w m))
takeCharsWhile = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *).
InputCharParsing m =>
(Char -> Bool) -> m (ParserInput m)
takeCharsWhile
   takeCharsWhile1 :: (Char -> Bool) -> WriterT w m (ParserInput (WriterT w m))
takeCharsWhile1 = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *).
InputCharParsing m =>
(Char -> Bool) -> m (ParserInput m)
takeCharsWhile1

instance (MonadPlus m, ConsumedInputParsing m, Monoid w) => ConsumedInputParsing (Strict.WriterT w m) where
  match :: forall a.
WriterT w m a -> WriterT w m (ParserInput (WriterT w m), a)
match = forall (m :: * -> *) a b w.
Applicative m =>
(m a -> m b) -> WriterT w m a -> WriterT w m b
mapStrictWriterT forall (m :: * -> *) a.
ConsumedInputParsing m =>
m a -> m (ParserInput m, a)
match

instance (MonadPlus m, InputParsing m) => InputParsing (Lazy.StateT s m) where
   type ParserInput (Lazy.StateT s m) = ParserInput m
   type ParserPosition (Lazy.StateT s m) = ParserPosition m
   getInput :: StateT s m (ParserInput (StateT s m))
getInput = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall (m :: * -> *). InputParsing m => m (ParserInput m)
getInput
   getSourcePos :: StateT s m (ParserPosition (StateT s m))
getSourcePos = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall (m :: * -> *). InputParsing m => m (ParserPosition m)
getSourcePos
   anyToken :: StateT s m (ParserInput (StateT s m))
anyToken = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall (m :: * -> *). InputParsing m => m (ParserInput m)
anyToken
   take :: Int -> StateT s m (ParserInput (StateT s m))
take = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *). InputParsing m => Int -> m (ParserInput m)
take
   satisfy :: (ParserInput (StateT s m) -> Bool)
-> StateT s m (ParserInput (StateT s m))
satisfy = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *).
InputParsing m =>
(ParserInput m -> Bool) -> m (ParserInput m)
satisfy
   notSatisfy :: (ParserInput (StateT s m) -> Bool) -> StateT s m ()
notSatisfy = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *).
InputParsing m =>
(ParserInput m -> Bool) -> m ()
notSatisfy
   scan :: forall state.
state
-> (state -> ParserInput (StateT s m) -> Maybe state)
-> StateT s m (ParserInput (StateT s m))
scan state
state state -> ParserInput (StateT s m) -> Maybe state
f = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (forall (m :: * -> *) state.
InputParsing m =>
state
-> (state -> ParserInput m -> Maybe state) -> m (ParserInput m)
scan state
state state -> ParserInput (StateT s m) -> Maybe state
f)
   string :: ParserInput (StateT s m) -> StateT s m (ParserInput (StateT s m))
string = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *).
InputParsing m =>
ParserInput m -> m (ParserInput m)
string
   takeWhile :: (ParserInput (StateT s m) -> Bool)
-> StateT s m (ParserInput (StateT s m))
takeWhile = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *).
InputParsing m =>
(ParserInput m -> Bool) -> m (ParserInput m)
takeWhile
   takeWhile1 :: (ParserInput (StateT s m) -> Bool)
-> StateT s m (ParserInput (StateT s m))
takeWhile1 = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *).
InputParsing m =>
(ParserInput m -> Bool) -> m (ParserInput m)
takeWhile1

instance (MonadPlus m, InputCharParsing m) => InputCharParsing (Lazy.StateT s m) where
   satisfyCharInput :: (Char -> Bool) -> StateT s m (ParserInput (StateT s m))
satisfyCharInput = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *).
InputCharParsing m =>
(Char -> Bool) -> m (ParserInput m)
satisfyCharInput
   notSatisfyChar :: (Char -> Bool) -> StateT s m ()
notSatisfyChar = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *). InputCharParsing m => (Char -> Bool) -> m ()
notSatisfyChar
   scanChars :: forall state.
state
-> (state -> Char -> Maybe state)
-> StateT s m (ParserInput (StateT s m))
scanChars state
state state -> Char -> Maybe state
f = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (forall (m :: * -> *) state.
InputCharParsing m =>
state -> (state -> Char -> Maybe state) -> m (ParserInput m)
scanChars state
state state -> Char -> Maybe state
f)
   takeCharsWhile :: (Char -> Bool) -> StateT s m (ParserInput (StateT s m))
takeCharsWhile = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *).
InputCharParsing m =>
(Char -> Bool) -> m (ParserInput m)
takeCharsWhile
   takeCharsWhile1 :: (Char -> Bool) -> StateT s m (ParserInput (StateT s m))
takeCharsWhile1 = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *).
InputCharParsing m =>
(Char -> Bool) -> m (ParserInput m)
takeCharsWhile1

instance (MonadPlus m, ConsumedInputParsing m) => ConsumedInputParsing (Lazy.StateT s m) where
  match :: forall a. StateT s m a -> StateT s m (ParserInput (StateT s m), a)
match = forall (m :: * -> *) a b w.
Applicative m =>
(m a -> m b) -> StateT w m a -> StateT w m b
mapLazyStateT forall (m :: * -> *) a.
ConsumedInputParsing m =>
m a -> m (ParserInput m, a)
match

instance (MonadPlus m, InputParsing m) => InputParsing (Strict.StateT s m) where
   type ParserInput (Strict.StateT s m) = ParserInput m
   type ParserPosition (Strict.StateT s m) = ParserPosition m
   getInput :: StateT s m (ParserInput (StateT s m))
getInput = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall (m :: * -> *). InputParsing m => m (ParserInput m)
getInput
   getSourcePos :: StateT s m (ParserPosition (StateT s m))
getSourcePos = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall (m :: * -> *). InputParsing m => m (ParserPosition m)
getSourcePos
   anyToken :: StateT s m (ParserInput (StateT s m))
anyToken = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall (m :: * -> *). InputParsing m => m (ParserInput m)
anyToken
   take :: Int -> StateT s m (ParserInput (StateT s m))
take = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *). InputParsing m => Int -> m (ParserInput m)
take
   satisfy :: (ParserInput (StateT s m) -> Bool)
-> StateT s m (ParserInput (StateT s m))
satisfy = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *).
InputParsing m =>
(ParserInput m -> Bool) -> m (ParserInput m)
satisfy
   notSatisfy :: (ParserInput (StateT s m) -> Bool) -> StateT s m ()
notSatisfy = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *).
InputParsing m =>
(ParserInput m -> Bool) -> m ()
notSatisfy
   scan :: forall state.
state
-> (state -> ParserInput (StateT s m) -> Maybe state)
-> StateT s m (ParserInput (StateT s m))
scan state
state state -> ParserInput (StateT s m) -> Maybe state
f = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (forall (m :: * -> *) state.
InputParsing m =>
state
-> (state -> ParserInput m -> Maybe state) -> m (ParserInput m)
scan state
state state -> ParserInput (StateT s m) -> Maybe state
f)
   string :: ParserInput (StateT s m) -> StateT s m (ParserInput (StateT s m))
string = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *).
InputParsing m =>
ParserInput m -> m (ParserInput m)
string
   takeWhile :: (ParserInput (StateT s m) -> Bool)
-> StateT s m (ParserInput (StateT s m))
takeWhile = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *).
InputParsing m =>
(ParserInput m -> Bool) -> m (ParserInput m)
takeWhile
   takeWhile1 :: (ParserInput (StateT s m) -> Bool)
-> StateT s m (ParserInput (StateT s m))
takeWhile1 = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *).
InputParsing m =>
(ParserInput m -> Bool) -> m (ParserInput m)
takeWhile1

instance (MonadPlus m, InputCharParsing m) => InputCharParsing (Strict.StateT s m) where
   satisfyCharInput :: (Char -> Bool) -> StateT s m (ParserInput (StateT s m))
satisfyCharInput = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *).
InputCharParsing m =>
(Char -> Bool) -> m (ParserInput m)
satisfyCharInput
   notSatisfyChar :: (Char -> Bool) -> StateT s m ()
notSatisfyChar = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *). InputCharParsing m => (Char -> Bool) -> m ()
notSatisfyChar
   scanChars :: forall state.
state
-> (state -> Char -> Maybe state)
-> StateT s m (ParserInput (StateT s m))
scanChars state
state state -> Char -> Maybe state
f = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (forall (m :: * -> *) state.
InputCharParsing m =>
state -> (state -> Char -> Maybe state) -> m (ParserInput m)
scanChars state
state state -> Char -> Maybe state
f)
   takeCharsWhile :: (Char -> Bool) -> StateT s m (ParserInput (StateT s m))
takeCharsWhile = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *).
InputCharParsing m =>
(Char -> Bool) -> m (ParserInput m)
takeCharsWhile
   takeCharsWhile1 :: (Char -> Bool) -> StateT s m (ParserInput (StateT s m))
takeCharsWhile1 = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *).
InputCharParsing m =>
(Char -> Bool) -> m (ParserInput m)
takeCharsWhile1

instance (MonadPlus m, ConsumedInputParsing m) => ConsumedInputParsing (Strict.StateT s m) where
  match :: forall a. StateT s m a -> StateT s m (ParserInput (StateT s m), a)
match = forall (m :: * -> *) a b s.
Applicative m =>
(m a -> m b) -> StateT s m a -> StateT s m b
mapStrictStateT forall (m :: * -> *) a.
ConsumedInputParsing m =>
m a -> m (ParserInput m, a)
match

instance (MonadPlus m, InputParsing m, Monoid w) => InputParsing (Lazy.RWST r w s m) where
   type ParserInput (Lazy.RWST r w s m) = ParserInput m
   type ParserPosition (Lazy.RWST r w s m) = ParserPosition m
   getInput :: RWST r w s m (ParserInput (RWST r w s m))
getInput = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall (m :: * -> *). InputParsing m => m (ParserInput m)
getInput
   getSourcePos :: RWST r w s m (ParserPosition (RWST r w s m))
getSourcePos = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall (m :: * -> *). InputParsing m => m (ParserPosition m)
getSourcePos
   anyToken :: RWST r w s m (ParserInput (RWST r w s m))
anyToken = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall (m :: * -> *). InputParsing m => m (ParserInput m)
anyToken
   take :: Int -> RWST r w s m (ParserInput (RWST r w s m))
take = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *). InputParsing m => Int -> m (ParserInput m)
take
   satisfy :: (ParserInput (RWST r w s m) -> Bool)
-> RWST r w s m (ParserInput (RWST r w s m))
satisfy = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *).
InputParsing m =>
(ParserInput m -> Bool) -> m (ParserInput m)
satisfy
   notSatisfy :: (ParserInput (RWST r w s m) -> Bool) -> RWST r w s m ()
notSatisfy = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *).
InputParsing m =>
(ParserInput m -> Bool) -> m ()
notSatisfy
   scan :: forall state.
state
-> (state -> ParserInput (RWST r w s m) -> Maybe state)
-> RWST r w s m (ParserInput (RWST r w s m))
scan state
state state -> ParserInput (RWST r w s m) -> Maybe state
f = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (forall (m :: * -> *) state.
InputParsing m =>
state
-> (state -> ParserInput m -> Maybe state) -> m (ParserInput m)
scan state
state state -> ParserInput (RWST r w s m) -> Maybe state
f)
   string :: ParserInput (RWST r w s m)
-> RWST r w s m (ParserInput (RWST r w s m))
string = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *).
InputParsing m =>
ParserInput m -> m (ParserInput m)
string
   takeWhile :: (ParserInput (RWST r w s m) -> Bool)
-> RWST r w s m (ParserInput (RWST r w s m))
takeWhile = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *).
InputParsing m =>
(ParserInput m -> Bool) -> m (ParserInput m)
takeWhile
   takeWhile1 :: (ParserInput (RWST r w s m) -> Bool)
-> RWST r w s m (ParserInput (RWST r w s m))
takeWhile1 = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *).
InputParsing m =>
(ParserInput m -> Bool) -> m (ParserInput m)
takeWhile1

instance (MonadPlus m, InputCharParsing m, Monoid w) => InputCharParsing (Lazy.RWST r w s m) where
   satisfyCharInput :: (Char -> Bool) -> RWST r w s m (ParserInput (RWST r w s m))
satisfyCharInput = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *).
InputCharParsing m =>
(Char -> Bool) -> m (ParserInput m)
satisfyCharInput
   notSatisfyChar :: (Char -> Bool) -> RWST r w s m ()
notSatisfyChar = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *). InputCharParsing m => (Char -> Bool) -> m ()
notSatisfyChar
   scanChars :: forall state.
state
-> (state -> Char -> Maybe state)
-> RWST r w s m (ParserInput (RWST r w s m))
scanChars state
state state -> Char -> Maybe state
f = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (forall (m :: * -> *) state.
InputCharParsing m =>
state -> (state -> Char -> Maybe state) -> m (ParserInput m)
scanChars state
state state -> Char -> Maybe state
f)
   takeCharsWhile :: (Char -> Bool) -> RWST r w s m (ParserInput (RWST r w s m))
takeCharsWhile = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *).
InputCharParsing m =>
(Char -> Bool) -> m (ParserInput m)
takeCharsWhile
   takeCharsWhile1 :: (Char -> Bool) -> RWST r w s m (ParserInput (RWST r w s m))
takeCharsWhile1 = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *).
InputCharParsing m =>
(Char -> Bool) -> m (ParserInput m)
takeCharsWhile1

instance (MonadPlus m, ConsumedInputParsing m, Monoid w) => ConsumedInputParsing (Lazy.RWST r w s m) where
  match :: forall a.
RWST r w s m a -> RWST r w s m (ParserInput (RWST r w s m), a)
match = forall (m :: * -> *) a b r w s.
Applicative m =>
(m a -> m b) -> RWST r w s m a -> RWST r w s m b
mapLazyRWST forall (m :: * -> *) a.
ConsumedInputParsing m =>
m a -> m (ParserInput m, a)
match

instance (MonadPlus m, InputParsing m, Monoid w) => InputParsing (Strict.RWST r w s m) where
   type ParserInput (Strict.RWST r w s m) = ParserInput m
   type ParserPosition (Strict.RWST r w s m) = ParserPosition m
   getInput :: RWST r w s m (ParserInput (RWST r w s m))
getInput = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall (m :: * -> *). InputParsing m => m (ParserInput m)
getInput
   getSourcePos :: RWST r w s m (ParserPosition (RWST r w s m))
getSourcePos = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall (m :: * -> *). InputParsing m => m (ParserPosition m)
getSourcePos
   anyToken :: RWST r w s m (ParserInput (RWST r w s m))
anyToken = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall (m :: * -> *). InputParsing m => m (ParserInput m)
anyToken
   take :: Int -> RWST r w s m (ParserInput (RWST r w s m))
take = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *). InputParsing m => Int -> m (ParserInput m)
take
   satisfy :: (ParserInput (RWST r w s m) -> Bool)
-> RWST r w s m (ParserInput (RWST r w s m))
satisfy = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *).
InputParsing m =>
(ParserInput m -> Bool) -> m (ParserInput m)
satisfy
   notSatisfy :: (ParserInput (RWST r w s m) -> Bool) -> RWST r w s m ()
notSatisfy = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *).
InputParsing m =>
(ParserInput m -> Bool) -> m ()
notSatisfy
   scan :: forall state.
state
-> (state -> ParserInput (RWST r w s m) -> Maybe state)
-> RWST r w s m (ParserInput (RWST r w s m))
scan state
state state -> ParserInput (RWST r w s m) -> Maybe state
f = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (forall (m :: * -> *) state.
InputParsing m =>
state
-> (state -> ParserInput m -> Maybe state) -> m (ParserInput m)
scan state
state state -> ParserInput (RWST r w s m) -> Maybe state
f)
   string :: ParserInput (RWST r w s m)
-> RWST r w s m (ParserInput (RWST r w s m))
string = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *).
InputParsing m =>
ParserInput m -> m (ParserInput m)
string
   takeWhile :: (ParserInput (RWST r w s m) -> Bool)
-> RWST r w s m (ParserInput (RWST r w s m))
takeWhile = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *).
InputParsing m =>
(ParserInput m -> Bool) -> m (ParserInput m)
takeWhile
   takeWhile1 :: (ParserInput (RWST r w s m) -> Bool)
-> RWST r w s m (ParserInput (RWST r w s m))
takeWhile1 = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *).
InputParsing m =>
(ParserInput m -> Bool) -> m (ParserInput m)
takeWhile1

instance (MonadPlus m, InputCharParsing m, Monoid w) => InputCharParsing (Strict.RWST r w s m) where
   satisfyCharInput :: (Char -> Bool) -> RWST r w s m (ParserInput (RWST r w s m))
satisfyCharInput = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *).
InputCharParsing m =>
(Char -> Bool) -> m (ParserInput m)
satisfyCharInput
   notSatisfyChar :: (Char -> Bool) -> RWST r w s m ()
notSatisfyChar = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *). InputCharParsing m => (Char -> Bool) -> m ()
notSatisfyChar
   scanChars :: forall state.
state
-> (state -> Char -> Maybe state)
-> RWST r w s m (ParserInput (RWST r w s m))
scanChars state
state state -> Char -> Maybe state
f = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (forall (m :: * -> *) state.
InputCharParsing m =>
state -> (state -> Char -> Maybe state) -> m (ParserInput m)
scanChars state
state state -> Char -> Maybe state
f)
   takeCharsWhile :: (Char -> Bool) -> RWST r w s m (ParserInput (RWST r w s m))
takeCharsWhile = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *).
InputCharParsing m =>
(Char -> Bool) -> m (ParserInput m)
takeCharsWhile
   takeCharsWhile1 :: (Char -> Bool) -> RWST r w s m (ParserInput (RWST r w s m))
takeCharsWhile1 = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *).
InputCharParsing m =>
(Char -> Bool) -> m (ParserInput m)
takeCharsWhile1

instance (MonadPlus m, ConsumedInputParsing m, Monoid w) => ConsumedInputParsing (Strict.RWST r w s m) where
  match :: forall a.
RWST r w s m a -> RWST r w s m (ParserInput (RWST r w s m), a)
match = forall (m :: * -> *) a b r w s.
Applicative m =>
(m a -> m b) -> RWST r w s m a -> RWST r w s m b
mapStrictRWST forall (m :: * -> *) a.
ConsumedInputParsing m =>
m a -> m (ParserInput m, a)
match

#ifdef MIN_VERSION_attoparsec
instance InputParsing Attoparsec.Parser where
   type ParserInput Attoparsec.Parser = ByteString
   getInput :: Parser (ParserInput Parser)
getInput = forall (m :: * -> *) a. LookAheadParsing m => m a -> m a
lookAhead Parser ByteString
Attoparsec.takeByteString
   anyToken :: Parser (ParserInput Parser)
anyToken = Int -> Parser ByteString
Attoparsec.take Int
1
   take :: Int -> Parser (ParserInput Parser)
take = Int -> Parser ByteString
Attoparsec.take
   satisfy :: (ParserInput Parser -> Bool) -> Parser (ParserInput Parser)
satisfy ParserInput Parser -> Bool
predicate = forall a. (Word8 -> a) -> (a -> Bool) -> Parser a
Attoparsec.satisfyWith Word8 -> ByteString
ByteString.singleton ParserInput Parser -> Bool
predicate
   string :: ParserInput Parser -> Parser (ParserInput Parser)
string = ByteString -> Parser ByteString
Attoparsec.string
   takeWhile :: (ParserInput Parser -> Bool) -> Parser (ParserInput Parser)
takeWhile ParserInput Parser -> Bool
predicate = (Word8 -> Bool) -> Parser ByteString
Attoparsec.takeWhile (ParserInput Parser -> Bool
predicate forall b c a. (b -> c) -> (a -> b) -> a -> c
. Word8 -> ByteString
ByteString.singleton)
   takeWhile1 :: (ParserInput Parser -> Bool) -> Parser (ParserInput Parser)
takeWhile1 ParserInput Parser -> Bool
predicate = (Word8 -> Bool) -> Parser ByteString
Attoparsec.takeWhile1 (ParserInput Parser -> Bool
predicate forall b c a. (b -> c) -> (a -> b) -> a -> c
. Word8 -> ByteString
ByteString.singleton)
   scan :: forall state.
state
-> (state -> ParserInput Parser -> Maybe state)
-> Parser (ParserInput Parser)
scan state
state state -> ParserInput Parser -> Maybe state
f = forall s. s -> (s -> Word8 -> Maybe s) -> Parser ByteString
Attoparsec.scan state
state state -> Word8 -> Maybe state
f'
      where f' :: state -> Word8 -> Maybe state
f' state
s Word8
byte = state -> ParserInput Parser -> Maybe state
f state
s (Word8 -> ByteString
ByteString.singleton Word8
byte)

instance InputCharParsing Attoparsec.Parser where
   satisfyCharInput :: (Char -> Bool) -> Parser (ParserInput Parser)
satisfyCharInput Char -> Bool
predicate = Char -> ByteString
ByteString.Char8.singleton forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Char -> Bool) -> Parser Char
Attoparsec.Char8.satisfy Char -> Bool
predicate
   scanChars :: forall state.
state
-> (state -> Char -> Maybe state) -> Parser (ParserInput Parser)
scanChars = forall s. s -> (s -> Char -> Maybe s) -> Parser ByteString
Attoparsec.Char8.scan
   takeCharsWhile :: (Char -> Bool) -> Parser (ParserInput Parser)
takeCharsWhile = (Char -> Bool) -> Parser ByteString
Attoparsec.Char8.takeWhile
   takeCharsWhile1 :: (Char -> Bool) -> Parser (ParserInput Parser)
takeCharsWhile1 = (Char -> Bool) -> Parser ByteString
Attoparsec.Char8.takeWhile1

instance ConsumedInputParsing Attoparsec.Parser where
   match :: forall a. Parser a -> Parser (ParserInput Parser, a)
match = forall a. Parser a -> Parser (ByteString, a)
Attoparsec.match

instance InputParsing Attoparsec.Text.Parser where
   type ParserInput Attoparsec.Text.Parser = Text
   getInput :: Parser (ParserInput Parser)
getInput = forall (m :: * -> *) a. LookAheadParsing m => m a -> m a
lookAhead Parser Text
Attoparsec.Text.takeText
   anyToken :: Parser (ParserInput Parser)
anyToken = Int -> Parser Text
Attoparsec.Text.take Int
1
   take :: Int -> Parser (ParserInput Parser)
take = Int -> Parser Text
Attoparsec.Text.take
   satisfy :: (ParserInput Parser -> Bool) -> Parser (ParserInput Parser)
satisfy ParserInput Parser -> Bool
predicate = forall a. (Char -> a) -> (a -> Bool) -> Parser a
Attoparsec.Text.satisfyWith Char -> Text
Text.singleton ParserInput Parser -> Bool
predicate
   string :: ParserInput Parser -> Parser (ParserInput Parser)
string = Text -> Parser Text
Attoparsec.Text.string
   takeWhile :: (ParserInput Parser -> Bool) -> Parser (ParserInput Parser)
takeWhile ParserInput Parser -> Bool
predicate = (Char -> Bool) -> Parser Text
Attoparsec.Text.takeWhile (ParserInput Parser -> Bool
predicate forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> Text
Text.singleton)
   takeWhile1 :: (ParserInput Parser -> Bool) -> Parser (ParserInput Parser)
takeWhile1 ParserInput Parser -> Bool
predicate = (Char -> Bool) -> Parser Text
Attoparsec.Text.takeWhile1 (ParserInput Parser -> Bool
predicate forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> Text
Text.singleton)
   scan :: forall state.
state
-> (state -> ParserInput Parser -> Maybe state)
-> Parser (ParserInput Parser)
scan state
state state -> ParserInput Parser -> Maybe state
f = forall s. s -> (s -> Char -> Maybe s) -> Parser Text
Attoparsec.Text.scan state
state state -> Char -> Maybe state
f'
      where f' :: state -> Char -> Maybe state
f' state
s Char
c = state -> ParserInput Parser -> Maybe state
f state
s (Char -> Text
Text.singleton Char
c)

instance InputCharParsing Attoparsec.Text.Parser where
   satisfyCharInput :: (Char -> Bool) -> Parser (ParserInput Parser)
satisfyCharInput Char -> Bool
predicate = Char -> Text
Text.singleton forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Char -> Bool) -> Parser Char
Attoparsec.Text.satisfy Char -> Bool
predicate
   scanChars :: forall state.
state
-> (state -> Char -> Maybe state) -> Parser (ParserInput Parser)
scanChars = forall s. s -> (s -> Char -> Maybe s) -> Parser Text
Attoparsec.Text.scan
   takeCharsWhile :: (Char -> Bool) -> Parser (ParserInput Parser)
takeCharsWhile = (Char -> Bool) -> Parser Text
Attoparsec.Text.takeWhile
   takeCharsWhile1 :: (Char -> Bool) -> Parser (ParserInput Parser)
takeCharsWhile1 = (Char -> Bool) -> Parser Text
Attoparsec.Text.takeWhile1

instance ConsumedInputParsing Attoparsec.Text.Parser where
   match :: forall a. Parser a -> Parser (ParserInput Parser, a)
match = forall a. Parser a -> Parser (Text, a)
Attoparsec.Text.match
#endif

#ifdef MIN_VERSION_parsec
instance (FactorialMonoid s, LeftReductive s, Show s, Parsec.Stream s m t, Show t) => InputParsing (ParsecT s u m) where
   type ParserInput (ParsecT s u m) = s
   getInput :: ParsecT s u m (ParserInput (ParsecT s u m))
getInput = forall (m :: * -> *) s u. Monad m => ParsecT s u m s
Parsec.getInput
   anyToken :: ParsecT s u m (ParserInput (ParsecT s u m))
anyToken = do s
rest <- forall (m :: * -> *) s u. Monad m => ParsecT s u m s
Parsec.getInput
                 case forall m. FactorialMonoid m => m -> Maybe (m, m)
Factorial.splitPrimePrefix s
rest
                   of Just (s
x, s
rest') -> s
x forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ forall (m :: * -> *) s u. Monad m => s -> ParsecT s u m ()
Parsec.setInput s
rest'
                      Maybe (s, s)
Nothing -> forall s u (m :: * -> *) a. String -> ParsecT s u m a
Parsec.parserFail String
"anyToken"
   take :: Int -> ParsecT s u m (ParserInput (ParsecT s u m))
take Int
n = do s
rest <- forall (m :: * -> *) s u. Monad m => ParsecT s u m s
Parsec.getInput
               case forall m. FactorialMonoid m => Int -> m -> (m, m)
Factorial.splitAt Int
n s
rest
                 of (s
prefix, s
suffix) | forall m. Factorial m => m -> Int
Factorial.length s
prefix forall a. Eq a => a -> a -> Bool
== Int
n -> s
prefix forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ forall (m :: * -> *) s u. Monad m => s -> ParsecT s u m ()
Parsec.setInput s
suffix
                    (s, s)
_ -> forall s u (m :: * -> *) a. String -> ParsecT s u m a
Parsec.parserFail (String
"take " forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> String
show Int
n)

instance (TextualMonoid s, Show s, Parsec.Stream s m Char) => InputCharParsing (ParsecT s u m) where
   satisfyCharInput :: (Char -> Bool) -> ParsecT s u m (ParserInput (ParsecT s u m))
satisfyCharInput = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall t. TextualMonoid t => Char -> t
Textual.singleton forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall s (m :: * -> *) u.
Stream s m Char =>
(Char -> Bool) -> ParsecT s u m Char
Parsec.satisfy
#endif

#ifdef MIN_VERSION_binary
instance InputParsing (Lazy Binary.Get) where
   type ParserInput (Lazy Binary.Get) = Lazy.ByteString
   type ParserPosition (Lazy Binary.Get) = Int
   getInput :: Lazy Get (ParserInput (Lazy Get))
getInput = forall (f :: * -> *) a. f a -> Lazy f a
Lazy (forall a. Get a -> Get a
Binary.lookAhead Get ByteString
Binary.getRemainingLazyByteString)
   getSourcePos :: Lazy Get (ParserPosition (Lazy Get))
getSourcePos = forall (f :: * -> *) a. f a -> Lazy f a
Lazy (Int -> Int
fromStart forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. (Integral a, Num b) => a -> b
fromIntegral forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Get Int64
Binary.bytesRead)
   anyToken :: Lazy Get (ParserInput (Lazy Get))
anyToken = forall (f :: * -> *) a. f a -> Lazy f a
Lazy (Int64 -> Get ByteString
Binary.getLazyByteString Int64
1)
   take :: Int -> Lazy Get (ParserInput (Lazy Get))
take Int
n = forall (f :: * -> *) a. f a -> Lazy f a
Lazy (Int64 -> Get ByteString
Binary.getLazyByteString forall a b. (a -> b) -> a -> b
$ forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
n)

instance InputParsing (Strict Binary.Get) where
   type ParserInput (Strict Binary.Get) = ByteString
   type ParserPosition (Strict Binary.Get) = Int
   getInput :: Strict Get (ParserInput (Strict Get))
getInput = forall (f :: * -> *) a. f a -> Strict f a
Strict (ByteString -> ByteString
Lazy.toStrict forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall a. Get a -> Get a
Binary.lookAhead Get ByteString
Binary.getRemainingLazyByteString)
   getSourcePos :: Strict Get (ParserPosition (Strict Get))
getSourcePos = forall (f :: * -> *) a. f a -> Strict f a
Strict (Int -> Int
fromStart forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. (Integral a, Num b) => a -> b
fromIntegral forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Get Int64
Binary.bytesRead)
   anyToken :: Strict Get (ParserInput (Strict Get))
anyToken = forall (f :: * -> *) a. f a -> Strict f a
Strict (Int -> Get ByteString
Binary.getByteString Int
1)
   take :: Int -> Strict Get (ParserInput (Strict Get))
take Int
n = forall (f :: * -> *) a. f a -> Strict f a
Strict (Int -> Get ByteString
Binary.getByteString Int
n)

instance ConsumedInputParsing (Lazy Binary.Get) where
  match :: forall a. Lazy Get a -> Lazy Get (ParserInput (Lazy Get), a)
match (Lazy Get a
p) = forall (f :: * -> *) a. f a -> Lazy f a
Lazy forall a b. (a -> b) -> a -> b
$ do ByteString
input <- forall a. Get a -> Get a
Binary.lookAhead Get ByteString
Binary.getRemainingLazyByteString
                             Int64
pos <- Get Int64
Binary.bytesRead
                             a
result <- Get a
p
                             Int64
pos' <- Get Int64
Binary.bytesRead
                             forall (f :: * -> *) a. Applicative f => a -> f a
pure (Int64 -> ByteString -> ByteString
Lazy.take (Int64
pos' forall a. Num a => a -> a -> a
- Int64
pos) ByteString
input, a
result)

instance ConsumedInputParsing (Strict Binary.Get) where
  match :: forall a. Strict Get a -> Strict Get (ParserInput (Strict Get), a)
match (Strict Get a
p) = forall (f :: * -> *) a. f a -> Strict f a
Strict forall a b. (a -> b) -> a -> b
$ do ByteString
input <- forall a. Get a -> Get a
Binary.lookAhead Get ByteString
Binary.getRemainingLazyByteString
                                 Int64
pos <- Get Int64
Binary.bytesRead
                                 a
result <- Get a
p
                                 Int64
pos' <- Get Int64
Binary.bytesRead
                                 forall (f :: * -> *) a. Applicative f => a -> f a
pure (ByteString -> ByteString
Lazy.toStrict (Int64 -> ByteString -> ByteString
Lazy.take (Int64
pos' forall a. Num a => a -> a -> a
- Int64
pos) ByteString
input), a
result)
#endif