-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/

-- | Fast combinator parsing for bytestrings and text
--   
--   A fast parser combinator library, aimed particularly at dealing
--   efficiently with network protocols and complicated text/binary file
--   formats.
@package attoparsec
@version 0.14.4

-- | Fast set membership tests for Word8 and 8-bit Char
--   values. The set representation is unboxed for efficiency. For small
--   sets, we test for membership using a binary search. For larger sets,
--   we use a lookup table.
module Data.Attoparsec.ByteString.FastSet
data FastSet
fromList :: [Word8] -> FastSet

-- | Create a set.
set :: ByteString -> FastSet

-- | Check the set for membership. Only works with 8-bit characters:
--   characters above code point 255 will give wrong answers.
memberChar :: Char -> FastSet -> Bool

-- | Check the set for membership.
memberWord8 :: Word8 -> FastSet -> Bool
fromSet :: FastSet -> ByteString
charClass :: String -> FastSet
instance GHC.Classes.Eq Data.Attoparsec.ByteString.FastSet.FastSet
instance GHC.Classes.Ord Data.Attoparsec.ByteString.FastSet.FastSet
instance GHC.Internal.Show.Show Data.Attoparsec.ByteString.FastSet.FastSet

module Data.Attoparsec.Internal.Compat
withPS :: ByteString -> (ForeignPtr Word8 -> Int -> Int -> r) -> r
mkPS :: ForeignPtr Word8 -> Int -> Int -> ByteString

module Data.Attoparsec.Internal.Fhthagn

-- | Just like unsafePerformIO, but we inline it. Big performance gains as
--   it exposes lots of things to further inlining. Very unsafe. In
--   particular, you should do no memory allocation inside an
--   inlinePerformIO block. On Hugs this is just
--   unsafePerformIO.
inlinePerformIO :: IO a -> a

-- | An "immutable" buffer that supports cheap appends.
--   
--   A Buffer is divided into an immutable read-only zone, followed by a
--   mutable area that we've preallocated, but not yet written to.
--   
--   We overallocate at the end of a Buffer so that we can cheaply append.
--   Since a user of an existing Buffer cannot see past the end of its
--   immutable zone into the data that will change during an append, this
--   is safe.
--   
--   Once we run out of space at the end of a Buffer, we do the usual
--   doubling of the buffer size.
--   
--   The fact of having a mutable buffer really helps with performance, but
--   it does have a consequence: if someone misuses the Partial API that
--   attoparsec uses by calling the same continuation repeatedly (which
--   never makes sense in practice), they could overwrite data.
--   
--   Since the API *looks* pure, it should *act* pure, too, so we use two
--   generation counters (one mutable, one immutable) to track the number
--   of appends to a mutable buffer. If the counters ever get out of sync,
--   someone is appending twice to a mutable buffer, so we duplicate the
--   entire buffer in order to preserve the immutability of its older self.
--   
--   While we could go a step further and gain protection against API abuse
--   on a multicore system, by use of an atomic increment instruction to
--   bump the mutable generation counter, that would be very expensive, and
--   feels like it would also be in the realm of the ridiculous. Clients
--   should never call a continuation more than once; we lack a linear type
--   system that could enforce this; and there's only so far we should go
--   to accommodate broken uses.
module Data.Attoparsec.ByteString.Buffer
data Buffer

-- | The initial Buffer has no mutable zone, so we can avoid all
--   copies in the (hopefully) common case of no further input being fed to
--   us.
buffer :: ByteString -> Buffer
unbuffer :: Buffer -> ByteString
pappend :: Buffer -> ByteString -> Buffer
length :: Buffer -> Int
unsafeIndex :: Buffer -> Int -> Word8
substring :: Int -> Int -> Buffer -> ByteString
unsafeDrop :: Int -> Buffer -> ByteString
instance GHC.Internal.Base.Monoid Data.Attoparsec.ByteString.Buffer.Buffer
instance GHC.Internal.Base.Semigroup Data.Attoparsec.ByteString.Buffer.Buffer
instance GHC.Internal.Show.Show Data.Attoparsec.ByteString.Buffer.Buffer

-- | This module is deprecated, and both the module and Number type
--   will be removed in the next major release. Use the scientific
--   package and the Scientific type instead.
--   
--   A simple number type, useful for parsing both exact and inexact
--   quantities without losing much precision.

-- | Deprecated: This module will be removed in the next major
--   release.
module Data.Attoparsec.Number

-- | A numeric type that can represent integers accurately, and floating
--   point numbers to the precision of a Double.
--   
--   Note: this type is deprecated, and will be removed in the next
--   major release. Use the Scientific type instead.
data Number
I :: !Integer -> Number
D :: {-# UNPACK #-} !Double -> Number
instance GHC.Internal.Data.Data.Data Data.Attoparsec.Number.Number
instance GHC.Classes.Eq Data.Attoparsec.Number.Number
instance GHC.Internal.Real.Fractional Data.Attoparsec.Number.Number
instance Control.DeepSeq.NFData Data.Attoparsec.Number.Number
instance GHC.Internal.Num.Num Data.Attoparsec.Number.Number
instance GHC.Classes.Ord Data.Attoparsec.Number.Number
instance GHC.Internal.Real.RealFrac Data.Attoparsec.Number.Number
instance GHC.Internal.Real.Real Data.Attoparsec.Number.Number
instance GHC.Internal.Show.Show Data.Attoparsec.Number.Number

-- | An immutable buffer that supports cheap appends.
module Data.Attoparsec.Text.Buffer
data Buffer

-- | The initial Buffer has no mutable zone, so we can avoid all
--   copies in the (hopefully) common case of no further input being fed to
--   us.
buffer :: Text -> Buffer
unbuffer :: Buffer -> Text
unbufferAt :: Int -> Buffer -> Text
length :: Buffer -> Int
pappend :: Buffer -> Text -> Buffer

-- | O(1) Iterate (unsafely) one step forwards through a UTF-8
--   array, returning the current character and the delta to add to give
--   the next offset to iterate at.
iter :: Buffer -> Int -> Iter

-- | O(1) Iterate one step through a UTF-8 array, returning the
--   delta to add to give the next offset to iterate at.
iter_ :: Buffer -> Int -> Int
substring :: Int -> Int -> Buffer -> Text
lengthCodeUnits :: Text -> Int
dropCodeUnits :: Int -> Buffer -> Text
instance GHC.Internal.Base.Monoid Data.Attoparsec.Text.Buffer.Buffer
instance GHC.Internal.Base.Semigroup Data.Attoparsec.Text.Buffer.Buffer
instance GHC.Internal.Show.Show Data.Attoparsec.Text.Buffer.Buffer

-- | Simple, efficient parser combinators, loosely based on the Parsec
--   library.
module Data.Attoparsec.Internal.Types

-- | The core parser type. This is parameterised over the type i
--   of string being processed.
--   
--   This type is an instance of the following classes:
--   
--   
--   
- Monad, where fail throws an exception (i.e. fails)
--   with an error message.
--   
- Functor and Applicative, which follow the usual
--   definitions.
--   
- MonadPlus, where mzero fails (with no error message)
--   and mplus executes the right-hand parser if the left-hand one
--   fails. When the parser on the right executes, the input is reset to
--   the same state as the parser on the left started with. (In other
--   words, attoparsec is a backtracking parser that supports arbitrary
--   lookahead.)
--   
- Alternative, which follows MonadPlus.
--   
newtype Parser i a
Parser :: (forall r. () => State i -> Pos -> More -> Failure i (State i) r -> Success i (State i) a r -> IResult i r) -> Parser i a
[runParser] :: Parser i a -> forall r. () => State i -> Pos -> More -> Failure i (State i) r -> Success i (State i) a r -> IResult i r
type family State i
type Failure i t r = t -> Pos -> More -> [String] -> String -> IResult i r
type Success i t a r = t -> Pos -> More -> a -> IResult i r
newtype Pos
Pos :: Int -> Pos
[fromPos] :: Pos -> Int

-- | The result of a parse. This is parameterised over the type i
--   of string that was processed.
--   
--   This type is an instance of Functor, where fmap
--   transforms the value in a Done result.
data IResult i r

-- | The parse failed. The i parameter is the input that had not
--   yet been consumed when the failure occurred. The
--   [String] is a list of contexts in which the
--   error occurred. The String is the message describing the error,
--   if any.
Fail :: i -> [String] -> String -> IResult i r

-- | Supply this continuation with more input so that the parser can
--   resume. To indicate that no more input is available, pass an empty
--   string to the continuation.
--   
--   Note: if you get a Partial result, do not call its
--   continuation more than once.
Partial :: (i -> IResult i r) -> IResult i r

-- | The parse succeeded. The i parameter is the input that had
--   not yet been consumed (if any) when the parse succeeded.
Done :: i -> r -> IResult i r

-- | Have we read all available input?
data More
Complete :: More
Incomplete :: More

-- | An associative operation.
--   
--   
Examples
--   
--   
--   >>> [1,2,3] <> [4,5,6]
--   [1,2,3,4,5,6]
--   
--   
--   
--   >>> Just [1, 2, 3] <> Just [4, 5, 6]
--   Just [1,2,3,4,5,6]
--   
--   
--   
--   >>> putStr "Hello, " <> putStrLn "World!"
--   Hello, World!
--   
(<>) :: Semigroup a => a -> a -> a
infixr 6 <>

-- | A common interface for input chunks.
class Monoid c => Chunk c where {
    type ChunkElem c;
}

-- | Test if the chunk is empty.
nullChunk :: Chunk c => c -> Bool

-- | Append chunk to a buffer.
pappendChunk :: Chunk c => State c -> c -> State c

-- | Position at the end of a buffer. The first argument is ignored.
atBufferEnd :: Chunk c => c -> State c -> Pos

-- | Return the buffer element at the given position along with its length.
bufferElemAt :: Chunk c => c -> Pos -> State c -> Maybe (ChunkElem c, Int)

-- | Map an element to the corresponding character. The first argument is
--   ignored.
chunkElemToChar :: Chunk c => c -> ChunkElem c -> Char
instance GHC.Internal.Base.Alternative (Data.Attoparsec.Internal.Types.Parser i)
instance GHC.Internal.Base.Applicative (Data.Attoparsec.Internal.Types.Parser i)
instance Data.Attoparsec.Internal.Types.Chunk Data.ByteString.Internal.Type.ByteString
instance Data.Attoparsec.Internal.Types.Chunk Data.Text.Internal.Text
instance GHC.Classes.Eq Data.Attoparsec.Internal.Types.More
instance GHC.Classes.Eq Data.Attoparsec.Internal.Types.Pos
instance GHC.Internal.Base.Functor (Data.Attoparsec.Internal.Types.IResult i)
instance GHC.Internal.Base.Functor (Data.Attoparsec.Internal.Types.Parser i)
instance GHC.Internal.Control.Monad.Fail.MonadFail (Data.Attoparsec.Internal.Types.Parser i)
instance GHC.Internal.Base.Monad (Data.Attoparsec.Internal.Types.Parser i)
instance GHC.Internal.Base.MonadPlus (Data.Attoparsec.Internal.Types.Parser i)
instance GHC.Internal.Base.Monoid Data.Attoparsec.Internal.Types.More
instance GHC.Internal.Base.Monoid (Data.Attoparsec.Internal.Types.Parser i a)
instance (Control.DeepSeq.NFData i, Control.DeepSeq.NFData r) => Control.DeepSeq.NFData (Data.Attoparsec.Internal.Types.IResult i r)
instance GHC.Internal.Num.Num Data.Attoparsec.Internal.Types.Pos
instance GHC.Classes.Ord Data.Attoparsec.Internal.Types.Pos
instance GHC.Internal.Base.Semigroup Data.Attoparsec.Internal.Types.More
instance GHC.Internal.Base.Semigroup (Data.Attoparsec.Internal.Types.Parser i a)
instance (GHC.Internal.Show.Show i, GHC.Internal.Show.Show r) => GHC.Internal.Show.Show (Data.Attoparsec.Internal.Types.IResult i r)
instance GHC.Internal.Show.Show Data.Attoparsec.Internal.Types.More
instance GHC.Internal.Show.Show Data.Attoparsec.Internal.Types.Pos

-- | Simple, efficient parser combinators, loosely based on the Parsec
--   library.
module Data.Attoparsec.Internal

-- | Compare two IResult values for equality.
--   
--   If both IResults are Partial, the result will be
--   Nothing, as they are incomplete and hence their equality cannot
--   be known. (This is why there is no Eq instance for
--   IResult.)
compareResults :: (Eq i, Eq r) => IResult i r -> IResult i r -> Maybe Bool

-- | Ask for input. If we receive any, pass the augmented input to a
--   success continuation, otherwise to a failure continuation.
prompt :: Chunk t => State t -> Pos -> More -> (State t -> Pos -> More -> IResult t r) -> (State t -> Pos -> More -> IResult t r) -> IResult t r

-- | Immediately demand more input via a Partial continuation
--   result.
demandInput :: Chunk t => Parser t ()

-- | Immediately demand more input via a Partial continuation
--   result. Return the new input.
demandInput_ :: Chunk t => Parser t t

-- | This parser always succeeds. It returns True if any input is
--   available either immediately or on demand, and False if the end
--   of all input has been reached.
wantInput :: Chunk t => Parser t Bool

-- | Match only if all input has been consumed.
endOfInput :: Chunk t => Parser t ()

-- | Return an indication of whether the end of input has been reached.
atEnd :: Chunk t => Parser t Bool

-- | The parser satisfyElem p succeeds for any chunk element for
--   which the predicate p returns True. Returns the
--   element that is actually parsed.
satisfyElem :: Chunk t => (ChunkElem t -> Bool) -> Parser t (ChunkElem t)

-- | Concatenate a monoid after reversing its elements. Used to glue
--   together a series of textual chunks that have been accumulated
--   "backwards".
concatReverse :: Monoid m => [m] -> m

-- | Fast set membership tests for Char values. We test for
--   membership using a hashtable implemented with Robin Hood collision
--   resolution. The set representation is unboxed, and the characters and
--   hashes interleaved, for efficiency.
module Data.Attoparsec.Text.FastSet
data FastSet
fromList :: String -> FastSet
set :: Text -> FastSet

-- | Check the set for membership.
member :: Char -> FastSet -> Bool
charClass :: String -> FastSet

-- | Simple, efficient parser combinators for strings, loosely based on the
--   Parsec library.
module Data.Attoparsec.Types

-- | The core parser type. This is parameterised over the type i
--   of string being processed.
--   
--   This type is an instance of the following classes:
--   
--   
--   
- Monad, where fail throws an exception (i.e. fails)
--   with an error message.
--   
- Functor and Applicative, which follow the usual
--   definitions.
--   
- MonadPlus, where mzero fails (with no error message)
--   and mplus executes the right-hand parser if the left-hand one
--   fails. When the parser on the right executes, the input is reset to
--   the same state as the parser on the left started with. (In other
--   words, attoparsec is a backtracking parser that supports arbitrary
--   lookahead.)
--   
- Alternative, which follows MonadPlus.
--   
data Parser i a

-- | The result of a parse. This is parameterised over the type i
--   of string that was processed.
--   
--   This type is an instance of Functor, where fmap
--   transforms the value in a Done result.
data IResult i r

-- | The parse failed. The i parameter is the input that had not
--   yet been consumed when the failure occurred. The
--   [String] is a list of contexts in which the
--   error occurred. The String is the message describing the error,
--   if any.
Fail :: i -> [String] -> String -> IResult i r

-- | Supply this continuation with more input so that the parser can
--   resume. To indicate that no more input is available, pass an empty
--   string to the continuation.
--   
--   Note: if you get a Partial result, do not call its
--   continuation more than once.
Partial :: (i -> IResult i r) -> IResult i r

-- | The parse succeeded. The i parameter is the input that had
--   not yet been consumed (if any) when the parse succeeded.
Done :: i -> r -> IResult i r

-- | A common interface for input chunks.
class Monoid c => Chunk c

-- | Map an element to the corresponding character. The first argument is
--   ignored.
chunkElemToChar :: Chunk c => c -> ChunkElem c -> Char

-- | A tiny, highly specialized combinator parser for ByteString
--   strings.
--   
--   While the main attoparsec module generally performs well, this module
--   is particularly fast for simple non-recursive loops that should not
--   normally result in failed parses.
--   
--   Warning: on more complex inputs involving recursion or failure,
--   parsers based on this module may be as much as ten times slower
--   than regular attoparsec! You should only use this module when
--   you have benchmarks that prove that its use speeds your code up.
module Data.Attoparsec.Zepto
type Parser a = ZeptoT Identity a

-- | A simple parser.
--   
--   This monad is strict in its state, and the monadic bind operator
--   (>>=) evaluates each result to weak head normal form
--   before passing it along.
data ZeptoT (m :: Type -> Type) a

-- | Run a parser.
parse :: Parser a -> ByteString -> Either String a

-- | Run a parser on top of the given base monad.
parseT :: Monad m => ZeptoT m a -> ByteString -> m (Either String a)

-- | Indicate whether the end of the input has been reached.
atEnd :: forall (m :: Type -> Type). Monad m => ZeptoT m Bool

-- | Match a string exactly.
string :: forall (m :: Type -> Type). Monad m => ByteString -> ZeptoT m ()

-- | Consume n bytes of input.
take :: forall (m :: Type -> Type). Monad m => Int -> ZeptoT m ByteString

-- | Consume input while the predicate returns True.
takeWhile :: forall (m :: Type -> Type). Monad m => (Word8 -> Bool) -> ZeptoT m ByteString
instance GHC.Internal.Base.Monad m => GHC.Internal.Base.Alternative (Data.Attoparsec.Zepto.ZeptoT m)
instance GHC.Internal.Base.Monad m => GHC.Internal.Base.Applicative (Data.Attoparsec.Zepto.ZeptoT m)
instance GHC.Internal.Base.Monad m => GHC.Internal.Base.Functor (Data.Attoparsec.Zepto.ZeptoT m)
instance GHC.Internal.Base.Monad m => GHC.Internal.Control.Monad.Fail.MonadFail (Data.Attoparsec.Zepto.ZeptoT m)
instance Control.Monad.IO.Class.MonadIO m => Control.Monad.IO.Class.MonadIO (Data.Attoparsec.Zepto.ZeptoT m)
instance GHC.Internal.Base.Monad m => GHC.Internal.Base.MonadPlus (Data.Attoparsec.Zepto.ZeptoT m)
instance GHC.Internal.Base.Monad m => GHC.Internal.Base.Monad (Data.Attoparsec.Zepto.ZeptoT m)
instance GHC.Internal.Base.Monad m => GHC.Internal.Base.Monoid (Data.Attoparsec.Zepto.ZeptoT m a)
instance GHC.Internal.Base.Monad m => GHC.Internal.Base.Semigroup (Data.Attoparsec.Zepto.ZeptoT m a)

-- | Useful parser combinators, similar to those provided by Parsec.
module Data.Attoparsec.Combinator

-- | Attempt a parse, and if it fails, rewind the input so that no input
--   appears to have been consumed.
--   
--   This combinator is provided for compatibility with Parsec. attoparsec
--   parsers always backtrack on failure.
try :: Parser i a -> Parser i a

-- | Name the parser, in case failure occurs.
(<?>) :: Parser i a -> String -> Parser i a
infix 0 <?>

-- | choice ps tries to apply the actions in the list ps
--   in order, until one of them succeeds. Returns the value of the
--   succeeding action.
choice :: Alternative f => [f a] -> f a

-- | Apply the given action repeatedly, returning every result.
count :: Monad m => Int -> m a -> m [a]

-- | option x p tries to apply action p. If p
--   fails without consuming input, it returns the value x,
--   otherwise the value returned by p.
--   
--   
--   priority  = option 0 (digitToInt <$> digit)
--   
option :: Alternative f => a -> f a -> f a

-- | many' p applies the action p zero or more
--   times. Returns a list of the returned values of p. The value
--   returned by p is forced to WHNF.
--   
--   
--   word  = many' letter
--   
many' :: MonadPlus m => m a -> m [a]

-- | many1 p applies the action p one or more
--   times. Returns a list of the returned values of p.
--   
--   
--   word  = many1 letter
--   
many1 :: Alternative f => f a -> f [a]

-- | many1' p applies the action p one or more
--   times. Returns a list of the returned values of p. The value
--   returned by p is forced to WHNF.
--   
--   
--   word  = many1' letter
--   
many1' :: MonadPlus m => m a -> m [a]

-- | manyTill p end applies action p zero or more
--   times until action end succeeds, and returns the list of
--   values returned by p. This can be used to scan comments:
--   
--   
--   simpleComment   = string "<!--" *> manyTill anyChar (string "-->")
--   
--   
--   (Note the overlapping parsers anyChar and string
--   "-->". While this will work, it is not very efficient, as it
--   will cause a lot of backtracking.)
manyTill :: Alternative f => f a -> f b -> f [a]

-- | manyTill' p end applies action p zero or more
--   times until action end succeeds, and returns the list of
--   values returned by p. This can be used to scan comments:
--   
--   
--   simpleComment   = string "<!--" *> manyTill' anyChar (string "-->")
--   
--   
--   (Note the overlapping parsers anyChar and string
--   "-->". While this will work, it is not very efficient, as it
--   will cause a lot of backtracking.)
--   
--   The value returned by p is forced to WHNF.
manyTill' :: MonadPlus m => m a -> m b -> m [a]

-- | sepBy p sep applies zero or more occurrences of
--   p, separated by sep. Returns a list of the values
--   returned by p.
--   
--   
--   commaSep p  = p `sepBy` (char ',')
--   
sepBy :: Alternative f => f a -> f s -> f [a]

-- | sepBy' p sep applies zero or more occurrences of
--   p, separated by sep. Returns a list of the values
--   returned by p. The value returned by p is forced to
--   WHNF.
--   
--   
--   commaSep p  = p `sepBy'` (char ',')
--   
sepBy' :: MonadPlus m => m a -> m s -> m [a]

-- | sepBy1 p sep applies one or more occurrences of
--   p, separated by sep. Returns a list of the values
--   returned by p.
--   
--   
--   commaSep p  = p `sepBy1` (char ',')
--   
sepBy1 :: Alternative f => f a -> f s -> f [a]

-- | sepBy1' p sep applies one or more occurrences of
--   p, separated by sep. Returns a list of the values
--   returned by p. The value returned by p is forced to
--   WHNF.
--   
--   
--   commaSep p  = p `sepBy1'` (char ',')
--   
sepBy1' :: MonadPlus m => m a -> m s -> m [a]

-- | Skip zero or more instances of an action.
skipMany :: Alternative f => f a -> f ()

-- | Skip one or more instances of an action.
skipMany1 :: Alternative f => f a -> f ()

-- | Combine two alternatives.
eitherP :: Alternative f => f a -> f b -> f (Either a b)

-- | If a parser has returned a Partial result, supply it with more
--   input.
feed :: Monoid i => IResult i r -> i -> IResult i r

-- | The parser satisfyElem p succeeds for any chunk element for
--   which the predicate p returns True. Returns the
--   element that is actually parsed.
satisfyElem :: Chunk t => (ChunkElem t -> Bool) -> Parser t (ChunkElem t)

-- | Match only if all input has been consumed.
endOfInput :: Chunk t => Parser t ()

-- | Return an indication of whether the end of input has been reached.
atEnd :: Chunk t => Parser t Bool

-- | Apply a parser without consuming any input.
lookAhead :: Parser i a -> Parser i a

-- | Simple, efficient combinator parsing for Text strings, loosely
--   based on the Parsec library.
module Data.Attoparsec.Text
type Parser = Parser Text
type Result = IResult Text

-- | The result of a parse. This is parameterised over the type i
--   of string that was processed.
--   
--   This type is an instance of Functor, where fmap
--   transforms the value in a Done result.
data IResult i r

-- | The parse failed. The i parameter is the input that had not
--   yet been consumed when the failure occurred. The
--   [String] is a list of contexts in which the
--   error occurred. The String is the message describing the error,
--   if any.
Fail :: i -> [String] -> String -> IResult i r

-- | Supply this continuation with more input so that the parser can
--   resume. To indicate that no more input is available, pass an empty
--   string to the continuation.
--   
--   Note: if you get a Partial result, do not call its
--   continuation more than once.
Partial :: (i -> IResult i r) -> IResult i r

-- | The parse succeeded. The i parameter is the input that had
--   not yet been consumed (if any) when the parse succeeded.
Done :: i -> r -> IResult i r

-- | Compare two IResult values for equality.
--   
--   If both IResults are Partial, the result will be
--   Nothing, as they are incomplete and hence their equality cannot
--   be known. (This is why there is no Eq instance for
--   IResult.)
compareResults :: (Eq i, Eq r) => IResult i r -> IResult i r -> Maybe Bool

-- | Run a parser.
parse :: Parser a -> Text -> Result a

-- | If a parser has returned a Partial result, supply it with more
--   input.
feed :: Monoid i => IResult i r -> i -> IResult i r

-- | Run a parser that cannot be resupplied via a Partial result.
--   
--   This function does not force a parser to consume all of its input.
--   Instead, any residual input will be discarded. To force a parser to
--   consume all of its input, use something like this:
--   
--   
--   parseOnly (myParser <* endOfInput)
--    
--   
parseOnly :: Parser a -> Text -> Either String a

-- | Run a parser with an initial input string, and a monadic action that
--   can supply more input if needed.
parseWith :: Monad m => m Text -> Parser a -> Text -> m (Result a)

-- | Run a parser and print its result to standard output.
parseTest :: Show a => Parser a -> Text -> IO ()

-- | Convert a Result value to a Maybe value. A
--   Partial result is treated as failure.
maybeResult :: Result r -> Maybe r

-- | Convert a Result value to an Either value. A
--   Partial result is treated as failure.
eitherResult :: Result r -> Either String r

-- | Match a specific character.
char :: Char -> Parser Char

-- | Match any character.
anyChar :: Parser Char

-- | Match any character except the given one.
notChar :: Char -> Parser Char

-- | The parser satisfy p succeeds for any character for which the
--   predicate p returns True. Returns the character that
--   is actually parsed.
--   
--   
--   digit = satisfy isDigit
--       where isDigit c = c >= '0' && c <= '9'
--   
satisfy :: (Char -> Bool) -> Parser Char

-- | The parser satisfyWith f p transforms a character, and
--   succeeds if the predicate p returns True on the
--   transformed value. The parser returns the transformed character that
--   was parsed.
satisfyWith :: (Char -> a) -> (a -> Bool) -> Parser a

-- | The parser skip p succeeds for any character for which the
--   predicate p returns True.
--   
--   
--   skipDigit = skip isDigit
--       where isDigit c = c >= '0' && c <= '9'
--   
skip :: (Char -> Bool) -> Parser ()

-- | Match any character, to perform lookahead. Returns Nothing if
--   end of input has been reached. Does not consume any input.
--   
--   Note: Because this parser does not fail, do not use it with
--   combinators such as many, because such parsers loop until a
--   failure occurs. Careless use will thus result in an infinite loop.
peekChar :: Parser (Maybe Char)

-- | Match any character, to perform lookahead. Does not consume any input,
--   but will fail if end of input has been reached.
peekChar' :: Parser Char

-- | Parse a single digit, as recognised by isDigit.
digit :: Parser Char

-- | Parse a letter, as recognised by isAlpha.
letter :: Parser Char

-- | Parse a space character, as recognised by isSpace.
space :: Parser Char

-- | Match any character in a set.
--   
--   
--   vowel = inClass "aeiou"
--   
--   
--   Range notation is supported.
--   
--   
--   halfAlphabet = inClass "a-nA-N"
--   
--   
--   To add a literal '-' to a set, place it at the beginning or
--   end of the string.
inClass :: String -> Char -> Bool

-- | Match any character not in a set.
notInClass :: String -> Char -> Bool

-- | string s parses a sequence of characters that identically
--   match s. Returns the parsed string (i.e. s). This
--   parser consumes no input if it fails (even if a partial match).
--   
--   Note: The behaviour of this parser is different to that of the
--   similarly-named parser in Parsec, as this one is all-or-nothing. To
--   illustrate the difference, the following parser will fail under Parsec
--   given an input of "for":
--   
--   
--   string "foo" <|> string "for"
--   
--   
--   The reason for its failure is that the first branch is a partial
--   match, and will consume the letters 'f' and 'o'
--   before failing. In attoparsec, the above parser will succeed on
--   that input, because the failed first branch will consume nothing.
string :: Text -> Parser Text

-- | Satisfy a literal string, ignoring case.
--   
--   Note: this function is currently quite inefficient. Unicode case
--   folding can change the length of a string ("ß" becomes "ss"), which
--   makes a simple, efficient implementation tricky. We have (for now)
--   chosen simplicity over efficiency.

-- | Deprecated: this is very inefficient, use asciiCI instead
stringCI :: Text -> Parser Text

-- | Satisfy a literal string, ignoring case for characters in the ASCII
--   range.
asciiCI :: Text -> Parser Text

-- | Skip over white space.
skipSpace :: Parser ()

-- | Skip past input for as long as the predicate returns True.
skipWhile :: (Char -> Bool) -> Parser ()

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

-- | Like scan, but generalized to return the final state of the
--   scanner.
runScanner :: s -> (s -> Char -> Maybe s) -> Parser (Text, s)

-- | Consume exactly n characters of input.
take :: Int -> Parser Text

-- | Consume input as long as the predicate returns True, and return
--   the consumed input.
--   
--   This parser does not fail. It will return an empty string if the
--   predicate returns False on the first character of input.
--   
--   Note: Because this parser does not fail, do not use it with
--   combinators such as many, because such parsers loop until a
--   failure occurs. Careless use will thus result in an infinite loop.
takeWhile :: (Char -> Bool) -> Parser Text

-- | Consume input as long as the predicate returns True, and return
--   the consumed input.
--   
--   This parser requires the predicate to succeed on at least one
--   character of input: it will fail if the predicate never returns
--   True or if there is no input left.
takeWhile1 :: (Char -> Bool) -> Parser Text

-- | Consume input as long as the predicate returns False (i.e.
--   until it returns True), and return the consumed input.
--   
--   This parser does not fail. It will return an empty string if the
--   predicate returns True on the first character of input.
--   
--   Note: Because this parser does not fail, do not use it with
--   combinators such as many, because such parsers loop until a
--   failure occurs. Careless use will thus result in an infinite loop.
takeTill :: (Char -> Bool) -> Parser Text

-- | Obsolete. A type-specialized version of *> for
--   Text. Use *> instead.

-- | Deprecated: This is no longer necessary, and will be removed. Use
--   *> instead.
(.*>) :: Text -> Parser a -> Parser a

-- | Obsolete. A type-specialized version of <* for
--   Text. Use *> instead.

-- | Deprecated: This is no longer necessary, and will be removed. Use
--   <* instead.
(<*.) :: Parser a -> Text -> Parser a

-- | Consume all remaining input and return it as a single string.
takeText :: Parser Text

-- | Consume all remaining input and return it as a single string.
takeLazyText :: Parser Text

-- | Match either a single newline character '\n', or a carriage
--   return followed by a newline character "\r\n".
endOfLine :: Parser ()

-- | A predicate that matches either a carriage return '\r' or
--   newline '\n' character.
isEndOfLine :: Char -> Bool

-- | A predicate that matches either a space ' ' or horizontal tab
--   '\t' character.
isHorizontalSpace :: Char -> Bool

-- | Parse and decode an unsigned decimal number.
decimal :: Integral a => Parser a

-- | Parse and decode an unsigned hexadecimal number. The hex digits
--   'a' through 'f' may be upper or lower case.
--   
--   This parser does not accept a leading "0x" string.
hexadecimal :: (Integral a, Bits a) => Parser a

-- | Parse a number with an optional leading '+' or '-'
--   sign character.
signed :: Num a => Parser a -> Parser a

-- | Parse a Double.
--   
--   This parser accepts an optional leading sign character, followed by at
--   most one decimal digit. The syntax is similar to that accepted by the
--   read function, with the exception that a trailing '.'
--   is consumed.
--   
--   
Examples
--   
--   These examples use this helper:
--   
--   
--   r :: Parser a -> Text -> Result a
--   r p s = feed (parse p s) mempty
--   
--   
--   Examples with behaviour identical to read, if you feed an empty
--   continuation to the first result:
--   
--   
--   r double "3"     == Done "" 3.0
--   r double "3.1"   == Done "" 3.1
--   r double "3e4"   == Done "" 30000.0
--   r double "3.1e4" == Done "" 31000.0
--   r double "3e"    == Done "e" 3.0
--   
--   
--   Examples with behaviour identical to read:
--   
--   
--   r double ".3"    == Fail ".3" _ _
--   r double "e3"    == Fail "e3" _ _
--   
--   
--   Example of difference from read:
--   
--   
--   r double "3.foo" == Done "foo" 3.0
--   
--   
--   This function does not accept string representations of "NaN" or
--   "Infinity".
double :: Parser Double

-- | A numeric type that can represent integers accurately, and floating
--   point numbers to the precision of a Double.
--   
--   Note: this type is deprecated, and will be removed in the next
--   major release. Use the Scientific type instead.
data Number
I :: !Integer -> Number
D :: {-# UNPACK #-} !Double -> Number

-- | Parse a number, attempting to preserve both speed and precision.
--   
--   The syntax accepted by this parser is the same as for double.
--   
--   This function does not accept string representations of "NaN" or
--   "Infinity".

-- | Deprecated: Use scientific instead.
number :: Parser Number

-- | Parse a rational number.
--   
--   The syntax accepted by this parser is the same as for double.
--   
--   Note: this parser is not safe for use with inputs from
--   untrusted sources. An input with a suitably large exponent such as
--   "1e1000000000" will cause a huge Integer to be
--   allocated, resulting in what is effectively a denial-of-service
--   attack.
--   
--   In most cases, it is better to use double or scientific
--   instead.
rational :: Fractional a => Parser a

-- | Parse a scientific number.
--   
--   The syntax accepted by this parser is the same as for double.
scientific :: Parser Scientific

-- | Attempt a parse, and if it fails, rewind the input so that no input
--   appears to have been consumed.
--   
--   This combinator is provided for compatibility with Parsec. attoparsec
--   parsers always backtrack on failure.
try :: Parser i a -> Parser i a

-- | Name the parser, in case failure occurs.
(<?>) :: Parser i a -> String -> Parser i a
infix 0 <?>

-- | choice ps tries to apply the actions in the list ps
--   in order, until one of them succeeds. Returns the value of the
--   succeeding action.
choice :: Alternative f => [f a] -> f a

-- | Apply the given action repeatedly, returning every result.
count :: Monad m => Int -> m a -> m [a]

-- | option x p tries to apply action p. If p
--   fails without consuming input, it returns the value x,
--   otherwise the value returned by p.
--   
--   
--   priority  = option 0 (digitToInt <$> digit)
--   
option :: Alternative f => a -> f a -> f a

-- | many' p applies the action p zero or more
--   times. Returns a list of the returned values of p. The value
--   returned by p is forced to WHNF.
--   
--   
--   word  = many' letter
--   
many' :: MonadPlus m => m a -> m [a]

-- | many1 p applies the action p one or more
--   times. Returns a list of the returned values of p.
--   
--   
--   word  = many1 letter
--   
many1 :: Alternative f => f a -> f [a]

-- | many1' p applies the action p one or more
--   times. Returns a list of the returned values of p. The value
--   returned by p is forced to WHNF.
--   
--   
--   word  = many1' letter
--   
many1' :: MonadPlus m => m a -> m [a]

-- | manyTill p end applies action p zero or more
--   times until action end succeeds, and returns the list of
--   values returned by p. This can be used to scan comments:
--   
--   
--   simpleComment   = string "<!--" *> manyTill anyChar (string "-->")
--   
--   
--   (Note the overlapping parsers anyChar and string
--   "-->". While this will work, it is not very efficient, as it
--   will cause a lot of backtracking.)
manyTill :: Alternative f => f a -> f b -> f [a]

-- | manyTill' p end applies action p zero or more
--   times until action end succeeds, and returns the list of
--   values returned by p. This can be used to scan comments:
--   
--   
--   simpleComment   = string "<!--" *> manyTill' anyChar (string "-->")
--   
--   
--   (Note the overlapping parsers anyChar and string
--   "-->". While this will work, it is not very efficient, as it
--   will cause a lot of backtracking.)
--   
--   The value returned by p is forced to WHNF.
manyTill' :: MonadPlus m => m a -> m b -> m [a]

-- | sepBy p sep applies zero or more occurrences of
--   p, separated by sep. Returns a list of the values
--   returned by p.
--   
--   
--   commaSep p  = p `sepBy` (char ',')
--   
sepBy :: Alternative f => f a -> f s -> f [a]

-- | sepBy' p sep applies zero or more occurrences of
--   p, separated by sep. Returns a list of the values
--   returned by p. The value returned by p is forced to
--   WHNF.
--   
--   
--   commaSep p  = p `sepBy'` (char ',')
--   
sepBy' :: MonadPlus m => m a -> m s -> m [a]

-- | sepBy1 p sep applies one or more occurrences of
--   p, separated by sep. Returns a list of the values
--   returned by p.
--   
--   
--   commaSep p  = p `sepBy1` (char ',')
--   
sepBy1 :: Alternative f => f a -> f s -> f [a]

-- | sepBy1' p sep applies one or more occurrences of
--   p, separated by sep. Returns a list of the values
--   returned by p. The value returned by p is forced to
--   WHNF.
--   
--   
--   commaSep p  = p `sepBy1'` (char ',')
--   
sepBy1' :: MonadPlus m => m a -> m s -> m [a]

-- | Skip zero or more instances of an action.
skipMany :: Alternative f => f a -> f ()

-- | Skip one or more instances of an action.
skipMany1 :: Alternative f => f a -> f ()

-- | Combine two alternatives.
eitherP :: Alternative f => f a -> f b -> f (Either a b)

-- | Return both the result of a parse and the portion of the input that
--   was consumed while it was being parsed.
match :: Parser a -> Parser (Text, a)

-- | Match only if all input has been consumed.
endOfInput :: Chunk t => Parser t ()

-- | Return an indication of whether the end of input has been reached.
atEnd :: Chunk t => Parser t Bool

-- | Simple, efficient combinator parsing that can consume lazy Text
--   strings, loosely based on the Parsec library.
--   
--   This is essentially the same code as in the Text module, only
--   with a parse function that can consume a lazy Text
--   incrementally, and a Result type that does not allow more input
--   to be fed in. Think of this as suitable for use with a lazily read
--   file, e.g. via readFile or hGetContents.
--   
--   Note: The various parser functions and combinators such as
--   string still expect strict Text parameters, and
--   return strict Text results. Behind the scenes, strict
--   Text values are still used internally to store parser input and
--   manipulate it efficiently.
module Data.Attoparsec.Text.Lazy

-- | The result of a parse.
data Result r

-- | The parse failed. The Text is the input that had not yet been
--   consumed when the failure occurred. The
--   [String] is a list of contexts in which the
--   error occurred. The String is the message describing the error,
--   if any.
Fail :: Text -> [String] -> String -> Result r

-- | The parse succeeded. The Text is the input that had not yet
--   been consumed (if any) when the parse succeeded.
Done :: Text -> r -> Result r

-- | Parse a scientific number.
--   
--   The syntax accepted by this parser is the same as for double.
scientific :: Parser Scientific

-- | A numeric type that can represent integers accurately, and floating
--   point numbers to the precision of a Double.
--   
--   Note: this type is deprecated, and will be removed in the next
--   major release. Use the Scientific type instead.
data Number
I :: !Integer -> Number
D :: {-# UNPACK #-} !Double -> Number

-- | Consume input as long as the predicate returns True, and return
--   the consumed input.
--   
--   This parser does not fail. It will return an empty string if the
--   predicate returns False on the first character of input.
--   
--   Note: Because this parser does not fail, do not use it with
--   combinators such as many, because such parsers loop until a
--   failure occurs. Careless use will thus result in an infinite loop.
takeWhile :: (Char -> Bool) -> Parser Text

-- | Consume exactly n characters of input.
take :: Int -> Parser Text

-- | The parser satisfy p succeeds for any character for which the
--   predicate p returns True. Returns the character that
--   is actually parsed.
--   
--   
--   digit = satisfy isDigit
--       where isDigit c = c >= '0' && c <= '9'
--   
satisfy :: (Char -> Bool) -> Parser Char

-- | Match a specific character.
char :: Char -> Parser Char

-- | string s parses a sequence of characters that identically
--   match s. Returns the parsed string (i.e. s). This
--   parser consumes no input if it fails (even if a partial match).
--   
--   Note: The behaviour of this parser is different to that of the
--   similarly-named parser in Parsec, as this one is all-or-nothing. To
--   illustrate the difference, the following parser will fail under Parsec
--   given an input of "for":
--   
--   
--   string "foo" <|> string "for"
--   
--   
--   The reason for its failure is that the first branch is a partial
--   match, and will consume the letters 'f' and 'o'
--   before failing. In attoparsec, the above parser will succeed on
--   that input, because the failed first branch will consume nothing.
string :: Text -> Parser Text

-- | choice ps tries to apply the actions in the list ps
--   in order, until one of them succeeds. Returns the value of the
--   succeeding action.
choice :: Alternative f => [f a] -> f a

-- | Apply the given action repeatedly, returning every result.
count :: Monad m => Int -> m a -> m [a]

-- | option x p tries to apply action p. If p
--   fails without consuming input, it returns the value x,
--   otherwise the value returned by p.
--   
--   
--   priority  = option 0 (digitToInt <$> digit)
--   
option :: Alternative f => a -> f a -> f a

-- | many1 p applies the action p one or more
--   times. Returns a list of the returned values of p.
--   
--   
--   word  = many1 letter
--   
many1 :: Alternative f => f a -> f [a]

-- | Skip zero or more instances of an action.
skipMany :: Alternative f => f a -> f ()

-- | Skip one or more instances of an action.
skipMany1 :: Alternative f => f a -> f ()

-- | sepBy p sep applies zero or more occurrences of
--   p, separated by sep. Returns a list of the values
--   returned by p.
--   
--   
--   commaSep p  = p `sepBy` (char ',')
--   
sepBy :: Alternative f => f a -> f s -> f [a]

-- | sepBy1 p sep applies one or more occurrences of
--   p, separated by sep. Returns a list of the values
--   returned by p.
--   
--   
--   commaSep p  = p `sepBy1` (char ',')
--   
sepBy1 :: Alternative f => f a -> f s -> f [a]

-- | manyTill p end applies action p zero or more
--   times until action end succeeds, and returns the list of
--   values returned by p. This can be used to scan comments:
--   
--   
--   simpleComment   = string "<!--" *> manyTill anyChar (string "-->")
--   
--   
--   (Note the overlapping parsers anyChar and string
--   "-->". While this will work, it is not very efficient, as it
--   will cause a lot of backtracking.)
manyTill :: Alternative f => f a -> f b -> f [a]

-- | Attempt a parse, and if it fails, rewind the input so that no input
--   appears to have been consumed.
--   
--   This combinator is provided for compatibility with Parsec. attoparsec
--   parsers always backtrack on failure.
try :: Parser i a -> Parser i a

-- | The parser skip p succeeds for any character for which the
--   predicate p returns True.
--   
--   
--   skipDigit = skip isDigit
--       where isDigit c = c >= '0' && c <= '9'
--   
skip :: (Char -> Bool) -> Parser ()

-- | Return both the result of a parse and the portion of the input that
--   was consumed while it was being parsed.
match :: Parser a -> Parser (Text, a)

-- | Parse a space character, as recognised by isSpace.
space :: Parser Char

-- | Parse a Double.
--   
--   This parser accepts an optional leading sign character, followed by at
--   most one decimal digit. The syntax is similar to that accepted by the
--   read function, with the exception that a trailing '.'
--   is consumed.
--   
--   
Examples
--   
--   These examples use this helper:
--   
--   
--   r :: Parser a -> Text -> Result a
--   r p s = feed (parse p s) mempty
--   
--   
--   Examples with behaviour identical to read, if you feed an empty
--   continuation to the first result:
--   
--   
--   r double "3"     == Done "" 3.0
--   r double "3.1"   == Done "" 3.1
--   r double "3e4"   == Done "" 30000.0
--   r double "3.1e4" == Done "" 31000.0
--   r double "3e"    == Done "e" 3.0
--   
--   
--   Examples with behaviour identical to read:
--   
--   
--   r double ".3"    == Fail ".3" _ _
--   r double "e3"    == Fail "e3" _ _
--   
--   
--   Example of difference from read:
--   
--   
--   r double "3.foo" == Done "foo" 3.0
--   
--   
--   This function does not accept string representations of "NaN" or
--   "Infinity".
double :: Parser Double

-- | Parse a rational number.
--   
--   The syntax accepted by this parser is the same as for double.
--   
--   Note: this parser is not safe for use with inputs from
--   untrusted sources. An input with a suitably large exponent such as
--   "1e1000000000" will cause a huge Integer to be
--   allocated, resulting in what is effectively a denial-of-service
--   attack.
--   
--   In most cases, it is better to use double or scientific
--   instead.
rational :: Fractional a => Parser a

-- | Parse and decode an unsigned decimal number.
decimal :: Integral a => Parser a

-- | Parse and decode an unsigned hexadecimal number. The hex digits
--   'a' through 'f' may be upper or lower case.
--   
--   This parser does not accept a leading "0x" string.
hexadecimal :: (Integral a, Bits a) => Parser a

-- | Parse a number with an optional leading '+' or '-'
--   sign character.
signed :: Num a => Parser a -> Parser a
type Parser = Parser Text

-- | Compare two IResult values for equality.
--   
--   If both IResults are Partial, the result will be
--   Nothing, as they are incomplete and hence their equality cannot
--   be known. (This is why there is no Eq instance for
--   IResult.)
compareResults :: (Eq i, Eq r) => IResult i r -> IResult i r -> Maybe Bool

-- | If a parser has returned a Partial result, supply it with more
--   input.
feed :: Monoid i => IResult i r -> i -> IResult i r

-- | The parser satisfyWith f p transforms a character, and
--   succeeds if the predicate p returns True on the
--   transformed value. The parser returns the transformed character that
--   was parsed.
satisfyWith :: (Char -> a) -> (a -> Bool) -> Parser a

-- | Match any character in a set.
--   
--   
--   vowel = inClass "aeiou"
--   
--   
--   Range notation is supported.
--   
--   
--   halfAlphabet = inClass "a-nA-N"
--   
--   
--   To add a literal '-' to a set, place it at the beginning or
--   end of the string.
inClass :: String -> Char -> Bool

-- | Match any character not in a set.
notInClass :: String -> Char -> Bool

-- | Skip past input for as long as the predicate returns True.
skipWhile :: (Char -> Bool) -> Parser ()

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

-- | Like scan, but generalized to return the final state of the
--   scanner.
runScanner :: s -> (s -> Char -> Maybe s) -> Parser (Text, s)

-- | Consume input as long as the predicate returns True, and return
--   the consumed input.
--   
--   This parser requires the predicate to succeed on at least one
--   character of input: it will fail if the predicate never returns
--   True or if there is no input left.
takeWhile1 :: (Char -> Bool) -> Parser Text

-- | Consume input as long as the predicate returns False (i.e.
--   until it returns True), and return the consumed input.
--   
--   This parser does not fail. It will return an empty string if the
--   predicate returns True on the first character of input.
--   
--   Note: Because this parser does not fail, do not use it with
--   combinators such as many, because such parsers loop until a
--   failure occurs. Careless use will thus result in an infinite loop.
takeTill :: (Char -> Bool) -> Parser Text

-- | Name the parser, in case failure occurs.
(<?>) :: Parser i a -> String -> Parser i a
infix 0 <?>

-- | many' p applies the action p zero or more
--   times. Returns a list of the returned values of p. The value
--   returned by p is forced to WHNF.
--   
--   
--   word  = many' letter
--   
many' :: MonadPlus m => m a -> m [a]

-- | many1' p applies the action p one or more
--   times. Returns a list of the returned values of p. The value
--   returned by p is forced to WHNF.
--   
--   
--   word  = many1' letter
--   
many1' :: MonadPlus m => m a -> m [a]

-- | manyTill' p end applies action p zero or more
--   times until action end succeeds, and returns the list of
--   values returned by p. This can be used to scan comments:
--   
--   
--   simpleComment   = string "<!--" *> manyTill' anyChar (string "-->")
--   
--   
--   (Note the overlapping parsers anyChar and string
--   "-->". While this will work, it is not very efficient, as it
--   will cause a lot of backtracking.)
--   
--   The value returned by p is forced to WHNF.
manyTill' :: MonadPlus m => m a -> m b -> m [a]

-- | sepBy' p sep applies zero or more occurrences of
--   p, separated by sep. Returns a list of the values
--   returned by p. The value returned by p is forced to
--   WHNF.
--   
--   
--   commaSep p  = p `sepBy'` (char ',')
--   
sepBy' :: MonadPlus m => m a -> m s -> m [a]

-- | sepBy1' p sep applies one or more occurrences of
--   p, separated by sep. Returns a list of the values
--   returned by p. The value returned by p is forced to
--   WHNF.
--   
--   
--   commaSep p  = p `sepBy1'` (char ',')
--   
sepBy1' :: MonadPlus m => m a -> m s -> m [a]

-- | Combine two alternatives.
eitherP :: Alternative f => f a -> f b -> f (Either a b)

-- | Match only if all input has been consumed.
endOfInput :: Chunk t => Parser t ()

-- | Return an indication of whether the end of input has been reached.
atEnd :: Chunk t => Parser t Bool

-- | Match any character.
anyChar :: Parser Char

-- | Match any character except the given one.
notChar :: Char -> Parser Char

-- | Match any character, to perform lookahead. Returns Nothing if
--   end of input has been reached. Does not consume any input.
--   
--   Note: Because this parser does not fail, do not use it with
--   combinators such as many, because such parsers loop until a
--   failure occurs. Careless use will thus result in an infinite loop.
peekChar :: Parser (Maybe Char)

-- | Match any character, to perform lookahead. Does not consume any input,
--   but will fail if end of input has been reached.
peekChar' :: Parser Char

-- | Parse a single digit, as recognised by isDigit.
digit :: Parser Char

-- | Satisfy a literal string, ignoring case.
--   
--   Note: this function is currently quite inefficient. Unicode case
--   folding can change the length of a string ("ß" becomes "ss"), which
--   makes a simple, efficient implementation tricky. We have (for now)
--   chosen simplicity over efficiency.

-- | Deprecated: this is very inefficient, use asciiCI instead
stringCI :: Text -> Parser Text

-- | Skip over white space.
skipSpace :: Parser ()

-- | Obsolete. A type-specialized version of *> for
--   Text. Use *> instead.

-- | Deprecated: This is no longer necessary, and will be removed. Use
--   *> instead.
(.*>) :: Text -> Parser a -> Parser a

-- | Obsolete. A type-specialized version of <* for
--   Text. Use *> instead.

-- | Deprecated: This is no longer necessary, and will be removed. Use
--   <* instead.
(<*.) :: Parser a -> Text -> Parser a

-- | Match either a single newline character '\n', or a carriage
--   return followed by a newline character "\r\n".
endOfLine :: Parser ()

-- | A predicate that matches either a carriage return '\r' or
--   newline '\n' character.
isEndOfLine :: Char -> Bool

-- | A predicate that matches either a space ' ' or horizontal tab
--   '\t' character.
isHorizontalSpace :: Char -> Bool

-- | Parse a number, attempting to preserve both speed and precision.
--   
--   The syntax accepted by this parser is the same as for double.
--   
--   This function does not accept string representations of "NaN" or
--   "Infinity".

-- | Deprecated: Use scientific instead.
number :: Parser Number

-- | Parse a letter, as recognised by isAlpha.
letter :: Parser Char

-- | Satisfy a literal string, ignoring case for characters in the ASCII
--   range.
asciiCI :: Text -> Parser Text

-- | Consume all remaining input and return it as a single string.
takeText :: Parser Text

-- | Consume all remaining input and return it as a single string.
takeLazyText :: Parser Text

-- | Run a parser and return its result.
parse :: Parser a -> Text -> Result a

-- | Run a parser that cannot be resupplied via a Partial result.
--   
--   This function does not force a parser to consume all of its input.
--   Instead, any residual input will be discarded. To force a parser to
--   consume all of its input, use something like this:
--   
--   
--   parseOnly (myParser <* endOfInput)
--    
--   
parseOnly :: Parser a -> Text -> Either String a

-- | Run a parser and print its result to standard output.
parseTest :: Show a => Parser a -> Text -> IO ()

-- | Convert a Result value to a Maybe value.
maybeResult :: Result r -> Maybe r

-- | Convert a Result value to an Either value.
eitherResult :: Result r -> Either String r
instance GHC.Internal.Base.Functor Data.Attoparsec.Text.Lazy.Result
instance Control.DeepSeq.NFData r => Control.DeepSeq.NFData (Data.Attoparsec.Text.Lazy.Result r)
instance GHC.Internal.Show.Show r => GHC.Internal.Show.Show (Data.Attoparsec.Text.Lazy.Result r)

-- | Simple, efficient combinator parsing for ByteString strings,
--   loosely based on the Parsec library.
module Data.Attoparsec.ByteString
type Parser = Parser ByteString
type Result = IResult ByteString

-- | The result of a parse. This is parameterised over the type i
--   of string that was processed.
--   
--   This type is an instance of Functor, where fmap
--   transforms the value in a Done result.
data IResult i r

-- | The parse failed. The i parameter is the input that had not
--   yet been consumed when the failure occurred. The
--   [String] is a list of contexts in which the
--   error occurred. The String is the message describing the error,
--   if any.
Fail :: i -> [String] -> String -> IResult i r

-- | Supply this continuation with more input so that the parser can
--   resume. To indicate that no more input is available, pass an empty
--   string to the continuation.
--   
--   Note: if you get a Partial result, do not call its
--   continuation more than once.
Partial :: (i -> IResult i r) -> IResult i r

-- | The parse succeeded. The i parameter is the input that had
--   not yet been consumed (if any) when the parse succeeded.
Done :: i -> r -> IResult i r

-- | Compare two IResult values for equality.
--   
--   If both IResults are Partial, the result will be
--   Nothing, as they are incomplete and hence their equality cannot
--   be known. (This is why there is no Eq instance for
--   IResult.)
compareResults :: (Eq i, Eq r) => IResult i r -> IResult i r -> Maybe Bool

-- | Run a parser.
parse :: Parser a -> ByteString -> Result a

-- | If a parser has returned a Partial result, supply it with more
--   input.
feed :: Monoid i => IResult i r -> i -> IResult i r

-- | Run a parser that cannot be resupplied via a Partial result.
--   
--   This function does not force a parser to consume all of its input.
--   Instead, any residual input will be discarded. To force a parser to
--   consume all of its input, use something like this:
--   
--   
--   parseOnly (myParser <* endOfInput)
--    
--   
parseOnly :: Parser a -> ByteString -> Either String a

-- | Run a parser with an initial input string, and a monadic action that
--   can supply more input if needed.
parseWith :: Monad m => m ByteString -> Parser a -> ByteString -> m (Result a)

-- | Run a parser and print its result to standard output.
parseTest :: Show a => Parser a -> ByteString -> IO ()

-- | Convert a Result value to a Maybe value. A
--   Partial result is treated as failure.
maybeResult :: Result r -> Maybe r

-- | Convert a Result value to an Either value. A
--   Partial result is treated as failure.
eitherResult :: Result r -> Either String r

-- | Match a specific byte.
word8 :: Word8 -> Parser Word8

-- | Match any byte.
anyWord8 :: Parser Word8

-- | Match any byte except the given one.
notWord8 :: Word8 -> Parser Word8

-- | The parser satisfy p succeeds for any byte for which the
--   predicate p returns True. Returns the byte that is
--   actually parsed.
--   
--   
--   digit = satisfy isDigit
--       where isDigit w = w >= 48 && w <= 57
--   
satisfy :: (Word8 -> Bool) -> Parser Word8

-- | The parser satisfyWith f p transforms a byte, and succeeds if
--   the predicate p returns True on the transformed value.
--   The parser returns the transformed byte that was parsed.
satisfyWith :: (Word8 -> a) -> (a -> Bool) -> Parser a

-- | The parser skip p succeeds for any byte for which the
--   predicate p returns True.
--   
--   
--   skipDigit = skip isDigit
--       where isDigit w = w >= 48 && w <= 57
--   
skip :: (Word8 -> Bool) -> Parser ()

-- | Match any byte, to perform lookahead. Returns Nothing if end of
--   input has been reached. Does not consume any input.
--   
--   Note: Because this parser does not fail, do not use it with
--   combinators such as many, because such parsers loop until a
--   failure occurs. Careless use will thus result in an infinite loop.
peekWord8 :: Parser (Maybe Word8)

-- | Match any byte, to perform lookahead. Does not consume any input, but
--   will fail if end of input has been reached.
peekWord8' :: Parser Word8

-- | Match any byte in a set.
--   
--   
--   vowel = inClass "aeiou"
--   
--   
--   Range notation is supported.
--   
--   
--   halfAlphabet = inClass "a-nA-N"
--   
--   
--   To add a literal '-' to a set, place it at the beginning or
--   end of the string.
inClass :: String -> Word8 -> Bool

-- | Match any byte not in a set.
notInClass :: String -> Word8 -> Bool

-- | string s parses a sequence of bytes that identically match
--   s. Returns the parsed string (i.e. s). This parser
--   consumes no input if it fails (even if a partial match).
--   
--   Note: The behaviour of this parser is different to that of the
--   similarly-named parser in Parsec, as this one is all-or-nothing. To
--   illustrate the difference, the following parser will fail under Parsec
--   given an input of "for":
--   
--   
--   string "foo" <|> string "for"
--   
--   
--   The reason for its failure is that the first branch is a partial
--   match, and will consume the letters 'f' and 'o'
--   before failing. In attoparsec, the above parser will succeed on
--   that input, because the failed first branch will consume nothing.
string :: ByteString -> Parser ByteString

-- | Skip past input for as long as the predicate returns True.
skipWhile :: (Word8 -> Bool) -> Parser ()

-- | Consume exactly n bytes of input.
take :: Int -> Parser ByteString

-- | A stateful scanner. The predicate consumes and transforms a state
--   argument, and each transformed state is passed to successive
--   invocations of the predicate on each byte of the input until one
--   returns Nothing or the input ends.
--   
--   This parser does not fail. It will return an empty string if the
--   predicate returns Nothing on the first byte of input.
--   
--   Note: Because this parser does not fail, do not use it with
--   combinators such as many, because such parsers loop until a
--   failure occurs. Careless use will thus result in an infinite loop.
scan :: s -> (s -> Word8 -> Maybe s) -> Parser ByteString

-- | Like scan, but generalized to return the final state of the
--   scanner.
runScanner :: s -> (s -> Word8 -> Maybe s) -> Parser (ByteString, s)

-- | Consume input as long as the predicate returns True, and return
--   the consumed input.
--   
--   This parser does not fail. It will return an empty string if the
--   predicate returns False on the first byte of input.
--   
--   Note: Because this parser does not fail, do not use it with
--   combinators such as many, because such parsers loop until a
--   failure occurs. Careless use will thus result in an infinite loop.
takeWhile :: (Word8 -> Bool) -> Parser ByteString

-- | Consume input as long as the predicate returns True, and return
--   the consumed input.
--   
--   This parser requires the predicate to succeed on at least one byte of
--   input: it will fail if the predicate never returns True or if
--   there is no input left.
takeWhile1 :: (Word8 -> Bool) -> Parser ByteString

-- | Consume input until immediately after the predicate returns
--   True, and return the consumed input.
--   
--   This parser will consume at least one Word8 or fail.
takeWhileIncluding :: (Word8 -> Bool) -> Parser ByteString

-- | Consume input as long as the predicate returns False (i.e.
--   until it returns True), and return the consumed input.
--   
--   This parser does not fail. It will return an empty string if the
--   predicate returns True on the first byte of input.
--   
--   Note: Because this parser does not fail, do not use it with
--   combinators such as many, because such parsers loop until a
--   failure occurs. Careless use will thus result in an infinite loop.
takeTill :: (Word8 -> Bool) -> Parser ByteString

-- | Return the rest of the current chunk without consuming anything.
--   
--   If the current chunk is empty, then ask for more input. If there is no
--   more input, then return Nothing
getChunk :: Parser (Maybe ByteString)

-- | Consume all remaining input and return it as a single string.
takeByteString :: Parser ByteString

-- | Consume all remaining input and return it as a single string.
takeLazyByteString :: Parser ByteString

-- | Attempt a parse, and if it fails, rewind the input so that no input
--   appears to have been consumed.
--   
--   This combinator is provided for compatibility with Parsec. attoparsec
--   parsers always backtrack on failure.
try :: Parser i a -> Parser i a

-- | Name the parser, in case failure occurs.
(<?>) :: Parser i a -> String -> Parser i a
infix 0 <?>

-- | choice ps tries to apply the actions in the list ps
--   in order, until one of them succeeds. Returns the value of the
--   succeeding action.
choice :: Alternative f => [f a] -> f a

-- | Apply the given action repeatedly, returning every result.
count :: Monad m => Int -> m a -> m [a]

-- | option x p tries to apply action p. If p
--   fails without consuming input, it returns the value x,
--   otherwise the value returned by p.
--   
--   
--   priority  = option 0 (digitToInt <$> digit)
--   
option :: Alternative f => a -> f a -> f a

-- | many' p applies the action p zero or more
--   times. Returns a list of the returned values of p. The value
--   returned by p is forced to WHNF.
--   
--   
--   word  = many' letter
--   
many' :: MonadPlus m => m a -> m [a]

-- | many1 p applies the action p one or more
--   times. Returns a list of the returned values of p.
--   
--   
--   word  = many1 letter
--   
many1 :: Alternative f => f a -> f [a]

-- | many1' p applies the action p one or more
--   times. Returns a list of the returned values of p. The value
--   returned by p is forced to WHNF.
--   
--   
--   word  = many1' letter
--   
many1' :: MonadPlus m => m a -> m [a]

-- | manyTill p end applies action p zero or more
--   times until action end succeeds, and returns the list of
--   values returned by p. This can be used to scan comments:
--   
--   
--   simpleComment   = string "<!--" *> manyTill anyChar (string "-->")
--   
--   
--   (Note the overlapping parsers anyChar and string
--   "-->". While this will work, it is not very efficient, as it
--   will cause a lot of backtracking.)
manyTill :: Alternative f => f a -> f b -> f [a]

-- | manyTill' p end applies action p zero or more
--   times until action end succeeds, and returns the list of
--   values returned by p. This can be used to scan comments:
--   
--   
--   simpleComment   = string "<!--" *> manyTill' anyChar (string "-->")
--   
--   
--   (Note the overlapping parsers anyChar and string
--   "-->". While this will work, it is not very efficient, as it
--   will cause a lot of backtracking.)
--   
--   The value returned by p is forced to WHNF.
manyTill' :: MonadPlus m => m a -> m b -> m [a]

-- | sepBy p sep applies zero or more occurrences of
--   p, separated by sep. Returns a list of the values
--   returned by p.
--   
--   
--   commaSep p  = p `sepBy` (char ',')
--   
sepBy :: Alternative f => f a -> f s -> f [a]

-- | sepBy' p sep applies zero or more occurrences of
--   p, separated by sep. Returns a list of the values
--   returned by p. The value returned by p is forced to
--   WHNF.
--   
--   
--   commaSep p  = p `sepBy'` (char ',')
--   
sepBy' :: MonadPlus m => m a -> m s -> m [a]

-- | sepBy1 p sep applies one or more occurrences of
--   p, separated by sep. Returns a list of the values
--   returned by p.
--   
--   
--   commaSep p  = p `sepBy1` (char ',')
--   
sepBy1 :: Alternative f => f a -> f s -> f [a]

-- | sepBy1' p sep applies one or more occurrences of
--   p, separated by sep. Returns a list of the values
--   returned by p. The value returned by p is forced to
--   WHNF.
--   
--   
--   commaSep p  = p `sepBy1'` (char ',')
--   
sepBy1' :: MonadPlus m => m a -> m s -> m [a]

-- | Skip zero or more instances of an action.
skipMany :: Alternative f => f a -> f ()

-- | Skip one or more instances of an action.
skipMany1 :: Alternative f => f a -> f ()

-- | Combine two alternatives.
eitherP :: Alternative f => f a -> f b -> f (Either a b)

-- | Return both the result of a parse and the portion of the input that
--   was consumed while it was being parsed.
match :: Parser a -> Parser (ByteString, a)

-- | Match only if all input has been consumed.
endOfInput :: Chunk t => Parser t ()

-- | Return an indication of whether the end of input has been reached.
atEnd :: Chunk t => Parser t Bool

-- | Simple, efficient combinator parsing that can consume lazy
--   ByteString strings, loosely based on the Parsec library.
--   
--   This is essentially the same code as in the Attoparsec module,
--   only with a parse function that can consume a lazy
--   ByteString incrementally, and a Result type that does
--   not allow more input to be fed in. Think of this as suitable for use
--   with a lazily read file, e.g. via readFile or
--   hGetContents.
--   
--   Note: The various parser functions and combinators such as
--   string still expect strict ByteString parameters,
--   and return strict ByteString results. Behind the scenes, strict
--   ByteString values are still used internally to store parser
--   input and manipulate it efficiently.
module Data.Attoparsec.ByteString.Lazy

-- | The result of a parse.
data Result r

-- | The parse failed. The ByteString is the input that had not yet
--   been consumed when the failure occurred. The
--   [String] is a list of contexts in which the
--   error occurred. The String is the message describing the error,
--   if any.
Fail :: ByteString -> [String] -> String -> Result r

-- | The parse succeeded. The ByteString is the input that had not
--   yet been consumed (if any) when the parse succeeded.
Done :: ByteString -> r -> Result r

-- | Consume input as long as the predicate returns True, and return
--   the consumed input.
--   
--   This parser does not fail. It will return an empty string if the
--   predicate returns False on the first byte of input.
--   
--   Note: Because this parser does not fail, do not use it with
--   combinators such as many, because such parsers loop until a
--   failure occurs. Careless use will thus result in an infinite loop.
takeWhile :: (Word8 -> Bool) -> Parser ByteString

-- | Consume exactly n bytes of input.
take :: Int -> Parser ByteString

-- | The parser satisfy p succeeds for any byte for which the
--   predicate p returns True. Returns the byte that is
--   actually parsed.
--   
--   
--   digit = satisfy isDigit
--       where isDigit w = w >= 48 && w <= 57
--   
satisfy :: (Word8 -> Bool) -> Parser Word8

-- | string s parses a sequence of bytes that identically match
--   s. Returns the parsed string (i.e. s). This parser
--   consumes no input if it fails (even if a partial match).
--   
--   Note: The behaviour of this parser is different to that of the
--   similarly-named parser in Parsec, as this one is all-or-nothing. To
--   illustrate the difference, the following parser will fail under Parsec
--   given an input of "for":
--   
--   
--   string "foo" <|> string "for"
--   
--   
--   The reason for its failure is that the first branch is a partial
--   match, and will consume the letters 'f' and 'o'
--   before failing. In attoparsec, the above parser will succeed on
--   that input, because the failed first branch will consume nothing.
string :: ByteString -> Parser ByteString

-- | choice ps tries to apply the actions in the list ps
--   in order, until one of them succeeds. Returns the value of the
--   succeeding action.
choice :: Alternative f => [f a] -> f a

-- | Apply the given action repeatedly, returning every result.
count :: Monad m => Int -> m a -> m [a]

-- | option x p tries to apply action p. If p
--   fails without consuming input, it returns the value x,
--   otherwise the value returned by p.
--   
--   
--   priority  = option 0 (digitToInt <$> digit)
--   
option :: Alternative f => a -> f a -> f a

-- | many1 p applies the action p one or more
--   times. Returns a list of the returned values of p.
--   
--   
--   word  = many1 letter
--   
many1 :: Alternative f => f a -> f [a]

-- | Skip zero or more instances of an action.
skipMany :: Alternative f => f a -> f ()

-- | Skip one or more instances of an action.
skipMany1 :: Alternative f => f a -> f ()

-- | sepBy p sep applies zero or more occurrences of
--   p, separated by sep. Returns a list of the values
--   returned by p.
--   
--   
--   commaSep p  = p `sepBy` (char ',')
--   
sepBy :: Alternative f => f a -> f s -> f [a]

-- | sepBy1 p sep applies one or more occurrences of
--   p, separated by sep. Returns a list of the values
--   returned by p.
--   
--   
--   commaSep p  = p `sepBy1` (char ',')
--   
sepBy1 :: Alternative f => f a -> f s -> f [a]

-- | manyTill p end applies action p zero or more
--   times until action end succeeds, and returns the list of
--   values returned by p. This can be used to scan comments:
--   
--   
--   simpleComment   = string "<!--" *> manyTill anyChar (string "-->")
--   
--   
--   (Note the overlapping parsers anyChar and string
--   "-->". While this will work, it is not very efficient, as it
--   will cause a lot of backtracking.)
manyTill :: Alternative f => f a -> f b -> f [a]

-- | Attempt a parse, and if it fails, rewind the input so that no input
--   appears to have been consumed.
--   
--   This combinator is provided for compatibility with Parsec. attoparsec
--   parsers always backtrack on failure.
try :: Parser i a -> Parser i a

-- | The parser skip p succeeds for any byte for which the
--   predicate p returns True.
--   
--   
--   skipDigit = skip isDigit
--       where isDigit w = w >= 48 && w <= 57
--   
skip :: (Word8 -> Bool) -> Parser ()

-- | Match a specific byte.
word8 :: Word8 -> Parser Word8

-- | Return both the result of a parse and the portion of the input that
--   was consumed while it was being parsed.
match :: Parser a -> Parser (ByteString, a)
type Parser = Parser ByteString

-- | Compare two IResult values for equality.
--   
--   If both IResults are Partial, the result will be
--   Nothing, as they are incomplete and hence their equality cannot
--   be known. (This is why there is no Eq instance for
--   IResult.)
compareResults :: (Eq i, Eq r) => IResult i r -> IResult i r -> Maybe Bool

-- | If a parser has returned a Partial result, supply it with more
--   input.
feed :: Monoid i => IResult i r -> i -> IResult i r

-- | Match any byte.
anyWord8 :: Parser Word8

-- | Match any byte except the given one.
notWord8 :: Word8 -> Parser Word8

-- | The parser satisfyWith f p transforms a byte, and succeeds if
--   the predicate p returns True on the transformed value.
--   The parser returns the transformed byte that was parsed.
satisfyWith :: (Word8 -> a) -> (a -> Bool) -> Parser a

-- | Match any byte, to perform lookahead. Returns Nothing if end of
--   input has been reached. Does not consume any input.
--   
--   Note: Because this parser does not fail, do not use it with
--   combinators such as many, because such parsers loop until a
--   failure occurs. Careless use will thus result in an infinite loop.
peekWord8 :: Parser (Maybe Word8)

-- | Match any byte, to perform lookahead. Does not consume any input, but
--   will fail if end of input has been reached.
peekWord8' :: Parser Word8

-- | Match any byte in a set.
--   
--   
--   vowel = inClass "aeiou"
--   
--   
--   Range notation is supported.
--   
--   
--   halfAlphabet = inClass "a-nA-N"
--   
--   
--   To add a literal '-' to a set, place it at the beginning or
--   end of the string.
inClass :: String -> Word8 -> Bool

-- | Match any byte not in a set.
notInClass :: String -> Word8 -> Bool

-- | Skip past input for as long as the predicate returns True.
skipWhile :: (Word8 -> Bool) -> Parser ()

-- | A stateful scanner. The predicate consumes and transforms a state
--   argument, and each transformed state is passed to successive
--   invocations of the predicate on each byte of the input until one
--   returns Nothing or the input ends.
--   
--   This parser does not fail. It will return an empty string if the
--   predicate returns Nothing on the first byte of input.
--   
--   Note: Because this parser does not fail, do not use it with
--   combinators such as many, because such parsers loop until a
--   failure occurs. Careless use will thus result in an infinite loop.
scan :: s -> (s -> Word8 -> Maybe s) -> Parser ByteString

-- | Like scan, but generalized to return the final state of the
--   scanner.
runScanner :: s -> (s -> Word8 -> Maybe s) -> Parser (ByteString, s)

-- | Consume input as long as the predicate returns True, and return
--   the consumed input.
--   
--   This parser requires the predicate to succeed on at least one byte of
--   input: it will fail if the predicate never returns True or if
--   there is no input left.
takeWhile1 :: (Word8 -> Bool) -> Parser ByteString

-- | Consume input until immediately after the predicate returns
--   True, and return the consumed input.
--   
--   This parser will consume at least one Word8 or fail.
takeWhileIncluding :: (Word8 -> Bool) -> Parser ByteString

-- | Consume input as long as the predicate returns False (i.e.
--   until it returns True), and return the consumed input.
--   
--   This parser does not fail. It will return an empty string if the
--   predicate returns True on the first byte of input.
--   
--   Note: Because this parser does not fail, do not use it with
--   combinators such as many, because such parsers loop until a
--   failure occurs. Careless use will thus result in an infinite loop.
takeTill :: (Word8 -> Bool) -> Parser ByteString

-- | Return the rest of the current chunk without consuming anything.
--   
--   If the current chunk is empty, then ask for more input. If there is no
--   more input, then return Nothing
getChunk :: Parser (Maybe ByteString)

-- | Consume all remaining input and return it as a single string.
takeByteString :: Parser ByteString

-- | Consume all remaining input and return it as a single string.
takeLazyByteString :: Parser ByteString

-- | Name the parser, in case failure occurs.
(<?>) :: Parser i a -> String -> Parser i a
infix 0 <?>

-- | many' p applies the action p zero or more
--   times. Returns a list of the returned values of p. The value
--   returned by p is forced to WHNF.
--   
--   
--   word  = many' letter
--   
many' :: MonadPlus m => m a -> m [a]

-- | many1' p applies the action p one or more
--   times. Returns a list of the returned values of p. The value
--   returned by p is forced to WHNF.
--   
--   
--   word  = many1' letter
--   
many1' :: MonadPlus m => m a -> m [a]

-- | manyTill' p end applies action p zero or more
--   times until action end succeeds, and returns the list of
--   values returned by p. This can be used to scan comments:
--   
--   
--   simpleComment   = string "<!--" *> manyTill' anyChar (string "-->")
--   
--   
--   (Note the overlapping parsers anyChar and string
--   "-->". While this will work, it is not very efficient, as it
--   will cause a lot of backtracking.)
--   
--   The value returned by p is forced to WHNF.
manyTill' :: MonadPlus m => m a -> m b -> m [a]

-- | sepBy' p sep applies zero or more occurrences of
--   p, separated by sep. Returns a list of the values
--   returned by p. The value returned by p is forced to
--   WHNF.
--   
--   
--   commaSep p  = p `sepBy'` (char ',')
--   
sepBy' :: MonadPlus m => m a -> m s -> m [a]

-- | sepBy1' p sep applies one or more occurrences of
--   p, separated by sep. Returns a list of the values
--   returned by p. The value returned by p is forced to
--   WHNF.
--   
--   
--   commaSep p  = p `sepBy1'` (char ',')
--   
sepBy1' :: MonadPlus m => m a -> m s -> m [a]

-- | Combine two alternatives.
eitherP :: Alternative f => f a -> f b -> f (Either a b)

-- | Match only if all input has been consumed.
endOfInput :: Chunk t => Parser t ()

-- | Return an indication of whether the end of input has been reached.
atEnd :: Chunk t => Parser t Bool

-- | Run a parser and return its result.
parse :: Parser a -> ByteString -> Result a

-- | Run a parser that cannot be resupplied via a Partial result.
--   
--   This function does not force a parser to consume all of its input.
--   Instead, any residual input will be discarded. To force a parser to
--   consume all of its input, use something like this:
--   
--   
--   parseOnly (myParser <* endOfInput)
--    
--   
parseOnly :: Parser a -> ByteString -> Either String a

-- | Run a parser and print its result to standard output.
parseTest :: Show a => Parser a -> ByteString -> IO ()

-- | Convert a Result value to a Maybe value.
maybeResult :: Result r -> Maybe r

-- | Convert a Result value to an Either value.
eitherResult :: Result r -> Either String r
instance GHC.Internal.Base.Functor Data.Attoparsec.ByteString.Lazy.Result
instance Control.DeepSeq.NFData r => Control.DeepSeq.NFData (Data.Attoparsec.ByteString.Lazy.Result r)
instance GHC.Internal.Show.Show r => GHC.Internal.Show.Show (Data.Attoparsec.ByteString.Lazy.Result r)

-- | Simple, efficient combinator parsing for lazy ByteString
--   strings, loosely based on the Parsec library.
--   
--   This is essentially the same code as in the Attoparsec module,
--   only with a parse function that can consume a lazy
--   ByteString incrementally, and a Result type that does
--   not allow more input to be fed in. Think of this as suitable for use
--   with a lazily read file, e.g. via readFile or
--   hGetContents.
--   
--   Behind the scenes, strict ByteString values are still used
--   internally to store parser input and manipulate it efficiently.
--   High-performance parsers such as string still expect strict
--   ByteString parameters.
module Data.Attoparsec.Lazy

-- | Simple, efficient, character-oriented combinator parsing for
--   ByteString strings, loosely based on the Parsec library.
module Data.Attoparsec.ByteString.Char8
type Parser = Parser ByteString
type Result = IResult ByteString

-- | The result of a parse. This is parameterised over the type i
--   of string that was processed.
--   
--   This type is an instance of Functor, where fmap
--   transforms the value in a Done result.
data IResult i r

-- | The parse failed. The i parameter is the input that had not
--   yet been consumed when the failure occurred. The
--   [String] is a list of contexts in which the
--   error occurred. The String is the message describing the error,
--   if any.
Fail :: i -> [String] -> String -> IResult i r

-- | Supply this continuation with more input so that the parser can
--   resume. To indicate that no more input is available, pass an empty
--   string to the continuation.
--   
--   Note: if you get a Partial result, do not call its
--   continuation more than once.
Partial :: (i -> IResult i r) -> IResult i r

-- | The parse succeeded. The i parameter is the input that had
--   not yet been consumed (if any) when the parse succeeded.
Done :: i -> r -> IResult i r

-- | Compare two IResult values for equality.
--   
--   If both IResults are Partial, the result will be
--   Nothing, as they are incomplete and hence their equality cannot
--   be known. (This is why there is no Eq instance for
--   IResult.)
compareResults :: (Eq i, Eq r) => IResult i r -> IResult i r -> Maybe Bool

-- | Run a parser.
parse :: Parser a -> ByteString -> Result a

-- | If a parser has returned a Partial result, supply it with more
--   input.
feed :: Monoid i => IResult i r -> i -> IResult i r

-- | Run a parser that cannot be resupplied via a Partial result.
--   
--   This function does not force a parser to consume all of its input.
--   Instead, any residual input will be discarded. To force a parser to
--   consume all of its input, use something like this:
--   
--   
--   parseOnly (myParser <* endOfInput)
--    
--   
parseOnly :: Parser a -> ByteString -> Either String a

-- | Run a parser with an initial input string, and a monadic action that
--   can supply more input if needed.
parseWith :: Monad m => m ByteString -> Parser a -> ByteString -> m (Result a)

-- | Run a parser and print its result to standard output.
parseTest :: Show a => Parser a -> ByteString -> IO ()

-- | Convert a Result value to a Maybe value. A
--   Partial result is treated as failure.
maybeResult :: Result r -> Maybe r

-- | Convert a Result value to an Either value. A
--   Partial result is treated as failure.
eitherResult :: Result r -> Either String r

-- | Match a specific character.
char :: Char -> Parser Char

-- | Match a specific character, but return its Word8 value.
char8 :: Char -> Parser Word8

-- | Match any character.
anyChar :: Parser Char

-- | Match any character except the given one.
notChar :: Char -> Parser Char

-- | The parser satisfy p succeeds for any byte for which the
--   predicate p returns True. Returns the byte that is
--   actually parsed.
--   
--   
--   digit = satisfy isDigit
--       where isDigit c = c >= '0' && c <= '9'
--   
satisfy :: (Char -> Bool) -> Parser Char

-- | Match any character, to perform lookahead. Returns Nothing if
--   end of input has been reached. Does not consume any input.
--   
--   Note: Because this parser does not fail, do not use it with
--   combinators such as many, because such parsers loop until a
--   failure occurs. Careless use will thus result in an infinite loop.
peekChar :: Parser (Maybe Char)

-- | Match any character, to perform lookahead. Does not consume any input,
--   but will fail if end of input has been reached.
peekChar' :: Parser Char

-- | Parse a single digit.
digit :: Parser Char

-- | Match a letter, in the ISO-8859-15 encoding.
letter_iso8859_15 :: Parser Char

-- | Match a letter, in the ASCII encoding.
letter_ascii :: Parser Char

-- | Parse a space character.
--   
--   Note: This parser only gives correct answers for the ASCII
--   encoding. For instance, it does not recognise U+00A0 (non-breaking
--   space) as a space character, even though it is a valid ISO-8859-15
--   byte.
space :: Parser Char

-- | A fast digit predicate.
isDigit :: Char -> Bool

-- | A fast digit predicate.
isDigit_w8 :: Word8 -> Bool

-- | A fast alphabetic predicate for the ISO-8859-15 encoding
--   
--   Note: For all character encodings other than ISO-8859-15, and
--   almost all Unicode code points above U+00A3, this predicate gives
--   wrong answers.
isAlpha_iso8859_15 :: Char -> Bool

-- | A fast alphabetic predicate for the ASCII encoding
--   
--   Note: For all character encodings other than ASCII, and almost
--   all Unicode code points above U+007F, this predicate gives wrong
--   answers.
isAlpha_ascii :: Char -> Bool

-- | Fast predicate for matching ASCII space characters.
--   
--   Note: This predicate only gives correct answers for the ASCII
--   encoding. For instance, it does not recognise U+00A0 (non-breaking
--   space) as a space character, even though it is a valid ISO-8859-15
--   byte. For a Unicode-aware and only slightly slower predicate, use
--   isSpace
isSpace :: Char -> Bool

-- | Fast Word8 predicate for matching ASCII space characters.
isSpace_w8 :: Word8 -> Bool

-- | Match any character in a set.
--   
--   
--   vowel = inClass "aeiou"
--   
--   
--   Range notation is supported.
--   
--   
--   halfAlphabet = inClass "a-nA-N"
--   
--   
--   To add a literal '-' to a set, place it at the beginning or end of the
--   string.
inClass :: String -> Char -> Bool

-- | Match any character not in a set.
notInClass :: String -> Char -> Bool

-- | string s parses a sequence of bytes that identically match
--   s. Returns the parsed string (i.e. s). This parser
--   consumes no input if it fails (even if a partial match).
--   
--   Note: The behaviour of this parser is different to that of the
--   similarly-named parser in Parsec, as this one is all-or-nothing. To
--   illustrate the difference, the following parser will fail under Parsec
--   given an input of "for":
--   
--   
--   string "foo" <|> string "for"
--   
--   
--   The reason for its failure is that the first branch is a partial
--   match, and will consume the letters 'f' and 'o'
--   before failing. In attoparsec, the above parser will succeed on
--   that input, because the failed first branch will consume nothing.
string :: ByteString -> Parser ByteString

-- | Satisfy a literal string, ignoring case.
stringCI :: ByteString -> Parser ByteString

-- | Skip over white space.
skipSpace :: Parser ()

-- | Skip past input for as long as the predicate returns True.
skipWhile :: (Char -> Bool) -> Parser ()

-- | Consume exactly n bytes of input.
take :: Int -> Parser ByteString

-- | A stateful scanner. The predicate consumes and transforms a state
--   argument, and each transformed state is passed to successive
--   invocations of the predicate on each byte of the input until one
--   returns Nothing or the input ends.
--   
--   This parser does not fail. It will return an empty string if the
--   predicate returns Nothing on the first byte of input.
--   
--   Note: Because this parser does not fail, do not use it with
--   combinators such as many, because such parsers loop until a
--   failure occurs. Careless use will thus result in an infinite loop.
scan :: s -> (s -> Char -> Maybe s) -> Parser ByteString

-- | Consume input as long as the predicate returns True, and return
--   the consumed input.
--   
--   This parser does not fail. It will return an empty string if the
--   predicate returns False on the first byte of input.
--   
--   Note: Because this parser does not fail, do not use it with
--   combinators such as many, because such parsers loop until a
--   failure occurs. Careless use will thus result in an infinite loop.
takeWhile :: (Char -> Bool) -> Parser ByteString

-- | Consume input as long as the predicate returns True, and return
--   the consumed input.
--   
--   This parser requires the predicate to succeed on at least one byte of
--   input: it will fail if the predicate never returns True or if
--   there is no input left.
takeWhile1 :: (Char -> Bool) -> Parser ByteString

-- | Consume input as long as the predicate returns False (i.e.
--   until it returns True), and return the consumed input.
--   
--   This parser does not fail. It will return an empty string if the
--   predicate returns True on the first byte of input.
--   
--   Note: Because this parser does not fail, do not use it with
--   combinators such as many, because such parsers loop until a
--   failure occurs. Careless use will thus result in an infinite loop.
takeTill :: (Char -> Bool) -> Parser ByteString

-- | Obsolete. A type-specialized version of *> for
--   ByteString. Use *> instead.

-- | Deprecated: This is no longer necessary, and will be removed. Use
--   *> instead.
(.*>) :: ByteString -> Parser a -> Parser a

-- | Obsolete. A type-specialized version of <* for
--   ByteString. Use <* instead.

-- | Deprecated: This is no longer necessary, and will be removed. Use
--   <* instead.
(<*.) :: Parser a -> ByteString -> Parser a

-- | Consume all remaining input and return it as a single string.
takeByteString :: Parser ByteString

-- | Consume all remaining input and return it as a single string.
takeLazyByteString :: Parser ByteString

-- | Match either a single newline character '\n', or a carriage
--   return followed by a newline character "\r\n".
endOfLine :: Parser ()

-- | A predicate that matches either a carriage return '\r' or
--   newline '\n' character.
isEndOfLine :: Word8 -> Bool

-- | A predicate that matches either a space ' ' or horizontal tab
--   '\t' character.
isHorizontalSpace :: Word8 -> Bool

-- | Parse and decode an unsigned decimal number.
decimal :: Integral a => Parser a

-- | Parse and decode an unsigned hexadecimal number. The hex digits
--   'a' through 'f' may be upper or lower case.
--   
--   This parser does not accept a leading "0x" string.
hexadecimal :: (Integral a, Bits a) => Parser a

-- | Parse a number with an optional leading '+' or '-'
--   sign character.
signed :: Num a => Parser a -> Parser a

-- | Parse a Double.
--   
--   This parser accepts an optional leading sign character, followed by at
--   most one decimal digit. The syntax is similar to that accepted by the
--   read function, with the exception that a trailing '.'
--   is consumed.
--   
--   
Examples
--   
--   These examples use this helper:
--   
--   
--   r :: Parser a -> ByteString -> Result a
--   r p s = feed (parse p s) mempty
--   
--   
--   Examples with behaviour identical to read, if you feed an empty
--   continuation to the first result:
--   
--   
--   double "3"     == Done "" 3.0
--   double "3.1"   == Done "" 3.1
--   double "3e4"   == Done "" 30000.0
--   double "3.1e4" == Done "" 31000.0
--   double "3e"    == Done "e" 3.0
--   
--   
--   Examples with behaviour identical to read:
--   
--   
--   double ".3"    == Fail ".3" _ _
--   double "e3"    == Fail "e3" _ _
--   
--   
--   Example of difference from read:
--   
--   
--   double "3.foo" == Done "foo" 3.0
--   
--   
--   This function does not accept string representations of "NaN" or
--   "Infinity".
double :: Parser Double

-- | A numeric type that can represent integers accurately, and floating
--   point numbers to the precision of a Double.
--   
--   Note: this type is deprecated, and will be removed in the next
--   major release. Use the Scientific type instead.
data Number
I :: !Integer -> Number
D :: {-# UNPACK #-} !Double -> Number

-- | Parse a number, attempting to preserve both speed and precision.
--   
--   The syntax accepted by this parser is the same as for double.

-- | Deprecated: Use scientific instead.
number :: Parser Number

-- | Parse a rational number.
--   
--   The syntax accepted by this parser is the same as for double.
--   
--   Note: this parser is not safe for use with inputs from
--   untrusted sources. An input with a suitably large exponent such as
--   "1e1000000000" will cause a huge Integer to be
--   allocated, resulting in what is effectively a denial-of-service
--   attack.
--   
--   In most cases, it is better to use double or scientific
--   instead.
rational :: Fractional a => Parser a

-- | Parse a scientific number.
--   
--   The syntax accepted by this parser is the same as for double.
scientific :: Parser Scientific

-- | Attempt a parse, and if it fails, rewind the input so that no input
--   appears to have been consumed.
--   
--   This combinator is provided for compatibility with Parsec. attoparsec
--   parsers always backtrack on failure.
try :: Parser i a -> Parser i a

-- | Name the parser, in case failure occurs.
(<?>) :: Parser i a -> String -> Parser i a
infix 0 <?>

-- | choice ps tries to apply the actions in the list ps
--   in order, until one of them succeeds. Returns the value of the
--   succeeding action.
choice :: Alternative f => [f a] -> f a

-- | Apply the given action repeatedly, returning every result.
count :: Monad m => Int -> m a -> m [a]

-- | option x p tries to apply action p. If p
--   fails without consuming input, it returns the value x,
--   otherwise the value returned by p.
--   
--   
--   priority  = option 0 (digitToInt <$> digit)
--   
option :: Alternative f => a -> f a -> f a

-- | many' p applies the action p zero or more
--   times. Returns a list of the returned values of p. The value
--   returned by p is forced to WHNF.
--   
--   
--   word  = many' letter
--   
many' :: MonadPlus m => m a -> m [a]

-- | many1 p applies the action p one or more
--   times. Returns a list of the returned values of p.
--   
--   
--   word  = many1 letter
--   
many1 :: Alternative f => f a -> f [a]

-- | many1' p applies the action p one or more
--   times. Returns a list of the returned values of p. The value
--   returned by p is forced to WHNF.
--   
--   
--   word  = many1' letter
--   
many1' :: MonadPlus m => m a -> m [a]

-- | manyTill p end applies action p zero or more
--   times until action end succeeds, and returns the list of
--   values returned by p. This can be used to scan comments:
--   
--   
--   simpleComment   = string "<!--" *> manyTill anyChar (string "-->")
--   
--   
--   (Note the overlapping parsers anyChar and string
--   "-->". While this will work, it is not very efficient, as it
--   will cause a lot of backtracking.)
manyTill :: Alternative f => f a -> f b -> f [a]

-- | manyTill' p end applies action p zero or more
--   times until action end succeeds, and returns the list of
--   values returned by p. This can be used to scan comments:
--   
--   
--   simpleComment   = string "<!--" *> manyTill' anyChar (string "-->")
--   
--   
--   (Note the overlapping parsers anyChar and string
--   "-->". While this will work, it is not very efficient, as it
--   will cause a lot of backtracking.)
--   
--   The value returned by p is forced to WHNF.
manyTill' :: MonadPlus m => m a -> m b -> m [a]

-- | sepBy p sep applies zero or more occurrences of
--   p, separated by sep. Returns a list of the values
--   returned by p.
--   
--   
--   commaSep p  = p `sepBy` (char ',')
--   
sepBy :: Alternative f => f a -> f s -> f [a]

-- | sepBy' p sep applies zero or more occurrences of
--   p, separated by sep. Returns a list of the values
--   returned by p. The value returned by p is forced to
--   WHNF.
--   
--   
--   commaSep p  = p `sepBy'` (char ',')
--   
sepBy' :: MonadPlus m => m a -> m s -> m [a]

-- | sepBy1 p sep applies one or more occurrences of
--   p, separated by sep. Returns a list of the values
--   returned by p.
--   
--   
--   commaSep p  = p `sepBy1` (char ',')
--   
sepBy1 :: Alternative f => f a -> f s -> f [a]

-- | sepBy1' p sep applies one or more occurrences of
--   p, separated by sep. Returns a list of the values
--   returned by p. The value returned by p is forced to
--   WHNF.
--   
--   
--   commaSep p  = p `sepBy1'` (char ',')
--   
sepBy1' :: MonadPlus m => m a -> m s -> m [a]

-- | Skip zero or more instances of an action.
skipMany :: Alternative f => f a -> f ()

-- | Skip one or more instances of an action.
skipMany1 :: Alternative f => f a -> f ()

-- | Combine two alternatives.
eitherP :: Alternative f => f a -> f b -> f (Either a b)

-- | Return both the result of a parse and the portion of the input that
--   was consumed while it was being parsed.
match :: Parser a -> Parser (ByteString, a)

-- | Match only if all input has been consumed.
endOfInput :: Chunk t => Parser t ()

-- | Return an indication of whether the end of input has been reached.
atEnd :: Chunk t => Parser t Bool
instance (a GHC.Types.~ Data.ByteString.Internal.Type.ByteString) => GHC.Internal.Data.String.IsString (Data.Attoparsec.ByteString.Internal.Parser a)

-- | Simple, efficient, character-oriented combinator parsing for
--   ByteString strings, loosely based on the Parsec library.
--   
--   This module is deprecated. Use Data.Attoparsec.ByteString.Char8
--   instead.

-- | Deprecated: This module will be removed in the next major
--   release.
module Data.Attoparsec.Char8

-- | Simple, efficient combinator parsing for ByteString strings,
--   loosely based on the Parsec library.
--   
--   This module is deprecated. Use Data.Attoparsec.ByteString
--   instead.

-- | Deprecated: This module will be removed in the next major
--   release.
module Data.Attoparsec
