/usr/share/doc/libghc-parsec3-doc/html/Text-Parsec-Prim.html is in libghc-parsec3-doc 3.1.11-3build2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>Text.Parsec.Prim</title><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean" /><script src="haddock-util.js" type="text/javascript"></script><script src="file:///usr/share/javascript/mathjax/MathJax.js" type="text/javascript"></script><script type="text/javascript">//<![CDATA[
window.onload = function () {pageLoad();setSynopsis("mini_Text-Parsec-Prim.html");};
//]]>
</script></head><body><div id="package-header"><ul class="links" id="page-menu"><li><a href="src/Text-Parsec-Prim.html">Source</a></li><li><a href="index.html">Contents</a></li><li><a href="doc-index.html">Index</a></li></ul><p class="caption">parsec-3.1.11: Monadic parser combinators</p></div><div id="content"><div id="module-header"><table class="info"><tr><th valign="top">Copyright</th><td>(c) Daan Leijen 1999-2001 (c) Paolo Martini 2007</td></tr><tr><th>License</th><td>BSD-style (see the LICENSE file)</td></tr><tr><th>Maintainer</th><td>derek.a.elkins@gmail.com</td></tr><tr><th>Stability</th><td>provisional</td></tr><tr><th>Portability</th><td>portable</td></tr><tr><th>Safe Haskell</th><td>Safe</td></tr><tr><th>Language</th><td>Haskell98</td></tr></table><p class="caption">Text.Parsec.Prim</p></div><div id="description"><p class="caption">Description</p><div class="doc"><p>The primitive parser combinators.</p></div></div><div id="synopsis"><p id="control.syn" class="caption expander" onclick="toggleSection('syn')">Synopsis</p><ul id="section.syn" class="hide" onclick="toggleSection('syn')"><li class="src short"><a href="#v:unknownError">unknownError</a> :: <a href="Text-Parsec-Prim.html#t:State">State</a> s u -> <a href="Text-Parsec-Error.html#t:ParseError">ParseError</a></li><li class="src short"><a href="#v:sysUnExpectError">sysUnExpectError</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-String.html#t:String">String</a> -> <a href="Text-Parsec-Pos.html#t:SourcePos">SourcePos</a> -> <a href="Text-Parsec-Prim.html#t:Reply">Reply</a> s u a</li><li class="src short"><a href="#v:unexpected">unexpected</a> :: <a href="Text-Parsec-Prim.html#t:Stream">Stream</a> s m t => <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-String.html#t:String">String</a> -> <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m a</li><li class="src short"><span class="keyword">data</span> <a href="#t:ParsecT">ParsecT</a> s u m a</li><li class="src short"><a href="#v:runParsecT">runParsecT</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Control-Monad.html#t:Monad">Monad</a> m => <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m a -> <a href="Text-Parsec-Prim.html#t:State">State</a> s u -> m (<a href="Text-Parsec-Prim.html#t:Consumed">Consumed</a> (m (<a href="Text-Parsec-Prim.html#t:Reply">Reply</a> s u a)))</li><li class="src short"><a href="#v:mkPT">mkPT</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Control-Monad.html#t:Monad">Monad</a> m => (<a href="Text-Parsec-Prim.html#t:State">State</a> s u -> m (<a href="Text-Parsec-Prim.html#t:Consumed">Consumed</a> (m (<a href="Text-Parsec-Prim.html#t:Reply">Reply</a> s u a)))) -> <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m a</li><li class="src short"><span class="keyword">type</span> <a href="#t:Parsec">Parsec</a> s u = <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Functor-Identity.html#t:Identity">Identity</a></li><li class="src short"><span class="keyword">data</span> <a href="#t:Consumed">Consumed</a> a<ul class="subs"><li>= <a href="#v:Consumed">Consumed</a> a</li><li>| <a href="#v:Empty">Empty</a> !a</li></ul></li><li class="src short"><span class="keyword">data</span> <a href="#t:Reply">Reply</a> s u a<ul class="subs"><li>= <a href="#v:Ok">Ok</a> a !(<a href="Text-Parsec-Prim.html#t:State">State</a> s u) <a href="Text-Parsec-Error.html#t:ParseError">ParseError</a></li><li>| <a href="#v:Error">Error</a> <a href="Text-Parsec-Error.html#t:ParseError">ParseError</a></li></ul></li><li class="src short"><span class="keyword">data</span> <a href="#t:State">State</a> s u = <a href="#v:State">State</a> {<ul class="subs"><li><a href="#v:stateInput">stateInput</a> :: s</li><li><a href="#v:statePos">statePos</a> :: !<a href="Text-Parsec-Pos.html#t:SourcePos">SourcePos</a></li><li><a href="#v:stateUser">stateUser</a> :: !u</li></ul>}</li><li class="src short"><a href="#v:parsecMap">parsecMap</a> :: (a -> b) -> <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m a -> <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m b</li><li class="src short"><a href="#v:parserReturn">parserReturn</a> :: a -> <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m a</li><li class="src short"><a href="#v:parserBind">parserBind</a> :: <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m a -> (a -> <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m b) -> <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m b</li><li class="src short"><a href="#v:mergeErrorReply">mergeErrorReply</a> :: <a href="Text-Parsec-Error.html#t:ParseError">ParseError</a> -> <a href="Text-Parsec-Prim.html#t:Reply">Reply</a> s u a -> <a href="Text-Parsec-Prim.html#t:Reply">Reply</a> s u a</li><li class="src short"><a href="#v:parserFail">parserFail</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-String.html#t:String">String</a> -> <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m a</li><li class="src short"><a href="#v:parserZero">parserZero</a> :: <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m a</li><li class="src short"><a href="#v:parserPlus">parserPlus</a> :: <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m a -> <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m a -> <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m a</li><li class="src short"><a href="#v:-60--63--62-">(<?>)</a> :: <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m a -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-String.html#t:String">String</a> -> <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m a</li><li class="src short"><a href="#v:-60--124--62-">(<|>)</a> :: <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m a -> <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m a -> <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m a</li><li class="src short"><a href="#v:label">label</a> :: <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m a -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-String.html#t:String">String</a> -> <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m a</li><li class="src short"><a href="#v:labels">labels</a> :: <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m a -> [<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-String.html#t:String">String</a>] -> <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m a</li><li class="src short"><a href="#v:lookAhead">lookAhead</a> :: <a href="Text-Parsec-Prim.html#t:Stream">Stream</a> s m t => <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m a -> <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m a</li><li class="src short"><span class="keyword">class</span> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Control-Monad.html#t:Monad">Monad</a> m => <a href="#t:Stream">Stream</a> s m t | s -> t <span class="keyword">where</span><ul class="subs"></ul></li><li class="src short"><a href="#v:tokens">tokens</a> :: (<a href="Text-Parsec-Prim.html#t:Stream">Stream</a> s m t, <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Eq.html#t:Eq">Eq</a> t) => ([t] -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-String.html#t:String">String</a>) -> (<a href="Text-Parsec-Pos.html#t:SourcePos">SourcePos</a> -> [t] -> <a href="Text-Parsec-Pos.html#t:SourcePos">SourcePos</a>) -> [t] -> <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m [t]</li><li class="src short"><a href="#v:try">try</a> :: <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m a -> <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m a</li><li class="src short"><a href="#v:token">token</a> :: <a href="Text-Parsec-Prim.html#t:Stream">Stream</a> s <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Functor-Identity.html#t:Identity">Identity</a> t => (t -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-String.html#t:String">String</a>) -> (t -> <a href="Text-Parsec-Pos.html#t:SourcePos">SourcePos</a>) -> (t -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Maybe.html#t:Maybe">Maybe</a> a) -> <a href="Text-Parsec-Prim.html#t:Parsec">Parsec</a> s u a</li><li class="src short"><a href="#v:tokenPrim">tokenPrim</a> :: <a href="Text-Parsec-Prim.html#t:Stream">Stream</a> s m t => (t -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-String.html#t:String">String</a>) -> (<a href="Text-Parsec-Pos.html#t:SourcePos">SourcePos</a> -> t -> s -> <a href="Text-Parsec-Pos.html#t:SourcePos">SourcePos</a>) -> (t -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Maybe.html#t:Maybe">Maybe</a> a) -> <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m a</li><li class="src short"><a href="#v:tokenPrimEx">tokenPrimEx</a> :: <a href="Text-Parsec-Prim.html#t:Stream">Stream</a> s m t => (t -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-String.html#t:String">String</a>) -> (<a href="Text-Parsec-Pos.html#t:SourcePos">SourcePos</a> -> t -> s -> <a href="Text-Parsec-Pos.html#t:SourcePos">SourcePos</a>) -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Maybe.html#t:Maybe">Maybe</a> (<a href="Text-Parsec-Pos.html#t:SourcePos">SourcePos</a> -> t -> s -> u -> u) -> (t -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Maybe.html#t:Maybe">Maybe</a> a) -> <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m a</li><li class="src short"><a href="#v:many">many</a> :: <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m a -> <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m [a]</li><li class="src short"><a href="#v:skipMany">skipMany</a> :: <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m a -> <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m ()</li><li class="src short"><a href="#v:manyAccum">manyAccum</a> :: (a -> [a] -> [a]) -> <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m a -> <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m [a]</li><li class="src short"><a href="#v:runPT">runPT</a> :: <a href="Text-Parsec-Prim.html#t:Stream">Stream</a> s m t => <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m a -> u -> <a href="Text-Parsec-Pos.html#t:SourceName">SourceName</a> -> s -> m (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Either.html#t:Either">Either</a> <a href="Text-Parsec-Error.html#t:ParseError">ParseError</a> a)</li><li class="src short"><a href="#v:runP">runP</a> :: <a href="Text-Parsec-Prim.html#t:Stream">Stream</a> s <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Functor-Identity.html#t:Identity">Identity</a> t => <a href="Text-Parsec-Prim.html#t:Parsec">Parsec</a> s u a -> u -> <a href="Text-Parsec-Pos.html#t:SourceName">SourceName</a> -> s -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Either.html#t:Either">Either</a> <a href="Text-Parsec-Error.html#t:ParseError">ParseError</a> a</li><li class="src short"><a href="#v:runParserT">runParserT</a> :: <a href="Text-Parsec-Prim.html#t:Stream">Stream</a> s m t => <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m a -> u -> <a href="Text-Parsec-Pos.html#t:SourceName">SourceName</a> -> s -> m (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Either.html#t:Either">Either</a> <a href="Text-Parsec-Error.html#t:ParseError">ParseError</a> a)</li><li class="src short"><a href="#v:runParser">runParser</a> :: <a href="Text-Parsec-Prim.html#t:Stream">Stream</a> s <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Functor-Identity.html#t:Identity">Identity</a> t => <a href="Text-Parsec-Prim.html#t:Parsec">Parsec</a> s u a -> u -> <a href="Text-Parsec-Pos.html#t:SourceName">SourceName</a> -> s -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Either.html#t:Either">Either</a> <a href="Text-Parsec-Error.html#t:ParseError">ParseError</a> a</li><li class="src short"><a href="#v:parse">parse</a> :: <a href="Text-Parsec-Prim.html#t:Stream">Stream</a> s <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Functor-Identity.html#t:Identity">Identity</a> t => <a href="Text-Parsec-Prim.html#t:Parsec">Parsec</a> s () a -> <a href="Text-Parsec-Pos.html#t:SourceName">SourceName</a> -> s -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Either.html#t:Either">Either</a> <a href="Text-Parsec-Error.html#t:ParseError">ParseError</a> a</li><li class="src short"><a href="#v:parseTest">parseTest</a> :: (<a href="Text-Parsec-Prim.html#t:Stream">Stream</a> s <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Functor-Identity.html#t:Identity">Identity</a> t, <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Text-Show.html#t:Show">Show</a> a) => <a href="Text-Parsec-Prim.html#t:Parsec">Parsec</a> s () a -> s -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/System-IO.html#t:IO">IO</a> ()</li><li class="src short"><a href="#v:getPosition">getPosition</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Control-Monad.html#t:Monad">Monad</a> m => <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m <a href="Text-Parsec-Pos.html#t:SourcePos">SourcePos</a></li><li class="src short"><a href="#v:getInput">getInput</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Control-Monad.html#t:Monad">Monad</a> m => <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m s</li><li class="src short"><a href="#v:setPosition">setPosition</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Control-Monad.html#t:Monad">Monad</a> m => <a href="Text-Parsec-Pos.html#t:SourcePos">SourcePos</a> -> <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m ()</li><li class="src short"><a href="#v:setInput">setInput</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Control-Monad.html#t:Monad">Monad</a> m => s -> <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m ()</li><li class="src short"><a href="#v:getParserState">getParserState</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Control-Monad.html#t:Monad">Monad</a> m => <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m (<a href="Text-Parsec-Prim.html#t:State">State</a> s u)</li><li class="src short"><a href="#v:setParserState">setParserState</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Control-Monad.html#t:Monad">Monad</a> m => <a href="Text-Parsec-Prim.html#t:State">State</a> s u -> <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m (<a href="Text-Parsec-Prim.html#t:State">State</a> s u)</li><li class="src short"><a href="#v:updateParserState">updateParserState</a> :: (<a href="Text-Parsec-Prim.html#t:State">State</a> s u -> <a href="Text-Parsec-Prim.html#t:State">State</a> s u) -> <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m (<a href="Text-Parsec-Prim.html#t:State">State</a> s u)</li><li class="src short"><a href="#v:getState">getState</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Control-Monad.html#t:Monad">Monad</a> m => <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m u</li><li class="src short"><a href="#v:putState">putState</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Control-Monad.html#t:Monad">Monad</a> m => u -> <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m ()</li><li class="src short"><a href="#v:modifyState">modifyState</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Control-Monad.html#t:Monad">Monad</a> m => (u -> u) -> <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m ()</li><li class="src short"><a href="#v:setState">setState</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Control-Monad.html#t:Monad">Monad</a> m => u -> <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m ()</li><li class="src short"><a href="#v:updateState">updateState</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Control-Monad.html#t:Monad">Monad</a> m => (u -> u) -> <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m ()</li></ul></div><div id="interface"><h1>Documentation</h1><div class="top"><p class="src"><a id="v:unknownError" class="def">unknownError</a> :: <a href="Text-Parsec-Prim.html#t:State">State</a> s u -> <a href="Text-Parsec-Error.html#t:ParseError">ParseError</a> <a href="src/Text-Parsec-Prim.html#unknownError" class="link">Source</a> <a href="#v:unknownError" class="selflink">#</a></p></div><div class="top"><p class="src"><a id="v:sysUnExpectError" class="def">sysUnExpectError</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-String.html#t:String">String</a> -> <a href="Text-Parsec-Pos.html#t:SourcePos">SourcePos</a> -> <a href="Text-Parsec-Prim.html#t:Reply">Reply</a> s u a <a href="src/Text-Parsec-Prim.html#sysUnExpectError" class="link">Source</a> <a href="#v:sysUnExpectError" class="selflink">#</a></p></div><div class="top"><p class="src"><a id="v:unexpected" class="def">unexpected</a> :: <a href="Text-Parsec-Prim.html#t:Stream">Stream</a> s m t => <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-String.html#t:String">String</a> -> <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m a <a href="src/Text-Parsec-Prim.html#unexpected" class="link">Source</a> <a href="#v:unexpected" class="selflink">#</a></p><div class="doc"><p>The parser <code>unexpected msg</code> always fails with an unexpected error
message <code>msg</code> without consuming any input.</p><p>The parsers <code><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Control-Monad.html#v:fail">fail</a></code>, (<code><a href="Text-Parsec-Prim.html#v:-60--63--62-"><?></a></code>) and <code>unexpected</code> are the three parsers
used to generate error messages. Of these, only (<code><a href="Text-Parsec-Prim.html#v:-60--63--62-"><?></a></code>) is commonly
used. For an example of the use of <code>unexpected</code>, see the definition
of <code><a href="Text-Parsec-Combinator.html#v:notFollowedBy">notFollowedBy</a></code>.</p></div></div><div class="top"><p class="src"><span class="keyword">data</span> <a id="t:ParsecT" class="def">ParsecT</a> s u m a <a href="src/Text-Parsec-Prim.html#ParsecT" class="link">Source</a> <a href="#t:ParsecT" class="selflink">#</a></p><div class="doc"><p>ParserT monad transformer and Parser type</p><p><code>ParsecT s u m a</code> is a parser with stream type <code>s</code>, user state type <code>u</code>,
underlying monad <code>m</code> and return type <code>a</code>. Parsec is strict in the user state.
If this is undesirable, simply used a data type like <code>data Box a = Box a</code> and
the state type <code>Box YourStateType</code> to add a level of indirection.</p></div><div class="subs instances"><p id="control.i:ParsecT" class="caption collapser" onclick="toggleSection('i:ParsecT')">Instances</p><div id="section.i:ParsecT" class="show"><table><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:ParsecT:MonadError:1" class="instance expander" onclick="toggleSection('i:id:ParsecT:MonadError:1')"></span> <a href="file:///usr/share/doc/libghc-mtl-doc/html/Control-Monad-Error-Class.html#t:MonadError">MonadError</a> e m => <a href="file:///usr/share/doc/libghc-mtl-doc/html/Control-Monad-Error-Class.html#t:MonadError">MonadError</a> e (<a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m)</span> <a href="src/Text-Parsec-Prim.html#line-225" class="link">Source</a> <a href="#t:ParsecT" class="selflink">#</a></td><td class="doc empty"> </td></tr><tr><td colspan="2"><div id="section.i:id:ParsecT:MonadError:1" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:throwError">throwError</a> :: e -> <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m a <a href="#v:throwError" class="selflink">#</a></p><p class="src"><a href="#v:catchError">catchError</a> :: <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m a -> (e -> <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m a) -> <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m a <a href="#v:catchError" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:ParsecT:MonadReader:2" class="instance expander" onclick="toggleSection('i:id:ParsecT:MonadReader:2')"></span> <a href="file:///usr/share/doc/libghc-mtl-doc/html/Control-Monad-Reader-Class.html#t:MonadReader">MonadReader</a> r m => <a href="file:///usr/share/doc/libghc-mtl-doc/html/Control-Monad-Reader-Class.html#t:MonadReader">MonadReader</a> r (<a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m)</span> <a href="src/Text-Parsec-Prim.html#line-208" class="link">Source</a> <a href="#t:ParsecT" class="selflink">#</a></td><td class="doc empty"> </td></tr><tr><td colspan="2"><div id="section.i:id:ParsecT:MonadReader:2" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:ask">ask</a> :: <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m r <a href="#v:ask" class="selflink">#</a></p><p class="src"><a href="#v:local">local</a> :: (r -> r) -> <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m a -> <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m a <a href="#v:local" class="selflink">#</a></p><p class="src"><a href="#v:reader">reader</a> :: (r -> a) -> <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m a <a href="#v:reader" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:ParsecT:MonadState:3" class="instance expander" onclick="toggleSection('i:id:ParsecT:MonadState:3')"></span> <a href="file:///usr/share/doc/libghc-mtl-doc/html/Control-Monad-State-Class.html#t:MonadState">MonadState</a> s m => <a href="file:///usr/share/doc/libghc-mtl-doc/html/Control-Monad-State-Class.html#t:MonadState">MonadState</a> s (<a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s' u m)</span> <a href="src/Text-Parsec-Prim.html#line-214" class="link">Source</a> <a href="#t:ParsecT" class="selflink">#</a></td><td class="doc empty"> </td></tr><tr><td colspan="2"><div id="section.i:id:ParsecT:MonadState:3" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:get">get</a> :: <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s' u m s <a href="#v:get" class="selflink">#</a></p><p class="src"><a href="#v:put">put</a> :: s -> <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s' u m () <a href="#v:put" class="selflink">#</a></p><p class="src"><a href="#v:state">state</a> :: (s -> (a, s)) -> <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s' u m a <a href="#v:state" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:ParsecT:MonadTrans:4" class="instance expander" onclick="toggleSection('i:id:ParsecT:MonadTrans:4')"></span> <a href="file:///usr/share/doc/ghc-doc/html/libraries/transformers-0.5.2.0/Control-Monad-Trans-Class.html#t:MonadTrans">MonadTrans</a> (<a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u)</span> <a href="src/Text-Parsec-Prim.html#line-312" class="link">Source</a> <a href="#t:ParsecT" class="selflink">#</a></td><td class="doc empty"> </td></tr><tr><td colspan="2"><div id="section.i:id:ParsecT:MonadTrans:4" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:lift">lift</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Control-Monad.html#t:Monad">Monad</a> m => m a -> <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m a <a href="#v:lift" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:ParsecT:Monad:5" class="instance expander" onclick="toggleSection('i:id:ParsecT:Monad:5')"></span> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Control-Monad.html#t:Monad">Monad</a> (<a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m)</span> <a href="src/Text-Parsec-Prim.html#line-200" class="link">Source</a> <a href="#t:ParsecT" class="selflink">#</a></td><td class="doc empty"> </td></tr><tr><td colspan="2"><div id="section.i:id:ParsecT:Monad:5" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:-62--62--61-">(>>=)</a> :: <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m a -> (a -> <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m b) -> <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m b <a href="#v:-62--62--61-" class="selflink">#</a></p><p class="src"><a href="#v:-62--62-">(>>)</a> :: <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m a -> <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m b -> <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m b <a href="#v:-62--62-" class="selflink">#</a></p><p class="src"><a href="#v:return">return</a> :: a -> <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m a <a href="#v:return" class="selflink">#</a></p><p class="src"><a href="#v:fail">fail</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-String.html#t:String">String</a> -> <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m a <a href="#v:fail" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:ParsecT:Functor:6" class="instance expander" onclick="toggleSection('i:id:ParsecT:Functor:6')"></span> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Functor.html#t:Functor">Functor</a> (<a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m)</span> <a href="src/Text-Parsec-Prim.html#line-184" class="link">Source</a> <a href="#t:ParsecT" class="selflink">#</a></td><td class="doc empty"> </td></tr><tr><td colspan="2"><div id="section.i:id:ParsecT:Functor:6" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:fmap">fmap</a> :: (a -> b) -> <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m a -> <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m b <a href="#v:fmap" class="selflink">#</a></p><p class="src"><a href="#v:-60--36-">(<$)</a> :: a -> <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m b -> <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m a <a href="#v:-60--36-" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:ParsecT:Applicative:7" class="instance expander" onclick="toggleSection('i:id:ParsecT:Applicative:7')"></span> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Control-Applicative.html#t:Applicative">Applicative</a> (<a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m)</span> <a href="src/Text-Parsec-Prim.html#line-192" class="link">Source</a> <a href="#t:ParsecT" class="selflink">#</a></td><td class="doc empty"> </td></tr><tr><td colspan="2"><div id="section.i:id:ParsecT:Applicative:7" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:pure">pure</a> :: a -> <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m a <a href="#v:pure" class="selflink">#</a></p><p class="src"><a href="#v:-60--42--62-">(<*>)</a> :: <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m (a -> b) -> <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m a -> <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m b <a href="#v:-60--42--62-" class="selflink">#</a></p><p class="src"><a href="#v:-42--62-">(*>)</a> :: <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m a -> <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m b -> <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m b <a href="#v:-42--62-" class="selflink">#</a></p><p class="src"><a href="#v:-60--42-">(<*)</a> :: <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m a -> <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m b -> <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m a <a href="#v:-60--42-" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:ParsecT:MonadIO:8" class="instance expander" onclick="toggleSection('i:id:ParsecT:MonadIO:8')"></span> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Control-Monad-IO-Class.html#t:MonadIO">MonadIO</a> m => <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Control-Monad-IO-Class.html#t:MonadIO">MonadIO</a> (<a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m)</span> <a href="src/Text-Parsec-Prim.html#line-205" class="link">Source</a> <a href="#t:ParsecT" class="selflink">#</a></td><td class="doc empty"> </td></tr><tr><td colspan="2"><div id="section.i:id:ParsecT:MonadIO:8" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:liftIO">liftIO</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/System-IO.html#t:IO">IO</a> a -> <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m a <a href="#v:liftIO" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:ParsecT:Alternative:9" class="instance expander" onclick="toggleSection('i:id:ParsecT:Alternative:9')"></span> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Control-Applicative.html#t:Alternative">Alternative</a> (<a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m)</span> <a href="src/Text-Parsec-Prim.html#line-196" class="link">Source</a> <a href="#t:ParsecT" class="selflink">#</a></td><td class="doc empty"> </td></tr><tr><td colspan="2"><div id="section.i:id:ParsecT:Alternative:9" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:empty">empty</a> :: <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m a <a href="#v:empty" class="selflink">#</a></p><p class="src"><a href="#v:-60--124--62-">(<|>)</a> :: <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m a -> <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m a -> <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m a <a href="#v:-60--124--62-" class="selflink">#</a></p><p class="src"><a href="#v:some">some</a> :: <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m a -> <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m [a] <a href="#v:some" class="selflink">#</a></p><p class="src"><a href="#v:many">many</a> :: <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m a -> <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m [a] <a href="#v:many" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:ParsecT:MonadPlus:10" class="instance expander" onclick="toggleSection('i:id:ParsecT:MonadPlus:10')"></span> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Control-Monad.html#t:MonadPlus">MonadPlus</a> (<a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m)</span> <a href="src/Text-Parsec-Prim.html#line-287" class="link">Source</a> <a href="#t:ParsecT" class="selflink">#</a></td><td class="doc empty"> </td></tr><tr><td colspan="2"><div id="section.i:id:ParsecT:MonadPlus:10" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:mzero">mzero</a> :: <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m a <a href="#v:mzero" class="selflink">#</a></p><p class="src"><a href="#v:mplus">mplus</a> :: <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m a -> <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m a -> <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m a <a href="#v:mplus" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:ParsecT:MonadCont:11" class="instance expander" onclick="toggleSection('i:id:ParsecT:MonadCont:11')"></span> <a href="file:///usr/share/doc/libghc-mtl-doc/html/Control-Monad-Cont-Class.html#t:MonadCont">MonadCont</a> m => <a href="file:///usr/share/doc/libghc-mtl-doc/html/Control-Monad-Cont-Class.html#t:MonadCont">MonadCont</a> (<a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m)</span> <a href="src/Text-Parsec-Prim.html#line-218" class="link">Source</a> <a href="#t:ParsecT" class="selflink">#</a></td><td class="doc empty"> </td></tr><tr><td colspan="2"><div id="section.i:id:ParsecT:MonadCont:11" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:callCC">callCC</a> :: ((a -> <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m b) -> <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m a) -> <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m a <a href="#v:callCC" class="selflink">#</a></p></div></div></td></tr></table></div></div></div><div class="top"><p class="src"><a id="v:runParsecT" class="def">runParsecT</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Control-Monad.html#t:Monad">Monad</a> m => <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m a -> <a href="Text-Parsec-Prim.html#t:State">State</a> s u -> m (<a href="Text-Parsec-Prim.html#t:Consumed">Consumed</a> (m (<a href="Text-Parsec-Prim.html#t:Reply">Reply</a> s u a))) <a href="src/Text-Parsec-Prim.html#runParsecT" class="link">Source</a> <a href="#v:runParsecT" class="selflink">#</a></p><div class="doc"><p>Low-level unpacking of the ParsecT type. To run your parser, please look to
runPT, runP, runParserT, runParser and other such functions.</p></div></div><div class="top"><p class="src"><a id="v:mkPT" class="def">mkPT</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Control-Monad.html#t:Monad">Monad</a> m => (<a href="Text-Parsec-Prim.html#t:State">State</a> s u -> m (<a href="Text-Parsec-Prim.html#t:Consumed">Consumed</a> (m (<a href="Text-Parsec-Prim.html#t:Reply">Reply</a> s u a)))) -> <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m a <a href="src/Text-Parsec-Prim.html#mkPT" class="link">Source</a> <a href="#v:mkPT" class="selflink">#</a></p><div class="doc"><p>Low-level creation of the ParsecT type. You really shouldn't have to do this.</p></div></div><div class="top"><p class="src"><span class="keyword">type</span> <a id="t:Parsec" class="def">Parsec</a> s u = <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Functor-Identity.html#t:Identity">Identity</a> <a href="src/Text-Parsec-Prim.html#Parsec" class="link">Source</a> <a href="#t:Parsec" class="selflink">#</a></p></div><div class="top"><p class="src"><span class="keyword">data</span> <a id="t:Consumed" class="def">Consumed</a> a <a href="src/Text-Parsec-Prim.html#Consumed" class="link">Source</a> <a href="#t:Consumed" class="selflink">#</a></p><div class="subs constructors"><p class="caption">Constructors</p><table><tr><td class="src"><a id="v:Consumed" class="def">Consumed</a> a</td><td class="doc empty"> </td></tr><tr><td class="src"><a id="v:Empty" class="def">Empty</a> !a</td><td class="doc empty"> </td></tr></table></div><div class="subs instances"><p id="control.i:Consumed" class="caption collapser" onclick="toggleSection('i:Consumed')">Instances</p><div id="section.i:Consumed" class="show"><table><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:Consumed:Functor:1" class="instance expander" onclick="toggleSection('i:id:Consumed:Functor:1')"></span> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Functor.html#t:Functor">Functor</a> <a href="Text-Parsec-Prim.html#t:Consumed">Consumed</a></span> <a href="src/Text-Parsec-Prim.html#line-176" class="link">Source</a> <a href="#t:Consumed" class="selflink">#</a></td><td class="doc empty"> </td></tr><tr><td colspan="2"><div id="section.i:id:Consumed:Functor:1" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:fmap">fmap</a> :: (a -> b) -> <a href="Text-Parsec-Prim.html#t:Consumed">Consumed</a> a -> <a href="Text-Parsec-Prim.html#t:Consumed">Consumed</a> b <a href="#v:fmap" class="selflink">#</a></p><p class="src"><a href="#v:-60--36-">(<$)</a> :: a -> <a href="Text-Parsec-Prim.html#t:Consumed">Consumed</a> b -> <a href="Text-Parsec-Prim.html#t:Consumed">Consumed</a> a <a href="#v:-60--36-" class="selflink">#</a></p></div></div></td></tr></table></div></div></div><div class="top"><p class="src"><span class="keyword">data</span> <a id="t:Reply" class="def">Reply</a> s u a <a href="src/Text-Parsec-Prim.html#Reply" class="link">Source</a> <a href="#t:Reply" class="selflink">#</a></p><div class="subs constructors"><p class="caption">Constructors</p><table><tr><td class="src"><a id="v:Ok" class="def">Ok</a> a !(<a href="Text-Parsec-Prim.html#t:State">State</a> s u) <a href="Text-Parsec-Error.html#t:ParseError">ParseError</a></td><td class="doc empty"> </td></tr><tr><td class="src"><a id="v:Error" class="def">Error</a> <a href="Text-Parsec-Error.html#t:ParseError">ParseError</a></td><td class="doc empty"> </td></tr></table></div><div class="subs instances"><p id="control.i:Reply" class="caption collapser" onclick="toggleSection('i:Reply')">Instances</p><div id="section.i:Reply" class="show"><table><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:Reply:Functor:1" class="instance expander" onclick="toggleSection('i:id:Reply:Functor:1')"></span> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Functor.html#t:Functor">Functor</a> (<a href="Text-Parsec-Prim.html#t:Reply">Reply</a> s u)</span> <a href="src/Text-Parsec-Prim.html#line-180" class="link">Source</a> <a href="#t:Reply" class="selflink">#</a></td><td class="doc empty"> </td></tr><tr><td colspan="2"><div id="section.i:id:Reply:Functor:1" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:fmap">fmap</a> :: (a -> b) -> <a href="Text-Parsec-Prim.html#t:Reply">Reply</a> s u a -> <a href="Text-Parsec-Prim.html#t:Reply">Reply</a> s u b <a href="#v:fmap" class="selflink">#</a></p><p class="src"><a href="#v:-60--36-">(<$)</a> :: a -> <a href="Text-Parsec-Prim.html#t:Reply">Reply</a> s u b -> <a href="Text-Parsec-Prim.html#t:Reply">Reply</a> s u a <a href="#v:-60--36-" class="selflink">#</a></p></div></div></td></tr></table></div></div></div><div class="top"><p class="src"><span class="keyword">data</span> <a id="t:State" class="def">State</a> s u <a href="src/Text-Parsec-Prim.html#State" class="link">Source</a> <a href="#t:State" class="selflink">#</a></p><div class="subs constructors"><p class="caption">Constructors</p><table><tr><td class="src"><a id="v:State" class="def">State</a></td><td class="doc empty"> </td></tr><tr><td colspan="2"><div class="subs fields"><p class="caption">Fields</p><ul><li><dfn class="src"><a id="v:stateInput" class="def">stateInput</a> :: s</dfn><div class="doc empty"> </div></li><li><dfn class="src"><a id="v:statePos" class="def">statePos</a> :: !<a href="Text-Parsec-Pos.html#t:SourcePos">SourcePos</a></dfn><div class="doc empty"> </div></li><li><dfn class="src"><a id="v:stateUser" class="def">stateUser</a> :: !u</dfn><div class="doc empty"> </div></li></ul></div></td></tr></table></div></div><div class="top"><p class="src"><a id="v:parsecMap" class="def">parsecMap</a> :: (a -> b) -> <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m a -> <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m b <a href="src/Text-Parsec-Prim.html#parsecMap" class="link">Source</a> <a href="#v:parsecMap" class="selflink">#</a></p></div><div class="top"><p class="src"><a id="v:parserReturn" class="def">parserReturn</a> :: a -> <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m a <a href="src/Text-Parsec-Prim.html#parserReturn" class="link">Source</a> <a href="#v:parserReturn" class="selflink">#</a></p></div><div class="top"><p class="src"><a id="v:parserBind" class="def">parserBind</a> :: <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m a -> (a -> <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m b) -> <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m b <a href="src/Text-Parsec-Prim.html#parserBind" class="link">Source</a> <a href="#v:parserBind" class="selflink">#</a></p></div><div class="top"><p class="src"><a id="v:mergeErrorReply" class="def">mergeErrorReply</a> :: <a href="Text-Parsec-Error.html#t:ParseError">ParseError</a> -> <a href="Text-Parsec-Prim.html#t:Reply">Reply</a> s u a -> <a href="Text-Parsec-Prim.html#t:Reply">Reply</a> s u a <a href="src/Text-Parsec-Prim.html#mergeErrorReply" class="link">Source</a> <a href="#v:mergeErrorReply" class="selflink">#</a></p></div><div class="top"><p class="src"><a id="v:parserFail" class="def">parserFail</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-String.html#t:String">String</a> -> <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m a <a href="src/Text-Parsec-Prim.html#parserFail" class="link">Source</a> <a href="#v:parserFail" class="selflink">#</a></p></div><div class="top"><p class="src"><a id="v:parserZero" class="def">parserZero</a> :: <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m a <a href="src/Text-Parsec-Prim.html#parserZero" class="link">Source</a> <a href="#v:parserZero" class="selflink">#</a></p><div class="doc"><p><code>parserZero</code> always fails without consuming any input. <code>parserZero</code> is defined
equal to the <code><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Control-Monad.html#v:mzero">mzero</a></code> member of the <code><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Control-Monad.html#t:MonadPlus">MonadPlus</a></code> class and to the <code><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Control-Applicative.html#v:empty">empty</a></code> member
of the <code><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Control-Applicative.html#v:Alternative">Alternative</a></code> class.</p></div></div><div class="top"><p class="src"><a id="v:parserPlus" class="def">parserPlus</a> :: <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m a -> <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m a -> <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m a <a href="src/Text-Parsec-Prim.html#parserPlus" class="link">Source</a> <a href="#v:parserPlus" class="selflink">#</a></p></div><div class="top"><p class="src"><a id="v:-60--63--62-" class="def">(<?>)</a> :: <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m a -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-String.html#t:String">String</a> -> <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m a <span class="fixity">infix 0</span><span class="rightedge"></span> <a href="src/Text-Parsec-Prim.html#%3C%3F%3E" class="link">Source</a> <a href="#v:-60--63--62-" class="selflink">#</a></p><div class="doc"><p>The parser <code>p <?> msg</code> behaves as parser <code>p</code>, but whenever the
parser <code>p</code> fails <em>without consuming any input</em>, it replaces expect
error messages with the expect error message <code>msg</code>.</p><p>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
<code>expr</code> parser from the <code><a href="Text-Parsec-Prim.html#v:try">try</a></code> example would fail, the error
message is: '...: expecting expression'. Without the <code>(<?>)</code>
combinator, the message would be like '...: expecting "let" or
letter', which is less friendly.</p></div></div><div class="top"><p class="src"><a id="v:-60--124--62-" class="def">(<|>)</a> :: <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m a -> <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m a -> <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m a <span class="fixity">infixr 1</span><span class="rightedge"></span> <a href="src/Text-Parsec-Prim.html#%3C%7C%3E" class="link">Source</a> <a href="#v:-60--124--62-" class="selflink">#</a></p><div class="doc"><p>This combinator implements choice. The parser <code>p <|> q</code> first
applies <code>p</code>. If it succeeds, the value of <code>p</code> is returned. If <code>p</code>
fails <em>without consuming any input</em>, parser <code>q</code> is tried. This
combinator is defined equal to the <code><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Control-Monad.html#v:mplus">mplus</a></code> member of the <code><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Control-Monad.html#t:MonadPlus">MonadPlus</a></code>
class and the (<code><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Control-Applicative.html#v:-60--124--62-"><|></a></code>) member of <code><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Control-Applicative.html#v:Alternative">Alternative</a></code>.</p><p>The parser is called <em>predictive</em> since <code>q</code> is only tried when
parser <code>p</code> 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.</p></div></div><div class="top"><p class="src"><a id="v:label" class="def">label</a> :: <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m a -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-String.html#t:String">String</a> -> <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m a <a href="src/Text-Parsec-Prim.html#label" class="link">Source</a> <a href="#v:label" class="selflink">#</a></p><div class="doc"><p>A synonym for <code><?></code>, but as a function instead of an operator.</p></div></div><div class="top"><p class="src"><a id="v:labels" class="def">labels</a> :: <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m a -> [<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-String.html#t:String">String</a>] -> <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m a <a href="src/Text-Parsec-Prim.html#labels" class="link">Source</a> <a href="#v:labels" class="selflink">#</a></p></div><div class="top"><p class="src"><a id="v:lookAhead" class="def">lookAhead</a> :: <a href="Text-Parsec-Prim.html#t:Stream">Stream</a> s m t => <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m a -> <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m a <a href="src/Text-Parsec-Prim.html#lookAhead" class="link">Source</a> <a href="#v:lookAhead" class="selflink">#</a></p><div class="doc"><p><code>lookAhead p</code> parses <code>p</code> without consuming any input.</p><p>If <code>p</code> fails and consumes some input, so does <code>lookAhead</code>. Combine with <code><a href="Text-Parsec-Prim.html#v:try">try</a></code>
if this is undesirable.</p></div></div><div class="top"><p class="src"><span class="keyword">class</span> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Control-Monad.html#t:Monad">Monad</a> m => <a id="t:Stream" class="def">Stream</a> s m t | s -> t <span class="keyword">where</span> <a href="src/Text-Parsec-Prim.html#Stream" class="link">Source</a> <a href="#t:Stream" class="selflink">#</a></p><div class="doc"><p>An instance of <code>Stream</code> has stream type <code>s</code>, underlying monad <code>m</code> and token type <code>t</code> determined by the stream</p><p>Some rough guidelines for a "correct" instance of Stream:</p><ul><li>unfoldM uncons gives the [t] corresponding to the stream</li><li>A <code>Stream</code> instance is responsible for maintaining the "position within the stream" in the stream state <code>s</code>. This is trivial unless you are using the monad in a non-trivial way.</li></ul></div><div class="subs minimal"><p class="caption">Minimal complete definition</p><p class="src"><a href="Text-Parsec-Prim.html#v:uncons">uncons</a></p></div><div class="subs methods"><p class="caption">Methods</p><p class="src"><a id="v:uncons" class="def">uncons</a> :: s -> m (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Maybe.html#t:Maybe">Maybe</a> (t, s)) <a href="src/Text-Parsec-Prim.html#uncons" class="link">Source</a> <a href="#v:uncons" class="selflink">#</a></p></div><div class="subs instances"><p id="control.i:Stream" class="caption collapser" onclick="toggleSection('i:Stream')">Instances</p><div id="section.i:Stream" class="show"><table><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:Stream:Stream:1" class="instance expander" onclick="toggleSection('i:ic:Stream:Stream:1')"></span> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Control-Monad.html#t:Monad">Monad</a> m => <a href="Text-Parsec-Prim.html#t:Stream">Stream</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/bytestring-0.10.8.1/Data-ByteString-Lazy.html#t:ByteString">ByteString</a> m <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Char.html#t:Char">Char</a></span> <a href="src/Text-Parsec-Prim.html#line-391" class="link">Source</a> <a href="#t:Stream" class="selflink">#</a></td><td class="doc empty"> </td></tr><tr><td colspan="2"><div id="section.i:ic:Stream:Stream:1" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:uncons">uncons</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/bytestring-0.10.8.1/Data-ByteString-Lazy.html#t:ByteString">ByteString</a> -> m (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Maybe.html#t:Maybe">Maybe</a> (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Char.html#t:Char">Char</a>, <a href="file:///usr/share/doc/ghc-doc/html/libraries/bytestring-0.10.8.1/Data-ByteString-Lazy.html#t:ByteString">ByteString</a>)) <a href="src/Text-Parsec-Prim.html#uncons" class="link">Source</a> <a href="#v:uncons" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:Stream:Stream:2" class="instance expander" onclick="toggleSection('i:ic:Stream:Stream:2')"></span> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Control-Monad.html#t:Monad">Monad</a> m => <a href="Text-Parsec-Prim.html#t:Stream">Stream</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/bytestring-0.10.8.1/Data-ByteString.html#t:ByteString">ByteString</a> m <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Char.html#t:Char">Char</a></span> <a href="src/Text-Parsec-Prim.html#line-394" class="link">Source</a> <a href="#t:Stream" class="selflink">#</a></td><td class="doc empty"> </td></tr><tr><td colspan="2"><div id="section.i:ic:Stream:Stream:2" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:uncons">uncons</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/bytestring-0.10.8.1/Data-ByteString.html#t:ByteString">ByteString</a> -> m (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Maybe.html#t:Maybe">Maybe</a> (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Char.html#t:Char">Char</a>, <a href="file:///usr/share/doc/ghc-doc/html/libraries/bytestring-0.10.8.1/Data-ByteString.html#t:ByteString">ByteString</a>)) <a href="src/Text-Parsec-Prim.html#uncons" class="link">Source</a> <a href="#v:uncons" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:Stream:Stream:3" class="instance expander" onclick="toggleSection('i:ic:Stream:Stream:3')"></span> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Control-Monad.html#t:Monad">Monad</a> m => <a href="Text-Parsec-Prim.html#t:Stream">Stream</a> <a href="file:///usr/share/doc/libghc-text-doc/html/Data-Text-Lazy.html#t:Text">Text</a> m <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Char.html#t:Char">Char</a></span> <a href="src/Text-Parsec-Prim.html#line-401" class="link">Source</a> <a href="#t:Stream" class="selflink">#</a></td><td class="doc empty"> </td></tr><tr><td colspan="2"><div id="section.i:ic:Stream:Stream:3" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:uncons">uncons</a> :: <a href="file:///usr/share/doc/libghc-text-doc/html/Data-Text-Lazy.html#t:Text">Text</a> -> m (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Maybe.html#t:Maybe">Maybe</a> (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Char.html#t:Char">Char</a>, <a href="file:///usr/share/doc/libghc-text-doc/html/Data-Text-Lazy.html#t:Text">Text</a>)) <a href="src/Text-Parsec-Prim.html#uncons" class="link">Source</a> <a href="#v:uncons" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:Stream:Stream:4" class="instance expander" onclick="toggleSection('i:ic:Stream:Stream:4')"></span> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Control-Monad.html#t:Monad">Monad</a> m => <a href="Text-Parsec-Prim.html#t:Stream">Stream</a> <a href="file:///usr/share/doc/libghc-text-doc/html/Data-Text.html#t:Text">Text</a> m <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Char.html#t:Char">Char</a></span> <a href="src/Text-Parsec-Prim.html#line-397" class="link">Source</a> <a href="#t:Stream" class="selflink">#</a></td><td class="doc empty"> </td></tr><tr><td colspan="2"><div id="section.i:ic:Stream:Stream:4" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:uncons">uncons</a> :: <a href="file:///usr/share/doc/libghc-text-doc/html/Data-Text.html#t:Text">Text</a> -> m (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Maybe.html#t:Maybe">Maybe</a> (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Char.html#t:Char">Char</a>, <a href="file:///usr/share/doc/libghc-text-doc/html/Data-Text.html#t:Text">Text</a>)) <a href="src/Text-Parsec-Prim.html#uncons" class="link">Source</a> <a href="#v:uncons" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:Stream:Stream:5" class="instance expander" onclick="toggleSection('i:ic:Stream:Stream:5')"></span> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Control-Monad.html#t:Monad">Monad</a> m => <a href="Text-Parsec-Prim.html#t:Stream">Stream</a> [tok] m tok</span> <a href="src/Text-Parsec-Prim.html#line-385" class="link">Source</a> <a href="#t:Stream" class="selflink">#</a></td><td class="doc empty"> </td></tr><tr><td colspan="2"><div id="section.i:ic:Stream:Stream:5" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:uncons">uncons</a> :: [tok] -> m (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Maybe.html#t:Maybe">Maybe</a> (tok, [tok])) <a href="src/Text-Parsec-Prim.html#uncons" class="link">Source</a> <a href="#v:uncons" class="selflink">#</a></p></div></div></td></tr></table></div></div></div><div class="top"><p class="src"><a id="v:tokens" class="def">tokens</a> :: (<a href="Text-Parsec-Prim.html#t:Stream">Stream</a> s m t, <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Eq.html#t:Eq">Eq</a> t) => ([t] -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-String.html#t:String">String</a>) -> (<a href="Text-Parsec-Pos.html#t:SourcePos">SourcePos</a> -> [t] -> <a href="Text-Parsec-Pos.html#t:SourcePos">SourcePos</a>) -> [t] -> <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m [t] <a href="src/Text-Parsec-Prim.html#tokens" class="link">Source</a> <a href="#v:tokens" class="selflink">#</a></p></div><div class="top"><p class="src"><a id="v:try" class="def">try</a> :: <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m a -> <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m a <a href="src/Text-Parsec-Prim.html#try" class="link">Source</a> <a href="#v:try" class="selflink">#</a></p><div class="doc"><p>The parser <code>try p</code> behaves like parser <code>p</code>, except that it
pretends that it hasn't consumed any input when an error occurs.</p><p>This combinator is used whenever arbitrary look ahead is needed.
Since it pretends that it hasn't consumed any input when <code>p</code> fails,
the (<code><a href="Text-Parsec-Prim.html#v:-60--124--62-"><|></a></code>) combinator will try its second alternative even when the
first parser failed while consuming input.</p><p>The <code>try</code> 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 <code>try</code>
combinator. Suppose we write:</p><pre> expr = letExpr <|> identifier <?> "expression"
letExpr = do{ string "let"; ... }
identifier = many1 letter</pre><p>If the user writes "lexical", the parser fails with: <code>unexpected
'x', expecting 't' in "let"</code>. Indeed, since the (<code><a href="Text-Parsec-Prim.html#v:-60--124--62-"><|></a></code>) combinator
only tries alternatives when the first alternative hasn't consumed
input, the <code>identifier</code> parser is never tried (because the prefix
"le" of the <code>string "let"</code> parser is already consumed). The
right behaviour can be obtained by adding the <code>try</code> combinator:</p><pre> expr = letExpr <|> identifier <?> "expression"
letExpr = do{ try (string "let"); ... }
identifier = many1 letter</pre></div></div><div class="top"><p class="src"><a id="v:token" class="def">token</a> <a href="src/Text-Parsec-Prim.html#token" class="link">Source</a> <a href="#v:token" class="selflink">#</a></p><div class="subs arguments"><p class="caption">Arguments</p><table><tr><td class="src">:: <a href="Text-Parsec-Prim.html#t:Stream">Stream</a> s <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Functor-Identity.html#t:Identity">Identity</a> t</td><td class="doc empty"> </td></tr><tr><td class="src">=> (t -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-String.html#t:String">String</a>)</td><td class="doc"><p>Token pretty-printing function.</p></td></tr><tr><td class="src">-> (t -> <a href="Text-Parsec-Pos.html#t:SourcePos">SourcePos</a>)</td><td class="doc"><p>Computes the position of a token.</p></td></tr><tr><td class="src">-> (t -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Maybe.html#t:Maybe">Maybe</a> a)</td><td class="doc"><p>Matching function for the token to parse.</p></td></tr><tr><td class="src">-> <a href="Text-Parsec-Prim.html#t:Parsec">Parsec</a> s u a</td><td class="doc empty"> </td></tr></table></div><div class="doc"><p>The parser <code>token showTok posFromTok testTok</code> accepts a token <code>t</code>
with result <code>x</code> when the function <code>testTok t</code> returns <code><code><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Maybe.html#v:Just">Just</a></code> x</code>. The
source position of the <code>t</code> should be returned by <code>posFromTok t</code> and
the token can be shown using <code>showTok t</code>.</p><p>This combinator is expressed in terms of <code><a href="Text-Parsec-Prim.html#v:tokenPrim">tokenPrim</a></code>.
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 than define a parser that accepts single tokens as:</p><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></div></div><div class="top"><p class="src"><a id="v:tokenPrim" class="def">tokenPrim</a> <a href="src/Text-Parsec-Prim.html#tokenPrim" class="link">Source</a> <a href="#v:tokenPrim" class="selflink">#</a></p><div class="subs arguments"><p class="caption">Arguments</p><table><tr><td class="src">:: <a href="Text-Parsec-Prim.html#t:Stream">Stream</a> s m t</td><td class="doc empty"> </td></tr><tr><td class="src">=> (t -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-String.html#t:String">String</a>)</td><td class="doc"><p>Token pretty-printing function.</p></td></tr><tr><td class="src">-> (<a href="Text-Parsec-Pos.html#t:SourcePos">SourcePos</a> -> t -> s -> <a href="Text-Parsec-Pos.html#t:SourcePos">SourcePos</a>)</td><td class="doc"><p>Next position calculating function.</p></td></tr><tr><td class="src">-> (t -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Maybe.html#t:Maybe">Maybe</a> a)</td><td class="doc"><p>Matching function for the token to parse.</p></td></tr><tr><td class="src">-> <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m a</td><td class="doc empty"> </td></tr></table></div><div class="doc"><p>The parser <code>tokenPrim showTok nextPos testTok</code> accepts a token <code>t</code>
with result <code>x</code> when the function <code>testTok t</code> returns <code><code><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Maybe.html#v:Just">Just</a></code> x</code>. The
token can be shown using <code>showTok t</code>. The position of the <em>next</em>
token should be returned when <code>nextPos</code> is called with the current
source position <code>pos</code>, the current token <code>t</code> and the rest of the
tokens <code>toks</code>, <code>nextPos pos t toks</code>.</p><p>This is the most primitive combinator for accepting tokens. For
example, the <code><a href="Text-Parsec-Char.html#v:char">char</a></code> parser could be implemented as:</p><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></div></div><div class="top"><p class="src"><a id="v:tokenPrimEx" class="def">tokenPrimEx</a> :: <a href="Text-Parsec-Prim.html#t:Stream">Stream</a> s m t => (t -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-String.html#t:String">String</a>) -> (<a href="Text-Parsec-Pos.html#t:SourcePos">SourcePos</a> -> t -> s -> <a href="Text-Parsec-Pos.html#t:SourcePos">SourcePos</a>) -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Maybe.html#t:Maybe">Maybe</a> (<a href="Text-Parsec-Pos.html#t:SourcePos">SourcePos</a> -> t -> s -> u -> u) -> (t -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Maybe.html#t:Maybe">Maybe</a> a) -> <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m a <a href="src/Text-Parsec-Prim.html#tokenPrimEx" class="link">Source</a> <a href="#v:tokenPrimEx" class="selflink">#</a></p></div><div class="top"><p class="src"><a id="v:many" class="def">many</a> :: <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m a -> <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m [a] <a href="src/Text-Parsec-Prim.html#many" class="link">Source</a> <a href="#v:many" class="selflink">#</a></p><div class="doc"><p><code>many p</code> applies the parser <code>p</code> <em>zero</em> or more times. Returns a
list of the returned values of <code>p</code>.</p><pre> identifier = do{ c <- letter
; cs <- many (alphaNum <|> char '_')
; return (c:cs)
}</pre></div></div><div class="top"><p class="src"><a id="v:skipMany" class="def">skipMany</a> :: <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m a -> <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m () <a href="src/Text-Parsec-Prim.html#skipMany" class="link">Source</a> <a href="#v:skipMany" class="selflink">#</a></p><div class="doc"><p><code>skipMany p</code> applies the parser <code>p</code> <em>zero</em> or more times, skipping
its result.</p><pre> spaces = skipMany space</pre></div></div><div class="top"><p class="src"><a id="v:manyAccum" class="def">manyAccum</a> :: (a -> [a] -> [a]) -> <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m a -> <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m [a] <a href="src/Text-Parsec-Prim.html#manyAccum" class="link">Source</a> <a href="#v:manyAccum" class="selflink">#</a></p></div><div class="top"><p class="src"><a id="v:runPT" class="def">runPT</a> :: <a href="Text-Parsec-Prim.html#t:Stream">Stream</a> s m t => <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m a -> u -> <a href="Text-Parsec-Pos.html#t:SourceName">SourceName</a> -> s -> m (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Either.html#t:Either">Either</a> <a href="Text-Parsec-Error.html#t:ParseError">ParseError</a> a) <a href="src/Text-Parsec-Prim.html#runPT" class="link">Source</a> <a href="#v:runPT" class="selflink">#</a></p></div><div class="top"><p class="src"><a id="v:runP" class="def">runP</a> :: <a href="Text-Parsec-Prim.html#t:Stream">Stream</a> s <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Functor-Identity.html#t:Identity">Identity</a> t => <a href="Text-Parsec-Prim.html#t:Parsec">Parsec</a> s u a -> u -> <a href="Text-Parsec-Pos.html#t:SourceName">SourceName</a> -> s -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Either.html#t:Either">Either</a> <a href="Text-Parsec-Error.html#t:ParseError">ParseError</a> a <a href="src/Text-Parsec-Prim.html#runP" class="link">Source</a> <a href="#v:runP" class="selflink">#</a></p></div><div class="top"><p class="src"><a id="v:runParserT" class="def">runParserT</a> :: <a href="Text-Parsec-Prim.html#t:Stream">Stream</a> s m t => <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m a -> u -> <a href="Text-Parsec-Pos.html#t:SourceName">SourceName</a> -> s -> m (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Either.html#t:Either">Either</a> <a href="Text-Parsec-Error.html#t:ParseError">ParseError</a> a) <a href="src/Text-Parsec-Prim.html#runParserT" class="link">Source</a> <a href="#v:runParserT" class="selflink">#</a></p><div class="doc"><p>The most general way to run a parser. <code>runParserT p state filePath
input</code> runs parser <code>p</code> on the input list of tokens <code>input</code>,
obtained from source <code>filePath</code> with the initial user state <code>st</code>.
The <code>filePath</code> is only used in error messages and may be the empty
string. Returns a computation in the underlying monad <code>m</code> that return either a <code><a href="Text-Parsec-Error.html#t:ParseError">ParseError</a></code> (<code><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Either.html#v:Left">Left</a></code>) or a
value of type <code>a</code> (<code><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Either.html#v:Right">Right</a></code>).</p></div></div><div class="top"><p class="src"><a id="v:runParser" class="def">runParser</a> :: <a href="Text-Parsec-Prim.html#t:Stream">Stream</a> s <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Functor-Identity.html#t:Identity">Identity</a> t => <a href="Text-Parsec-Prim.html#t:Parsec">Parsec</a> s u a -> u -> <a href="Text-Parsec-Pos.html#t:SourceName">SourceName</a> -> s -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Either.html#t:Either">Either</a> <a href="Text-Parsec-Error.html#t:ParseError">ParseError</a> a <a href="src/Text-Parsec-Prim.html#runParser" class="link">Source</a> <a href="#v:runParser" class="selflink">#</a></p><div class="doc"><p>The most general way to run a parser over the Identity monad. <code>runParser p state filePath
input</code> runs parser <code>p</code> on the input list of tokens <code>input</code>,
obtained from source <code>filePath</code> with the initial user state <code>st</code>.
The <code>filePath</code> is only used in error messages and may be the empty
string. Returns either a <code><a href="Text-Parsec-Error.html#t:ParseError">ParseError</a></code> (<code><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Either.html#v:Left">Left</a></code>) or a
value of type <code>a</code> (<code><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Either.html#v:Right">Right</a></code>).</p><pre> parseFromFile p fname
= do{ input <- readFile fname
; return (runParser p () fname input)
}</pre></div></div><div class="top"><p class="src"><a id="v:parse" class="def">parse</a> :: <a href="Text-Parsec-Prim.html#t:Stream">Stream</a> s <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Functor-Identity.html#t:Identity">Identity</a> t => <a href="Text-Parsec-Prim.html#t:Parsec">Parsec</a> s () a -> <a href="Text-Parsec-Pos.html#t:SourceName">SourceName</a> -> s -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Either.html#t:Either">Either</a> <a href="Text-Parsec-Error.html#t:ParseError">ParseError</a> a <a href="src/Text-Parsec-Prim.html#parse" class="link">Source</a> <a href="#v:parse" class="selflink">#</a></p><div class="doc"><p><code>parse p filePath input</code> runs a parser <code>p</code> over Identity without user
state. The <code>filePath</code> is only used in error messages and may be the
empty string. Returns either a <code><a href="Text-Parsec-Error.html#t:ParseError">ParseError</a></code> (<code><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Either.html#v:Left">Left</a></code>)
or a value of type <code>a</code> (<code><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Either.html#v:Right">Right</a></code>).</p><pre> main = case (parse numbers "" "11, 2, 43") of
Left err -> print err
Right xs -> print (sum xs)
numbers = commaSep integer</pre></div></div><div class="top"><p class="src"><a id="v:parseTest" class="def">parseTest</a> :: (<a href="Text-Parsec-Prim.html#t:Stream">Stream</a> s <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Functor-Identity.html#t:Identity">Identity</a> t, <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Text-Show.html#t:Show">Show</a> a) => <a href="Text-Parsec-Prim.html#t:Parsec">Parsec</a> s () a -> s -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/System-IO.html#t:IO">IO</a> () <a href="src/Text-Parsec-Prim.html#parseTest" class="link">Source</a> <a href="#v:parseTest" class="selflink">#</a></p><div class="doc"><p>The expression <code>parseTest p input</code> applies a parser <code>p</code> against
input <code>input</code> and prints the result to stdout. Used for testing
parsers.</p></div></div><div class="top"><p class="src"><a id="v:getPosition" class="def">getPosition</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Control-Monad.html#t:Monad">Monad</a> m => <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m <a href="Text-Parsec-Pos.html#t:SourcePos">SourcePos</a> <a href="src/Text-Parsec-Prim.html#getPosition" class="link">Source</a> <a href="#v:getPosition" class="selflink">#</a></p><div class="doc"><p>Returns the current source position. See also <code><a href="Text-Parsec-Pos.html#t:SourcePos">SourcePos</a></code>.</p></div></div><div class="top"><p class="src"><a id="v:getInput" class="def">getInput</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Control-Monad.html#t:Monad">Monad</a> m => <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m s <a href="src/Text-Parsec-Prim.html#getInput" class="link">Source</a> <a href="#v:getInput" class="selflink">#</a></p><div class="doc"><p>Returns the current input </p></div></div><div class="top"><p class="src"><a id="v:setPosition" class="def">setPosition</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Control-Monad.html#t:Monad">Monad</a> m => <a href="Text-Parsec-Pos.html#t:SourcePos">SourcePos</a> -> <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m () <a href="src/Text-Parsec-Prim.html#setPosition" class="link">Source</a> <a href="#v:setPosition" class="selflink">#</a></p><div class="doc"><p><code>setPosition pos</code> sets the current source position to <code>pos</code>. </p></div></div><div class="top"><p class="src"><a id="v:setInput" class="def">setInput</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Control-Monad.html#t:Monad">Monad</a> m => s -> <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m () <a href="src/Text-Parsec-Prim.html#setInput" class="link">Source</a> <a href="#v:setInput" class="selflink">#</a></p><div class="doc"><p><code>setInput input</code> continues parsing with <code>input</code>. The <code><a href="Text-Parsec-Prim.html#v:getInput">getInput</a></code> and
<code>setInput</code> functions can for example be used to deal with #include
files. </p></div></div><div class="top"><p class="src"><a id="v:getParserState" class="def">getParserState</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Control-Monad.html#t:Monad">Monad</a> m => <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m (<a href="Text-Parsec-Prim.html#t:State">State</a> s u) <a href="src/Text-Parsec-Prim.html#getParserState" class="link">Source</a> <a href="#v:getParserState" class="selflink">#</a></p><div class="doc"><p>Returns the full parser state as a <code><a href="Text-Parsec-Prim.html#t:State">State</a></code> record.</p></div></div><div class="top"><p class="src"><a id="v:setParserState" class="def">setParserState</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Control-Monad.html#t:Monad">Monad</a> m => <a href="Text-Parsec-Prim.html#t:State">State</a> s u -> <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m (<a href="Text-Parsec-Prim.html#t:State">State</a> s u) <a href="src/Text-Parsec-Prim.html#setParserState" class="link">Source</a> <a href="#v:setParserState" class="selflink">#</a></p><div class="doc"><p><code>setParserState st</code> set the full parser state to <code>st</code>. </p></div></div><div class="top"><p class="src"><a id="v:updateParserState" class="def">updateParserState</a> :: (<a href="Text-Parsec-Prim.html#t:State">State</a> s u -> <a href="Text-Parsec-Prim.html#t:State">State</a> s u) -> <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m (<a href="Text-Parsec-Prim.html#t:State">State</a> s u) <a href="src/Text-Parsec-Prim.html#updateParserState" class="link">Source</a> <a href="#v:updateParserState" class="selflink">#</a></p><div class="doc"><p><code>updateParserState f</code> applies function <code>f</code> to the parser state.</p></div></div><div class="top"><p class="src"><a id="v:getState" class="def">getState</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Control-Monad.html#t:Monad">Monad</a> m => <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m u <a href="src/Text-Parsec-Prim.html#getState" class="link">Source</a> <a href="#v:getState" class="selflink">#</a></p><div class="doc"><p>Returns the current user state. </p></div></div><div class="top"><p class="src"><a id="v:putState" class="def">putState</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Control-Monad.html#t:Monad">Monad</a> m => u -> <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m () <a href="src/Text-Parsec-Prim.html#putState" class="link">Source</a> <a href="#v:putState" class="selflink">#</a></p><div class="doc"><p><code>putState st</code> set the user state to <code>st</code>. </p></div></div><div class="top"><p class="src"><a id="v:modifyState" class="def">modifyState</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Control-Monad.html#t:Monad">Monad</a> m => (u -> u) -> <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m () <a href="src/Text-Parsec-Prim.html#modifyState" class="link">Source</a> <a href="#v:modifyState" class="selflink">#</a></p><div class="doc"><p><code>modifyState f</code> applies function <code>f</code> to the user state. Suppose
that we want to count identifiers in a source, we could use the user
state as:</p><pre> expr = do{ x <- identifier
; modifyState (+1)
; return (Id x)
}</pre></div></div><div class="top"><p class="src"><a id="v:setState" class="def">setState</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Control-Monad.html#t:Monad">Monad</a> m => u -> <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m () <a href="src/Text-Parsec-Prim.html#setState" class="link">Source</a> <a href="#v:setState" class="selflink">#</a></p><div class="doc"><p>An alias for putState for backwards compatibility.</p></div></div><div class="top"><p class="src"><a id="v:updateState" class="def">updateState</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Control-Monad.html#t:Monad">Monad</a> m => (u -> u) -> <a href="Text-Parsec-Prim.html#t:ParsecT">ParsecT</a> s u m () <a href="src/Text-Parsec-Prim.html#updateState" class="link">Source</a> <a href="#v:updateState" class="selflink">#</a></p><div class="doc"><p>An alias for modifyState for backwards compatibility.</p></div></div></div></div><div id="footer"><p>Produced by <a href="http://www.haskell.org/haddock/">Haddock</a> version 2.17.3</p></div></body></html>
|