{-# LANGUAGE CPP #-}
{-# LANGUAGE DefaultSignatures #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE TypeFamilies #-}
#if defined (__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ < 802
{-# LANGUAGE TypeSynonymInstances #-}
#endif
module Text.Parser.Input (InputParsing(..), InputCharParsing(..), ConsumedInputParsing(..),
Lazy(..), Strict(..)) where
import Control.Applicative (Applicative ((<*>), pure), 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(WriterT))
import qualified Control.Monad.Trans.Writer.Strict as Strict (WriterT(WriterT))
import qualified Control.Monad.Trans.State.Lazy as Lazy (StateT(StateT))
import qualified Control.Monad.Trans.State.Strict as Strict (StateT(StateT))
import qualified Control.Monad.Trans.RWS.Lazy as Lazy (RWST(RWST))
import qualified Control.Monad.Trans.RWS.Strict as Strict (RWST(RWST))
import Data.Functor ((<$>))
import qualified Data.List as List
import Data.Monoid (Monoid, Dual, mappend, mempty)
import Data.String (IsString (fromString))
import Text.ParserCombinators.ReadP (ReadP)
import qualified Text.ParserCombinators.ReadP as ReadP
import Text.Parser.Char (CharParsing)
import Text.Parser.Combinators (Parsing, 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.ByteString (ByteString)
import Data.Text (Text)
import qualified Data.ByteString as ByteString
import qualified Data.ByteString.Char8 as ByteString.Char8
import qualified Data.ByteString.Lazy as Lazy
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 (Position, fromEnd, fromStart)
import Text.Parser.Internal (mapLazyWriterT, mapStrictWriterT,
mapLazyStateT, mapStrictStateT,
mapLazyRWST, mapStrictRWST)
import Text.Parser.Wrapper (Lazy(..), Strict(..))
import Prelude hiding (take, takeWhile)
class LookAheadParsing m => InputParsing m where
type ParserInput m
type ParserPosition m
getInput :: m (ParserInput m)
getSourcePos :: m (ParserPosition m)
anyToken :: m (ParserInput m)
take :: Int -> m (ParserInput m)
satisfy :: (ParserInput m -> Bool) -> m (ParserInput m)
notSatisfy :: (ParserInput m -> Bool) -> m ()
scan :: state -> (state -> ParserInput m -> Maybe state) -> m (ParserInput m)
string :: ParserInput m -> m (ParserInput m)
takeWhile :: (ParserInput m -> Bool) -> m (ParserInput m)
takeWhile1 :: (ParserInput m -> Bool) -> m (ParserInput m)
type ParserPosition m = Dual Int
default getSourcePos :: (FactorialMonoid (ParserInput m), Functor m, ParserPosition m ~ Dual Int)
=> m (ParserPosition m)
getSourcePos = Int -> Dual Int
fromEnd (Int -> Dual Int)
-> (ParserInput m -> Int) -> ParserInput m -> Dual Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ParserInput m -> Int
forall m. Factorial m => m -> Int
Factorial.length (ParserInput m -> Dual Int) -> m (ParserInput m) -> m (Dual Int)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m (ParserInput m)
forall (m :: * -> *). InputParsing m => m (ParserInput m)
getInput
anyToken = Int -> m (ParserInput m)
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 = m (ParserInput m)
forall (m :: * -> *). InputParsing m => m (ParserInput m)
anyToken m (ParserInput m)
-> (ParserInput m -> m (ParserInput m)) -> m (ParserInput m)
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 ParserInput m -> m (ParserInput m)
forall (f :: * -> *) a. Applicative f => a -> f a
pure ParserInput m
x else m (ParserInput m)
forall (f :: * -> *) a. Alternative f => f a
empty
notSatisfy ParserInput m -> Bool
predicate = m () -> m ()
forall (m :: * -> *) a. Parsing m => m a -> m a
try (m (ParserInput m) -> m ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (m (ParserInput m) -> m ()) -> m (ParserInput m) -> m ()
forall a b. (a -> b) -> a -> b
$ (ParserInput m -> Bool) -> m (ParserInput m)
forall (m :: * -> *).
InputParsing m =>
(ParserInput m -> Bool) -> m (ParserInput m)
satisfy ((ParserInput m -> Bool) -> m (ParserInput m))
-> (ParserInput m -> Bool) -> m (ParserInput m)
forall a b. (a -> b) -> a -> b
$ Bool -> Bool
not (Bool -> Bool) -> (ParserInput m -> Bool) -> ParserInput m -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ParserInput m -> Bool
predicate) m () -> m () -> m ()
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> m ()
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 <- m (ParserInput m)
forall (m :: * -> *). InputParsing m => m (ParserInput m)
getInput
if ParserInput m
s ParserInput m -> ParserInput m -> Bool
forall m. LeftReductive m => m -> m -> Bool
`Cancellative.isPrefixOf` ParserInput m
i
then Int -> m (ParserInput m)
forall (m :: * -> *). InputParsing m => Int -> m (ParserInput m)
take (ParserInput m -> Int
forall m. Factorial m => m -> Int
Factorial.length ParserInput m
s)
else String -> m (ParserInput m)
forall (m :: * -> *) a. Parsing m => String -> m a
unexpected (String
"string " String -> String -> String
forall a. Semigroup a => a -> a -> a
<> ParserInput m -> String
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 <- m (ParserInput m)
forall (m :: * -> *). InputParsing m => m (ParserInput m)
getInput
let (ParserInput m
prefix, ParserInput m
_suffix, state
_state) = state
-> (state -> ParserInput m -> Maybe state)
-> ParserInput m
-> (ParserInput m, ParserInput m, 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
Int -> m (ParserInput m)
forall (m :: * -> *). InputParsing m => Int -> m (ParserInput m)
take (ParserInput m -> Int
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 <- m (ParserInput m)
forall (m :: * -> *). InputParsing m => m (ParserInput m)
getInput
Int -> m (ParserInput m)
forall (m :: * -> *). InputParsing m => Int -> m (ParserInput m)
take (ParserInput m -> Int
forall m. Factorial m => m -> Int
Factorial.length (ParserInput m -> Int) -> ParserInput m -> Int
forall a b. (a -> b) -> a -> b
$ (ParserInput m -> Bool) -> ParserInput m -> ParserInput m
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 <- (ParserInput m -> Bool) -> m (ParserInput m)
forall (m :: * -> *).
InputParsing m =>
(ParserInput m -> Bool) -> m (ParserInput m)
takeWhile ParserInput m -> Bool
predicate
if ParserInput m -> Bool
forall m. MonoidNull m => m -> Bool
Null.null ParserInput m
x then String -> m (ParserInput m)
forall (m :: * -> *) a. Parsing m => String -> m a
unexpected String
"takeWhile1" else ParserInput m -> m (ParserInput m)
forall (f :: * -> *) a. Applicative f => a -> f a
pure ParserInput m
x
class (CharParsing m, InputParsing m) => InputCharParsing m where
satisfyCharInput :: (Char -> Bool) -> m (ParserInput m)
notSatisfyChar :: (Char -> Bool) -> m ()
scanChars :: state -> (state -> Char -> Maybe state) -> m (ParserInput m)
takeCharsWhile :: (Char -> Bool) -> m (ParserInput m)
takeCharsWhile1 :: (Char -> Bool) -> m (ParserInput m)
notSatisfyChar = m Char -> m ()
forall (m :: * -> *) a. (Parsing m, Show a) => m a -> m ()
notFollowedBy (m Char -> m ())
-> ((Char -> Bool) -> m Char) -> (Char -> Bool) -> m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Char -> Bool) -> m Char
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 <- m (ParserInput m)
forall (m :: * -> *). InputParsing m => m (ParserInput m)
getInput
let (ParserInput m
prefix, ParserInput m
_suffix, state
_state) = state
-> (state -> ParserInput m -> Maybe state)
-> (state -> Char -> Maybe state)
-> ParserInput m
-> (ParserInput m, ParserInput m, state)
forall t s.
TextualMonoid t =>
s
-> (s -> t -> Maybe s) -> (s -> Char -> Maybe s) -> t -> (t, t, s)
Textual.spanMaybe' state
state ((ParserInput m -> Maybe state)
-> state -> ParserInput m -> Maybe state
forall a b. a -> b -> a
const ((ParserInput m -> Maybe state)
-> state -> ParserInput m -> Maybe state)
-> (ParserInput m -> Maybe state)
-> state
-> ParserInput m
-> Maybe state
forall a b. (a -> b) -> a -> b
$ Maybe state -> ParserInput m -> Maybe state
forall a b. a -> b -> a
const Maybe state
forall a. Maybe a
Nothing) state -> Char -> Maybe state
f ParserInput m
i
Int -> m (ParserInput m)
forall (m :: * -> *). InputParsing m => Int -> m (ParserInput m)
take (ParserInput m -> Int
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 <- m (ParserInput m)
forall (m :: * -> *). InputParsing m => m (ParserInput m)
getInput
Int -> m (ParserInput m)
forall (m :: * -> *). InputParsing m => Int -> m (ParserInput m)
take (ParserInput m -> Int
forall m. Factorial m => m -> Int
Factorial.length (ParserInput m -> Int) -> ParserInput m -> Int
forall a b. (a -> b) -> a -> b
$ Bool -> (Char -> Bool) -> ParserInput m -> ParserInput m
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 <- (Char -> Bool) -> m (ParserInput m)
forall (m :: * -> *).
InputCharParsing m =>
(Char -> Bool) -> m (ParserInput m)
takeCharsWhile Char -> Bool
predicate
if ParserInput m -> Bool
forall m. MonoidNull m => m -> Bool
Null.null ParserInput m
x then String -> m (ParserInput m)
forall (m :: * -> *) a. Parsing m => String -> m a
unexpected String
"takeCharsWhile1" else ParserInput m -> m (ParserInput m)
forall (f :: * -> *) a. Applicative f => a -> f a
pure ParserInput m
x
class InputParsing m => ConsumedInputParsing m where
match :: m a -> m (ParserInput m, a)
instance InputParsing ReadP where
type ParserInput ReadP = String
getInput :: ReadP (ParserInput ReadP)
getInput = ReadP String
ReadP (ParserInput ReadP)
ReadP.look
take :: Int -> ReadP (ParserInput ReadP)
take Int
n = Int -> ReadP Char -> ReadP String
forall (m :: * -> *) a. Applicative m => Int -> m a -> m [a]
count Int
n ReadP Char
ReadP.get
anyToken :: ReadP (ParserInput ReadP)
anyToken = Char -> String
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Char -> String) -> ReadP Char -> ReadP String
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 = Char -> String
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Char -> String) -> ReadP Char -> ReadP String
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Char -> Bool) -> ReadP Char
ReadP.satisfy (String -> Bool
ParserInput ReadP -> Bool
predicate (String -> Bool) -> (Char -> String) -> Char -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> String
forall (f :: * -> *) a. Applicative f => a -> f a
pure)
string :: ParserInput ReadP -> ReadP (ParserInput ReadP)
string = String -> ReadP String
ParserInput ReadP -> ReadP (ParserInput ReadP)
ReadP.string
instance InputCharParsing ReadP where
satisfyCharInput :: (Char -> Bool) -> ReadP (ParserInput ReadP)
satisfyCharInput Char -> Bool
predicate = Char -> String
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Char -> String) -> ReadP Char -> ReadP String
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 :: ReadP a -> ReadP (ParserInput ReadP, a)
match = ReadP a -> ReadP (ParserInput ReadP, a)
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 = m (ParserInput m) -> IdentityT m (ParserInput m)
forall k (f :: k -> *) (a :: k). f a -> IdentityT f a
IdentityT m (ParserInput m)
forall (m :: * -> *). InputParsing m => m (ParserInput m)
getInput
getSourcePos :: IdentityT m (ParserPosition (IdentityT m))
getSourcePos = m (ParserPosition m) -> IdentityT m (ParserPosition m)
forall k (f :: k -> *) (a :: k). f a -> IdentityT f a
IdentityT m (ParserPosition m)
forall (m :: * -> *). InputParsing m => m (ParserPosition m)
getSourcePos
anyToken :: IdentityT m (ParserInput (IdentityT m))
anyToken = m (ParserInput m) -> IdentityT m (ParserInput m)
forall k (f :: k -> *) (a :: k). f a -> IdentityT f a
IdentityT m (ParserInput m)
forall (m :: * -> *). InputParsing m => m (ParserInput m)
anyToken
take :: Int -> IdentityT m (ParserInput (IdentityT m))
take = m (ParserInput m) -> IdentityT m (ParserInput m)
forall k (f :: k -> *) (a :: k). f a -> IdentityT f a
IdentityT (m (ParserInput m) -> IdentityT m (ParserInput m))
-> (Int -> m (ParserInput m)) -> Int -> IdentityT m (ParserInput m)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> m (ParserInput m)
forall (m :: * -> *). InputParsing m => Int -> m (ParserInput m)
take
satisfy :: (ParserInput (IdentityT m) -> Bool)
-> IdentityT m (ParserInput (IdentityT m))
satisfy = m (ParserInput m) -> IdentityT m (ParserInput m)
forall k (f :: k -> *) (a :: k). f a -> IdentityT f a
IdentityT (m (ParserInput m) -> IdentityT m (ParserInput m))
-> ((ParserInput m -> Bool) -> m (ParserInput m))
-> (ParserInput m -> Bool)
-> IdentityT m (ParserInput m)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ParserInput m -> Bool) -> m (ParserInput m)
forall (m :: * -> *).
InputParsing m =>
(ParserInput m -> Bool) -> m (ParserInput m)
satisfy
notSatisfy :: (ParserInput (IdentityT m) -> Bool) -> IdentityT m ()
notSatisfy = m () -> IdentityT m ()
forall k (f :: k -> *) (a :: k). f a -> IdentityT f a
IdentityT (m () -> IdentityT m ())
-> ((ParserInput m -> Bool) -> m ())
-> (ParserInput m -> Bool)
-> IdentityT m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ParserInput m -> Bool) -> m ()
forall (m :: * -> *).
InputParsing m =>
(ParserInput m -> Bool) -> m ()
notSatisfy
scan :: state
-> (state -> ParserInput (IdentityT m) -> Maybe state)
-> IdentityT m (ParserInput (IdentityT m))
scan state
state state -> ParserInput (IdentityT m) -> Maybe state
f = m (ParserInput m) -> IdentityT m (ParserInput m)
forall k (f :: k -> *) (a :: k). f a -> IdentityT f a
IdentityT (state
-> (state -> ParserInput m -> Maybe state) -> m (ParserInput m)
forall (m :: * -> *) state.
InputParsing m =>
state
-> (state -> ParserInput m -> Maybe state) -> m (ParserInput m)
scan state
state state -> ParserInput m -> Maybe state
state -> ParserInput (IdentityT m) -> Maybe state
f)
string :: ParserInput (IdentityT m)
-> IdentityT m (ParserInput (IdentityT m))
string = m (ParserInput m) -> IdentityT m (ParserInput m)
forall k (f :: k -> *) (a :: k). f a -> IdentityT f a
IdentityT (m (ParserInput m) -> IdentityT m (ParserInput m))
-> (ParserInput m -> m (ParserInput m))
-> ParserInput m
-> IdentityT m (ParserInput m)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ParserInput m -> m (ParserInput m)
forall (m :: * -> *).
InputParsing m =>
ParserInput m -> m (ParserInput m)
string
takeWhile :: (ParserInput (IdentityT m) -> Bool)
-> IdentityT m (ParserInput (IdentityT m))
takeWhile = m (ParserInput m) -> IdentityT m (ParserInput m)
forall k (f :: k -> *) (a :: k). f a -> IdentityT f a
IdentityT (m (ParserInput m) -> IdentityT m (ParserInput m))
-> ((ParserInput m -> Bool) -> m (ParserInput m))
-> (ParserInput m -> Bool)
-> IdentityT m (ParserInput m)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ParserInput m -> Bool) -> m (ParserInput m)
forall (m :: * -> *).
InputParsing m =>
(ParserInput m -> Bool) -> m (ParserInput m)
takeWhile
takeWhile1 :: (ParserInput (IdentityT m) -> Bool)
-> IdentityT m (ParserInput (IdentityT m))
takeWhile1 = m (ParserInput m) -> IdentityT m (ParserInput m)
forall k (f :: k -> *) (a :: k). f a -> IdentityT f a
IdentityT (m (ParserInput m) -> IdentityT m (ParserInput m))
-> ((ParserInput m -> Bool) -> m (ParserInput m))
-> (ParserInput m -> Bool)
-> IdentityT m (ParserInput m)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ParserInput m -> Bool) -> m (ParserInput m)
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 = m (ParserInput m) -> IdentityT m (ParserInput m)
forall k (f :: k -> *) (a :: k). f a -> IdentityT f a
IdentityT (m (ParserInput m) -> IdentityT m (ParserInput m))
-> ((Char -> Bool) -> m (ParserInput m))
-> (Char -> Bool)
-> IdentityT m (ParserInput m)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Char -> Bool) -> m (ParserInput m)
forall (m :: * -> *).
InputCharParsing m =>
(Char -> Bool) -> m (ParserInput m)
satisfyCharInput
notSatisfyChar :: (Char -> Bool) -> IdentityT m ()
notSatisfyChar = m () -> IdentityT m ()
forall k (f :: k -> *) (a :: k). f a -> IdentityT f a
IdentityT (m () -> IdentityT m ())
-> ((Char -> Bool) -> m ()) -> (Char -> Bool) -> IdentityT m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Char -> Bool) -> m ()
forall (m :: * -> *). InputCharParsing m => (Char -> Bool) -> m ()
notSatisfyChar
scanChars :: state
-> (state -> Char -> Maybe state)
-> IdentityT m (ParserInput (IdentityT m))
scanChars state
state state -> Char -> Maybe state
f = m (ParserInput m) -> IdentityT m (ParserInput m)
forall k (f :: k -> *) (a :: k). f a -> IdentityT f a
IdentityT (state -> (state -> Char -> Maybe state) -> m (ParserInput m)
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 = m (ParserInput m) -> IdentityT m (ParserInput m)
forall k (f :: k -> *) (a :: k). f a -> IdentityT f a
IdentityT (m (ParserInput m) -> IdentityT m (ParserInput m))
-> ((Char -> Bool) -> m (ParserInput m))
-> (Char -> Bool)
-> IdentityT m (ParserInput m)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Char -> Bool) -> m (ParserInput m)
forall (m :: * -> *).
InputCharParsing m =>
(Char -> Bool) -> m (ParserInput m)
takeCharsWhile
takeCharsWhile1 :: (Char -> Bool) -> IdentityT m (ParserInput (IdentityT m))
takeCharsWhile1 = m (ParserInput m) -> IdentityT m (ParserInput m)
forall k (f :: k -> *) (a :: k). f a -> IdentityT f a
IdentityT (m (ParserInput m) -> IdentityT m (ParserInput m))
-> ((Char -> Bool) -> m (ParserInput m))
-> (Char -> Bool)
-> IdentityT m (ParserInput m)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Char -> Bool) -> m (ParserInput m)
forall (m :: * -> *).
InputCharParsing m =>
(Char -> Bool) -> m (ParserInput m)
takeCharsWhile1
instance (Monad m, ConsumedInputParsing m) => ConsumedInputParsing (IdentityT m) where
match :: IdentityT m a -> IdentityT m (ParserInput (IdentityT m), a)
match (IdentityT m a
p) = m (ParserInput m, a) -> IdentityT m (ParserInput m, a)
forall k (f :: k -> *) (a :: k). f a -> IdentityT f a
IdentityT (m a -> m (ParserInput m, a)
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 = m (ParserInput m) -> ReaderT e m (ParserInput m)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m (ParserInput m)
forall (m :: * -> *). InputParsing m => m (ParserInput m)
getInput
getSourcePos :: ReaderT e m (ParserPosition (ReaderT e m))
getSourcePos = m (ParserPosition m) -> ReaderT e m (ParserPosition m)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m (ParserPosition m)
forall (m :: * -> *). InputParsing m => m (ParserPosition m)
getSourcePos
anyToken :: ReaderT e m (ParserInput (ReaderT e m))
anyToken = m (ParserInput m) -> ReaderT e m (ParserInput m)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m (ParserInput m)
forall (m :: * -> *). InputParsing m => m (ParserInput m)
anyToken
take :: Int -> ReaderT e m (ParserInput (ReaderT e m))
take = m (ParserInput m) -> ReaderT e m (ParserInput m)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (ParserInput m) -> ReaderT e m (ParserInput m))
-> (Int -> m (ParserInput m)) -> Int -> ReaderT e m (ParserInput m)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> m (ParserInput m)
forall (m :: * -> *). InputParsing m => Int -> m (ParserInput m)
take
satisfy :: (ParserInput (ReaderT e m) -> Bool)
-> ReaderT e m (ParserInput (ReaderT e m))
satisfy = m (ParserInput m) -> ReaderT e m (ParserInput m)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (ParserInput m) -> ReaderT e m (ParserInput m))
-> ((ParserInput m -> Bool) -> m (ParserInput m))
-> (ParserInput m -> Bool)
-> ReaderT e m (ParserInput m)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ParserInput m -> Bool) -> m (ParserInput m)
forall (m :: * -> *).
InputParsing m =>
(ParserInput m -> Bool) -> m (ParserInput m)
satisfy
notSatisfy :: (ParserInput (ReaderT e m) -> Bool) -> ReaderT e m ()
notSatisfy = m () -> ReaderT e m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> ReaderT e m ())
-> ((ParserInput m -> Bool) -> m ())
-> (ParserInput m -> Bool)
-> ReaderT e m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ParserInput m -> Bool) -> m ()
forall (m :: * -> *).
InputParsing m =>
(ParserInput m -> Bool) -> m ()
notSatisfy
scan :: 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 = m (ParserInput m) -> ReaderT e m (ParserInput m)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (state
-> (state -> ParserInput m -> Maybe state) -> m (ParserInput m)
forall (m :: * -> *) state.
InputParsing m =>
state
-> (state -> ParserInput m -> Maybe state) -> m (ParserInput m)
scan state
state state -> ParserInput m -> Maybe state
state -> ParserInput (ReaderT e m) -> Maybe state
f)
string :: ParserInput (ReaderT e m)
-> ReaderT e m (ParserInput (ReaderT e m))
string = m (ParserInput m) -> ReaderT e m (ParserInput m)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (ParserInput m) -> ReaderT e m (ParserInput m))
-> (ParserInput m -> m (ParserInput m))
-> ParserInput m
-> ReaderT e m (ParserInput m)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ParserInput m -> m (ParserInput m)
forall (m :: * -> *).
InputParsing m =>
ParserInput m -> m (ParserInput m)
string
takeWhile :: (ParserInput (ReaderT e m) -> Bool)
-> ReaderT e m (ParserInput (ReaderT e m))
takeWhile = m (ParserInput m) -> ReaderT e m (ParserInput m)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (ParserInput m) -> ReaderT e m (ParserInput m))
-> ((ParserInput m -> Bool) -> m (ParserInput m))
-> (ParserInput m -> Bool)
-> ReaderT e m (ParserInput m)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ParserInput m -> Bool) -> m (ParserInput m)
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 = m (ParserInput m) -> ReaderT e m (ParserInput m)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (ParserInput m) -> ReaderT e m (ParserInput m))
-> ((ParserInput m -> Bool) -> m (ParserInput m))
-> (ParserInput m -> Bool)
-> ReaderT e m (ParserInput m)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ParserInput m -> Bool) -> m (ParserInput m)
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 = m (ParserInput m) -> ReaderT e m (ParserInput m)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (ParserInput m) -> ReaderT e m (ParserInput m))
-> ((Char -> Bool) -> m (ParserInput m))
-> (Char -> Bool)
-> ReaderT e m (ParserInput m)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Char -> Bool) -> m (ParserInput m)
forall (m :: * -> *).
InputCharParsing m =>
(Char -> Bool) -> m (ParserInput m)
satisfyCharInput
notSatisfyChar :: (Char -> Bool) -> ReaderT e m ()
notSatisfyChar = m () -> ReaderT e m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> ReaderT e m ())
-> ((Char -> Bool) -> m ()) -> (Char -> Bool) -> ReaderT e m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Char -> Bool) -> m ()
forall (m :: * -> *). InputCharParsing m => (Char -> Bool) -> m ()
notSatisfyChar
scanChars :: state
-> (state -> Char -> Maybe state)
-> ReaderT e m (ParserInput (ReaderT e m))
scanChars state
state state -> Char -> Maybe state
f = m (ParserInput m) -> ReaderT e m (ParserInput m)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (state -> (state -> Char -> Maybe state) -> m (ParserInput m)
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 = m (ParserInput m) -> ReaderT e m (ParserInput m)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (ParserInput m) -> ReaderT e m (ParserInput m))
-> ((Char -> Bool) -> m (ParserInput m))
-> (Char -> Bool)
-> ReaderT e m (ParserInput m)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Char -> Bool) -> m (ParserInput m)
forall (m :: * -> *).
InputCharParsing m =>
(Char -> Bool) -> m (ParserInput m)
takeCharsWhile
takeCharsWhile1 :: (Char -> Bool) -> ReaderT e m (ParserInput (ReaderT e m))
takeCharsWhile1 = m (ParserInput m) -> ReaderT e m (ParserInput m)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (ParserInput m) -> ReaderT e m (ParserInput m))
-> ((Char -> Bool) -> m (ParserInput m))
-> (Char -> Bool)
-> ReaderT e m (ParserInput m)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Char -> Bool) -> m (ParserInput m)
forall (m :: * -> *).
InputCharParsing m =>
(Char -> Bool) -> m (ParserInput m)
takeCharsWhile1
instance (MonadPlus m, ConsumedInputParsing m) => ConsumedInputParsing (ReaderT e m) where
match :: ReaderT e m a -> ReaderT e m (ParserInput (ReaderT e m), a)
match = (m a -> m (ParserInput m, a))
-> ReaderT e m a -> ReaderT e m (ParserInput m, a)
forall (m :: * -> *) a (n :: * -> *) b r.
(m a -> n b) -> ReaderT r m a -> ReaderT r n b
mapReaderT m a -> m (ParserInput m, a)
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 = m (ParserInput m) -> WriterT w m (ParserInput m)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m (ParserInput m)
forall (m :: * -> *). InputParsing m => m (ParserInput m)
getInput
getSourcePos :: WriterT w m (ParserPosition (WriterT w m))
getSourcePos = m (ParserPosition m) -> WriterT w m (ParserPosition m)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m (ParserPosition m)
forall (m :: * -> *). InputParsing m => m (ParserPosition m)
getSourcePos
anyToken :: WriterT w m (ParserInput (WriterT w m))
anyToken = m (ParserInput m) -> WriterT w m (ParserInput m)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m (ParserInput m)
forall (m :: * -> *). InputParsing m => m (ParserInput m)
anyToken
take :: Int -> WriterT w m (ParserInput (WriterT w m))
take = m (ParserInput m) -> WriterT w m (ParserInput m)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (ParserInput m) -> WriterT w m (ParserInput m))
-> (Int -> m (ParserInput m)) -> Int -> WriterT w m (ParserInput m)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> m (ParserInput m)
forall (m :: * -> *). InputParsing m => Int -> m (ParserInput m)
take
satisfy :: (ParserInput (WriterT w m) -> Bool)
-> WriterT w m (ParserInput (WriterT w m))
satisfy = m (ParserInput m) -> WriterT w m (ParserInput m)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (ParserInput m) -> WriterT w m (ParserInput m))
-> ((ParserInput m -> Bool) -> m (ParserInput m))
-> (ParserInput m -> Bool)
-> WriterT w m (ParserInput m)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ParserInput m -> Bool) -> m (ParserInput m)
forall (m :: * -> *).
InputParsing m =>
(ParserInput m -> Bool) -> m (ParserInput m)
satisfy
notSatisfy :: (ParserInput (WriterT w m) -> Bool) -> WriterT w m ()
notSatisfy = m () -> WriterT w m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> WriterT w m ())
-> ((ParserInput m -> Bool) -> m ())
-> (ParserInput m -> Bool)
-> WriterT w m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ParserInput m -> Bool) -> m ()
forall (m :: * -> *).
InputParsing m =>
(ParserInput m -> Bool) -> m ()
notSatisfy
scan :: 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 = m (ParserInput m) -> WriterT w m (ParserInput m)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (state
-> (state -> ParserInput m -> Maybe state) -> m (ParserInput m)
forall (m :: * -> *) state.
InputParsing m =>
state
-> (state -> ParserInput m -> Maybe state) -> m (ParserInput m)
scan state
state state -> ParserInput m -> Maybe state
state -> ParserInput (WriterT w m) -> Maybe state
f)
string :: ParserInput (WriterT w m)
-> WriterT w m (ParserInput (WriterT w m))
string = m (ParserInput m) -> WriterT w m (ParserInput m)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (ParserInput m) -> WriterT w m (ParserInput m))
-> (ParserInput m -> m (ParserInput m))
-> ParserInput m
-> WriterT w m (ParserInput m)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ParserInput m -> m (ParserInput m)
forall (m :: * -> *).
InputParsing m =>
ParserInput m -> m (ParserInput m)
string
takeWhile :: (ParserInput (WriterT w m) -> Bool)
-> WriterT w m (ParserInput (WriterT w m))
takeWhile = m (ParserInput m) -> WriterT w m (ParserInput m)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (ParserInput m) -> WriterT w m (ParserInput m))
-> ((ParserInput m -> Bool) -> m (ParserInput m))
-> (ParserInput m -> Bool)
-> WriterT w m (ParserInput m)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ParserInput m -> Bool) -> m (ParserInput m)
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 = m (ParserInput m) -> WriterT w m (ParserInput m)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (ParserInput m) -> WriterT w m (ParserInput m))
-> ((ParserInput m -> Bool) -> m (ParserInput m))
-> (ParserInput m -> Bool)
-> WriterT w m (ParserInput m)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ParserInput m -> Bool) -> m (ParserInput m)
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 = m (ParserInput m) -> WriterT w m (ParserInput m)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (ParserInput m) -> WriterT w m (ParserInput m))
-> ((Char -> Bool) -> m (ParserInput m))
-> (Char -> Bool)
-> WriterT w m (ParserInput m)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Char -> Bool) -> m (ParserInput m)
forall (m :: * -> *).
InputCharParsing m =>
(Char -> Bool) -> m (ParserInput m)
satisfyCharInput
notSatisfyChar :: (Char -> Bool) -> WriterT w m ()
notSatisfyChar = m () -> WriterT w m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> WriterT w m ())
-> ((Char -> Bool) -> m ()) -> (Char -> Bool) -> WriterT w m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Char -> Bool) -> m ()
forall (m :: * -> *). InputCharParsing m => (Char -> Bool) -> m ()
notSatisfyChar
scanChars :: state
-> (state -> Char -> Maybe state)
-> WriterT w m (ParserInput (WriterT w m))
scanChars state
state state -> Char -> Maybe state
f = m (ParserInput m) -> WriterT w m (ParserInput m)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (state -> (state -> Char -> Maybe state) -> m (ParserInput m)
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 = m (ParserInput m) -> WriterT w m (ParserInput m)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (ParserInput m) -> WriterT w m (ParserInput m))
-> ((Char -> Bool) -> m (ParserInput m))
-> (Char -> Bool)
-> WriterT w m (ParserInput m)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Char -> Bool) -> m (ParserInput m)
forall (m :: * -> *).
InputCharParsing m =>
(Char -> Bool) -> m (ParserInput m)
takeCharsWhile
takeCharsWhile1 :: (Char -> Bool) -> WriterT w m (ParserInput (WriterT w m))
takeCharsWhile1 = m (ParserInput m) -> WriterT w m (ParserInput m)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (ParserInput m) -> WriterT w m (ParserInput m))
-> ((Char -> Bool) -> m (ParserInput m))
-> (Char -> Bool)
-> WriterT w m (ParserInput m)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Char -> Bool) -> m (ParserInput m)
forall (m :: * -> *).
InputCharParsing m =>
(Char -> Bool) -> m (ParserInput m)
takeCharsWhile1
instance (MonadPlus m, ConsumedInputParsing m, Monoid w) => ConsumedInputParsing (Lazy.WriterT w m) where
match :: WriterT w m a -> WriterT w m (ParserInput (WriterT w m), a)
match = (m a -> m (ParserInput m, a))
-> WriterT w m a -> WriterT w m (ParserInput m, a)
forall (m :: * -> *) a b w.
Applicative m =>
(m a -> m b) -> WriterT w m a -> WriterT w m b
mapLazyWriterT m a -> m (ParserInput m, a)
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 = m (ParserInput m) -> WriterT w m (ParserInput m)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m (ParserInput m)
forall (m :: * -> *). InputParsing m => m (ParserInput m)
getInput
getSourcePos :: WriterT w m (ParserPosition (WriterT w m))
getSourcePos = m (ParserPosition m) -> WriterT w m (ParserPosition m)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m (ParserPosition m)
forall (m :: * -> *). InputParsing m => m (ParserPosition m)
getSourcePos
anyToken :: WriterT w m (ParserInput (WriterT w m))
anyToken = m (ParserInput m) -> WriterT w m (ParserInput m)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m (ParserInput m)
forall (m :: * -> *). InputParsing m => m (ParserInput m)
anyToken
take :: Int -> WriterT w m (ParserInput (WriterT w m))
take = m (ParserInput m) -> WriterT w m (ParserInput m)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (ParserInput m) -> WriterT w m (ParserInput m))
-> (Int -> m (ParserInput m)) -> Int -> WriterT w m (ParserInput m)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> m (ParserInput m)
forall (m :: * -> *). InputParsing m => Int -> m (ParserInput m)
take
satisfy :: (ParserInput (WriterT w m) -> Bool)
-> WriterT w m (ParserInput (WriterT w m))
satisfy = m (ParserInput m) -> WriterT w m (ParserInput m)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (ParserInput m) -> WriterT w m (ParserInput m))
-> ((ParserInput m -> Bool) -> m (ParserInput m))
-> (ParserInput m -> Bool)
-> WriterT w m (ParserInput m)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ParserInput m -> Bool) -> m (ParserInput m)
forall (m :: * -> *).
InputParsing m =>
(ParserInput m -> Bool) -> m (ParserInput m)
satisfy
notSatisfy :: (ParserInput (WriterT w m) -> Bool) -> WriterT w m ()
notSatisfy = m () -> WriterT w m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> WriterT w m ())
-> ((ParserInput m -> Bool) -> m ())
-> (ParserInput m -> Bool)
-> WriterT w m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ParserInput m -> Bool) -> m ()
forall (m :: * -> *).
InputParsing m =>
(ParserInput m -> Bool) -> m ()
notSatisfy
scan :: 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 = m (ParserInput m) -> WriterT w m (ParserInput m)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (state
-> (state -> ParserInput m -> Maybe state) -> m (ParserInput m)
forall (m :: * -> *) state.
InputParsing m =>
state
-> (state -> ParserInput m -> Maybe state) -> m (ParserInput m)
scan state
state state -> ParserInput m -> Maybe state
state -> ParserInput (WriterT w m) -> Maybe state
f)
string :: ParserInput (WriterT w m)
-> WriterT w m (ParserInput (WriterT w m))
string = m (ParserInput m) -> WriterT w m (ParserInput m)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (ParserInput m) -> WriterT w m (ParserInput m))
-> (ParserInput m -> m (ParserInput m))
-> ParserInput m
-> WriterT w m (ParserInput m)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ParserInput m -> m (ParserInput m)
forall (m :: * -> *).
InputParsing m =>
ParserInput m -> m (ParserInput m)
string
takeWhile :: (ParserInput (WriterT w m) -> Bool)
-> WriterT w m (ParserInput (WriterT w m))
takeWhile = m (ParserInput m) -> WriterT w m (ParserInput m)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (ParserInput m) -> WriterT w m (ParserInput m))
-> ((ParserInput m -> Bool) -> m (ParserInput m))
-> (ParserInput m -> Bool)
-> WriterT w m (ParserInput m)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ParserInput m -> Bool) -> m (ParserInput m)
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 = m (ParserInput m) -> WriterT w m (ParserInput m)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (ParserInput m) -> WriterT w m (ParserInput m))
-> ((ParserInput m -> Bool) -> m (ParserInput m))
-> (ParserInput m -> Bool)
-> WriterT w m (ParserInput m)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ParserInput m -> Bool) -> m (ParserInput m)
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 = m (ParserInput m) -> WriterT w m (ParserInput m)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (ParserInput m) -> WriterT w m (ParserInput m))
-> ((Char -> Bool) -> m (ParserInput m))
-> (Char -> Bool)
-> WriterT w m (ParserInput m)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Char -> Bool) -> m (ParserInput m)
forall (m :: * -> *).
InputCharParsing m =>
(Char -> Bool) -> m (ParserInput m)
satisfyCharInput
notSatisfyChar :: (Char -> Bool) -> WriterT w m ()
notSatisfyChar = m () -> WriterT w m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> WriterT w m ())
-> ((Char -> Bool) -> m ()) -> (Char -> Bool) -> WriterT w m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Char -> Bool) -> m ()
forall (m :: * -> *). InputCharParsing m => (Char -> Bool) -> m ()
notSatisfyChar
scanChars :: state
-> (state -> Char -> Maybe state)
-> WriterT w m (ParserInput (WriterT w m))
scanChars state
state state -> Char -> Maybe state
f = m (ParserInput m) -> WriterT w m (ParserInput m)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (state -> (state -> Char -> Maybe state) -> m (ParserInput m)
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 = m (ParserInput m) -> WriterT w m (ParserInput m)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (ParserInput m) -> WriterT w m (ParserInput m))
-> ((Char -> Bool) -> m (ParserInput m))
-> (Char -> Bool)
-> WriterT w m (ParserInput m)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Char -> Bool) -> m (ParserInput m)
forall (m :: * -> *).
InputCharParsing m =>
(Char -> Bool) -> m (ParserInput m)
takeCharsWhile
takeCharsWhile1 :: (Char -> Bool) -> WriterT w m (ParserInput (WriterT w m))
takeCharsWhile1 = m (ParserInput m) -> WriterT w m (ParserInput m)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (ParserInput m) -> WriterT w m (ParserInput m))
-> ((Char -> Bool) -> m (ParserInput m))
-> (Char -> Bool)
-> WriterT w m (ParserInput m)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Char -> Bool) -> m (ParserInput m)
forall (m :: * -> *).
InputCharParsing m =>
(Char -> Bool) -> m (ParserInput m)
takeCharsWhile1
instance (MonadPlus m, ConsumedInputParsing m, Monoid w) => ConsumedInputParsing (Strict.WriterT w m) where
match :: WriterT w m a -> WriterT w m (ParserInput (WriterT w m), a)
match = (m a -> m (ParserInput m, a))
-> WriterT w m a -> WriterT w m (ParserInput m, a)
forall (m :: * -> *) a b w.
Applicative m =>
(m a -> m b) -> WriterT w m a -> WriterT w m b
mapStrictWriterT m a -> m (ParserInput m, a)
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 = m (ParserInput m) -> StateT s m (ParserInput m)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m (ParserInput m)
forall (m :: * -> *). InputParsing m => m (ParserInput m)
getInput
getSourcePos :: StateT s m (ParserPosition (StateT s m))
getSourcePos = m (ParserPosition m) -> StateT s m (ParserPosition m)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m (ParserPosition m)
forall (m :: * -> *). InputParsing m => m (ParserPosition m)
getSourcePos
anyToken :: StateT s m (ParserInput (StateT s m))
anyToken = m (ParserInput m) -> StateT s m (ParserInput m)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m (ParserInput m)
forall (m :: * -> *). InputParsing m => m (ParserInput m)
anyToken
take :: Int -> StateT s m (ParserInput (StateT s m))
take = m (ParserInput m) -> StateT s m (ParserInput m)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (ParserInput m) -> StateT s m (ParserInput m))
-> (Int -> m (ParserInput m)) -> Int -> StateT s m (ParserInput m)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> m (ParserInput m)
forall (m :: * -> *). InputParsing m => Int -> m (ParserInput m)
take
satisfy :: (ParserInput (StateT s m) -> Bool)
-> StateT s m (ParserInput (StateT s m))
satisfy = m (ParserInput m) -> StateT s m (ParserInput m)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (ParserInput m) -> StateT s m (ParserInput m))
-> ((ParserInput m -> Bool) -> m (ParserInput m))
-> (ParserInput m -> Bool)
-> StateT s m (ParserInput m)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ParserInput m -> Bool) -> m (ParserInput m)
forall (m :: * -> *).
InputParsing m =>
(ParserInput m -> Bool) -> m (ParserInput m)
satisfy
notSatisfy :: (ParserInput (StateT s m) -> Bool) -> StateT s m ()
notSatisfy = m () -> StateT s m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> StateT s m ())
-> ((ParserInput m -> Bool) -> m ())
-> (ParserInput m -> Bool)
-> StateT s m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ParserInput m -> Bool) -> m ()
forall (m :: * -> *).
InputParsing m =>
(ParserInput m -> Bool) -> m ()
notSatisfy
scan :: 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 = m (ParserInput m) -> StateT s m (ParserInput m)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (state
-> (state -> ParserInput m -> Maybe state) -> m (ParserInput m)
forall (m :: * -> *) state.
InputParsing m =>
state
-> (state -> ParserInput m -> Maybe state) -> m (ParserInput m)
scan state
state state -> ParserInput m -> Maybe state
state -> ParserInput (StateT s m) -> Maybe state
f)
string :: ParserInput (StateT s m) -> StateT s m (ParserInput (StateT s m))
string = m (ParserInput m) -> StateT s m (ParserInput m)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (ParserInput m) -> StateT s m (ParserInput m))
-> (ParserInput m -> m (ParserInput m))
-> ParserInput m
-> StateT s m (ParserInput m)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ParserInput m -> m (ParserInput m)
forall (m :: * -> *).
InputParsing m =>
ParserInput m -> m (ParserInput m)
string
takeWhile :: (ParserInput (StateT s m) -> Bool)
-> StateT s m (ParserInput (StateT s m))
takeWhile = m (ParserInput m) -> StateT s m (ParserInput m)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (ParserInput m) -> StateT s m (ParserInput m))
-> ((ParserInput m -> Bool) -> m (ParserInput m))
-> (ParserInput m -> Bool)
-> StateT s m (ParserInput m)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ParserInput m -> Bool) -> m (ParserInput m)
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 = m (ParserInput m) -> StateT s m (ParserInput m)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (ParserInput m) -> StateT s m (ParserInput m))
-> ((ParserInput m -> Bool) -> m (ParserInput m))
-> (ParserInput m -> Bool)
-> StateT s m (ParserInput m)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ParserInput m -> Bool) -> m (ParserInput m)
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 = m (ParserInput m) -> StateT s m (ParserInput m)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (ParserInput m) -> StateT s m (ParserInput m))
-> ((Char -> Bool) -> m (ParserInput m))
-> (Char -> Bool)
-> StateT s m (ParserInput m)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Char -> Bool) -> m (ParserInput m)
forall (m :: * -> *).
InputCharParsing m =>
(Char -> Bool) -> m (ParserInput m)
satisfyCharInput
notSatisfyChar :: (Char -> Bool) -> StateT s m ()
notSatisfyChar = m () -> StateT s m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> StateT s m ())
-> ((Char -> Bool) -> m ()) -> (Char -> Bool) -> StateT s m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Char -> Bool) -> m ()
forall (m :: * -> *). InputCharParsing m => (Char -> Bool) -> m ()
notSatisfyChar
scanChars :: state
-> (state -> Char -> Maybe state)
-> StateT s m (ParserInput (StateT s m))
scanChars state
state state -> Char -> Maybe state
f = m (ParserInput m) -> StateT s m (ParserInput m)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (state -> (state -> Char -> Maybe state) -> m (ParserInput m)
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 = m (ParserInput m) -> StateT s m (ParserInput m)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (ParserInput m) -> StateT s m (ParserInput m))
-> ((Char -> Bool) -> m (ParserInput m))
-> (Char -> Bool)
-> StateT s m (ParserInput m)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Char -> Bool) -> m (ParserInput m)
forall (m :: * -> *).
InputCharParsing m =>
(Char -> Bool) -> m (ParserInput m)
takeCharsWhile
takeCharsWhile1 :: (Char -> Bool) -> StateT s m (ParserInput (StateT s m))
takeCharsWhile1 = m (ParserInput m) -> StateT s m (ParserInput m)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (ParserInput m) -> StateT s m (ParserInput m))
-> ((Char -> Bool) -> m (ParserInput m))
-> (Char -> Bool)
-> StateT s m (ParserInput m)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Char -> Bool) -> m (ParserInput m)
forall (m :: * -> *).
InputCharParsing m =>
(Char -> Bool) -> m (ParserInput m)
takeCharsWhile1
instance (MonadPlus m, ConsumedInputParsing m) => ConsumedInputParsing (Lazy.StateT s m) where
match :: StateT s m a -> StateT s m (ParserInput (StateT s m), a)
match = (m a -> m (ParserInput m, a))
-> StateT s m a -> StateT s m (ParserInput m, a)
forall (m :: * -> *) a b w.
Applicative m =>
(m a -> m b) -> StateT w m a -> StateT w m b
mapLazyStateT m a -> m (ParserInput m, a)
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 = m (ParserInput m) -> StateT s m (ParserInput m)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m (ParserInput m)
forall (m :: * -> *). InputParsing m => m (ParserInput m)
getInput
getSourcePos :: StateT s m (ParserPosition (StateT s m))
getSourcePos = m (ParserPosition m) -> StateT s m (ParserPosition m)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m (ParserPosition m)
forall (m :: * -> *). InputParsing m => m (ParserPosition m)
getSourcePos
anyToken :: StateT s m (ParserInput (StateT s m))
anyToken = m (ParserInput m) -> StateT s m (ParserInput m)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m (ParserInput m)
forall (m :: * -> *). InputParsing m => m (ParserInput m)
anyToken
take :: Int -> StateT s m (ParserInput (StateT s m))
take = m (ParserInput m) -> StateT s m (ParserInput m)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (ParserInput m) -> StateT s m (ParserInput m))
-> (Int -> m (ParserInput m)) -> Int -> StateT s m (ParserInput m)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> m (ParserInput m)
forall (m :: * -> *). InputParsing m => Int -> m (ParserInput m)
take
satisfy :: (ParserInput (StateT s m) -> Bool)
-> StateT s m (ParserInput (StateT s m))
satisfy = m (ParserInput m) -> StateT s m (ParserInput m)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (ParserInput m) -> StateT s m (ParserInput m))
-> ((ParserInput m -> Bool) -> m (ParserInput m))
-> (ParserInput m -> Bool)
-> StateT s m (ParserInput m)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ParserInput m -> Bool) -> m (ParserInput m)
forall (m :: * -> *).
InputParsing m =>
(ParserInput m -> Bool) -> m (ParserInput m)
satisfy
notSatisfy :: (ParserInput (StateT s m) -> Bool) -> StateT s m ()
notSatisfy = m () -> StateT s m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> StateT s m ())
-> ((ParserInput m -> Bool) -> m ())
-> (ParserInput m -> Bool)
-> StateT s m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ParserInput m -> Bool) -> m ()
forall (m :: * -> *).
InputParsing m =>
(ParserInput m -> Bool) -> m ()
notSatisfy
scan :: 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 = m (ParserInput m) -> StateT s m (ParserInput m)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (state
-> (state -> ParserInput m -> Maybe state) -> m (ParserInput m)
forall (m :: * -> *) state.
InputParsing m =>
state
-> (state -> ParserInput m -> Maybe state) -> m (ParserInput m)
scan state
state state -> ParserInput m -> Maybe state
state -> ParserInput (StateT s m) -> Maybe state
f)
string :: ParserInput (StateT s m) -> StateT s m (ParserInput (StateT s m))
string = m (ParserInput m) -> StateT s m (ParserInput m)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (ParserInput m) -> StateT s m (ParserInput m))
-> (ParserInput m -> m (ParserInput m))
-> ParserInput m
-> StateT s m (ParserInput m)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ParserInput m -> m (ParserInput m)
forall (m :: * -> *).
InputParsing m =>
ParserInput m -> m (ParserInput m)
string
takeWhile :: (ParserInput (StateT s m) -> Bool)
-> StateT s m (ParserInput (StateT s m))
takeWhile = m (ParserInput m) -> StateT s m (ParserInput m)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (ParserInput m) -> StateT s m (ParserInput m))
-> ((ParserInput m -> Bool) -> m (ParserInput m))
-> (ParserInput m -> Bool)
-> StateT s m (ParserInput m)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ParserInput m -> Bool) -> m (ParserInput m)
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 = m (ParserInput m) -> StateT s m (ParserInput m)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (ParserInput m) -> StateT s m (ParserInput m))
-> ((ParserInput m -> Bool) -> m (ParserInput m))
-> (ParserInput m -> Bool)
-> StateT s m (ParserInput m)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ParserInput m -> Bool) -> m (ParserInput m)
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 = m (ParserInput m) -> StateT s m (ParserInput m)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (ParserInput m) -> StateT s m (ParserInput m))
-> ((Char -> Bool) -> m (ParserInput m))
-> (Char -> Bool)
-> StateT s m (ParserInput m)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Char -> Bool) -> m (ParserInput m)
forall (m :: * -> *).
InputCharParsing m =>
(Char -> Bool) -> m (ParserInput m)
satisfyCharInput
notSatisfyChar :: (Char -> Bool) -> StateT s m ()
notSatisfyChar = m () -> StateT s m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> StateT s m ())
-> ((Char -> Bool) -> m ()) -> (Char -> Bool) -> StateT s m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Char -> Bool) -> m ()
forall (m :: * -> *). InputCharParsing m => (Char -> Bool) -> m ()
notSatisfyChar
scanChars :: state
-> (state -> Char -> Maybe state)
-> StateT s m (ParserInput (StateT s m))
scanChars state
state state -> Char -> Maybe state
f = m (ParserInput m) -> StateT s m (ParserInput m)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (state -> (state -> Char -> Maybe state) -> m (ParserInput m)
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 = m (ParserInput m) -> StateT s m (ParserInput m)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (ParserInput m) -> StateT s m (ParserInput m))
-> ((Char -> Bool) -> m (ParserInput m))
-> (Char -> Bool)
-> StateT s m (ParserInput m)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Char -> Bool) -> m (ParserInput m)
forall (m :: * -> *).
InputCharParsing m =>
(Char -> Bool) -> m (ParserInput m)
takeCharsWhile
takeCharsWhile1 :: (Char -> Bool) -> StateT s m (ParserInput (StateT s m))
takeCharsWhile1 = m (ParserInput m) -> StateT s m (ParserInput m)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (ParserInput m) -> StateT s m (ParserInput m))
-> ((Char -> Bool) -> m (ParserInput m))
-> (Char -> Bool)
-> StateT s m (ParserInput m)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Char -> Bool) -> m (ParserInput m)
forall (m :: * -> *).
InputCharParsing m =>
(Char -> Bool) -> m (ParserInput m)
takeCharsWhile1
instance (MonadPlus m, ConsumedInputParsing m) => ConsumedInputParsing (Strict.StateT s m) where
match :: StateT s m a -> StateT s m (ParserInput (StateT s m), a)
match = (m a -> m (ParserInput m, a))
-> StateT s m a -> StateT s m (ParserInput m, a)
forall (m :: * -> *) a b s.
Applicative m =>
(m a -> m b) -> StateT s m a -> StateT s m b
mapStrictStateT m a -> m (ParserInput m, a)
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 = m (ParserInput m) -> RWST r w s m (ParserInput m)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m (ParserInput m)
forall (m :: * -> *). InputParsing m => m (ParserInput m)
getInput
getSourcePos :: RWST r w s m (ParserPosition (RWST r w s m))
getSourcePos = m (ParserPosition m) -> RWST r w s m (ParserPosition m)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m (ParserPosition m)
forall (m :: * -> *). InputParsing m => m (ParserPosition m)
getSourcePos
anyToken :: RWST r w s m (ParserInput (RWST r w s m))
anyToken = m (ParserInput m) -> RWST r w s m (ParserInput m)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m (ParserInput m)
forall (m :: * -> *). InputParsing m => m (ParserInput m)
anyToken
take :: Int -> RWST r w s m (ParserInput (RWST r w s m))
take = m (ParserInput m) -> RWST r w s m (ParserInput m)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (ParserInput m) -> RWST r w s m (ParserInput m))
-> (Int -> m (ParserInput m))
-> Int
-> RWST r w s m (ParserInput m)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> m (ParserInput m)
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 = m (ParserInput m) -> RWST r w s m (ParserInput m)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (ParserInput m) -> RWST r w s m (ParserInput m))
-> ((ParserInput m -> Bool) -> m (ParserInput m))
-> (ParserInput m -> Bool)
-> RWST r w s m (ParserInput m)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ParserInput m -> Bool) -> m (ParserInput m)
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 = m () -> RWST r w s m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> RWST r w s m ())
-> ((ParserInput m -> Bool) -> m ())
-> (ParserInput m -> Bool)
-> RWST r w s m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ParserInput m -> Bool) -> m ()
forall (m :: * -> *).
InputParsing m =>
(ParserInput m -> Bool) -> m ()
notSatisfy
scan :: 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 = m (ParserInput m) -> RWST r w s m (ParserInput m)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (state
-> (state -> ParserInput m -> Maybe state) -> m (ParserInput m)
forall (m :: * -> *) state.
InputParsing m =>
state
-> (state -> ParserInput m -> Maybe state) -> m (ParserInput m)
scan state
state state -> ParserInput m -> Maybe 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 = m (ParserInput m) -> RWST r w s m (ParserInput m)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (ParserInput m) -> RWST r w s m (ParserInput m))
-> (ParserInput m -> m (ParserInput m))
-> ParserInput m
-> RWST r w s m (ParserInput m)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ParserInput m -> m (ParserInput m)
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 = m (ParserInput m) -> RWST r w s m (ParserInput m)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (ParserInput m) -> RWST r w s m (ParserInput m))
-> ((ParserInput m -> Bool) -> m (ParserInput m))
-> (ParserInput m -> Bool)
-> RWST r w s m (ParserInput m)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ParserInput m -> Bool) -> m (ParserInput m)
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 = m (ParserInput m) -> RWST r w s m (ParserInput m)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (ParserInput m) -> RWST r w s m (ParserInput m))
-> ((ParserInput m -> Bool) -> m (ParserInput m))
-> (ParserInput m -> Bool)
-> RWST r w s m (ParserInput m)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ParserInput m -> Bool) -> m (ParserInput m)
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 = m (ParserInput m) -> RWST r w s m (ParserInput m)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (ParserInput m) -> RWST r w s m (ParserInput m))
-> ((Char -> Bool) -> m (ParserInput m))
-> (Char -> Bool)
-> RWST r w s m (ParserInput m)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Char -> Bool) -> m (ParserInput m)
forall (m :: * -> *).
InputCharParsing m =>
(Char -> Bool) -> m (ParserInput m)
satisfyCharInput
notSatisfyChar :: (Char -> Bool) -> RWST r w s m ()
notSatisfyChar = m () -> RWST r w s m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> RWST r w s m ())
-> ((Char -> Bool) -> m ()) -> (Char -> Bool) -> RWST r w s m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Char -> Bool) -> m ()
forall (m :: * -> *). InputCharParsing m => (Char -> Bool) -> m ()
notSatisfyChar
scanChars :: state
-> (state -> Char -> Maybe state)
-> RWST r w s m (ParserInput (RWST r w s m))
scanChars state
state state -> Char -> Maybe state
f = m (ParserInput m) -> RWST r w s m (ParserInput m)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (state -> (state -> Char -> Maybe state) -> m (ParserInput m)
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 = m (ParserInput m) -> RWST r w s m (ParserInput m)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (ParserInput m) -> RWST r w s m (ParserInput m))
-> ((Char -> Bool) -> m (ParserInput m))
-> (Char -> Bool)
-> RWST r w s m (ParserInput m)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Char -> Bool) -> m (ParserInput m)
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 = m (ParserInput m) -> RWST r w s m (ParserInput m)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (ParserInput m) -> RWST r w s m (ParserInput m))
-> ((Char -> Bool) -> m (ParserInput m))
-> (Char -> Bool)
-> RWST r w s m (ParserInput m)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Char -> Bool) -> m (ParserInput m)
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 :: RWST r w s m a -> RWST r w s m (ParserInput (RWST r w s m), a)
match = (m a -> m (ParserInput m, a))
-> RWST r w s m a -> RWST r w s m (ParserInput m, a)
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 m a -> m (ParserInput m, a)
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 = m (ParserInput m) -> RWST r w s m (ParserInput m)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m (ParserInput m)
forall (m :: * -> *). InputParsing m => m (ParserInput m)
getInput
getSourcePos :: RWST r w s m (ParserPosition (RWST r w s m))
getSourcePos = m (ParserPosition m) -> RWST r w s m (ParserPosition m)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m (ParserPosition m)
forall (m :: * -> *). InputParsing m => m (ParserPosition m)
getSourcePos
anyToken :: RWST r w s m (ParserInput (RWST r w s m))
anyToken = m (ParserInput m) -> RWST r w s m (ParserInput m)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m (ParserInput m)
forall (m :: * -> *). InputParsing m => m (ParserInput m)
anyToken
take :: Int -> RWST r w s m (ParserInput (RWST r w s m))
take = m (ParserInput m) -> RWST r w s m (ParserInput m)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (ParserInput m) -> RWST r w s m (ParserInput m))
-> (Int -> m (ParserInput m))
-> Int
-> RWST r w s m (ParserInput m)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> m (ParserInput m)
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 = m (ParserInput m) -> RWST r w s m (ParserInput m)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (ParserInput m) -> RWST r w s m (ParserInput m))
-> ((ParserInput m -> Bool) -> m (ParserInput m))
-> (ParserInput m -> Bool)
-> RWST r w s m (ParserInput m)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ParserInput m -> Bool) -> m (ParserInput m)
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 = m () -> RWST r w s m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> RWST r w s m ())
-> ((ParserInput m -> Bool) -> m ())
-> (ParserInput m -> Bool)
-> RWST r w s m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ParserInput m -> Bool) -> m ()
forall (m :: * -> *).
InputParsing m =>
(ParserInput m -> Bool) -> m ()
notSatisfy
scan :: 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 = m (ParserInput m) -> RWST r w s m (ParserInput m)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (state
-> (state -> ParserInput m -> Maybe state) -> m (ParserInput m)
forall (m :: * -> *) state.
InputParsing m =>
state
-> (state -> ParserInput m -> Maybe state) -> m (ParserInput m)
scan state
state state -> ParserInput m -> Maybe 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 = m (ParserInput m) -> RWST r w s m (ParserInput m)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (ParserInput m) -> RWST r w s m (ParserInput m))
-> (ParserInput m -> m (ParserInput m))
-> ParserInput m
-> RWST r w s m (ParserInput m)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ParserInput m -> m (ParserInput m)
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 = m (ParserInput m) -> RWST r w s m (ParserInput m)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (ParserInput m) -> RWST r w s m (ParserInput m))
-> ((ParserInput m -> Bool) -> m (ParserInput m))
-> (ParserInput m -> Bool)
-> RWST r w s m (ParserInput m)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ParserInput m -> Bool) -> m (ParserInput m)
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 = m (ParserInput m) -> RWST r w s m (ParserInput m)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (ParserInput m) -> RWST r w s m (ParserInput m))
-> ((ParserInput m -> Bool) -> m (ParserInput m))
-> (ParserInput m -> Bool)
-> RWST r w s m (ParserInput m)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ParserInput m -> Bool) -> m (ParserInput m)
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 = m (ParserInput m) -> RWST r w s m (ParserInput m)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (ParserInput m) -> RWST r w s m (ParserInput m))
-> ((Char -> Bool) -> m (ParserInput m))
-> (Char -> Bool)
-> RWST r w s m (ParserInput m)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Char -> Bool) -> m (ParserInput m)
forall (m :: * -> *).
InputCharParsing m =>
(Char -> Bool) -> m (ParserInput m)
satisfyCharInput
notSatisfyChar :: (Char -> Bool) -> RWST r w s m ()
notSatisfyChar = m () -> RWST r w s m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> RWST r w s m ())
-> ((Char -> Bool) -> m ()) -> (Char -> Bool) -> RWST r w s m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Char -> Bool) -> m ()
forall (m :: * -> *). InputCharParsing m => (Char -> Bool) -> m ()
notSatisfyChar
scanChars :: state
-> (state -> Char -> Maybe state)
-> RWST r w s m (ParserInput (RWST r w s m))
scanChars state
state state -> Char -> Maybe state
f = m (ParserInput m) -> RWST r w s m (ParserInput m)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (state -> (state -> Char -> Maybe state) -> m (ParserInput m)
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 = m (ParserInput m) -> RWST r w s m (ParserInput m)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (ParserInput m) -> RWST r w s m (ParserInput m))
-> ((Char -> Bool) -> m (ParserInput m))
-> (Char -> Bool)
-> RWST r w s m (ParserInput m)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Char -> Bool) -> m (ParserInput m)
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 = m (ParserInput m) -> RWST r w s m (ParserInput m)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (ParserInput m) -> RWST r w s m (ParserInput m))
-> ((Char -> Bool) -> m (ParserInput m))
-> (Char -> Bool)
-> RWST r w s m (ParserInput m)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Char -> Bool) -> m (ParserInput m)
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 :: RWST r w s m a -> RWST r w s m (ParserInput (RWST r w s m), a)
match = (m a -> m (ParserInput m, a))
-> RWST r w s m a -> RWST r w s m (ParserInput m, a)
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 m a -> m (ParserInput m, a)
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 = Parser ByteString ByteString -> Parser ByteString ByteString
forall (m :: * -> *) a. LookAheadParsing m => m a -> m a
lookAhead Parser ByteString ByteString
Attoparsec.takeByteString
anyToken :: Parser (ParserInput Parser)
anyToken = Int -> Parser ByteString ByteString
Attoparsec.take Int
1
take :: Int -> Parser (ParserInput Parser)
take = Int -> Parser ByteString ByteString
Int -> Parser (ParserInput Parser)
Attoparsec.take
satisfy :: (ParserInput Parser -> Bool) -> Parser (ParserInput Parser)
satisfy ParserInput Parser -> Bool
predicate = (Word8 -> ByteString)
-> (ByteString -> Bool) -> Parser ByteString ByteString
forall a. (Word8 -> a) -> (a -> Bool) -> Parser a
Attoparsec.satisfyWith Word8 -> ByteString
ByteString.singleton ByteString -> Bool
ParserInput Parser -> Bool
predicate
string :: ParserInput Parser -> Parser (ParserInput Parser)
string = ByteString -> Parser ByteString ByteString
ParserInput Parser -> Parser (ParserInput Parser)
Attoparsec.string
takeWhile :: (ParserInput Parser -> Bool) -> Parser (ParserInput Parser)
takeWhile ParserInput Parser -> Bool
predicate = (Word8 -> Bool) -> Parser ByteString ByteString
Attoparsec.takeWhile (ByteString -> Bool
ParserInput Parser -> Bool
predicate (ByteString -> Bool) -> (Word8 -> ByteString) -> Word8 -> Bool
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 ByteString
Attoparsec.takeWhile1 (ByteString -> Bool
ParserInput Parser -> Bool
predicate (ByteString -> Bool) -> (Word8 -> ByteString) -> Word8 -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Word8 -> ByteString
ByteString.singleton)
scan :: state
-> (state -> ParserInput Parser -> Maybe state)
-> Parser (ParserInput Parser)
scan state
state state -> ParserInput Parser -> Maybe state
f = state
-> (state -> Word8 -> Maybe state) -> Parser ByteString ByteString
forall s.
s -> (s -> Word8 -> Maybe s) -> Parser ByteString 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 (Char -> ByteString)
-> Parser ByteString Char -> Parser ByteString ByteString
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Char -> Bool) -> Parser ByteString Char
Attoparsec.Char8.satisfy Char -> Bool
predicate
scanChars :: state
-> (state -> Char -> Maybe state) -> Parser (ParserInput Parser)
scanChars = state
-> (state -> Char -> Maybe state) -> Parser (ParserInput Parser)
forall s.
s -> (s -> Char -> Maybe s) -> Parser ByteString ByteString
Attoparsec.Char8.scan
takeCharsWhile :: (Char -> Bool) -> Parser (ParserInput Parser)
takeCharsWhile = (Char -> Bool) -> Parser ByteString ByteString
(Char -> Bool) -> Parser (ParserInput Parser)
Attoparsec.Char8.takeWhile
takeCharsWhile1 :: (Char -> Bool) -> Parser (ParserInput Parser)
takeCharsWhile1 = (Char -> Bool) -> Parser ByteString ByteString
(Char -> Bool) -> Parser (ParserInput Parser)
Attoparsec.Char8.takeWhile1
instance ConsumedInputParsing Attoparsec.Parser where
match :: Parser a -> Parser (ParserInput Parser, a)
match = Parser a -> Parser (ParserInput Parser, a)
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 = Parser Text Text -> Parser Text Text
forall (m :: * -> *) a. LookAheadParsing m => m a -> m a
lookAhead Parser Text Text
Attoparsec.Text.takeText
anyToken :: Parser (ParserInput Parser)
anyToken = Int -> Parser Text Text
Attoparsec.Text.take Int
1
take :: Int -> Parser (ParserInput Parser)
take = Int -> Parser Text Text
Int -> Parser (ParserInput Parser)
Attoparsec.Text.take
satisfy :: (ParserInput Parser -> Bool) -> Parser (ParserInput Parser)
satisfy ParserInput Parser -> Bool
predicate = (Char -> Text) -> (Text -> Bool) -> Parser Text Text
forall a. (Char -> a) -> (a -> Bool) -> Parser a
Attoparsec.Text.satisfyWith Char -> Text
Text.singleton Text -> Bool
ParserInput Parser -> Bool
predicate
string :: ParserInput Parser -> Parser (ParserInput Parser)
string = Text -> Parser Text Text
ParserInput Parser -> Parser (ParserInput Parser)
Attoparsec.Text.string
takeWhile :: (ParserInput Parser -> Bool) -> Parser (ParserInput Parser)
takeWhile ParserInput Parser -> Bool
predicate = (Char -> Bool) -> Parser Text Text
Attoparsec.Text.takeWhile (Text -> Bool
ParserInput Parser -> Bool
predicate (Text -> Bool) -> (Char -> Text) -> Char -> Bool
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 Text
Attoparsec.Text.takeWhile1 (Text -> Bool
ParserInput Parser -> Bool
predicate (Text -> Bool) -> (Char -> Text) -> Char -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> Text
Text.singleton)
scan :: state
-> (state -> ParserInput Parser -> Maybe state)
-> Parser (ParserInput Parser)
scan state
state state -> ParserInput Parser -> Maybe state
f = state -> (state -> Char -> Maybe state) -> Parser Text Text
forall s. s -> (s -> Char -> Maybe s) -> Parser Text 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 (Char -> Text) -> Parser Text Char -> Parser Text Text
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Char -> Bool) -> Parser Text Char
Attoparsec.Text.satisfy Char -> Bool
predicate
scanChars :: state
-> (state -> Char -> Maybe state) -> Parser (ParserInput Parser)
scanChars = state
-> (state -> Char -> Maybe state) -> Parser (ParserInput Parser)
forall s. s -> (s -> Char -> Maybe s) -> Parser Text Text
Attoparsec.Text.scan
takeCharsWhile :: (Char -> Bool) -> Parser (ParserInput Parser)
takeCharsWhile = (Char -> Bool) -> Parser Text Text
(Char -> Bool) -> Parser (ParserInput Parser)
Attoparsec.Text.takeWhile
takeCharsWhile1 :: (Char -> Bool) -> Parser (ParserInput Parser)
takeCharsWhile1 = (Char -> Bool) -> Parser Text Text
(Char -> Bool) -> Parser (ParserInput Parser)
Attoparsec.Text.takeWhile1
instance ConsumedInputParsing Attoparsec.Text.Parser where
match :: Parser a -> Parser (ParserInput Parser, a)
match = Parser a -> Parser (ParserInput Parser, a)
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 = ParsecT s u m (ParserInput (ParsecT s u m))
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 <- ParsecT s u m s
forall (m :: * -> *) s u. Monad m => ParsecT s u m s
Parsec.getInput
case s -> Maybe (s, s)
forall m. FactorialMonoid m => m -> Maybe (m, m)
Factorial.splitPrimePrefix s
rest
of Just (s
x, s
rest') -> s
x s -> ParsecT s u m () -> ParsecT s u m s
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ s -> ParsecT s u m ()
forall (m :: * -> *) s u. Monad m => s -> ParsecT s u m ()
Parsec.setInput s
rest'
Maybe (s, s)
Nothing -> String -> ParsecT s u m s
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 <- ParsecT s u m s
forall (m :: * -> *) s u. Monad m => ParsecT s u m s
Parsec.getInput
case Int -> s -> (s, s)
forall m. FactorialMonoid m => Int -> m -> (m, m)
Factorial.splitAt Int
n s
rest
of (s
prefix, s
suffix) | s -> Int
forall m. Factorial m => m -> Int
Factorial.length s
prefix Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
n -> s
prefix s -> ParsecT s u m () -> ParsecT s u m s
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ s -> ParsecT s u m ()
forall (m :: * -> *) s u. Monad m => s -> ParsecT s u m ()
Parsec.setInput s
suffix
(s, s)
_ -> String -> ParsecT s u m s
forall s u (m :: * -> *) a. String -> ParsecT s u m a
Parsec.parserFail (String
"take " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Int -> String
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 = (Char -> s) -> ParsecT s u m Char -> ParsecT s u m s
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Char -> s
forall t. TextualMonoid t => Char -> t
Textual.singleton (ParsecT s u m Char -> ParsecT s u m s)
-> ((Char -> Bool) -> ParsecT s u m Char)
-> (Char -> Bool)
-> ParsecT s u m s
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Char -> Bool) -> ParsecT s u m Char
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 = Get ByteString -> Lazy Get ByteString
forall (f :: * -> *) a. f a -> Lazy f a
Lazy (Get ByteString -> Get ByteString
forall a. Get a -> Get a
Binary.lookAhead Get ByteString
Binary.getRemainingLazyByteString)
getSourcePos :: Lazy Get (ParserPosition (Lazy Get))
getSourcePos = Get Int -> Lazy Get Int
forall (f :: * -> *) a. f a -> Lazy f a
Lazy (Int -> Int
fromStart (Int -> Int) -> (Int64 -> Int) -> Int64 -> Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int64 -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int64 -> Int) -> Get Int64 -> Get Int
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Get Int64
Binary.bytesRead)
anyToken :: Lazy Get (ParserInput (Lazy Get))
anyToken = Get ByteString -> Lazy Get ByteString
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 = Get ByteString -> Lazy Get ByteString
forall (f :: * -> *) a. f a -> Lazy f a
Lazy (Int64 -> Get ByteString
Binary.getLazyByteString (Int64 -> Get ByteString) -> Int64 -> Get ByteString
forall a b. (a -> b) -> a -> b
$ Int -> Int64
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 = Get ByteString -> Strict Get ByteString
forall (f :: * -> *) a. f a -> Strict f a
Strict (ByteString -> ByteString
Lazy.toStrict (ByteString -> ByteString) -> Get ByteString -> Get ByteString
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Get ByteString -> Get ByteString
forall a. Get a -> Get a
Binary.lookAhead Get ByteString
Binary.getRemainingLazyByteString)
getSourcePos :: Strict Get (ParserPosition (Strict Get))
getSourcePos = Get Int -> Strict Get Int
forall (f :: * -> *) a. f a -> Strict f a
Strict (Int -> Int
fromStart (Int -> Int) -> (Int64 -> Int) -> Int64 -> Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int64 -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int64 -> Int) -> Get Int64 -> Get Int
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Get Int64
Binary.bytesRead)
anyToken :: Strict Get (ParserInput (Strict Get))
anyToken = Get ByteString -> Strict Get ByteString
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 = Get ByteString -> Strict Get ByteString
forall (f :: * -> *) a. f a -> Strict f a
Strict (Int -> Get ByteString
Binary.getByteString Int
n)
instance ConsumedInputParsing (Lazy Binary.Get) where
match :: Lazy Get a -> Lazy Get (ParserInput (Lazy Get), a)
match (Lazy Get a
p) = Get (ByteString, a) -> Lazy Get (ByteString, a)
forall (f :: * -> *) a. f a -> Lazy f a
Lazy (Get (ByteString, a) -> Lazy Get (ByteString, a))
-> Get (ByteString, a) -> Lazy Get (ByteString, a)
forall a b. (a -> b) -> a -> b
$ do ByteString
input <- Get ByteString -> Get ByteString
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
(ByteString, a) -> Get (ByteString, a)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Int64 -> ByteString -> ByteString
Lazy.take (Int64
pos' Int64 -> Int64 -> Int64
forall a. Num a => a -> a -> a
- Int64
pos) ByteString
input, a
result)
instance ConsumedInputParsing (Strict Binary.Get) where
match :: Strict Get a -> Strict Get (ParserInput (Strict Get), a)
match (Strict Get a
p) = Get (ByteString, a) -> Strict Get (ByteString, a)
forall (f :: * -> *) a. f a -> Strict f a
Strict (Get (ByteString, a) -> Strict Get (ByteString, a))
-> Get (ByteString, a) -> Strict Get (ByteString, a)
forall a b. (a -> b) -> a -> b
$ do ByteString
input <- Get ByteString -> Get ByteString
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
(ByteString, a) -> Get (ByteString, a)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (ByteString -> ByteString
Lazy.toStrict (Int64 -> ByteString -> ByteString
Lazy.take (Int64
pos' Int64 -> Int64 -> Int64
forall a. Num a => a -> a -> a
- Int64
pos) ByteString
input), a
result)
#endif