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


-- | Class of types that can be constructed from their text representation
--   
--   This library provides the type class <a>HasParser</a> as a dual to
--   <a>Pretty</a>. Instances of this class provide a parser than can be
--   used to construct the type from its text representation.
@package parsec-class
@version 1.0.0.0

module Text.Parsec.Class.Orphans
instance GHC.Exception.Type.Exception Text.Parsec.Error.ParseError


-- | <a>HasParser</a> can be considered a dual to <tt>Pretty</tt> like
--   <a>Read</a> is to <a>Show</a>. The class provides <a>Data.Parsec</a>
--   parsers for its instances that construct the type from its textual
--   representation. Combined with the <a>parseM</a> and <a>parse</a>
--   convenience functions, this class makes parsing simple. Unlike
--   <a>Read</a>, Parsec parsers return reasonable error messages in case
--   of failure. Also, there is a rich set of combinators and additional
--   libraries available for re-use.
module Text.Parsec.Class

-- | A simplified <a>ParsecT</a> parser that consumes some kind of
--   character stream without requiring any particular state state.
type CharParser st input m a = Stream st m Char => ParsecT st input m a

-- | Types that are instances of this class can be parsed and constructed
--   from some character based text representation.
class HasParser a
parser :: HasParser a => CharParser st input m a

-- | Parsers functions like <a>parse</a> or <a>parseM</a> use this type to
--   provide a helpful context in case the parser failes. Parsec uses the
--   synonym <a>SourceName</a> for the same purpose, but in fact this type
--   doesn't necessarily have to be a file name. It can be any name or
--   identifier. Oftentimes, it it's useful to pass the name of the type
--   that the parser attempted to parse.
type ErrorContext = String

-- | Convenience wrapper around <a>runParserT</a> that uses the
--   <a>HasParser</a> class to determine the desired parser for the given
--   result type. The function reports syntax errors via <a>fail</a>.
--   
--   <pre>
--   &gt;&gt;&gt; parseM "Natural" "987654321" :: IO Natural
--   987654321
--   
--   &gt;&gt;&gt; parseM "Natural" "123456789" :: Maybe Natural
--   Just 123456789
--   </pre>
--   
--   Please note that parsers run this way do not ignore any white space:
--   
--   <pre>
--   &gt;&gt;&gt; parseM "Natural" " 1" :: Maybe Natural
--   Nothing
--   
--   &gt;&gt;&gt; parseM "Natural" "1 " :: Maybe Natural
--   Nothing
--   </pre>
parseM :: (MonadFail m, Stream input m Char, HasParser a) => ErrorContext -> input -> m a

-- | Convenience wrapper around <a>runParser</a> that uses the
--   <a>HasParser</a> class to determine the desired parser for the given
--   result type. The function reports syntax errors by <a>throw</a>ing
--   <a>ParseError</a>. This approach is inherently impure and complicates
--   error handling greatly. Use this function only on occasions where
--   parser errors are fatal errors that your code cannot recover from. In
--   almost all cases, <a>parseM</a> is the better choice.
--   
--   <pre>
--   &gt;&gt;&gt; parse "Natural" "12345" :: Natural
--   12345
--   </pre>
--   
--   Like <a>parseM</a>, this function does not skip over any white space.
--   Use Parsec's primitive <a>runParser</a> or <a>runParserT</a> functions
--   if you don't like this behavior:
--   
--   <pre>
--   &gt;&gt;&gt; runParser (spaces &gt;&gt; parser) () "Natural" "  1  " :: Either ParseError Natural
--   Right 1
--   </pre>
parse :: (Stream input Identity Char, HasParser a) => ErrorContext -> input -> a

-- | <tt>string s</tt> parses a sequence of characters given by <tt>s</tt>.
--   Returns the parsed string (i.e. <tt>s</tt>).
--   
--   <pre>
--   divOrMod    =   string "div"
--               &lt;|&gt; string "mod"
--   </pre>
string :: forall s (m :: Type -> Type) u. Stream s m Char => String -> ParsecT s u m String

-- | The parser <tt>satisfy f</tt> succeeds for any character for which the
--   supplied function <tt>f</tt> returns <a>True</a>. Returns the
--   character that is actually parsed.
satisfy :: forall s (m :: Type -> Type) u. Stream s m Char => (Char -> Bool) -> ParsecT s u m Char

-- | This parser succeeds for any character. Returns the parsed character.
anyChar :: forall s (m :: Type -> Type) u. Stream s m Char => ParsecT s u m Char

-- | <tt>char c</tt> parses a single character <tt>c</tt>. Returns the
--   parsed character (i.e. <tt>c</tt>).
--   
--   <pre>
--   semiColon  = char ';'
--   </pre>
char :: forall s (m :: Type -> Type) u. Stream s m Char => Char -> ParsecT s u m Char

-- | Parses an octal digit (a character between '0' and '7'). Returns the
--   parsed character.
octDigit :: forall s (m :: Type -> Type) u. Stream s m Char => ParsecT s u m Char

-- | Parses a hexadecimal digit (a digit or a letter between 'a' and 'f' or
--   'A' and 'F'). Returns the parsed character.
hexDigit :: forall s (m :: Type -> Type) u. Stream s m Char => ParsecT s u m Char

-- | Parses an ASCII digit. Returns the parsed character.
digit :: forall s (m :: Type -> Type) u. Stream s m Char => ParsecT s u m Char

-- | Parses an alphabetic Unicode characters (lower-case, upper-case and
--   title-case letters, plus letters of caseless scripts and modifiers
--   letters according to <a>isAlpha</a>). Returns the parsed character.
letter :: forall s (m :: Type -> Type) u. Stream s m Char => ParsecT s u m Char

-- | Parses a alphabetic or numeric Unicode characters according to
--   <a>isAlphaNum</a>. Returns the parsed character.
--   
--   Note that numeric digits outside the ASCII range (such as arabic-indic
--   digits like e.g. "٤" or <tt>U+0664</tt>), as well as numeric
--   characters which aren't digits, are parsed by this function but not by
--   <a>digit</a>.
alphaNum :: forall s (m :: Type -> Type) u. Stream s m Char => ParsecT s u m Char

-- | Parses a lower case character (according to <a>isLower</a>). Returns
--   the parsed character.
lower :: forall s (m :: Type -> Type) u. Stream s m Char => ParsecT s u m Char

-- | Parses an upper case letter (according to <a>isUpper</a>). Returns the
--   parsed character.
upper :: forall s (m :: Type -> Type) u. Stream s m Char => ParsecT s u m Char

-- | Parses a tab character ('\t'). Returns a tab character.
tab :: forall s (m :: Type -> Type) u. Stream s m Char => ParsecT s u m Char

-- | Parses a CRLF (see <a>crlf</a>) or LF (see <a>newline</a>)
--   end-of-line. Returns a newline character ('\n').
--   
--   <pre>
--   endOfLine = newline &lt;|&gt; crlf
--   </pre>
endOfLine :: forall s (m :: Type -> Type) u. Stream s m Char => ParsecT s u m Char

-- | Parses a carriage return character ('\r') followed by a newline
--   character ('\n'). Returns a newline character.
crlf :: forall s (m :: Type -> Type) u. Stream s m Char => ParsecT s u m Char

-- | Parses a newline character ('\n'). Returns a newline character.
newline :: forall s (m :: Type -> Type) u. Stream s m Char => ParsecT s u m Char

-- | Parses a white space character (any character which satisfies
--   <a>isSpace</a>) Returns the parsed character.
space :: forall s (m :: Type -> Type) u. Stream s m Char => ParsecT s u m Char

-- | Skips <i>zero</i> or more white space characters. See also
--   <a>skipMany</a>.
spaces :: forall s (m :: Type -> Type) u. Stream s m Char => ParsecT s u m ()

-- | As the dual of <a>oneOf</a>, <tt>noneOf cs</tt> succeeds if the
--   current character <i>not</i> in the supplied list of characters
--   <tt>cs</tt>. Returns the parsed character.
--   
--   <pre>
--   consonant = noneOf "aeiou"
--   </pre>
noneOf :: forall s (m :: Type -> Type) u. Stream s m Char => [Char] -> ParsecT s u m Char

-- | <tt>oneOf cs</tt> succeeds if the current character is in the supplied
--   list of characters <tt>cs</tt>. Returns the parsed character. See also
--   <a>satisfy</a>.
--   
--   <pre>
--   vowel  = oneOf "aeiou"
--   </pre>
oneOf :: forall s (m :: Type -> Type) u. Stream s m Char => [Char] -> ParsecT s u m Char

-- | <tt>parserTraced label p</tt> is an impure function, implemented with
--   <a>Debug.Trace</a> that prints to the console the remaining parser
--   state at the time it is invoked. It then continues to apply parser
--   <tt>p</tt>, and if <tt>p</tt> fails will indicate that the label has
--   been backtracked. It is intended to be used for debugging parsers by
--   inspecting their intermediate states.
--   
--   <pre>
--   *&gt;  parseTest (oneOf "aeiou"  &gt;&gt; parserTraced "label" (oneOf "nope")) "atest"
--   label: "test"
--   label backtracked
--   parse error at (line 1, column 2):
--   ...
--   </pre>
parserTraced :: forall s (m :: Type -> Type) t u b. (Stream s m t, Show t) => String -> ParsecT s u m b -> ParsecT s u m b

-- | <tt>parserTrace label</tt> is an impure function, implemented with
--   <a>Debug.Trace</a> that prints to the console the remaining parser
--   state at the time it is invoked. It is intended to be used for
--   debugging parsers by inspecting their intermediate states.
--   
--   <pre>
--   *&gt; parseTest (oneOf "aeiou"  &gt;&gt; parserTrace "label") "atest"
--   label: "test"
--   ...
--   </pre>
parserTrace :: forall t s (m :: Type -> Type) u. (Show t, Stream s m t) => String -> ParsecT s u m ()

-- | <tt>manyTill p end</tt> applies parser <tt>p</tt> <i>zero</i> or more
--   times until parser <tt>end</tt> succeeds. Returns the list of values
--   returned by <tt>p</tt>. This parser can be used to scan comments:
--   
--   <pre>
--   simpleComment   = do{ string "&lt;!--"
--                       ; manyTill anyChar (try (string "--&gt;"))
--                       }
--   </pre>
--   
--   Note the overlapping parsers <tt>anyChar</tt> and <tt>string
--   "--&gt;"</tt>, and therefore the use of the <a>try</a> combinator.
manyTill :: forall s (m :: Type -> Type) t u a end. Stream s m t => ParsecT s u m a -> ParsecT s u m end -> ParsecT s u m [a]

-- | <tt>notFollowedBy p</tt> only succeeds when parser <tt>p</tt> fails.
--   This parser does not consume any input. This parser can be used to
--   implement the 'longest match' rule. For example, when recognizing
--   keywords (for example <tt>let</tt>), we want to make sure that a
--   keyword is not followed by a legal identifier character, in which case
--   the keyword is actually an identifier (for example <tt>lets</tt>). We
--   can program this behaviour as follows:
--   
--   <pre>
--   keywordLet  = try (do{ string "let"
--                        ; notFollowedBy alphaNum
--                        })
--   </pre>
--   
--   <b>NOTE</b>: Currently, <a>notFollowedBy</a> exhibits surprising
--   behaviour when applied to a parser <tt>p</tt> that doesn't consume any
--   input; specifically
--   
--   <ul>
--   <li><tt><a>notFollowedBy</a> . <a>notFollowedBy</a></tt> is <i>not</i>
--   equivalent to <a>lookAhead</a>, and</li>
--   <li><tt><a>notFollowedBy</a> <a>eof</a></tt> <i>never</i> fails.</li>
--   </ul>
--   
--   See <a>haskell/parsec#8</a> for more details.
notFollowedBy :: forall s (m :: Type -> Type) t a u. (Stream s m t, Show a) => ParsecT s u m a -> ParsecT s u m ()

-- | This parser only succeeds at the end of the input. This is not a
--   primitive parser but it is defined using <a>notFollowedBy</a>.
--   
--   <pre>
--   eof  = notFollowedBy anyToken &lt;?&gt; "end of input"
--   </pre>
eof :: forall s (m :: Type -> Type) t u. (Stream s m t, Show t) => ParsecT s u m ()

-- | The parser <tt>anyToken</tt> accepts any kind of token. It is for
--   example used to implement <a>eof</a>. Returns the accepted token.
anyToken :: forall s (m :: Type -> Type) t u. (Stream s m t, Show t) => ParsecT s u m t

-- | <tt>chainr1 p op x</tt> parses <i>one</i> or more occurrences of |p|,
--   separated by <tt>op</tt> Returns a value obtained by a <i>right</i>
--   associative application of all functions returned by <tt>op</tt> to
--   the values returned by <tt>p</tt>.
chainr1 :: forall s (m :: Type -> Type) t u a. Stream s m t => ParsecT s u m a -> ParsecT s u m (a -> a -> a) -> ParsecT s u m a

-- | <tt>chainl1 p op</tt> parses <i>one</i> or more occurrences of
--   <tt>p</tt>, separated by <tt>op</tt> Returns a value obtained by a
--   <i>left</i> associative application of all functions returned by
--   <tt>op</tt> to the values returned by <tt>p</tt>. This parser can for
--   example be used to eliminate left recursion which typically occurs in
--   expression grammars.
--   
--   <pre>
--   expr    = term   `chainl1` addop
--   term    = factor `chainl1` mulop
--   factor  = parens expr &lt;|&gt; integer
--   
--   mulop   =   do{ symbol "*"; return (*)   }
--           &lt;|&gt; do{ symbol "/"; return (div) }
--   
--   addop   =   do{ symbol "+"; return (+) }
--           &lt;|&gt; do{ symbol "-"; return (-) }
--   </pre>
chainl1 :: forall s (m :: Type -> Type) t u a. Stream s m t => ParsecT s u m a -> ParsecT s u m (a -> a -> a) -> ParsecT s u m a

-- | <tt>chainl p op x</tt> parses <i>zero</i> or more occurrences of
--   <tt>p</tt>, separated by <tt>op</tt>. Returns a value obtained by a
--   <i>left</i> associative application of all functions returned by
--   <tt>op</tt> to the values returned by <tt>p</tt>. If there are zero
--   occurrences of <tt>p</tt>, the value <tt>x</tt> is returned.
chainl :: forall s (m :: Type -> Type) t u a. Stream s m t => ParsecT s u m a -> ParsecT s u m (a -> a -> a) -> a -> ParsecT s u m a

-- | <tt>chainr p op x</tt> parses <i>zero</i> or more occurrences of
--   <tt>p</tt>, separated by <tt>op</tt> Returns a value obtained by a
--   <i>right</i> associative application of all functions returned by
--   <tt>op</tt> to the values returned by <tt>p</tt>. If there are no
--   occurrences of <tt>p</tt>, the value <tt>x</tt> is returned.
chainr :: forall s (m :: Type -> Type) t u a. Stream s m t => ParsecT s u m a -> ParsecT s u m (a -> a -> a) -> a -> ParsecT s u m a

-- | <tt>count n p</tt> parses <tt>n</tt> occurrences of <tt>p</tt>. If
--   <tt>n</tt> is smaller or equal to zero, the parser equals to
--   <tt>return []</tt>. Returns a list of <tt>n</tt> values returned by
--   <tt>p</tt>.
count :: forall s (m :: Type -> Type) t u a. Stream s m t => Int -> ParsecT s u m a -> ParsecT s u m [a]

-- | <tt>endBy p sep</tt> parses <i>zero</i> or more occurrences of
--   <tt>p</tt>, separated and ended by <tt>sep</tt>. Returns a list of
--   values returned by <tt>p</tt>.
--   
--   <pre>
--   cStatements  = cStatement `endBy` semi
--   </pre>
endBy :: forall s (m :: Type -> Type) t u a sep. Stream s m t => ParsecT s u m a -> ParsecT s u m sep -> ParsecT s u m [a]

-- | <tt>endBy1 p sep</tt> parses <i>one</i> or more occurrences of
--   <tt>p</tt>, separated and ended by <tt>sep</tt>. Returns a list of
--   values returned by <tt>p</tt>.
endBy1 :: forall s (m :: Type -> Type) t u a sep. Stream s m t => ParsecT s u m a -> ParsecT s u m sep -> ParsecT s u m [a]

-- | <tt>sepEndBy p sep</tt> parses <i>zero</i> or more occurrences of
--   <tt>p</tt>, separated and optionally ended by <tt>sep</tt>, ie.
--   haskell style statements. Returns a list of values returned by
--   <tt>p</tt>.
--   
--   <pre>
--   haskellStatements  = haskellStatement `sepEndBy` semi
--   </pre>
sepEndBy :: forall s (m :: Type -> Type) t u a sep. Stream s m t => ParsecT s u m a -> ParsecT s u m sep -> ParsecT s u m [a]

-- | <tt>sepEndBy1 p sep</tt> parses <i>one</i> or more occurrences of
--   <tt>p</tt>, separated and optionally ended by <tt>sep</tt>. Returns a
--   list of values returned by <tt>p</tt>.
sepEndBy1 :: forall s (m :: Type -> Type) t u a sep. Stream s m t => ParsecT s u m a -> ParsecT s u m sep -> ParsecT s u m [a]

-- | <tt>sepBy1 p sep</tt> parses <i>one</i> or more occurrences of
--   <tt>p</tt>, separated by <tt>sep</tt>. Returns a list of values
--   returned by <tt>p</tt>.
sepBy1 :: forall s (m :: Type -> Type) t u a sep. Stream s m t => ParsecT s u m a -> ParsecT s u m sep -> ParsecT s u m [a]

-- | <tt>sepBy p sep</tt> parses <i>zero</i> or more occurrences of
--   <tt>p</tt>, separated by <tt>sep</tt>. Returns a list of values
--   returned by <tt>p</tt>.
--   
--   <pre>
--   commaSep p  = p `sepBy` (symbol ",")
--   </pre>
sepBy :: forall s (m :: Type -> Type) t u a sep. Stream s m t => ParsecT s u m a -> ParsecT s u m sep -> ParsecT s u m [a]

-- | <tt>many1 p</tt> applies the parser <tt>p</tt> <i>one</i> or more
--   times. Returns a list of the returned values of <tt>p</tt>.
--   
--   <pre>
--   word  = many1 letter
--   </pre>
many1 :: forall s (m :: Type -> Type) t u a. Stream s m t => ParsecT s u m a -> ParsecT s u m [a]

-- | <tt>skipMany1 p</tt> applies the parser <tt>p</tt> <i>one</i> or more
--   times, skipping its result.
skipMany1 :: forall s (m :: Type -> Type) t u a. Stream s m t => ParsecT s u m a -> ParsecT s u m ()

-- | <tt>between open close p</tt> parses <tt>open</tt>, followed by
--   <tt>p</tt> and <tt>close</tt>. Returns the value returned by
--   <tt>p</tt>.
--   
--   <pre>
--   braces  = between (symbol "{") (symbol "}")
--   </pre>
between :: forall s (m :: Type -> Type) t u open close a. Stream s m t => ParsecT s u m open -> ParsecT s u m close -> ParsecT s u m a -> ParsecT s u m a

-- | <tt>optional p</tt> tries to apply parser <tt>p</tt>. It will parse
--   <tt>p</tt> or nothing. It only fails if <tt>p</tt> fails after
--   consuming input. It discards the result of <tt>p</tt>.
optional :: forall s (m :: Type -> Type) t u a. Stream s m t => ParsecT s u m a -> ParsecT s u m ()

-- | <tt>optionMaybe p</tt> tries to apply parser <tt>p</tt>. If <tt>p</tt>
--   fails without consuming input, it return <a>Nothing</a>, otherwise it
--   returns <a>Just</a> the value returned by <tt>p</tt>.
optionMaybe :: forall s (m :: Type -> Type) t u a. Stream s m t => ParsecT s u m a -> ParsecT s u m (Maybe a)

-- | <tt>option x p</tt> tries to apply parser <tt>p</tt>. If <tt>p</tt>
--   fails without consuming input, it returns the value <tt>x</tt>,
--   otherwise the value returned by <tt>p</tt>.
--   
--   <pre>
--   priority  = option 0 (do{ d &lt;- digit
--                           ; return (digitToInt d)
--                           })
--   </pre>
option :: forall s (m :: Type -> Type) t a u. Stream s m t => a -> ParsecT s u m a -> ParsecT s u m a

-- | <tt>choice ps</tt> tries to apply the parsers in the list <tt>ps</tt>
--   in order, until one of them succeeds. Returns the value of the
--   succeeding parser.
choice :: forall s (m :: Type -> Type) t u a. Stream s m t => [ParsecT s u m a] -> ParsecT s u m a

-- | An alias for modifyState for backwards compatibility.
updateState :: forall (m :: Type -> Type) u s. Monad m => (u -> u) -> ParsecT s u m ()

-- | An alias for putState for backwards compatibility.
setState :: forall (m :: Type -> Type) u s. Monad m => u -> ParsecT s u m ()

-- | <tt>modifyState f</tt> applies function <tt>f</tt> to the user state.
--   Suppose that we want to count identifiers in a source, we could use
--   the user state as:
--   
--   <pre>
--   expr  = do{ x &lt;- identifier
--             ; modifyState (+1)
--             ; return (Id x)
--             }
--   </pre>
modifyState :: forall (m :: Type -> Type) u s. Monad m => (u -> u) -> ParsecT s u m ()

-- | <tt>putState st</tt> set the user state to <tt>st</tt>.
putState :: forall (m :: Type -> Type) u s. Monad m => u -> ParsecT s u m ()

-- | Returns the current user state.
getState :: forall (m :: Type -> Type) s u. Monad m => ParsecT s u m u

-- | <tt>updateParserState f</tt> applies function <tt>f</tt> to the parser
--   state.
updateParserState :: forall s u (m :: Type -> Type). (State s u -> State s u) -> ParsecT s u m (State s u)

-- | <tt>setParserState st</tt> set the full parser state to <tt>st</tt>.
setParserState :: forall (m :: Type -> Type) s u. Monad m => State s u -> ParsecT s u m (State s u)

-- | Returns the full parser state as a <a>State</a> record.
getParserState :: forall (m :: Type -> Type) s u. Monad m => ParsecT s u m (State s u)

-- | <tt>setInput input</tt> continues parsing with <tt>input</tt>. The
--   <a>getInput</a> and <tt>setInput</tt> functions can for example be
--   used to deal with #include files.
setInput :: forall (m :: Type -> Type) s u. Monad m => s -> ParsecT s u m ()

-- | <tt>setPosition pos</tt> sets the current source position to
--   <tt>pos</tt>.
setPosition :: forall (m :: Type -> Type) s u. Monad m => SourcePos -> ParsecT s u m ()

-- | Returns the current input
getInput :: forall (m :: Type -> Type) s u. Monad m => ParsecT s u m s

-- | Returns the current source position. See also <a>SourcePos</a>.
getPosition :: forall (m :: Type -> Type) s u. Monad m => ParsecT s u m SourcePos

-- | The expression <tt>parseTest p input</tt> applies a parser <tt>p</tt>
--   against input <tt>input</tt> and prints the result to stdout. Used for
--   testing parsers.
parseTest :: (Stream s Identity t, Show a) => Parsec s () a -> s -> IO ()

-- | The most general way to run a parser over the Identity monad.
--   <tt>runParser p state filePath input</tt> runs parser <tt>p</tt> on
--   the input list of tokens <tt>input</tt>, obtained from source
--   <tt>filePath</tt> with the initial user state <tt>st</tt>. The
--   <tt>filePath</tt> is only used in error messages and may be the empty
--   string. Returns either a <a>ParseError</a> (<a>Left</a>) or a value of
--   type <tt>a</tt> (<a>Right</a>).
--   
--   <pre>
--   parseFromFile p fname
--     = do{ input &lt;- readFile fname
--         ; return (runParser p () fname input)
--         }
--   </pre>
runParser :: Stream s Identity t => Parsec s u a -> u -> SourceName -> s -> Either ParseError a

-- | The most general way to run a parser. <tt>runParserT p state filePath
--   input</tt> runs parser <tt>p</tt> on the input list of tokens
--   <tt>input</tt>, obtained from source <tt>filePath</tt> with the
--   initial user state <tt>st</tt>. The <tt>filePath</tt> is only used in
--   error messages and may be the empty string. Returns a computation in
--   the underlying monad <tt>m</tt> that return either a <a>ParseError</a>
--   (<a>Left</a>) or a value of type <tt>a</tt> (<a>Right</a>).
runParserT :: Stream s m t => ParsecT s u m a -> u -> SourceName -> s -> m (Either ParseError a)
runP :: Stream s Identity t => Parsec s u a -> u -> SourceName -> s -> Either ParseError a
runPT :: Stream s m t => ParsecT s u m a -> u -> SourceName -> s -> m (Either ParseError a)
manyAccum :: forall a s u (m :: Type -> Type). (a -> [a] -> [a]) -> ParsecT s u m a -> ParsecT s u m [a]

-- | <tt>skipMany p</tt> applies the parser <tt>p</tt> <i>zero</i> or more
--   times, skipping its result.
--   
--   <pre>
--   spaces  = skipMany space
--   </pre>
skipMany :: forall s u (m :: Type -> Type) a. ParsecT s u m a -> ParsecT s u m ()

-- | <tt>many p</tt> applies the parser <tt>p</tt> <i>zero</i> or more
--   times. Returns a list of the returned values of <tt>p</tt>.
--   
--   <pre>
--   identifier  = do{ c  &lt;- letter
--                   ; cs &lt;- many (alphaNum &lt;|&gt; char '_')
--                   ; return (c:cs)
--                   }
--   </pre>
many :: forall s u (m :: Type -> Type) a. ParsecT s u m a -> ParsecT s u m [a]
tokenPrimEx :: forall s (m :: Type -> Type) t u a. Stream s m t => (t -> String) -> (SourcePos -> t -> s -> SourcePos) -> Maybe (SourcePos -> t -> s -> u -> u) -> (t -> Maybe a) -> ParsecT s u m a

-- | The parser <tt>tokenPrim showTok nextPos testTok</tt> accepts a token
--   <tt>t</tt> with result <tt>x</tt> when the function <tt>testTok t</tt>
--   returns <tt><a>Just</a> x</tt>. The token can be shown using
--   <tt>showTok t</tt>. The position of the <i>next</i> token should be
--   returned when <tt>nextPos</tt> is called with the current source
--   position <tt>pos</tt>, the current token <tt>t</tt> and the rest of
--   the tokens <tt>toks</tt>, <tt>nextPos pos t toks</tt>.
--   
--   This is the most primitive combinator for accepting tokens. For
--   example, the <a>char</a> parser could be implemented as:
--   
--   <pre>
--   char c
--     = tokenPrim showChar nextPos testChar
--     where
--       showChar x        = "'" ++ x ++ "'"
--       testChar x        = if x == c then Just x else Nothing
--       nextPos pos x xs  = updatePosChar pos x
--   </pre>
tokenPrim :: forall s (m :: Type -> Type) t a u. Stream s m t => (t -> String) -> (SourcePos -> t -> s -> SourcePos) -> (t -> Maybe a) -> ParsecT s u m a

-- | The parser <tt>token showTok posFromTok testTok</tt> accepts a token
--   <tt>t</tt> with result <tt>x</tt> when the function <tt>testTok t</tt>
--   returns <tt><a>Just</a> x</tt>. The source position of the <tt>t</tt>
--   should be returned by <tt>posFromTok t</tt> and the token can be shown
--   using <tt>showTok t</tt>.
--   
--   This combinator is expressed in terms of <a>tokenPrim</a>. It is used
--   to accept user defined token streams. For example, suppose that we
--   have a stream of basic tokens tupled with source positions. We can
--   then define a parser that accepts single tokens as:
--   
--   <pre>
--   mytoken x
--     = token showTok posFromTok testTok
--     where
--       showTok (pos,t)     = show t
--       posFromTok (pos,t)  = pos
--       testTok (pos,t)     = if x == t then Just t else Nothing
--   </pre>
token :: Stream s Identity t => (t -> String) -> (t -> SourcePos) -> (t -> Maybe a) -> Parsec s u a

-- | <tt>lookAhead p</tt> parses <tt>p</tt> without consuming any input.
--   
--   If <tt>p</tt> fails and consumes some input, so does
--   <tt>lookAhead</tt>. Combine with <a>try</a> if this is undesirable.
lookAhead :: forall s (m :: Type -> Type) t u a. Stream s m t => ParsecT s u m a -> ParsecT s u m a

-- | The parser <tt>try p</tt> behaves like parser <tt>p</tt>, except that
--   it pretends that it hasn't consumed any input when an error occurs.
--   
--   This combinator is used whenever arbitrary look ahead is needed. Since
--   it pretends that it hasn't consumed any input when <tt>p</tt> fails,
--   the (<a>&lt;|&gt;</a>) combinator will try its second alternative even
--   when the first parser failed while consuming input.
--   
--   The <tt>try</tt> combinator can for example be used to distinguish
--   identifiers and reserved words. Both reserved words and identifiers
--   are a sequence of letters. Whenever we expect a certain reserved word
--   where we can also expect an identifier we have to use the <tt>try</tt>
--   combinator. Suppose we write:
--   
--   <pre>
--   expr        = letExpr &lt;|&gt; identifier &lt;?&gt; "expression"
--   
--   letExpr     = do{ string "let"; ... }
--   identifier  = many1 letter
--   </pre>
--   
--   If the user writes "lexical", the parser fails with: <tt>unexpected
--   'x', expecting 't' in "let"</tt>. Indeed, since the (<a>&lt;|&gt;</a>)
--   combinator only tries alternatives when the first alternative hasn't
--   consumed input, the <tt>identifier</tt> parser is never tried (because
--   the prefix "le" of the <tt>string "let"</tt> parser is already
--   consumed). The right behaviour can be obtained by adding the
--   <tt>try</tt> combinator:
--   
--   <pre>
--   expr        = letExpr &lt;|&gt; identifier &lt;?&gt; "expression"
--   
--   letExpr     = do{ try (string "let"); ... }
--   identifier  = many1 letter
--   </pre>
try :: forall s u (m :: Type -> Type) a. ParsecT s u m a -> ParsecT s u m a
tokens :: forall s (m :: Type -> Type) t u. (Stream s m t, Eq t) => ([t] -> String) -> (SourcePos -> [t] -> SourcePos) -> [t] -> ParsecT s u m [t]
labels :: forall s u (m :: Type -> Type) a. ParsecT s u m a -> [String] -> ParsecT s u m a

-- | A synonym for <tt>&lt;?&gt;</tt>, but as a function instead of an
--   operator.
label :: forall s u (m :: Type -> Type) a. ParsecT s u m a -> String -> ParsecT s u m a

-- | This combinator implements choice. The parser <tt>p &lt;|&gt; q</tt>
--   first applies <tt>p</tt>. If it succeeds, the value of <tt>p</tt> is
--   returned. If <tt>p</tt> fails <i>without consuming any input</i>,
--   parser <tt>q</tt> is tried. This combinator is defined equal to the
--   <a>mplus</a> member of the <a>MonadPlus</a> class and the
--   (<a>&lt;|&gt;</a>) member of <a>Alternative</a>.
--   
--   The parser is called <i>predictive</i> since <tt>q</tt> is only tried
--   when parser <tt>p</tt> didn't consume any input (i.e.. the look ahead
--   is 1). This non-backtracking behaviour allows for both an efficient
--   implementation of the parser combinators and the generation of good
--   error messages.
(<|>) :: forall s u (m :: Type -> Type) a. ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
infixr 1 <|>

-- | The parser <tt>p &lt;?&gt; msg</tt> behaves as parser <tt>p</tt>, but
--   whenever the parser <tt>p</tt> fails <i>without consuming any
--   input</i>, it replaces expect error messages with the expect error
--   message <tt>msg</tt>.
--   
--   This is normally used at the end of a set alternatives where we want
--   to return an error message in terms of a higher level construct rather
--   than returning all possible characters. For example, if the
--   <tt>expr</tt> parser from the <a>try</a> example would fail, the error
--   message is: '...: expecting expression'. Without the
--   <tt>(&lt;?&gt;)</tt> combinator, the message would be like '...:
--   expecting "let" or letter', which is less friendly.
(<?>) :: forall s u (m :: Type -> Type) a. ParsecT s u m a -> String -> ParsecT s u m a
infix 0 <?>
parserPlus :: forall s u (m :: Type -> Type) a. ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a

-- | <tt>parserZero</tt> always fails without consuming any input.
--   <tt>parserZero</tt> is defined equal to the <a>mzero</a> member of the
--   <a>MonadPlus</a> class and to the <a>empty</a> member of the
--   <a>Alternative</a> class.
parserZero :: forall s u (m :: Type -> Type) a. ParsecT s u m a
parserFail :: forall s u (m :: Type -> Type) a. String -> ParsecT s u m a
mergeErrorReply :: ParseError -> Reply s u a -> Reply s u a
parserBind :: forall s u (m :: Type -> Type) a b. ParsecT s u m a -> (a -> ParsecT s u m b) -> ParsecT s u m b
parserReturn :: forall a s u (m :: Type -> Type). a -> ParsecT s u m a
parsecMap :: forall a b s u (m :: Type -> Type). (a -> b) -> ParsecT s u m a -> ParsecT s u m b

-- | Low-level creation of the ParsecT type. You really shouldn't have to
--   do this.
mkPT :: Monad m => (State s u -> m (Consumed (m (Reply s u a)))) -> ParsecT s u m a

-- | Low-level unpacking of the ParsecT type. To run your parser, please
--   look to runPT, runP, runParserT, runParser and other such functions.
runParsecT :: Monad m => ParsecT s u m a -> State s u -> m (Consumed (m (Reply s u a)))

-- | The parser <tt>unexpected msg</tt> always fails with an unexpected
--   error message <tt>msg</tt> without consuming any input.
--   
--   The parsers <a>fail</a>, (<a>&lt;?&gt;</a>) and <tt>unexpected</tt>
--   are the three parsers used to generate error messages. Of these, only
--   (<a>&lt;?&gt;</a>) is commonly used. For an example of the use of
--   <tt>unexpected</tt>, see the definition of <a>notFollowedBy</a>.
unexpected :: forall s (m :: Type -> Type) t u a. Stream s m t => String -> ParsecT s u m a
sysUnExpectError :: String -> SourcePos -> Reply s u a
unknownError :: State s u -> ParseError

-- | ParserT monad transformer and Parser type
--   
--   <tt>ParsecT s u m a</tt> is a parser with stream type <tt>s</tt>, user
--   state type <tt>u</tt>, underlying monad <tt>m</tt> and return type
--   <tt>a</tt>. Parsec is strict in the user state. If this is
--   undesirable, simply use a data type like <tt>data Box a = Box a</tt>
--   and the state type <tt>Box YourStateType</tt> to add a level of
--   indirection.
data ParsecT s u (m :: Type -> Type) a
type Parsec s u = ParsecT s u Identity
data Consumed a
Consumed :: a -> Consumed a
Empty :: !a -> Consumed a
data Reply s u a
Ok :: a -> !State s u -> ParseError -> Reply s u a
Error :: ParseError -> Reply s u a
data State s u
State :: s -> !SourcePos -> !u -> State s u
[stateInput] :: State s u -> s
[statePos] :: State s u -> !SourcePos
[stateUser] :: State s u -> !u

-- | An instance of <tt>Stream</tt> has stream type <tt>s</tt>, underlying
--   monad <tt>m</tt> and token type <tt>t</tt> determined by the stream
--   
--   Some rough guidelines for a "correct" instance of Stream:
--   
--   <ul>
--   <li>unfoldM uncons gives the [t] corresponding to the stream</li>
--   <li>A <tt>Stream</tt> instance is responsible for maintaining the
--   "position within the stream" in the stream state <tt>s</tt>. This is
--   trivial unless you are using the monad in a non-trivial way.</li>
--   </ul>
class Monad m => Stream s (m :: Type -> Type) t | s -> t
uncons :: Stream s m t => s -> m (Maybe (t, s))

-- | Extracts the source position from the parse error
errorPos :: ParseError -> SourcePos

-- | The abstract data type <tt>ParseError</tt> represents parse errors. It
--   provides the source position (<a>SourcePos</a>) of the error and a
--   list of error messages (<a>Message</a>). A <tt>ParseError</tt> can be
--   returned by the function <a>parse</a>. <tt>ParseError</tt> is an
--   instance of the <a>Show</a> and <a>Eq</a> classes.
data ParseError

-- | Set the column number of a source position.
setSourceColumn :: SourcePos -> Column -> SourcePos

-- | Set the line number of a source position.
setSourceLine :: SourcePos -> Line -> SourcePos

-- | Set the name of the source.
setSourceName :: SourcePos -> SourceName -> SourcePos

-- | Increments the column number of a source position.
incSourceColumn :: SourcePos -> Column -> SourcePos

-- | Increments the line number of a source position.
incSourceLine :: SourcePos -> Line -> SourcePos

-- | Extracts the column number from a source position.
sourceColumn :: SourcePos -> Column

-- | Extracts the line number from a source position.
sourceLine :: SourcePos -> Line

-- | Extracts the name of the source from a source position.
sourceName :: SourcePos -> SourceName
type SourceName = String
type Line = Int
type Column = Int

-- | The abstract data type <tt>SourcePos</tt> represents source positions.
--   It contains the name of the source (i.e. file name), a line number and
--   a column number. <tt>SourcePos</tt> is an instance of the <a>Show</a>,
--   <a>Eq</a> and <a>Ord</a> class.
data SourcePos
instance Text.Parsec.Class.HasParser GHC.Natural.Natural
