packages feed

polyparse-1.1: docs/haddock/Text-ParserCombinators-Poly-Lazy.html

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!--Rendered using the Haskell Html Library v0.2-->
<HTML
><HEAD
><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8"
><TITLE
>Text.ParserCombinators.Poly.Lazy</TITLE
><LINK HREF="haddock.css" REL="stylesheet" TYPE="text/css"
><SCRIPT SRC="haddock.js" TYPE="text/javascript"
></SCRIPT
></HEAD
><BODY
><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"
><TR
><TD CLASS="topbar"
><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"
><TR
><TD
><IMG SRC="haskell_icon.gif" WIDTH="16" HEIGHT="16" ALT=" "
></TD
><TD CLASS="title"
>polyparse</TD
><TD CLASS="topbut"
><A HREF="src/Text/ParserCombinators/Poly/Lazy.html"
>Source code</A
></TD
><TD CLASS="topbut"
><A HREF="index.html"
>Contents</A
></TD
><TD CLASS="topbut"
><A HREF="doc-index.html"
>Index</A
></TD
></TR
></TABLE
></TD
></TR
><TR
><TD CLASS="modulebar"
><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"
><TR
><TD
><FONT SIZE="6"
>Text.ParserCombinators.Poly.Lazy</FONT
></TD
></TR
></TABLE
></TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD
><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"
><TR
><TD CLASS="section4"
><B
>Contents</B
></TD
></TR
><TR
><TD
><DL
><DT
><A HREF="#1"
>The Parser datatype.
</A
></DT
><DD
><DL
><DT
><A HREF="#2"
>basic parsers
</A
></DT
><DT
><A HREF="#3"
>Re-parsing
</A
></DT
></DL
></DD
><DT
><A HREF="#4"
>Re-export all more general combinators
</A
></DT
></DL
></TD
></TR
></TABLE
></TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="section1"
>Synopsis</TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="body"
><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"
><TR
><TD CLASS="decl"
><SPAN CLASS="keyword"
>newtype</SPAN
> <A HREF="#t%3AParser"
>Parser</A
> t a = <A HREF="#v%3AP"
>P</A
> ([t] -&gt; (Either String a, [t]))</TD
></TR
><TR
><TD CLASS="s8"
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="#v%3ArunParser"
>runParser</A
> :: <A HREF="Text-ParserCombinators-Poly-Lazy.html#t%3AParser"
>Parser</A
> t a -&gt; [t] -&gt; (a, [t])</TD
></TR
><TR
><TD CLASS="s8"
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="#v%3Asatisfy"
>satisfy</A
> :: (t -&gt; Bool) -&gt; <A HREF="Text-ParserCombinators-Poly-Lazy.html#t%3AParser"
>Parser</A
> t t</TD
></TR
><TR
><TD CLASS="s8"
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="#v%3AmanyFinally"
>manyFinally</A
> :: <A HREF="Text-ParserCombinators-Poly-Lazy.html#t%3AParser"
>Parser</A
> t a -&gt; <A HREF="Text-ParserCombinators-Poly-Lazy.html#t%3AParser"
>Parser</A
> t z -&gt; <A HREF="Text-ParserCombinators-Poly-Lazy.html#t%3AParser"
>Parser</A
> t [a]</TD
></TR
><TR
><TD CLASS="s8"
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="#v%3Areparse"
>reparse</A
> :: [t] -&gt; <A HREF="Text-ParserCombinators-Poly-Lazy.html#t%3AParser"
>Parser</A
> t ()</TD
></TR
><TR
><TD CLASS="s8"
></TD
></TR
><TR
><TD CLASS="decl"
>module <A HREF="Text-ParserCombinators-Poly-Base.html"
>Text.ParserCombinators.Poly.Base</A
></TD
></TR
></TABLE
></TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="section1"
><A NAME="1"
>The Parser datatype.
</A
></TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="doc"
>When applied, these parsers do not return explicit failure.
 An exception is
 raised instead.  This allows partial results to be returned
 before a full parse is complete.
 One of the key ways to ensure that your parser is properly lazy,
 is to parse the initial portion of text returning a function, then
 use the <TT
>apply</TT
> combinator to build the final value.
</TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="topdecl"
><TABLE CLASS="declbar"
><TR
><TD CLASS="declname"
><SPAN CLASS="keyword"
>newtype</SPAN
> <A NAME="t%3AParser"
></A
><B
>Parser</B
> t a</TD
><TD CLASS="declbut"
><A HREF="src/Text/ParserCombinators/Poly/Lazy.html#Parser"
>Source</A
></TD
></TR
></TABLE
></TD
></TR
><TR
><TD CLASS="body"
><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"
><TR
><TD CLASS="ndoc"
>The <TT
>Parser</TT
> datatype is a fairly generic parsing monad with error
   reporting.  It can be used for arbitrary token types, not just
   String input.  (If you require a running state, use module PolyStateLazy
   instead.)
</TD
></TR
><TR
><TD CLASS="section4"
>Constructors</TD
></TR
><TR
><TD CLASS="body"
><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0"
><TR
><TD CLASS="arg"
><A NAME="v%3AP"
></A
><B
>P</B
> ([t] -&gt; (Either String a, [t]))</TD
><TD CLASS="rdoc"
></TD
></TR
></TABLE
></TD
></TR
><TR
><TD CLASS="section4"
><IMG SRC="minus.gif" CLASS="coll" ONCLICK="toggle(this,'i:Parser')" ALT="show/hide"
> Instances</TD
></TR
><TR
><TD CLASS="body"
><DIV ID="i:Parser" STYLE="display:block;"
><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0"
><TR
><TD CLASS="decl"
>Functor (<A HREF="Text-ParserCombinators-Poly-Lazy.html#t%3AParser"
>Parser</A
> t)</TD
></TR
><TR
><TD CLASS="decl"
>Monad (<A HREF="Text-ParserCombinators-Poly-Lazy.html#t%3AParser"
>Parser</A
> t)</TD
></TR
><TR
><TD CLASS="decl"
><A HREF="Text-ParserCombinators-Poly-Base.html#t%3APolyParse"
>PolyParse</A
> (<A HREF="Text-ParserCombinators-Poly-Lazy.html#t%3AParser"
>Parser</A
> t)</TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
></TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="topdecl"
><TABLE CLASS="declbar"
><TR
><TD CLASS="declname"
><A NAME="v%3ArunParser"
></A
><B
>runParser</B
> :: <A HREF="Text-ParserCombinators-Poly-Lazy.html#t%3AParser"
>Parser</A
> t a -&gt; [t] -&gt; (a, [t])</TD
><TD CLASS="declbut"
><A HREF="src/Text/ParserCombinators/Poly/Lazy.html#runParser"
>Source</A
></TD
></TR
></TABLE
></TD
></TR
><TR
><TD CLASS="doc"
>Apply a parser to an input token sequence.  The parser cannot return
   an error value explicitly, so errors raise an exception.  Thus, results
   can be partial (lazily constructed, but containing undefined).
</TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="section2"
><A NAME="2"
>basic parsers
</A
></TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="topdecl"
><TABLE CLASS="declbar"
><TR
><TD CLASS="declname"
><A NAME="v%3Asatisfy"
></A
><B
>satisfy</B
> :: (t -&gt; Bool) -&gt; <A HREF="Text-ParserCombinators-Poly-Lazy.html#t%3AParser"
>Parser</A
> t t</TD
><TD CLASS="declbut"
><A HREF="src/Text/ParserCombinators/Poly/Lazy.html#satisfy"
>Source</A
></TD
></TR
></TABLE
></TD
></TR
><TR
><TD CLASS="doc"
>One token satifying a predicate
</TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="topdecl"
><TABLE CLASS="declbar"
><TR
><TD CLASS="declname"
><A NAME="v%3AmanyFinally"
></A
><B
>manyFinally</B
> :: <A HREF="Text-ParserCombinators-Poly-Lazy.html#t%3AParser"
>Parser</A
> t a -&gt; <A HREF="Text-ParserCombinators-Poly-Lazy.html#t%3AParser"
>Parser</A
> t z -&gt; <A HREF="Text-ParserCombinators-Poly-Lazy.html#t%3AParser"
>Parser</A
> t [a]</TD
><TD CLASS="declbut"
><A HREF="src/Text/ParserCombinators/Poly/Lazy.html#manyFinally"
>Source</A
></TD
></TR
></TABLE
></TD
></TR
><TR
><TD CLASS="doc"
>'manyFinally e t' parses a possibly-empty sequence of e's,
   terminated by a t.  Any parse failures could be due either to
   a badly-formed terminator or a badly-formed element, so raise
   both possible errors.
</TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="section2"
><A NAME="3"
>Re-parsing
</A
></TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="topdecl"
><TABLE CLASS="declbar"
><TR
><TD CLASS="declname"
><A NAME="v%3Areparse"
></A
><B
>reparse</B
> :: [t] -&gt; <A HREF="Text-ParserCombinators-Poly-Lazy.html#t%3AParser"
>Parser</A
> t ()</TD
><TD CLASS="declbut"
><A HREF="src/Text/ParserCombinators/Poly/Lazy.html#reparse"
>Source</A
></TD
></TR
></TABLE
></TD
></TR
><TR
><TD CLASS="doc"
>Push some tokens back onto the front of the input stream and reparse.
   This is useful e.g. for recursively expanding macros.  When the
   user-parser recognises a macro use, it can lookup the macro
   expansion from the parse state, lex it, and then stuff the
   lexed expansion back down into the parser.
</TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="section1"
><A NAME="4"
>Re-export all more general combinators
</A
></TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="decl"
>module <A HREF="Text-ParserCombinators-Poly-Base.html"
>Text.ParserCombinators.Poly.Base</A
></TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="botbar"
>Produced by <A HREF="http://www.haskell.org/haddock/"
>Haddock</A
> version 0.8</TD
></TR
></TABLE
></BODY
></HTML
>