HaXml 1.19 → 1.19.1
raw patch · 36 files changed
+1477/−13155 lines, 36 files
Files
- Build.bat +1/−1
- HaXml.cabal +3/−3
- Makefile +1/−1
- configure +1/−1
- docs/HaXml/Text-ParserCombinators-HuttonMeijer.html +0/−1572
- docs/HaXml/Text-ParserCombinators-HuttonMeijerWallace.html +0/−1352
- docs/HaXml/Text-ParserCombinators-Poly.html +0/−1382
- docs/HaXml/Text-ParserCombinators-PolyLazy.html +0/−1385
- docs/HaXml/Text-ParserCombinators-PolyState.html +0/−1471
- docs/HaXml/Text-ParserCombinators-PolyStateLazy.html +0/−1524
- docs/HaXml/Text-ParserCombinators-TextParser.html +0/−781
- docs/HaXml/Text-XML-HaXml-TypeMapping.html +1/−40
- docs/HaXml/Text-XML-HaXml-Types.html +656/−2
- docs/HaXml/Text-XML-HaXml-XmlContent.html +38/−2
- docs/HaXml/doc-index-43.html +0/−198
- docs/HaXml/doc-index-J.html +0/−186
- docs/HaXml/doc-index-S.html +0/−8
- docs/HaXml/src/Text/ParserCombinators/HuttonMeijer.html +0/−219
- docs/HaXml/src/Text/ParserCombinators/HuttonMeijerWallace.html +0/−298
- docs/HaXml/src/Text/ParserCombinators/Poly.html +0/−238
- docs/HaXml/src/Text/ParserCombinators/PolyLazy.html +0/−261
- docs/HaXml/src/Text/ParserCombinators/PolyState.html +0/−249
- docs/HaXml/src/Text/ParserCombinators/PolyStateLazy.html +0/−279
- docs/HaXml/src/Text/ParserCombinators/TextParser.html +0/−166
- docs/HaXml/src/Text/XML/HaXml/SAX.html +1/−1
- docs/HaXml/src/Text/XML/HaXml/TypeMapping.html +144/−152
- docs/HaXml/src/Text/XML/HaXml/Types.html +175/−159
- docs/HaXml/src/Text/XML/HaXml/Xtract/Parse.html +397/−396
- docs/index.html +4/−3
- examples/GXL.hs +0/−641
- examples/gxl-1.0.dtd +0/−138
- src/Makefile +1/−1
- src/Text/XML/HaXml/SAX.hs +1/−1
- src/Text/XML/HaXml/TypeMapping.hs +0/−8
- src/Text/XML/HaXml/Types.hs +52/−36
- src/Text/XML/HaXml/Xtract/Parse.hs +1/−0
Build.bat view
@@ -25,7 +25,7 @@ set LD=C:\DEV\ghc\ghc-%GHCVER%\gcc-lib\ld.exe rem Source directory for HaXml: -set SRC=C:\DEV\Haskell\lib\HaXml-1.19\src +set SRC=C:\DEV\Haskell\lib\HaXml-1.19.1\src rem Two very long lines (500-600 chars) follow here. rem They should not need changing.
HaXml.cabal view
@@ -1,7 +1,7 @@ name: HaXml-version: 1.19-ghc-options: -DVERSION="1.19"-cc-options: -DVERSION="1.19"+version: 1.19.1+ghc-options: -DVERSION="1.19.1"+cc-options: -DVERSION="1.19.1" nhc98-options: -K10M license: LGPL license-file: COPYRIGHT
Makefile view
@@ -1,5 +1,5 @@ SOFTWARE = HaXml-VERSION = 1.19+VERSION = 1.19.1 #CPP = cpp -traditional CPP = cpphs --text --noline # useful e.g. on MacOS X
configure view
@@ -2,7 +2,7 @@ # configure -- prepare to compile/install the HaXml package # author: Malcolm.Wallace@cs.york.ac.uk, August 2002 -VERSION="1.18"+VERSION="1.19.1" if [ -f obj/prefix ] then INSTALLDIR=`cat obj/prefix`
− docs/HaXml/Text-ParserCombinators-HuttonMeijer.html
@@ -1,1572 +0,0 @@-<!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.HuttonMeijer</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"->HaXml</TD-><TD CLASS="topbut"-><A HREF="src/Text/ParserCombinators/HuttonMeijer.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.HuttonMeijer</FONT-></TD-><TD ALIGN="right"-><TABLE CLASS="narrow" CELLSPACING="0" CELLPADDING="0"-><TR-><TD CLASS="infohead"->Portability</TD-><TD CLASS="infoval"->All-- A LIBRARY OF MONADIC PARSER COMBINATORS- - 29th July 1996- - Graham Hutton Erik Meijer- University of Nottingham University of Utrecht</TD-></TR-><TR-><TD CLASS="infohead"->Stability</TD-><TD CLASS="infoval"->Stable</TD-></TR-><TR-><TD CLASS="infohead"->Maintainer</TD-><TD CLASS="infoval"->Malcolm Wallace <Malcolm.Wallace@cs.york.ac.uk></TD-></TR-></TABLE-></TD-></TR-></TABLE-></TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD-><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"-></TABLE-></TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="section1"->Description</TD-></TR-><TR-><TD CLASS="doc"-><P->This Haskell script defines a library of parser combinators, and is- taken from sections 1-6 of our article <A HREF="Monadic Parser Combinators.html"->Monadic Parser Combinators</A->.- Some changes to the library have been made in the move from Gofer- to Haskell:-</P-><UL-><LI-> Do notation is used in place of monad comprehension notation;-</LI-><LI-> The parser datatype is defined using <A HREF="newtype.html"->newtype</A->, to avoid the overhead- of tagging and untagging parsers with the P constructor.-</LI-></UL-></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-> a = <A HREF="#v%3AP"->P</A-> ([Token] -> [(a, [Token])])</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3Aitem"->item</A-> :: <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"->Parser</A-> Token</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3Afirst"->first</A-> :: <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"->Parser</A-> a -> <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"->Parser</A-> a</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3Apapply"->papply</A-> :: <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"->Parser</A-> a -> [Token] -> [(a, [Token])]</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3A%2B%2B%2B"->(+++)</A-> :: <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"->Parser</A-> a -> <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"->Parser</A-> a -> <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"->Parser</A-> a</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3Asat"->sat</A-> :: (Token -> Bool) -> <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"->Parser</A-> Token</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3Amany"->many</A-> :: <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"->Parser</A-> a -> <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"->Parser</A-> [a]</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3Amany1"->many1</A-> :: <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"->Parser</A-> a -> <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"->Parser</A-> [a]</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3Asepby"->sepby</A-> :: <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"->Parser</A-> a -> <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"->Parser</A-> b -> <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"->Parser</A-> [a]</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3Asepby1"->sepby1</A-> :: <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"->Parser</A-> a -> <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"->Parser</A-> b -> <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"->Parser</A-> [a]</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3Achainl"->chainl</A-> :: <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"->Parser</A-> a -> <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"->Parser</A-> (a -> a -> a) -> a -> <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"->Parser</A-> a</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3Achainl1"->chainl1</A-> :: <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"->Parser</A-> a -> <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"->Parser</A-> (a -> a -> a) -> <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"->Parser</A-> a</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3Achainr"->chainr</A-> :: <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"->Parser</A-> a -> <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"->Parser</A-> (a -> a -> a) -> a -> <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"->Parser</A-> a</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3Achainr1"->chainr1</A-> :: <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"->Parser</A-> a -> <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"->Parser</A-> (a -> a -> a) -> <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"->Parser</A-> a</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3Aops"->ops</A-> :: [(<A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"->Parser</A-> a, b)] -> <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"->Parser</A-> b</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3Abracket"->bracket</A-> :: <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"->Parser</A-> a -> <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"->Parser</A-> b -> <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"->Parser</A-> c -> <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"->Parser</A-> b</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3Achar"->char</A-> :: Char -> <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"->Parser</A-> Char</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3Adigit"->digit</A-> :: <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"->Parser</A-> Char</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3Alower"->lower</A-> :: <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"->Parser</A-> Char</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3Aupper"->upper</A-> :: <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"->Parser</A-> Char</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3Aletter"->letter</A-> :: <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"->Parser</A-> Char</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3Aalphanum"->alphanum</A-> :: <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"->Parser</A-> Char</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3Astring"->string</A-> :: String -> <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"->Parser</A-> String</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3Aident"->ident</A-> :: <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"->Parser</A-> String</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3Anat"->nat</A-> :: <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"->Parser</A-> Int</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3Aint"->int</A-> :: <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"->Parser</A-> Int</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3Aspaces"->spaces</A-> :: <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"->Parser</A-> ()</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3Acomment"->comment</A-> :: <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"->Parser</A-> ()</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3Ajunk"->junk</A-> :: <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"->Parser</A-> ()</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3Askip"->skip</A-> :: <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"->Parser</A-> a -> <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"->Parser</A-> a</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3Atoken"->token</A-> :: <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"->Parser</A-> a -> <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"->Parser</A-> a</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3Anatural"->natural</A-> :: <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"->Parser</A-> Int</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3Ainteger"->integer</A-> :: <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"->Parser</A-> Int</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3Asymbol"->symbol</A-> :: String -> <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"->Parser</A-> String</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3Aidentifier"->identifier</A-> :: [String] -> <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"->Parser</A-> String</TD-></TR-></TABLE-></TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="section1"->Documentation</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-> a</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/HuttonMeijer.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 parser monad-</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-> ([Token] -> [(a, [Token])])</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-HuttonMeijer.html#t%3AParser"->Parser</A-></TD-></TR-><TR-><TD CLASS="decl"->Monad <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"->Parser</A-></TD-></TR-><TR-><TD CLASS="decl"->MonadPlus <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"->Parser</A-></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%3Aitem"-></A-><B->item</B-> :: <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"->Parser</A-> Token</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/HuttonMeijer.html#item"->Source</A-></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%3Afirst"-></A-><B->first</B-> :: <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"->Parser</A-> a -> <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"->Parser</A-> a</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/HuttonMeijer.html#first"->Source</A-></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%3Apapply"-></A-><B->papply</B-> :: <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"->Parser</A-> a -> [Token] -> [(a, [Token])]</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/HuttonMeijer.html#papply"->Source</A-></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%3A%2B%2B%2B"-></A-><B->(+++)</B-> :: <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"->Parser</A-> a -> <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"->Parser</A-> a -> <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"->Parser</A-> a</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/HuttonMeijer.html#%2B%2B%2B"->Source</A-></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%3Asat"-></A-><B->sat</B-> :: (Token -> Bool) -> <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"->Parser</A-> Token</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/HuttonMeijer.html#sat"->Source</A-></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%3Amany"-></A-><B->many</B-> :: <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"->Parser</A-> a -> <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"->Parser</A-> [a]</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/HuttonMeijer.html#many"->Source</A-></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%3Amany1"-></A-><B->many1</B-> :: <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"->Parser</A-> a -> <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"->Parser</A-> [a]</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/HuttonMeijer.html#many1"->Source</A-></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%3Asepby"-></A-><B->sepby</B-> :: <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"->Parser</A-> a -> <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"->Parser</A-> b -> <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"->Parser</A-> [a]</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/HuttonMeijer.html#sepby"->Source</A-></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%3Asepby1"-></A-><B->sepby1</B-> :: <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"->Parser</A-> a -> <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"->Parser</A-> b -> <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"->Parser</A-> [a]</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/HuttonMeijer.html#sepby1"->Source</A-></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%3Achainl"-></A-><B->chainl</B-> :: <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"->Parser</A-> a -> <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"->Parser</A-> (a -> a -> a) -> a -> <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"->Parser</A-> a</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/HuttonMeijer.html#chainl"->Source</A-></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%3Achainl1"-></A-><B->chainl1</B-> :: <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"->Parser</A-> a -> <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"->Parser</A-> (a -> a -> a) -> <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"->Parser</A-> a</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/HuttonMeijer.html#chainl1"->Source</A-></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%3Achainr"-></A-><B->chainr</B-> :: <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"->Parser</A-> a -> <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"->Parser</A-> (a -> a -> a) -> a -> <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"->Parser</A-> a</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/HuttonMeijer.html#chainr"->Source</A-></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%3Achainr1"-></A-><B->chainr1</B-> :: <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"->Parser</A-> a -> <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"->Parser</A-> (a -> a -> a) -> <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"->Parser</A-> a</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/HuttonMeijer.html#chainr1"->Source</A-></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%3Aops"-></A-><B->ops</B-> :: [(<A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"->Parser</A-> a, b)] -> <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"->Parser</A-> b</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/HuttonMeijer.html#ops"->Source</A-></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%3Abracket"-></A-><B->bracket</B-> :: <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"->Parser</A-> a -> <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"->Parser</A-> b -> <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"->Parser</A-> c -> <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"->Parser</A-> b</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/HuttonMeijer.html#bracket"->Source</A-></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%3Achar"-></A-><B->char</B-> :: Char -> <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"->Parser</A-> Char</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/HuttonMeijer.html#char"->Source</A-></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%3Adigit"-></A-><B->digit</B-> :: <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"->Parser</A-> Char</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/HuttonMeijer.html#digit"->Source</A-></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%3Alower"-></A-><B->lower</B-> :: <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"->Parser</A-> Char</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/HuttonMeijer.html#lower"->Source</A-></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%3Aupper"-></A-><B->upper</B-> :: <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"->Parser</A-> Char</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/HuttonMeijer.html#upper"->Source</A-></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%3Aletter"-></A-><B->letter</B-> :: <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"->Parser</A-> Char</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/HuttonMeijer.html#letter"->Source</A-></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%3Aalphanum"-></A-><B->alphanum</B-> :: <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"->Parser</A-> Char</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/HuttonMeijer.html#alphanum"->Source</A-></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%3Astring"-></A-><B->string</B-> :: String -> <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"->Parser</A-> String</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/HuttonMeijer.html#string"->Source</A-></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%3Aident"-></A-><B->ident</B-> :: <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"->Parser</A-> String</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/HuttonMeijer.html#ident"->Source</A-></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%3Anat"-></A-><B->nat</B-> :: <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"->Parser</A-> Int</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/HuttonMeijer.html#nat"->Source</A-></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%3Aint"-></A-><B->int</B-> :: <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"->Parser</A-> Int</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/HuttonMeijer.html#int"->Source</A-></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%3Aspaces"-></A-><B->spaces</B-> :: <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"->Parser</A-> ()</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/HuttonMeijer.html#spaces"->Source</A-></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%3Acomment"-></A-><B->comment</B-> :: <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"->Parser</A-> ()</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/HuttonMeijer.html#comment"->Source</A-></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%3Ajunk"-></A-><B->junk</B-> :: <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"->Parser</A-> ()</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/HuttonMeijer.html#junk"->Source</A-></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%3Askip"-></A-><B->skip</B-> :: <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"->Parser</A-> a -> <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"->Parser</A-> a</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/HuttonMeijer.html#skip"->Source</A-></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%3Atoken"-></A-><B->token</B-> :: <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"->Parser</A-> a -> <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"->Parser</A-> a</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/HuttonMeijer.html#token"->Source</A-></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%3Anatural"-></A-><B->natural</B-> :: <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"->Parser</A-> Int</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/HuttonMeijer.html#natural"->Source</A-></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%3Ainteger"-></A-><B->integer</B-> :: <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"->Parser</A-> Int</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/HuttonMeijer.html#integer"->Source</A-></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%3Asymbol"-></A-><B->symbol</B-> :: String -> <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"->Parser</A-> String</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/HuttonMeijer.html#symbol"->Source</A-></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%3Aidentifier"-></A-><B->identifier</B-> :: [String] -> <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"->Parser</A-> String</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/HuttonMeijer.html#identifier"->Source</A-></TD-></TR-></TABLE-></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->
− docs/HaXml/Text-ParserCombinators-HuttonMeijerWallace.html
@@ -1,1352 +0,0 @@-<!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.HuttonMeijerWallace</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"->HaXml</TD-><TD CLASS="topbut"-><A HREF="src/Text/ParserCombinators/HuttonMeijerWallace.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.HuttonMeijerWallace</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 monad-</A-></DT-><DT-><A HREF="#2"->Primitive parser combinators-</A-></DT-><DT-><A HREF="#3"->Derived combinators-</A-></DT-><DT-><A HREF="#4"->Error handling-</A-></DT-><DT-><A HREF="#5"->State handling-</A-></DT-><DT-><A HREF="#6"->Re-parsing-</A-></DT-></DL-></TD-></TR-></TABLE-></TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="section1"->Description</TD-></TR-><TR-><TD CLASS="doc"->This library of monadic parser combinators is based on the ones- defined by Graham Hutton and Erik Meijer. It has been extended by- Malcolm Wallace to use an abstract token type (no longer just a- string) as input, and to incorporate a State Transformer monad, useful- for symbol tables, macros, and so on. Basic facilities for error- reporting have also been added, and later extended by Graham Klyne- to return the errors through an <TT->Either</TT-> type, rather than just- calling <TT->error</TT->.-</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-> s t e a = <A HREF="#v%3AP"->P</A-> (s -> [Either e t] -> ParseResult s t e a)</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3Aitem"->item</A-> :: <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"->Parser</A-> s t e t</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3Aeof"->eof</A-> :: Show p => <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"->Parser</A-> s (p, t) String ()</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3Apapply"->papply</A-> :: <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"->Parser</A-> s t String a -> s -> [Either String t] -> [(a, s, [Either String t])]</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3Apapply%27"->papply'</A-> :: <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"->Parser</A-> s t e a -> s -> [Either e t] -> Either e [(a, s, [Either e t])]</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3A%2B%2B%2B"->(+++)</A-> :: <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"->Parser</A-> s t e a -> <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"->Parser</A-> s t e a -> <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"->Parser</A-> s t e a</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3Atok"->tok</A-> :: Eq t => t -> <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"->Parser</A-> s (p, t) e t</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3Anottok"->nottok</A-> :: Eq t => [t] -> <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"->Parser</A-> s (p, t) e t</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3Amany"->many</A-> :: <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"->Parser</A-> s t e a -> <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"->Parser</A-> s t e [a]</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3Amany1"->many1</A-> :: <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"->Parser</A-> s t e a -> <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"->Parser</A-> s t e [a]</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3Asepby"->sepby</A-> :: <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"->Parser</A-> s t e a -> <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"->Parser</A-> s t e b -> <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"->Parser</A-> s t e [a]</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3Asepby1"->sepby1</A-> :: <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"->Parser</A-> s t e a -> <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"->Parser</A-> s t e b -> <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"->Parser</A-> s t e [a]</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3Achainl"->chainl</A-> :: <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"->Parser</A-> s t e a -> <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"->Parser</A-> s t e (a -> a -> a) -> a -> <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"->Parser</A-> s t e a</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3Achainl1"->chainl1</A-> :: <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"->Parser</A-> s t e a -> <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"->Parser</A-> s t e (a -> a -> a) -> <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"->Parser</A-> s t e a</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3Achainr"->chainr</A-> :: <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"->Parser</A-> s t e a -> <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"->Parser</A-> s t e (a -> a -> a) -> a -> <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"->Parser</A-> s t e a</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3Achainr1"->chainr1</A-> :: <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"->Parser</A-> s t e a -> <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"->Parser</A-> s t e (a -> a -> a) -> <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"->Parser</A-> s t e a</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3Aops"->ops</A-> :: [(<A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"->Parser</A-> s t e a, b)] -> <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"->Parser</A-> s t e b</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3Abracket"->bracket</A-> :: (Show p, Show t) => <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"->Parser</A-> s (p, t) e a -> <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"->Parser</A-> s (p, t) e b -> <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"->Parser</A-> s (p, t) e c -> <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"->Parser</A-> s (p, t) e b</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3AtoEOF"->toEOF</A-> :: Show p => <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"->Parser</A-> s (p, t) String a -> <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"->Parser</A-> s (p, t) String a</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3Aelserror"->elserror</A-> :: (Show p, Show t) => <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"->Parser</A-> s (p, t) String a -> String -> <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"->Parser</A-> s (p, t) String a</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3Astupd"->stupd</A-> :: (s -> s) -> <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"->Parser</A-> s t e ()</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3Astquery"->stquery</A-> :: (s -> a) -> <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"->Parser</A-> s t e a</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3Astget"->stget</A-> :: <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"->Parser</A-> s t e s</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3Areparse"->reparse</A-> :: [Either e t] -> <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"->Parser</A-> s t e ()</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 monad-</A-></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-> s t e a</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/HuttonMeijerWallace.html#Parser"->Source</A-></TD-></TR-></TABLE-></TD-></TR-><TR-><TD CLASS="body"-><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"-><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-> (s -> [Either e t] -> ParseResult s t e a)</TD-><TD CLASS="rdoc"->The parser type is parametrised on the types of the state <TT->s</TT->,- the input tokens <TT->t</TT->, error-type <TT->e</TT->, and the result value <TT->a</TT->.- The state and remaining input are threaded through the monad.-</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-HuttonMeijerWallace.html#t%3AParser"->Parser</A-> s t e)</TD-></TR-><TR-><TD CLASS="decl"->Monad (<A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"->Parser</A-> s t e)</TD-></TR-><TR-><TD CLASS="decl"->MonadPlus (<A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"->Parser</A-> s t e)</TD-></TR-></TABLE-></DIV-></TD-></TR-></TABLE-></TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="section1"-><A NAME="2"->Primitive parser combinators-</A-></TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="topdecl"-><TABLE CLASS="declbar"-><TR-><TD CLASS="declname"-><A NAME="v%3Aitem"-></A-><B->item</B-> :: <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"->Parser</A-> s t e t</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/HuttonMeijerWallace.html#item"->Source</A-></TD-></TR-></TABLE-></TD-></TR-><TR-><TD CLASS="doc"->Deliver the first remaining token.-</TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="topdecl"-><TABLE CLASS="declbar"-><TR-><TD CLASS="declname"-><A NAME="v%3Aeof"-></A-><B->eof</B-> :: Show p => <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"->Parser</A-> s (p, t) String ()</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/HuttonMeijerWallace.html#eof"->Source</A-></TD-></TR-></TABLE-></TD-></TR-><TR-><TD CLASS="doc"->Fail if end of input is not reached-</TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="topdecl"-><TABLE CLASS="declbar"-><TR-><TD CLASS="declname"-><A NAME="v%3Apapply"-></A-><B->papply</B-> :: <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"->Parser</A-> s t String a -> s -> [Either String t] -> [(a, s, [Either String t])]</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/HuttonMeijerWallace.html#papply"->Source</A-></TD-></TR-></TABLE-></TD-></TR-><TR-><TD CLASS="doc"->Apply the parser to some real input, given an initial state value.- If the parser fails, raise error to halt the program.- (This is the original exported behaviour - to allow the caller to- deal with the error differently, see <TT->papply'</TT->.)-</TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="topdecl"-><TABLE CLASS="declbar"-><TR-><TD CLASS="declname"-><A NAME="v%3Apapply%27"-></A-><B->papply'</B-> :: <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"->Parser</A-> s t e a -> s -> [Either e t] -> Either e [(a, s, [Either e t])]</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/HuttonMeijerWallace.html#papply%27"->Source</A-></TD-></TR-></TABLE-></TD-></TR-><TR-><TD CLASS="doc"->Apply the parser to some real input, given an initial state value.- If the parser fails, return a diagnostic message to the caller.-</TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="section1"-><A NAME="3"->Derived combinators-</A-></TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="topdecl"-><TABLE CLASS="declbar"-><TR-><TD CLASS="declname"-><A NAME="v%3A%2B%2B%2B"-></A-><B->(+++)</B-> :: <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"->Parser</A-> s t e a -> <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"->Parser</A-> s t e a -> <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"->Parser</A-> s t e a</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/HuttonMeijerWallace.html#%2B%2B%2B"->Source</A-></TD-></TR-></TABLE-></TD-></TR-><TR-><TD CLASS="doc"->A choice between parsers. Keep only the first success.-</TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="topdecl"-><TABLE CLASS="declbar"-><TR-><TD CLASS="declname"-><A NAME="v%3Atok"-></A-><B->tok</B-> :: Eq t => t -> <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"->Parser</A-> s (p, t) e t</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/HuttonMeijerWallace.html#tok"->Source</A-></TD-></TR-></TABLE-></TD-></TR-><TR-><TD CLASS="doc"->Deliver the first token if it equals the argument.-</TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="topdecl"-><TABLE CLASS="declbar"-><TR-><TD CLASS="declname"-><A NAME="v%3Anottok"-></A-><B->nottok</B-> :: Eq t => [t] -> <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"->Parser</A-> s (p, t) e t</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/HuttonMeijerWallace.html#nottok"->Source</A-></TD-></TR-></TABLE-></TD-></TR-><TR-><TD CLASS="doc"->Deliver the first token if it does not equal the argument.-</TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="topdecl"-><TABLE CLASS="declbar"-><TR-><TD CLASS="declname"-><A NAME="v%3Amany"-></A-><B->many</B-> :: <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"->Parser</A-> s t e a -> <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"->Parser</A-> s t e [a]</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/HuttonMeijerWallace.html#many"->Source</A-></TD-></TR-></TABLE-></TD-></TR-><TR-><TD CLASS="doc"->Deliver zero or more values of <TT->a</TT->.-</TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="topdecl"-><TABLE CLASS="declbar"-><TR-><TD CLASS="declname"-><A NAME="v%3Amany1"-></A-><B->many1</B-> :: <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"->Parser</A-> s t e a -> <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"->Parser</A-> s t e [a]</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/HuttonMeijerWallace.html#many1"->Source</A-></TD-></TR-></TABLE-></TD-></TR-><TR-><TD CLASS="doc"->Deliver one or more values of <TT->a</TT->.-</TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="topdecl"-><TABLE CLASS="declbar"-><TR-><TD CLASS="declname"-><A NAME="v%3Asepby"-></A-><B->sepby</B-> :: <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"->Parser</A-> s t e a -> <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"->Parser</A-> s t e b -> <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"->Parser</A-> s t e [a]</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/HuttonMeijerWallace.html#sepby"->Source</A-></TD-></TR-></TABLE-></TD-></TR-><TR-><TD CLASS="doc"->Deliver zero or more values of <TT->a</TT-> separated by <TT->b</TT->'s.-</TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="topdecl"-><TABLE CLASS="declbar"-><TR-><TD CLASS="declname"-><A NAME="v%3Asepby1"-></A-><B->sepby1</B-> :: <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"->Parser</A-> s t e a -> <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"->Parser</A-> s t e b -> <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"->Parser</A-> s t e [a]</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/HuttonMeijerWallace.html#sepby1"->Source</A-></TD-></TR-></TABLE-></TD-></TR-><TR-><TD CLASS="doc"->Deliver one or more values of <TT->a</TT-> separated by <TT->b</TT->'s.-</TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="topdecl"-><TABLE CLASS="declbar"-><TR-><TD CLASS="declname"-><A NAME="v%3Achainl"-></A-><B->chainl</B-> :: <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"->Parser</A-> s t e a -> <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"->Parser</A-> s t e (a -> a -> a) -> a -> <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"->Parser</A-> s t e a</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/HuttonMeijerWallace.html#chainl"->Source</A-></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%3Achainl1"-></A-><B->chainl1</B-> :: <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"->Parser</A-> s t e a -> <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"->Parser</A-> s t e (a -> a -> a) -> <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"->Parser</A-> s t e a</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/HuttonMeijerWallace.html#chainl1"->Source</A-></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%3Achainr"-></A-><B->chainr</B-> :: <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"->Parser</A-> s t e a -> <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"->Parser</A-> s t e (a -> a -> a) -> a -> <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"->Parser</A-> s t e a</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/HuttonMeijerWallace.html#chainr"->Source</A-></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%3Achainr1"-></A-><B->chainr1</B-> :: <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"->Parser</A-> s t e a -> <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"->Parser</A-> s t e (a -> a -> a) -> <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"->Parser</A-> s t e a</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/HuttonMeijerWallace.html#chainr1"->Source</A-></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%3Aops"-></A-><B->ops</B-> :: [(<A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"->Parser</A-> s t e a, b)] -> <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"->Parser</A-> s t e b</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/HuttonMeijerWallace.html#ops"->Source</A-></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%3Abracket"-></A-><B->bracket</B-> :: (Show p, Show t) => <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"->Parser</A-> s (p, t) e a -> <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"->Parser</A-> s (p, t) e b -> <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"->Parser</A-> s (p, t) e c -> <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"->Parser</A-> s (p, t) e b</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/HuttonMeijerWallace.html#bracket"->Source</A-></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%3AtoEOF"-></A-><B->toEOF</B-> :: Show p => <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"->Parser</A-> s (p, t) String a -> <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"->Parser</A-> s (p, t) String a</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/HuttonMeijerWallace.html#toEOF"->Source</A-></TD-></TR-></TABLE-></TD-></TR-><TR-><TD CLASS="doc"->Accept a complete parse of the input only, no partial parses.-</TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="section1"-><A NAME="4"->Error handling-</A-></TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="topdecl"-><TABLE CLASS="declbar"-><TR-><TD CLASS="declname"-><A NAME="v%3Aelserror"-></A-><B->elserror</B-> :: (Show p, Show t) => <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"->Parser</A-> s (p, t) String a -> String -> <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"->Parser</A-> s (p, t) String a</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/HuttonMeijerWallace.html#elserror"->Source</A-></TD-></TR-></TABLE-></TD-></TR-><TR-><TD CLASS="doc"->If the parser fails, generate an error message.-</TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="section1"-><A NAME="5"->State handling-</A-></TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="topdecl"-><TABLE CLASS="declbar"-><TR-><TD CLASS="declname"-><A NAME="v%3Astupd"-></A-><B->stupd</B-> :: (s -> s) -> <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"->Parser</A-> s t e ()</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/HuttonMeijerWallace.html#stupd"->Source</A-></TD-></TR-></TABLE-></TD-></TR-><TR-><TD CLASS="doc"->Update the internal state.-</TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="topdecl"-><TABLE CLASS="declbar"-><TR-><TD CLASS="declname"-><A NAME="v%3Astquery"-></A-><B->stquery</B-> :: (s -> a) -> <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"->Parser</A-> s t e a</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/HuttonMeijerWallace.html#stquery"->Source</A-></TD-></TR-></TABLE-></TD-></TR-><TR-><TD CLASS="doc"->Query the internal state.-</TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="topdecl"-><TABLE CLASS="declbar"-><TR-><TD CLASS="declname"-><A NAME="v%3Astget"-></A-><B->stget</B-> :: <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"->Parser</A-> s t e s</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/HuttonMeijerWallace.html#stget"->Source</A-></TD-></TR-></TABLE-></TD-></TR-><TR-><TD CLASS="doc"->Deliver the entire internal state.-</TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="section1"-><A NAME="6"->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-> :: [Either e t] -> <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"->Parser</A-> s t e ()</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/HuttonMeijerWallace.html#reparse"->Source</A-></TD-></TR-></TABLE-></TD-></TR-><TR-><TD CLASS="doc"->This is useful 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="botbar"->Produced by <A HREF="http://www.haskell.org/haddock/"->Haddock</A-> version 0.8</TD-></TR-></TABLE-></BODY-></HTML->
− docs/HaXml/Text-ParserCombinators-Poly.html
@@ -1,1382 +0,0 @@-<!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</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"->HaXml</TD-><TD CLASS="topbut"-><A HREF="src/Text/ParserCombinators/Poly.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</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"->A Parser datatype parameterised on arbitrary token type-</A-></DT-><DT-><A HREF="#2"->Combinators-</A-></DT-><DD-><DL-><DT-><A HREF="#3"->primitives-</A-></DT-><DT-><A HREF="#4"->error-handling-</A-></DT-><DT-><A HREF="#5"->choices-</A-></DT-><DT-><A HREF="#6"->sequences-</A-></DT-><DT-><A HREF="#7"->re-parsing-</A-></DT-></DL-></DD-></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] -> (EitherE 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.html#t%3AParser"->Parser</A-> t a -> [t] -> (Either String a, [t])</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3AfailBad"->failBad</A-> :: String -> <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"->Parser</A-> t a</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3Acommit"->commit</A-> :: <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"->Parser</A-> t a -> <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"->Parser</A-> t a</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3Anext"->next</A-> :: <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"->Parser</A-> t t</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3Asatisfy"->satisfy</A-> :: (t -> Bool) -> <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"->Parser</A-> t t</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3Aapply"->apply</A-> :: <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"->Parser</A-> t (a -> b) -> <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"->Parser</A-> t a -> <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"->Parser</A-> t b</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3Adiscard"->discard</A-> :: <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"->Parser</A-> t a -> <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"->Parser</A-> t b -> <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"->Parser</A-> t a</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3AadjustErr"->adjustErr</A-> :: <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"->Parser</A-> t a -> (String -> String) -> <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"->Parser</A-> t a</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3AadjustErrBad"->adjustErrBad</A-> :: <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"->Parser</A-> t a -> (String -> String) -> <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"->Parser</A-> t a</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3Aindent"->indent</A-> :: Int -> String -> String</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3AonFail"->onFail</A-> :: <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"->Parser</A-> t a -> <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"->Parser</A-> t a -> <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"->Parser</A-> t a</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3AoneOf"->oneOf</A-> :: [<A HREF="Text-ParserCombinators-Poly.html#t%3AParser"->Parser</A-> t a] -> <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"->Parser</A-> t a</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3AoneOf%27"->oneOf'</A-> :: [(String, <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"->Parser</A-> t a)] -> <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"->Parser</A-> t a</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3Aoptional"->optional</A-> :: <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"->Parser</A-> t a -> <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"->Parser</A-> t (Maybe a)</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3Amany"->many</A-> :: <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"->Parser</A-> t a -> <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"->Parser</A-> t [a]</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3Amany1"->many1</A-> :: <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"->Parser</A-> t a -> <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"->Parser</A-> t [a]</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3AsepBy"->sepBy</A-> :: <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"->Parser</A-> t a -> <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"->Parser</A-> t sep -> <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"->Parser</A-> t [a]</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3AsepBy1"->sepBy1</A-> :: <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"->Parser</A-> t a -> <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"->Parser</A-> t sep -> <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"->Parser</A-> t [a]</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3AbracketSep"->bracketSep</A-> :: <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"->Parser</A-> t bra -> <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"->Parser</A-> t sep -> <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"->Parser</A-> t ket -> <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"->Parser</A-> t a -> <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"->Parser</A-> t [a]</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3Abracket"->bracket</A-> :: <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"->Parser</A-> t bra -> <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"->Parser</A-> t ket -> <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"->Parser</A-> t a -> <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"->Parser</A-> t a</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3AmanyFinally"->manyFinally</A-> :: <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"->Parser</A-> t a -> <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"->Parser</A-> t z -> <A HREF="Text-ParserCombinators-Poly.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] -> <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"->Parser</A-> t ()</TD-></TR-></TABLE-></TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="section1"-><A NAME="1"->A Parser datatype parameterised on arbitrary token type-</A-></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.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 PolyState- 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] -> (EitherE 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.html#t%3AParser"->Parser</A-> t)</TD-></TR-><TR-><TD CLASS="decl"->Monad (<A HREF="Text-ParserCombinators-Poly.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.html#t%3AParser"->Parser</A-> t a -> [t] -> (Either String a, [t])</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/Poly.html#runParser"->Source</A-></TD-></TR-></TABLE-></TD-></TR-><TR-><TD CLASS="doc"->Apply a parser to an input token sequence.-</TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="topdecl"-><TABLE CLASS="declbar"-><TR-><TD CLASS="declname"-><A NAME="v%3AfailBad"-></A-><B->failBad</B-> :: String -> <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"->Parser</A-> t a</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/Poly.html#failBad"->Source</A-></TD-></TR-></TABLE-></TD-></TR-><TR-><TD CLASS="doc"->When a simple fail is not strong enough, use failBad for emphasis.- An emphasised (severe) error can propagate out through choice operators.-</TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="topdecl"-><TABLE CLASS="declbar"-><TR-><TD CLASS="declname"-><A NAME="v%3Acommit"-></A-><B->commit</B-> :: <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"->Parser</A-> t a -> <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"->Parser</A-> t a</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/Poly.html#commit"->Source</A-></TD-></TR-></TABLE-></TD-></TR-><TR-><TD CLASS="doc"->Commit is a way of raising the severity of any errors found within- its argument. Used in the middle of a parser definition, it means that- any operations prior to commitment fail softly, but after commitment,- they fail hard.-</TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="section1"-><A NAME="2"->Combinators-</A-></TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="section2"-><A NAME="3"->primitives-</A-></TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="topdecl"-><TABLE CLASS="declbar"-><TR-><TD CLASS="declname"-><A NAME="v%3Anext"-></A-><B->next</B-> :: <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"->Parser</A-> t t</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/Poly.html#next"->Source</A-></TD-></TR-></TABLE-></TD-></TR-><TR-><TD CLASS="doc"->One token-</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 -> Bool) -> <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"->Parser</A-> t t</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/Poly.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%3Aapply"-></A-><B->apply</B-> :: <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"->Parser</A-> t (a -> b) -> <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"->Parser</A-> t a -> <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"->Parser</A-> t b</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/Poly.html#apply"->Source</A-></TD-></TR-></TABLE-></TD-></TR-><TR-><TD CLASS="doc"->Apply a parsed function to a parsed value-</TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="topdecl"-><TABLE CLASS="declbar"-><TR-><TD CLASS="declname"-><A NAME="v%3Adiscard"-></A-><B->discard</B-> :: <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"->Parser</A-> t a -> <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"->Parser</A-> t b -> <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"->Parser</A-> t a</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/Poly.html#discard"->Source</A-></TD-></TR-></TABLE-></TD-></TR-><TR-><TD CLASS="doc"-><TT->x <TT-><A HREF="Text-ParserCombinators-Poly.html#v%3Adiscard"->discard</A-></TT-> y</TT-> parses both x and y, but discards the result of y-</TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="section2"-><A NAME="4"->error-handling-</A-></TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="topdecl"-><TABLE CLASS="declbar"-><TR-><TD CLASS="declname"-><A NAME="v%3AadjustErr"-></A-><B->adjustErr</B-> :: <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"->Parser</A-> t a -> (String -> String) -> <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"->Parser</A-> t a</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/Poly.html#adjustErr"->Source</A-></TD-></TR-></TABLE-></TD-></TR-><TR-><TD CLASS="doc"-><TT->p <TT-><A HREF="Text-ParserCombinators-Poly.html#v%3AadjustErr"->adjustErr</A-></TT-> f</TT-> applies the transformation <TT->f</TT-> to any error message- generated in <TT->p</TT->, having no effect if <TT->p</TT-> succeeds.-</TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="topdecl"-><TABLE CLASS="declbar"-><TR-><TD CLASS="declname"-><A NAME="v%3AadjustErrBad"-></A-><B->adjustErrBad</B-> :: <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"->Parser</A-> t a -> (String -> String) -> <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"->Parser</A-> t a</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/Poly.html#adjustErrBad"->Source</A-></TD-></TR-></TABLE-></TD-></TR-><TR-><TD CLASS="doc"-><TT->adjustErrBad</TT-> is just like <TT->adjustErr</TT-> except it also raises the- severity of the error.-</TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="topdecl"-><TABLE CLASS="declbar"-><TR-><TD CLASS="declname"-><A NAME="v%3Aindent"-></A-><B->indent</B-> :: Int -> String -> String</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/Poly.html#indent"->Source</A-></TD-></TR-></TABLE-></TD-></TR-><TR-><TD CLASS="doc"->Helper for formatting error messages: indents all lines by a fixed amount.-</TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="section2"-><A NAME="5"->choices-</A-></TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="topdecl"-><TABLE CLASS="declbar"-><TR-><TD CLASS="declname"-><A NAME="v%3AonFail"-></A-><B->onFail</B-> :: <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"->Parser</A-> t a -> <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"->Parser</A-> t a -> <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"->Parser</A-> t a</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/Poly.html#onFail"->Source</A-></TD-></TR-></TABLE-></TD-></TR-><TR-><TD CLASS="doc"-><TT->p <TT-><A HREF="Text-ParserCombinators-Poly.html#v%3AonFail"->onFail</A-></TT-> q</TT-> means parse p unless p fails in which case parse q instead.- Can be chained together to give multiple attempts to parse something.- (Note that q could itself be a failing parser, e.g. to change the error- message from that defined in p to something different.)- However, a *severe* failure in p cannot be ignored.-</TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="topdecl"-><TABLE CLASS="declbar"-><TR-><TD CLASS="declname"-><A NAME="v%3AoneOf"-></A-><B->oneOf</B-> :: [<A HREF="Text-ParserCombinators-Poly.html#t%3AParser"->Parser</A-> t a] -> <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"->Parser</A-> t a</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/Poly.html#oneOf"->Source</A-></TD-></TR-></TABLE-></TD-></TR-><TR-><TD CLASS="doc"->Parse the first alternative in the list that succeeds.-</TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="topdecl"-><TABLE CLASS="declbar"-><TR-><TD CLASS="declname"-><A NAME="v%3AoneOf%27"-></A-><B->oneOf'</B-> :: [(String, <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"->Parser</A-> t a)] -> <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"->Parser</A-> t a</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/Poly.html#oneOf%27"->Source</A-></TD-></TR-></TABLE-></TD-></TR-><TR-><TD CLASS="doc"->Parse the first alternative that succeeds, but if none succeed,- report only the severe errors, and if none of those, then report- all the soft errors.-</TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="topdecl"-><TABLE CLASS="declbar"-><TR-><TD CLASS="declname"-><A NAME="v%3Aoptional"-></A-><B->optional</B-> :: <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"->Parser</A-> t a -> <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"->Parser</A-> t (Maybe a)</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/Poly.html#optional"->Source</A-></TD-></TR-></TABLE-></TD-></TR-><TR-><TD CLASS="doc"-><TT-><A HREF="Text-ParserCombinators-Poly.html#v%3Aoptional"->optional</A-></TT-> indicates whether the parser succeeded through the Maybe type.-</TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="section2"-><A NAME="6"->sequences-</A-></TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="topdecl"-><TABLE CLASS="declbar"-><TR-><TD CLASS="declname"-><A NAME="v%3Amany"-></A-><B->many</B-> :: <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"->Parser</A-> t a -> <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"->Parser</A-> t [a]</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/Poly.html#many"->Source</A-></TD-></TR-></TABLE-></TD-></TR-><TR-><TD CLASS="doc"->'many p' parses a list of elements with individual parser p.- Cannot fail, since an empty list is a valid return value.-</TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="topdecl"-><TABLE CLASS="declbar"-><TR-><TD CLASS="declname"-><A NAME="v%3Amany1"-></A-><B->many1</B-> :: <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"->Parser</A-> t a -> <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"->Parser</A-> t [a]</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/Poly.html#many1"->Source</A-></TD-></TR-></TABLE-></TD-></TR-><TR-><TD CLASS="doc"->Parse a non-empty list of items.-</TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="topdecl"-><TABLE CLASS="declbar"-><TR-><TD CLASS="declname"-><A NAME="v%3AsepBy"-></A-><B->sepBy</B-> :: <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"->Parser</A-> t a -> <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"->Parser</A-> t sep -> <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"->Parser</A-> t [a]</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/Poly.html#sepBy"->Source</A-></TD-></TR-></TABLE-></TD-></TR-><TR-><TD CLASS="doc"->Parse a list of items separated by discarded junk.-</TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="topdecl"-><TABLE CLASS="declbar"-><TR-><TD CLASS="declname"-><A NAME="v%3AsepBy1"-></A-><B->sepBy1</B-> :: <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"->Parser</A-> t a -> <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"->Parser</A-> t sep -> <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"->Parser</A-> t [a]</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/Poly.html#sepBy1"->Source</A-></TD-></TR-></TABLE-></TD-></TR-><TR-><TD CLASS="doc"->Parse a non-empty list of items separated by discarded junk.-</TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="topdecl"-><TABLE CLASS="declbar"-><TR-><TD CLASS="declname"-><A NAME="v%3AbracketSep"-></A-><B->bracketSep</B-> :: <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"->Parser</A-> t bra -> <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"->Parser</A-> t sep -> <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"->Parser</A-> t ket -> <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"->Parser</A-> t a -> <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"->Parser</A-> t [a]</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/Poly.html#bracketSep"->Source</A-></TD-></TR-></TABLE-></TD-></TR-><TR-><TD CLASS="doc"->Parse a list of items, discarding the start, end, and separator- items.-</TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="topdecl"-><TABLE CLASS="declbar"-><TR-><TD CLASS="declname"-><A NAME="v%3Abracket"-></A-><B->bracket</B-> :: <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"->Parser</A-> t bra -> <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"->Parser</A-> t ket -> <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"->Parser</A-> t a -> <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"->Parser</A-> t a</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/Poly.html#bracket"->Source</A-></TD-></TR-></TABLE-></TD-></TR-><TR-><TD CLASS="doc"->Parse a bracketed item, discarding the brackets.-</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.html#t%3AParser"->Parser</A-> t a -> <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"->Parser</A-> t z -> <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"->Parser</A-> t [a]</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/Poly.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="7"->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] -> <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"->Parser</A-> t ()</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/Poly.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="botbar"->Produced by <A HREF="http://www.haskell.org/haddock/"->Haddock</A-> version 0.8</TD-></TR-></TABLE-></BODY-></HTML->
− docs/HaXml/Text-ParserCombinators-PolyLazy.html
@@ -1,1385 +0,0 @@-<!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.PolyLazy</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"->HaXml</TD-><TD CLASS="topbut"-><A HREF="src/Text/ParserCombinators/PolyLazy.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.PolyLazy</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"->A Parser datatype parameterised on arbitrary token type.-</A-></DT-><DT-><A HREF="#2"->Combinators-</A-></DT-><DD-><DL-><DT-><A HREF="#3"->primitives-</A-></DT-><DT-><A HREF="#4"->error-handling-</A-></DT-><DT-><A HREF="#5"->choices-</A-></DT-><DT-><A HREF="#6"->sequences-</A-></DT-><DT-><A HREF="#7"->re-parsing-</A-></DT-></DL-></DD-></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] -> (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-PolyLazy.html#t%3AParser"->Parser</A-> t a -> [t] -> (a, [t])</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3AfailBad"->failBad</A-> :: String -> <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"->Parser</A-> t a</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3Acommit"->commit</A-> :: <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"->Parser</A-> t a -> <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"->Parser</A-> t a</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3Anext"->next</A-> :: <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"->Parser</A-> t t</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3Asatisfy"->satisfy</A-> :: (t -> Bool) -> <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"->Parser</A-> t t</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3Aapply"->apply</A-> :: <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"->Parser</A-> t (a -> b) -> <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"->Parser</A-> t a -> <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"->Parser</A-> t b</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3Adiscard"->discard</A-> :: <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"->Parser</A-> t a -> <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"->Parser</A-> t b -> <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"->Parser</A-> t a</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3AadjustErr"->adjustErr</A-> :: <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"->Parser</A-> t a -> (String -> String) -> <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"->Parser</A-> t a</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3AadjustErrBad"->adjustErrBad</A-> :: <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"->Parser</A-> t a -> (String -> String) -> <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"->Parser</A-> t a</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3Aindent"->indent</A-> :: Int -> String -> String</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3AonFail"->onFail</A-> :: <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"->Parser</A-> t a -> <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"->Parser</A-> t a -> <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"->Parser</A-> t a</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3AoneOf"->oneOf</A-> :: [<A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"->Parser</A-> t a] -> <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"->Parser</A-> t a</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3AoneOf%27"->oneOf'</A-> :: [(String, <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"->Parser</A-> t a)] -> <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"->Parser</A-> t a</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3Aoptional"->optional</A-> :: <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"->Parser</A-> t a -> <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"->Parser</A-> t (Maybe a)</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3Amany"->many</A-> :: <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"->Parser</A-> t a -> <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"->Parser</A-> t [a]</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3Amany1"->many1</A-> :: <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"->Parser</A-> t a -> <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"->Parser</A-> t [a]</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3AsepBy"->sepBy</A-> :: <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"->Parser</A-> t a -> <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"->Parser</A-> t sep -> <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"->Parser</A-> t [a]</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3AsepBy1"->sepBy1</A-> :: <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"->Parser</A-> t a -> <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"->Parser</A-> t sep -> <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"->Parser</A-> t [a]</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3AbracketSep"->bracketSep</A-> :: <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"->Parser</A-> t bra -> <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"->Parser</A-> t sep -> <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"->Parser</A-> t ket -> <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"->Parser</A-> t a -> <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"->Parser</A-> t [a]</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3Abracket"->bracket</A-> :: <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"->Parser</A-> t bra -> <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"->Parser</A-> t ket -> <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"->Parser</A-> t a -> <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"->Parser</A-> t a</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3AmanyFinally"->manyFinally</A-> :: <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"->Parser</A-> t a -> <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"->Parser</A-> t z -> <A HREF="Text-ParserCombinators-PolyLazy.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] -> <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"->Parser</A-> t ()</TD-></TR-></TABLE-></TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="section1"-><A NAME="1"->A Parser datatype parameterised on arbitrary token type.-</A-></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/PolyLazy.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 PolyState- 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] -> (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-PolyLazy.html#t%3AParser"->Parser</A-> t)</TD-></TR-><TR-><TD CLASS="decl"->Monad (<A HREF="Text-ParserCombinators-PolyLazy.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-PolyLazy.html#t%3AParser"->Parser</A-> t a -> [t] -> (a, [t])</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/PolyLazy.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="topdecl"-><TABLE CLASS="declbar"-><TR-><TD CLASS="declname"-><A NAME="v%3AfailBad"-></A-><B->failBad</B-> :: String -> <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"->Parser</A-> t a</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/PolyLazy.html#failBad"->Source</A-></TD-></TR-></TABLE-></TD-></TR-><TR-><TD CLASS="doc"->Simple failure can be corrected, but when a simple fail is not strong- enough, use failBad for emphasis. It guarantees parsing will- terminate with an exception.-</TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="topdecl"-><TABLE CLASS="declbar"-><TR-><TD CLASS="declname"-><A NAME="v%3Acommit"-></A-><B->commit</B-> :: <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"->Parser</A-> t a -> <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"->Parser</A-> t a</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/PolyLazy.html#commit"->Source</A-></TD-></TR-></TABLE-></TD-></TR-><TR-><TD CLASS="doc"->Commit is a way of raising the severity of any errors found within- its argument. Used in the middle of a parser definition, it means that- any operations prior to commitment fail softly, but after commitment,- they fail hard.-</TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="section1"-><A NAME="2"->Combinators-</A-></TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="section2"-><A NAME="3"->primitives-</A-></TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="topdecl"-><TABLE CLASS="declbar"-><TR-><TD CLASS="declname"-><A NAME="v%3Anext"-></A-><B->next</B-> :: <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"->Parser</A-> t t</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/PolyLazy.html#next"->Source</A-></TD-></TR-></TABLE-></TD-></TR-><TR-><TD CLASS="doc"->One token-</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 -> Bool) -> <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"->Parser</A-> t t</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/PolyLazy.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%3Aapply"-></A-><B->apply</B-> :: <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"->Parser</A-> t (a -> b) -> <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"->Parser</A-> t a -> <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"->Parser</A-> t b</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/PolyLazy.html#apply"->Source</A-></TD-></TR-></TABLE-></TD-></TR-><TR-><TD CLASS="doc"->Apply a parsed function to a parsed value-</TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="topdecl"-><TABLE CLASS="declbar"-><TR-><TD CLASS="declname"-><A NAME="v%3Adiscard"-></A-><B->discard</B-> :: <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"->Parser</A-> t a -> <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"->Parser</A-> t b -> <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"->Parser</A-> t a</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/PolyLazy.html#discard"->Source</A-></TD-></TR-></TABLE-></TD-></TR-><TR-><TD CLASS="doc"-><TT->x <TT-><A HREF="Text-ParserCombinators-PolyLazy.html#v%3Adiscard"->discard</A-></TT-> y</TT-> parses both x and y, but discards the result of y-</TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="section2"-><A NAME="4"->error-handling-</A-></TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="topdecl"-><TABLE CLASS="declbar"-><TR-><TD CLASS="declname"-><A NAME="v%3AadjustErr"-></A-><B->adjustErr</B-> :: <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"->Parser</A-> t a -> (String -> String) -> <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"->Parser</A-> t a</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/PolyLazy.html#adjustErr"->Source</A-></TD-></TR-></TABLE-></TD-></TR-><TR-><TD CLASS="doc"-><TT->p <TT-><A HREF="Text-ParserCombinators-PolyLazy.html#v%3AadjustErr"->adjustErr</A-></TT-> f</TT-> applies the transformation <TT->f</TT-> to any error message- generated in <TT->p</TT->, having no effect if <TT->p</TT-> succeeds.-</TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="topdecl"-><TABLE CLASS="declbar"-><TR-><TD CLASS="declname"-><A NAME="v%3AadjustErrBad"-></A-><B->adjustErrBad</B-> :: <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"->Parser</A-> t a -> (String -> String) -> <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"->Parser</A-> t a</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/PolyLazy.html#adjustErrBad"->Source</A-></TD-></TR-></TABLE-></TD-></TR-><TR-><TD CLASS="doc"-><TT->adjustErrBad</TT-> is just like <TT->adjustErr</TT-> except it also raises the- severity of the error.-</TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="topdecl"-><TABLE CLASS="declbar"-><TR-><TD CLASS="declname"-><A NAME="v%3Aindent"-></A-><B->indent</B-> :: Int -> String -> String</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/PolyLazy.html#indent"->Source</A-></TD-></TR-></TABLE-></TD-></TR-><TR-><TD CLASS="doc"->Helper for formatting error messages: indents all lines by a fixed amount.-</TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="section2"-><A NAME="5"->choices-</A-></TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="topdecl"-><TABLE CLASS="declbar"-><TR-><TD CLASS="declname"-><A NAME="v%3AonFail"-></A-><B->onFail</B-> :: <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"->Parser</A-> t a -> <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"->Parser</A-> t a -> <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"->Parser</A-> t a</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/PolyLazy.html#onFail"->Source</A-></TD-></TR-></TABLE-></TD-></TR-><TR-><TD CLASS="doc"-><TT->p <TT-><A HREF="Text-ParserCombinators-PolyLazy.html#v%3AonFail"->onFail</A-></TT-> q</TT-> means parse p unless p fails in which case parse q instead.- Can be chained together to give multiple attempts to parse something.- (Note that q could itself be a failing parser, e.g. to change the error- message from that defined in p to something different.)- However, a *severe* failure in p cannot be ignored.-</TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="topdecl"-><TABLE CLASS="declbar"-><TR-><TD CLASS="declname"-><A NAME="v%3AoneOf"-></A-><B->oneOf</B-> :: [<A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"->Parser</A-> t a] -> <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"->Parser</A-> t a</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/PolyLazy.html#oneOf"->Source</A-></TD-></TR-></TABLE-></TD-></TR-><TR-><TD CLASS="doc"->Parse the first alternative in the list that succeeds.-</TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="topdecl"-><TABLE CLASS="declbar"-><TR-><TD CLASS="declname"-><A NAME="v%3AoneOf%27"-></A-><B->oneOf'</B-> :: [(String, <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"->Parser</A-> t a)] -> <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"->Parser</A-> t a</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/PolyLazy.html#oneOf%27"->Source</A-></TD-></TR-></TABLE-></TD-></TR-><TR-><TD CLASS="doc"->Parse the first alternative that succeeds, but if none succeed,- report only the severe errors, and if none of those, then report- all the soft errors.-</TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="topdecl"-><TABLE CLASS="declbar"-><TR-><TD CLASS="declname"-><A NAME="v%3Aoptional"-></A-><B->optional</B-> :: <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"->Parser</A-> t a -> <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"->Parser</A-> t (Maybe a)</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/PolyLazy.html#optional"->Source</A-></TD-></TR-></TABLE-></TD-></TR-><TR-><TD CLASS="doc"-><TT-><A HREF="Text-ParserCombinators-PolyLazy.html#v%3Aoptional"->optional</A-></TT-> indicates whether the parser succeeded through the Maybe type.-</TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="section2"-><A NAME="6"->sequences-</A-></TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="topdecl"-><TABLE CLASS="declbar"-><TR-><TD CLASS="declname"-><A NAME="v%3Amany"-></A-><B->many</B-> :: <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"->Parser</A-> t a -> <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"->Parser</A-> t [a]</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/PolyLazy.html#many"->Source</A-></TD-></TR-></TABLE-></TD-></TR-><TR-><TD CLASS="doc"->'many p' parses a list of elements with individual parser p.- Cannot fail, since an empty list is a valid return value.-</TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="topdecl"-><TABLE CLASS="declbar"-><TR-><TD CLASS="declname"-><A NAME="v%3Amany1"-></A-><B->many1</B-> :: <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"->Parser</A-> t a -> <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"->Parser</A-> t [a]</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/PolyLazy.html#many1"->Source</A-></TD-></TR-></TABLE-></TD-></TR-><TR-><TD CLASS="doc"->Parse a non-empty list of items.-</TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="topdecl"-><TABLE CLASS="declbar"-><TR-><TD CLASS="declname"-><A NAME="v%3AsepBy"-></A-><B->sepBy</B-> :: <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"->Parser</A-> t a -> <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"->Parser</A-> t sep -> <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"->Parser</A-> t [a]</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/PolyLazy.html#sepBy"->Source</A-></TD-></TR-></TABLE-></TD-></TR-><TR-><TD CLASS="doc"->Parse a list of items separated by discarded junk.-</TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="topdecl"-><TABLE CLASS="declbar"-><TR-><TD CLASS="declname"-><A NAME="v%3AsepBy1"-></A-><B->sepBy1</B-> :: <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"->Parser</A-> t a -> <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"->Parser</A-> t sep -> <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"->Parser</A-> t [a]</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/PolyLazy.html#sepBy1"->Source</A-></TD-></TR-></TABLE-></TD-></TR-><TR-><TD CLASS="doc"->Parse a non-empty list of items separated by discarded junk.-</TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="topdecl"-><TABLE CLASS="declbar"-><TR-><TD CLASS="declname"-><A NAME="v%3AbracketSep"-></A-><B->bracketSep</B-> :: <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"->Parser</A-> t bra -> <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"->Parser</A-> t sep -> <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"->Parser</A-> t ket -> <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"->Parser</A-> t a -> <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"->Parser</A-> t [a]</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/PolyLazy.html#bracketSep"->Source</A-></TD-></TR-></TABLE-></TD-></TR-><TR-><TD CLASS="doc"->Parse a list of items, discarding the start, end, and separator- items.-</TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="topdecl"-><TABLE CLASS="declbar"-><TR-><TD CLASS="declname"-><A NAME="v%3Abracket"-></A-><B->bracket</B-> :: <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"->Parser</A-> t bra -> <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"->Parser</A-> t ket -> <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"->Parser</A-> t a -> <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"->Parser</A-> t a</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/PolyLazy.html#bracket"->Source</A-></TD-></TR-></TABLE-></TD-></TR-><TR-><TD CLASS="doc"->Parse a bracketed item, discarding the brackets.-</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-PolyLazy.html#t%3AParser"->Parser</A-> t a -> <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"->Parser</A-> t z -> <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"->Parser</A-> t [a]</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/PolyLazy.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="7"->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] -> <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"->Parser</A-> t ()</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/PolyLazy.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="botbar"->Produced by <A HREF="http://www.haskell.org/haddock/"->Haddock</A-> version 0.8</TD-></TR-></TABLE-></BODY-></HTML->
− docs/HaXml/Text-ParserCombinators-PolyState.html
@@ -1,1471 +0,0 @@-<!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.PolyState</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"->HaXml</TD-><TD CLASS="topbut"-><A HREF="src/Text/ParserCombinators/PolyState.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.PolyState</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"->A Parser datatype parameterised on arbitrary token type and state type-</A-></DT-><DT-><A HREF="#2"->Combinators-</A-></DT-><DD-><DL-><DT-><A HREF="#3"->primitives-</A-></DT-><DT-><A HREF="#4"->error-handling-</A-></DT-><DT-><A HREF="#5"->choices-</A-></DT-><DT-><A HREF="#6"->sequences-</A-></DT-><DT-><A HREF="#7"->state-handling-</A-></DT-><DT-><A HREF="#8"->re-parsing-</A-></DT-></DL-></DD-></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-> s t a = <A HREF="#v%3AP"->P</A-> (s -> [t] -> (EitherE String a, s, [t]))</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3ArunParser"->runParser</A-> :: <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"->Parser</A-> s t a -> s -> [t] -> (Either String a, s, [t])</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3AfailBad"->failBad</A-> :: String -> <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"->Parser</A-> s t a</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3Acommit"->commit</A-> :: <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"->Parser</A-> s t a -> <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"->Parser</A-> s t a</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3Anext"->next</A-> :: <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"->Parser</A-> s t t</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3Asatisfy"->satisfy</A-> :: (t -> Bool) -> <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"->Parser</A-> s t t</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3Aapply"->apply</A-> :: <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"->Parser</A-> s t (a -> b) -> <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"->Parser</A-> s t a -> <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"->Parser</A-> s t b</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3Adiscard"->discard</A-> :: <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"->Parser</A-> s t a -> <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"->Parser</A-> s t b -> <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"->Parser</A-> s t a</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3AadjustErr"->adjustErr</A-> :: <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"->Parser</A-> s t a -> (String -> String) -> <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"->Parser</A-> s t a</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3AadjustErrBad"->adjustErrBad</A-> :: <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"->Parser</A-> s t a -> (String -> String) -> <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"->Parser</A-> s t a</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3Aindent"->indent</A-> :: Int -> String -> String</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3AonFail"->onFail</A-> :: <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"->Parser</A-> s t a -> <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"->Parser</A-> s t a -> <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"->Parser</A-> s t a</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3AoneOf"->oneOf</A-> :: [<A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"->Parser</A-> s t a] -> <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"->Parser</A-> s t a</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3AoneOf%27"->oneOf'</A-> :: [(String, <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"->Parser</A-> s t a)] -> <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"->Parser</A-> s t a</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3Amany"->many</A-> :: <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"->Parser</A-> s t a -> <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"->Parser</A-> s t [a]</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3Amany1"->many1</A-> :: <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"->Parser</A-> s t a -> <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"->Parser</A-> s t [a]</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3AsepBy"->sepBy</A-> :: <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"->Parser</A-> s t a -> <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"->Parser</A-> s t sep -> <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"->Parser</A-> s t [a]</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3AsepBy1"->sepBy1</A-> :: <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"->Parser</A-> s t a -> <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"->Parser</A-> s t sep -> <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"->Parser</A-> s t [a]</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3AbracketSep"->bracketSep</A-> :: <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"->Parser</A-> s t bra -> <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"->Parser</A-> s t sep -> <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"->Parser</A-> s t ket -> <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"->Parser</A-> s t a -> <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"->Parser</A-> s t [a]</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3Abracket"->bracket</A-> :: <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"->Parser</A-> s t bra -> <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"->Parser</A-> s t ket -> <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"->Parser</A-> s t a -> <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"->Parser</A-> s t a</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3AmanyFinally"->manyFinally</A-> :: <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"->Parser</A-> s t a -> <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"->Parser</A-> s t z -> <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"->Parser</A-> s t [a]</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3AstUpdate"->stUpdate</A-> :: (s -> s) -> <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"->Parser</A-> s t ()</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3AstQuery"->stQuery</A-> :: (s -> a) -> <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"->Parser</A-> s t a</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3AstGet"->stGet</A-> :: <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"->Parser</A-> s t s</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3Areparse"->reparse</A-> :: [t] -> <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"->Parser</A-> s t ()</TD-></TR-></TABLE-></TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="section1"-><A NAME="1"->A Parser datatype parameterised on arbitrary token type and state type-</A-></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-> s t a</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/PolyState.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 and a running state. It can be used for arbitrary token- types, not just String input.-</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-> (s -> [t] -> (EitherE String a, s, [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-PolyState.html#t%3AParser"->Parser</A-> s t)</TD-></TR-><TR-><TD CLASS="decl"->Monad (<A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"->Parser</A-> s 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-PolyState.html#t%3AParser"->Parser</A-> s t a -> s -> [t] -> (Either String a, s, [t])</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/PolyState.html#runParser"->Source</A-></TD-></TR-></TABLE-></TD-></TR-><TR-><TD CLASS="doc"->Apply a parser to an initial state and input token sequence.-</TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="topdecl"-><TABLE CLASS="declbar"-><TR-><TD CLASS="declname"-><A NAME="v%3AfailBad"-></A-><B->failBad</B-> :: String -> <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"->Parser</A-> s t a</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/PolyState.html#failBad"->Source</A-></TD-></TR-></TABLE-></TD-></TR-><TR-><TD CLASS="doc"->When a simple fail is not strong enough, use failBad for emphasis.- An emphasised (severe) error can propagate out through choice operators.-</TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="topdecl"-><TABLE CLASS="declbar"-><TR-><TD CLASS="declname"-><A NAME="v%3Acommit"-></A-><B->commit</B-> :: <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"->Parser</A-> s t a -> <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"->Parser</A-> s t a</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/PolyState.html#commit"->Source</A-></TD-></TR-></TABLE-></TD-></TR-><TR-><TD CLASS="doc"->Commit is a way of raising the severity of any errors found within- its argument. Used in the middle of a parser definition, it means that- any operations prior to commitment fail softly, but after commitment,- they fail hard.-</TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="section1"-><A NAME="2"->Combinators-</A-></TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="section2"-><A NAME="3"->primitives-</A-></TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="topdecl"-><TABLE CLASS="declbar"-><TR-><TD CLASS="declname"-><A NAME="v%3Anext"-></A-><B->next</B-> :: <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"->Parser</A-> s t t</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/PolyState.html#next"->Source</A-></TD-></TR-></TABLE-></TD-></TR-><TR-><TD CLASS="doc"->One token-</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 -> Bool) -> <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"->Parser</A-> s t t</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/PolyState.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%3Aapply"-></A-><B->apply</B-> :: <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"->Parser</A-> s t (a -> b) -> <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"->Parser</A-> s t a -> <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"->Parser</A-> s t b</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/PolyState.html#apply"->Source</A-></TD-></TR-></TABLE-></TD-></TR-><TR-><TD CLASS="doc"->Apply a parsed function to a parsed value-</TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="topdecl"-><TABLE CLASS="declbar"-><TR-><TD CLASS="declname"-><A NAME="v%3Adiscard"-></A-><B->discard</B-> :: <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"->Parser</A-> s t a -> <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"->Parser</A-> s t b -> <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"->Parser</A-> s t a</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/PolyState.html#discard"->Source</A-></TD-></TR-></TABLE-></TD-></TR-><TR-><TD CLASS="doc"-><TT->x <TT-><A HREF="Text-ParserCombinators-PolyState.html#v%3Adiscard"->discard</A-></TT-> y</TT-> parses both x and y, but discards the result of y-</TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="section2"-><A NAME="4"->error-handling-</A-></TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="topdecl"-><TABLE CLASS="declbar"-><TR-><TD CLASS="declname"-><A NAME="v%3AadjustErr"-></A-><B->adjustErr</B-> :: <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"->Parser</A-> s t a -> (String -> String) -> <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"->Parser</A-> s t a</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/PolyState.html#adjustErr"->Source</A-></TD-></TR-></TABLE-></TD-></TR-><TR-><TD CLASS="doc"-><TT->p <TT-><A HREF="Text-ParserCombinators-PolyState.html#v%3AadjustErr"->adjustErr</A-></TT-> f</TT-> applies the transformation <TT->f</TT-> to any error message- generated in <TT->p</TT->, having no effect if <TT->p</TT-> succeeds.-</TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="topdecl"-><TABLE CLASS="declbar"-><TR-><TD CLASS="declname"-><A NAME="v%3AadjustErrBad"-></A-><B->adjustErrBad</B-> :: <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"->Parser</A-> s t a -> (String -> String) -> <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"->Parser</A-> s t a</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/PolyState.html#adjustErrBad"->Source</A-></TD-></TR-></TABLE-></TD-></TR-><TR-><TD CLASS="doc"-><TT->adjustErrBad</TT-> is just like <TT->adjustErr</TT-> except it also raises the- severity of the error.-</TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="topdecl"-><TABLE CLASS="declbar"-><TR-><TD CLASS="declname"-><A NAME="v%3Aindent"-></A-><B->indent</B-> :: Int -> String -> String</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/PolyState.html#indent"->Source</A-></TD-></TR-></TABLE-></TD-></TR-><TR-><TD CLASS="doc"->Helper for formatting error messages: indents all lines by a fixed amount.-</TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="section2"-><A NAME="5"->choices-</A-></TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="topdecl"-><TABLE CLASS="declbar"-><TR-><TD CLASS="declname"-><A NAME="v%3AonFail"-></A-><B->onFail</B-> :: <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"->Parser</A-> s t a -> <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"->Parser</A-> s t a -> <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"->Parser</A-> s t a</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/PolyState.html#onFail"->Source</A-></TD-></TR-></TABLE-></TD-></TR-><TR-><TD CLASS="doc"-><TT->p <TT-><A HREF="Text-ParserCombinators-PolyState.html#v%3AonFail"->onFail</A-></TT-> q</TT-> means parse p unless p fails in which case parse q instead.- Can be chained together to give multiple attempts to parse something.- (Note that q could itself be a failing parser, e.g. to change the error- message from that defined in p to something different.)- However, a severe failure in p cannot be ignored.-</TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="topdecl"-><TABLE CLASS="declbar"-><TR-><TD CLASS="declname"-><A NAME="v%3AoneOf"-></A-><B->oneOf</B-> :: [<A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"->Parser</A-> s t a] -> <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"->Parser</A-> s t a</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/PolyState.html#oneOf"->Source</A-></TD-></TR-></TABLE-></TD-></TR-><TR-><TD CLASS="doc"->Parse the first alternative in the list that succeeds.-</TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="topdecl"-><TABLE CLASS="declbar"-><TR-><TD CLASS="declname"-><A NAME="v%3AoneOf%27"-></A-><B->oneOf'</B-> :: [(String, <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"->Parser</A-> s t a)] -> <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"->Parser</A-> s t a</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/PolyState.html#oneOf%27"->Source</A-></TD-></TR-></TABLE-></TD-></TR-><TR-><TD CLASS="doc"->Parse the first alternative that succeeds, but if none succeed,- report only the severe errors, and if none of those, then report- all the soft errors.-</TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="section2"-><A NAME="6"->sequences-</A-></TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="topdecl"-><TABLE CLASS="declbar"-><TR-><TD CLASS="declname"-><A NAME="v%3Amany"-></A-><B->many</B-> :: <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"->Parser</A-> s t a -> <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"->Parser</A-> s t [a]</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/PolyState.html#many"->Source</A-></TD-></TR-></TABLE-></TD-></TR-><TR-><TD CLASS="doc"->'many p' parses a list of elements with individual parser p.- Cannot fail, since an empty list is a valid return value.-</TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="topdecl"-><TABLE CLASS="declbar"-><TR-><TD CLASS="declname"-><A NAME="v%3Amany1"-></A-><B->many1</B-> :: <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"->Parser</A-> s t a -> <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"->Parser</A-> s t [a]</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/PolyState.html#many1"->Source</A-></TD-></TR-></TABLE-></TD-></TR-><TR-><TD CLASS="doc"->Parse a non-empty list of items.-</TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="topdecl"-><TABLE CLASS="declbar"-><TR-><TD CLASS="declname"-><A NAME="v%3AsepBy"-></A-><B->sepBy</B-> :: <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"->Parser</A-> s t a -> <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"->Parser</A-> s t sep -> <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"->Parser</A-> s t [a]</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/PolyState.html#sepBy"->Source</A-></TD-></TR-></TABLE-></TD-></TR-><TR-><TD CLASS="doc"->Parse a list of items separated by discarded junk.-</TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="topdecl"-><TABLE CLASS="declbar"-><TR-><TD CLASS="declname"-><A NAME="v%3AsepBy1"-></A-><B->sepBy1</B-> :: <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"->Parser</A-> s t a -> <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"->Parser</A-> s t sep -> <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"->Parser</A-> s t [a]</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/PolyState.html#sepBy1"->Source</A-></TD-></TR-></TABLE-></TD-></TR-><TR-><TD CLASS="doc"->Parse a non-empty list of items separated by discarded junk.-</TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="topdecl"-><TABLE CLASS="declbar"-><TR-><TD CLASS="declname"-><A NAME="v%3AbracketSep"-></A-><B->bracketSep</B-> :: <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"->Parser</A-> s t bra -> <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"->Parser</A-> s t sep -> <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"->Parser</A-> s t ket -> <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"->Parser</A-> s t a -> <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"->Parser</A-> s t [a]</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/PolyState.html#bracketSep"->Source</A-></TD-></TR-></TABLE-></TD-></TR-><TR-><TD CLASS="doc"->Parse a list of items, discarding the start, end, and separator- items.-</TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="topdecl"-><TABLE CLASS="declbar"-><TR-><TD CLASS="declname"-><A NAME="v%3Abracket"-></A-><B->bracket</B-> :: <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"->Parser</A-> s t bra -> <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"->Parser</A-> s t ket -> <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"->Parser</A-> s t a -> <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"->Parser</A-> s t a</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/PolyState.html#bracket"->Source</A-></TD-></TR-></TABLE-></TD-></TR-><TR-><TD CLASS="doc"->Parse a bracketed item, discarding the brackets.-</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-PolyState.html#t%3AParser"->Parser</A-> s t a -> <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"->Parser</A-> s t z -> <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"->Parser</A-> s t [a]</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/PolyState.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="7"->state-handling-</A-></TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="topdecl"-><TABLE CLASS="declbar"-><TR-><TD CLASS="declname"-><A NAME="v%3AstUpdate"-></A-><B->stUpdate</B-> :: (s -> s) -> <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"->Parser</A-> s t ()</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/PolyState.html#stUpdate"->Source</A-></TD-></TR-></TABLE-></TD-></TR-><TR-><TD CLASS="doc"->Update the internal state.-</TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="topdecl"-><TABLE CLASS="declbar"-><TR-><TD CLASS="declname"-><A NAME="v%3AstQuery"-></A-><B->stQuery</B-> :: (s -> a) -> <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"->Parser</A-> s t a</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/PolyState.html#stQuery"->Source</A-></TD-></TR-></TABLE-></TD-></TR-><TR-><TD CLASS="doc"->Query the internal state.-</TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="topdecl"-><TABLE CLASS="declbar"-><TR-><TD CLASS="declname"-><A NAME="v%3AstGet"-></A-><B->stGet</B-> :: <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"->Parser</A-> s t s</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/PolyState.html#stGet"->Source</A-></TD-></TR-></TABLE-></TD-></TR-><TR-><TD CLASS="doc"->Deliver the entire internal state.-</TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="section2"-><A NAME="8"->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] -> <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"->Parser</A-> s t ()</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/PolyState.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="botbar"->Produced by <A HREF="http://www.haskell.org/haddock/"->Haddock</A-> version 0.8</TD-></TR-></TABLE-></BODY-></HTML->
− docs/HaXml/Text-ParserCombinators-PolyStateLazy.html
@@ -1,1524 +0,0 @@-<!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.PolyStateLazy</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"->HaXml</TD-><TD CLASS="topbut"-><A HREF="src/Text/ParserCombinators/PolyStateLazy.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.PolyStateLazy</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"->A Parser datatype parameterised on arbitrary token type and state type.-</A-></DT-><DT-><A HREF="#2"->Combinators-</A-></DT-><DD-><DL-><DT-><A HREF="#3"->primitives-</A-></DT-><DT-><A HREF="#4"->error-handling-</A-></DT-><DT-><A HREF="#5"->choices-</A-></DT-><DT-><A HREF="#6"->sequences-</A-></DT-><DT-><A HREF="#7"->state-handling-</A-></DT-><DT-><A HREF="#8"->re-parsing-</A-></DT-></DL-></DD-></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-> s t a = <A HREF="#v%3AP"->P</A-> (s -> [t] -> (Either String a, s, [t]))</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3ArunParser"->runParser</A-> :: <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"->Parser</A-> s t a -> s -> [t] -> (a, s, [t])</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3AfailBad"->failBad</A-> :: String -> <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"->Parser</A-> s t a</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3Acommit"->commit</A-> :: <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"->Parser</A-> s t a -> <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"->Parser</A-> s t a</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3Anext"->next</A-> :: <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"->Parser</A-> s t t</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3Asatisfy"->satisfy</A-> :: (t -> Bool) -> <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"->Parser</A-> s t t</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3Aapply"->apply</A-> :: <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"->Parser</A-> s t (a -> b) -> <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"->Parser</A-> s t a -> <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"->Parser</A-> s t b</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3Adiscard"->discard</A-> :: <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"->Parser</A-> s t a -> <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"->Parser</A-> s t b -> <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"->Parser</A-> s t a</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3AadjustErr"->adjustErr</A-> :: <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"->Parser</A-> s t a -> (String -> String) -> <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"->Parser</A-> s t a</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3AadjustErrBad"->adjustErrBad</A-> :: <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"->Parser</A-> s t a -> (String -> String) -> <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"->Parser</A-> s t a</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3Aindent"->indent</A-> :: Int -> String -> String</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3AonFail"->onFail</A-> :: <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"->Parser</A-> s t a -> <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"->Parser</A-> s t a -> <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"->Parser</A-> s t a</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3AoneOf"->oneOf</A-> :: [<A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"->Parser</A-> s t a] -> <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"->Parser</A-> s t a</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3AoneOf%27"->oneOf'</A-> :: [(String, <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"->Parser</A-> s t a)] -> <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"->Parser</A-> s t a</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3Aoptional"->optional</A-> :: <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"->Parser</A-> s t a -> <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"->Parser</A-> s t (Maybe a)</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3Amany"->many</A-> :: <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"->Parser</A-> s t a -> <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"->Parser</A-> s t [a]</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3Amany1"->many1</A-> :: <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"->Parser</A-> s t a -> <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"->Parser</A-> s t [a]</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3AsepBy"->sepBy</A-> :: <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"->Parser</A-> s t a -> <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"->Parser</A-> s t sep -> <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"->Parser</A-> s t [a]</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3AsepBy1"->sepBy1</A-> :: <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"->Parser</A-> s t a -> <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"->Parser</A-> s t sep -> <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"->Parser</A-> s t [a]</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3AbracketSep"->bracketSep</A-> :: <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"->Parser</A-> s t bra -> <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"->Parser</A-> s t sep -> <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"->Parser</A-> s t ket -> <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"->Parser</A-> s t a -> <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"->Parser</A-> s t [a]</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3Abracket"->bracket</A-> :: <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"->Parser</A-> s t bra -> <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"->Parser</A-> s t ket -> <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"->Parser</A-> s t a -> <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"->Parser</A-> s t a</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3AmanyFinally"->manyFinally</A-> :: <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"->Parser</A-> s t a -> <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"->Parser</A-> s t z -> <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"->Parser</A-> s t [a]</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3AstUpdate"->stUpdate</A-> :: (s -> s) -> <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"->Parser</A-> s t ()</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3AstQuery"->stQuery</A-> :: (s -> a) -> <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"->Parser</A-> s t a</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3AstGet"->stGet</A-> :: <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"->Parser</A-> s t s</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3Areparse"->reparse</A-> :: [t] -> <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"->Parser</A-> s t ()</TD-></TR-></TABLE-></TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="section1"-><A NAME="1"->A Parser datatype parameterised on arbitrary token type and state type.-</A-></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-> s t a</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/PolyStateLazy.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 and a running state. It can be used for arbitrary token- types, not just String input.-</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-> (s -> [t] -> (Either String a, s, [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-PolyStateLazy.html#t%3AParser"->Parser</A-> s t)</TD-></TR-><TR-><TD CLASS="decl"->Monad (<A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"->Parser</A-> s 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-PolyStateLazy.html#t%3AParser"->Parser</A-> s t a -> s -> [t] -> (a, s, [t])</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/PolyStateLazy.html#runParser"->Source</A-></TD-></TR-></TABLE-></TD-></TR-><TR-><TD CLASS="doc"->Apply a parser to an initial state and 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="topdecl"-><TABLE CLASS="declbar"-><TR-><TD CLASS="declname"-><A NAME="v%3AfailBad"-></A-><B->failBad</B-> :: String -> <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"->Parser</A-> s t a</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/PolyStateLazy.html#failBad"->Source</A-></TD-></TR-></TABLE-></TD-></TR-><TR-><TD CLASS="doc"->Simple failure can be corrected, but when a simple fail is not strong- enough, use failBad for emphasis. It guarantees parsing will terminate- with an exception.-</TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="topdecl"-><TABLE CLASS="declbar"-><TR-><TD CLASS="declname"-><A NAME="v%3Acommit"-></A-><B->commit</B-> :: <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"->Parser</A-> s t a -> <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"->Parser</A-> s t a</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/PolyStateLazy.html#commit"->Source</A-></TD-></TR-></TABLE-></TD-></TR-><TR-><TD CLASS="doc"->Commit is a way of raising the severity of any errors found within- its argument. Used in the middle of a parser definition, it means that- any operations prior to commitment fail softly, but after commitment,- they fail hard.-</TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="section1"-><A NAME="2"->Combinators-</A-></TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="section2"-><A NAME="3"->primitives-</A-></TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="topdecl"-><TABLE CLASS="declbar"-><TR-><TD CLASS="declname"-><A NAME="v%3Anext"-></A-><B->next</B-> :: <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"->Parser</A-> s t t</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/PolyStateLazy.html#next"->Source</A-></TD-></TR-></TABLE-></TD-></TR-><TR-><TD CLASS="doc"->One token-</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 -> Bool) -> <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"->Parser</A-> s t t</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/PolyStateLazy.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%3Aapply"-></A-><B->apply</B-> :: <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"->Parser</A-> s t (a -> b) -> <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"->Parser</A-> s t a -> <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"->Parser</A-> s t b</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/PolyStateLazy.html#apply"->Source</A-></TD-></TR-></TABLE-></TD-></TR-><TR-><TD CLASS="doc"->Apply a parsed function to a parsed value-</TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="topdecl"-><TABLE CLASS="declbar"-><TR-><TD CLASS="declname"-><A NAME="v%3Adiscard"-></A-><B->discard</B-> :: <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"->Parser</A-> s t a -> <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"->Parser</A-> s t b -> <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"->Parser</A-> s t a</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/PolyStateLazy.html#discard"->Source</A-></TD-></TR-></TABLE-></TD-></TR-><TR-><TD CLASS="doc"-><TT->x <TT-><A HREF="Text-ParserCombinators-PolyStateLazy.html#v%3Adiscard"->discard</A-></TT-> y</TT-> parses both x and y, but discards the result of y-</TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="section2"-><A NAME="4"->error-handling-</A-></TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="topdecl"-><TABLE CLASS="declbar"-><TR-><TD CLASS="declname"-><A NAME="v%3AadjustErr"-></A-><B->adjustErr</B-> :: <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"->Parser</A-> s t a -> (String -> String) -> <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"->Parser</A-> s t a</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/PolyStateLazy.html#adjustErr"->Source</A-></TD-></TR-></TABLE-></TD-></TR-><TR-><TD CLASS="doc"-><TT->p <TT-><A HREF="Text-ParserCombinators-PolyStateLazy.html#v%3AadjustErr"->adjustErr</A-></TT-> f</TT-> applies the transformation <TT->f</TT-> to any error message- generated in <TT->p</TT->, having no effect if <TT->p</TT-> succeeds.-</TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="topdecl"-><TABLE CLASS="declbar"-><TR-><TD CLASS="declname"-><A NAME="v%3AadjustErrBad"-></A-><B->adjustErrBad</B-> :: <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"->Parser</A-> s t a -> (String -> String) -> <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"->Parser</A-> s t a</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/PolyStateLazy.html#adjustErrBad"->Source</A-></TD-></TR-></TABLE-></TD-></TR-><TR-><TD CLASS="doc"-><TT->adjustErrBad</TT-> is just like <TT->adjustErr</TT-> except it also raises the- severity of the error.-</TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="topdecl"-><TABLE CLASS="declbar"-><TR-><TD CLASS="declname"-><A NAME="v%3Aindent"-></A-><B->indent</B-> :: Int -> String -> String</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/PolyStateLazy.html#indent"->Source</A-></TD-></TR-></TABLE-></TD-></TR-><TR-><TD CLASS="doc"->Helper for formatting error messages: indents all lines by a fixed amount.-</TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="section2"-><A NAME="5"->choices-</A-></TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="topdecl"-><TABLE CLASS="declbar"-><TR-><TD CLASS="declname"-><A NAME="v%3AonFail"-></A-><B->onFail</B-> :: <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"->Parser</A-> s t a -> <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"->Parser</A-> s t a -> <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"->Parser</A-> s t a</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/PolyStateLazy.html#onFail"->Source</A-></TD-></TR-></TABLE-></TD-></TR-><TR-><TD CLASS="doc"-><TT->p <TT-><A HREF="Text-ParserCombinators-PolyStateLazy.html#v%3AonFail"->onFail</A-></TT-> q</TT-> means parse p unless p fails in which case parse q instead.- Can be chained together to give multiple attempts to parse something.- (Note that q could itself be a failing parser, e.g. to change the error- message from that defined in p to something different.)- However, a *severe* failure in p cannot be ignored.-</TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="topdecl"-><TABLE CLASS="declbar"-><TR-><TD CLASS="declname"-><A NAME="v%3AoneOf"-></A-><B->oneOf</B-> :: [<A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"->Parser</A-> s t a] -> <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"->Parser</A-> s t a</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/PolyStateLazy.html#oneOf"->Source</A-></TD-></TR-></TABLE-></TD-></TR-><TR-><TD CLASS="doc"->Parse the first alternative in the list that succeeds.-</TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="topdecl"-><TABLE CLASS="declbar"-><TR-><TD CLASS="declname"-><A NAME="v%3AoneOf%27"-></A-><B->oneOf'</B-> :: [(String, <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"->Parser</A-> s t a)] -> <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"->Parser</A-> s t a</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/PolyStateLazy.html#oneOf%27"->Source</A-></TD-></TR-></TABLE-></TD-></TR-><TR-><TD CLASS="doc"->Parse the first alternative that succeeds, but if none succeed,- report only the severe errors, and if none of those, then report- all the soft errors.-</TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="topdecl"-><TABLE CLASS="declbar"-><TR-><TD CLASS="declname"-><A NAME="v%3Aoptional"-></A-><B->optional</B-> :: <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"->Parser</A-> s t a -> <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"->Parser</A-> s t (Maybe a)</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/PolyStateLazy.html#optional"->Source</A-></TD-></TR-></TABLE-></TD-></TR-><TR-><TD CLASS="doc"-><TT-><A HREF="Text-ParserCombinators-PolyStateLazy.html#v%3Aoptional"->optional</A-></TT-> indicates whether the parser succeeded through the Maybe type.-</TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="section2"-><A NAME="6"->sequences-</A-></TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="topdecl"-><TABLE CLASS="declbar"-><TR-><TD CLASS="declname"-><A NAME="v%3Amany"-></A-><B->many</B-> :: <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"->Parser</A-> s t a -> <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"->Parser</A-> s t [a]</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/PolyStateLazy.html#many"->Source</A-></TD-></TR-></TABLE-></TD-></TR-><TR-><TD CLASS="doc"->'many p' parses a list of elements with individual parser p.- Cannot fail, since an empty list is a valid return value.-</TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="topdecl"-><TABLE CLASS="declbar"-><TR-><TD CLASS="declname"-><A NAME="v%3Amany1"-></A-><B->many1</B-> :: <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"->Parser</A-> s t a -> <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"->Parser</A-> s t [a]</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/PolyStateLazy.html#many1"->Source</A-></TD-></TR-></TABLE-></TD-></TR-><TR-><TD CLASS="doc"->Parse a non-empty list of items.-</TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="topdecl"-><TABLE CLASS="declbar"-><TR-><TD CLASS="declname"-><A NAME="v%3AsepBy"-></A-><B->sepBy</B-> :: <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"->Parser</A-> s t a -> <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"->Parser</A-> s t sep -> <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"->Parser</A-> s t [a]</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/PolyStateLazy.html#sepBy"->Source</A-></TD-></TR-></TABLE-></TD-></TR-><TR-><TD CLASS="doc"->Parse a list of items separated by discarded junk.-</TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="topdecl"-><TABLE CLASS="declbar"-><TR-><TD CLASS="declname"-><A NAME="v%3AsepBy1"-></A-><B->sepBy1</B-> :: <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"->Parser</A-> s t a -> <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"->Parser</A-> s t sep -> <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"->Parser</A-> s t [a]</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/PolyStateLazy.html#sepBy1"->Source</A-></TD-></TR-></TABLE-></TD-></TR-><TR-><TD CLASS="doc"->Parse a non-empty list of items separated by discarded junk.-</TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="topdecl"-><TABLE CLASS="declbar"-><TR-><TD CLASS="declname"-><A NAME="v%3AbracketSep"-></A-><B->bracketSep</B-> :: <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"->Parser</A-> s t bra -> <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"->Parser</A-> s t sep -> <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"->Parser</A-> s t ket -> <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"->Parser</A-> s t a -> <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"->Parser</A-> s t [a]</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/PolyStateLazy.html#bracketSep"->Source</A-></TD-></TR-></TABLE-></TD-></TR-><TR-><TD CLASS="doc"->Parse a list of items, discarding the start, end, and separator- items.-</TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="topdecl"-><TABLE CLASS="declbar"-><TR-><TD CLASS="declname"-><A NAME="v%3Abracket"-></A-><B->bracket</B-> :: <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"->Parser</A-> s t bra -> <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"->Parser</A-> s t ket -> <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"->Parser</A-> s t a -> <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"->Parser</A-> s t a</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/PolyStateLazy.html#bracket"->Source</A-></TD-></TR-></TABLE-></TD-></TR-><TR-><TD CLASS="doc"->Parse a bracketed item, discarding the brackets.-</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-PolyStateLazy.html#t%3AParser"->Parser</A-> s t a -> <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"->Parser</A-> s t z -> <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"->Parser</A-> s t [a]</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/PolyStateLazy.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="7"->state-handling-</A-></TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="topdecl"-><TABLE CLASS="declbar"-><TR-><TD CLASS="declname"-><A NAME="v%3AstUpdate"-></A-><B->stUpdate</B-> :: (s -> s) -> <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"->Parser</A-> s t ()</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/PolyStateLazy.html#stUpdate"->Source</A-></TD-></TR-></TABLE-></TD-></TR-><TR-><TD CLASS="doc"->Update the internal state.-</TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="topdecl"-><TABLE CLASS="declbar"-><TR-><TD CLASS="declname"-><A NAME="v%3AstQuery"-></A-><B->stQuery</B-> :: (s -> a) -> <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"->Parser</A-> s t a</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/PolyStateLazy.html#stQuery"->Source</A-></TD-></TR-></TABLE-></TD-></TR-><TR-><TD CLASS="doc"->Query the internal state.-</TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="topdecl"-><TABLE CLASS="declbar"-><TR-><TD CLASS="declname"-><A NAME="v%3AstGet"-></A-><B->stGet</B-> :: <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"->Parser</A-> s t s</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/PolyStateLazy.html#stGet"->Source</A-></TD-></TR-></TABLE-></TD-></TR-><TR-><TD CLASS="doc"->Deliver the entire internal state.-</TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="section2"-><A NAME="8"->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] -> <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"->Parser</A-> s t ()</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/PolyStateLazy.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="botbar"->Produced by <A HREF="http://www.haskell.org/haddock/"->Haddock</A-> version 0.8</TD-></TR-></TABLE-></BODY-></HTML->
− docs/HaXml/Text-ParserCombinators-TextParser.html
@@ -1,781 +0,0 @@-<!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.TextParser</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"->HaXml</TD-><TD CLASS="topbut"-><A HREF="src/Text/ParserCombinators/TextParser.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.TextParser</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 Parse class is a replacement for the Read class. It is a-</A-></DT-><DD-><DL-><DT-><A HREF="#2"->Combinators specific to string input, lexed haskell-style-</A-></DT-><DT-><A HREF="#3"->Re-export all the more general combinators too-</A-></DT-></DL-></DD-></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"->type</SPAN-> <A HREF="#t%3ATextParser"->TextParser</A-> a = <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"->Parser</A-> Char a</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><SPAN CLASS="keyword"->class</SPAN-> <A HREF="#t%3AParse"->Parse</A-> a <SPAN CLASS="keyword"->where</SPAN-></TD-></TR-><TR-><TD CLASS="body"-><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"-><TR-><TD CLASS="decl"-><A HREF="#v%3Aparse"->parse</A-> :: <A HREF="Text-ParserCombinators-TextParser.html#t%3ATextParser"->TextParser</A-> a</TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3AparseList"->parseList</A-> :: <A HREF="Text-ParserCombinators-TextParser.html#t%3ATextParser"->TextParser</A-> [a]</TD-></TR-></TABLE-></TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3AparseByRead"->parseByRead</A-> :: Read a => String -> <A HREF="Text-ParserCombinators-TextParser.html#t%3ATextParser"->TextParser</A-> a</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3Aword"->word</A-> :: <A HREF="Text-ParserCombinators-TextParser.html#t%3ATextParser"->TextParser</A-> String</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3AisWord"->isWord</A-> :: String -> <A HREF="Text-ParserCombinators-TextParser.html#t%3ATextParser"->TextParser</A-> String</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3AoptionalParens"->optionalParens</A-> :: <A HREF="Text-ParserCombinators-TextParser.html#t%3ATextParser"->TextParser</A-> a -> <A HREF="Text-ParserCombinators-TextParser.html#t%3ATextParser"->TextParser</A-> a</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3Afield"->field</A-> :: <A HREF="Text-ParserCombinators-TextParser.html#t%3AParse"->Parse</A-> a => String -> <A HREF="Text-ParserCombinators-TextParser.html#t%3ATextParser"->TextParser</A-> a</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3Aconstructors"->constructors</A-> :: [(String, <A HREF="Text-ParserCombinators-TextParser.html#t%3ATextParser"->TextParser</A-> a)] -> <A HREF="Text-ParserCombinators-TextParser.html#t%3ATextParser"->TextParser</A-> a</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"-><A HREF="#v%3Aenumeration"->enumeration</A-> :: Show a => String -> [a] -> <A HREF="Text-ParserCombinators-TextParser.html#t%3ATextParser"->TextParser</A-> a</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="decl"->module <A HREF="Text-ParserCombinators-Poly.html"->Text.ParserCombinators.Poly</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 Parse class is a replacement for the Read class. It is a-</A-></TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="topdecl"-><TABLE CLASS="declbar"-><TR-><TD CLASS="declname"-><SPAN CLASS="keyword"->type</SPAN-> <A NAME="t%3ATextParser"-></A-><B->TextParser</B-> a = <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"->Parser</A-> Char a</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/TextParser.html#TextParser"->Source</A-></TD-></TR-></TABLE-></TD-></TR-><TR-><TD CLASS="doc"->A synonym for Parser Char, i.e. string input (no state)-</TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="topdecl"-><TABLE CLASS="declbar"-><TR-><TD CLASS="declname"-><SPAN CLASS="keyword"->class</SPAN-> <A NAME="t%3AParse"-></A-><B->Parse</B-> a <SPAN CLASS="keyword"->where</SPAN-></TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/TextParser.html#Parse"->Source</A-></TD-></TR-></TABLE-></TD-></TR-><TR-><TD CLASS="body"-><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"-><TR-><TD CLASS="ndoc"->The class <TT->Parse</TT-> is a replacement for <TT->Read</TT->, operating over String input.- Essentially, it permits better error messages for why something failed to- parse. It is rather important that <TT->parse</TT-> can read back exactly what- is generated by the corresponding instance of <TT->show</TT->.-</TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="section4"->Methods</TD-></TR-><TR-><TD CLASS="body"-><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"-><TR-><TD CLASS="topdecl"-><TABLE CLASS="declbar"-><TR-><TD CLASS="declname"-><A NAME="v%3Aparse"-></A-><B->parse</B-> :: <A HREF="Text-ParserCombinators-TextParser.html#t%3ATextParser"->TextParser</A-> a</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/TextParser.html#parse"->Source</A-></TD-></TR-></TABLE-></TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="topdecl"-><TABLE CLASS="declbar"-><TR-><TD CLASS="declname"-><A NAME="v%3AparseList"-></A-><B->parseList</B-> :: <A HREF="Text-ParserCombinators-TextParser.html#t%3ATextParser"->TextParser</A-> [a]</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/TextParser.html#parseList"->Source</A-></TD-></TR-></TABLE-></TD-></TR-></TABLE-></TD-></TR-><TR-><TD CLASS="s8"-></TD-></TR-><TR-><TD CLASS="section4"-><IMG SRC="minus.gif" CLASS="coll" ONCLICK="toggle(this,'i:Parse')" ALT="show/hide"-> Instances</TD-></TR-><TR-><TD CLASS="body"-><DIV ID="i:Parse" STYLE="display:block;"-><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0"-><TR-><TD CLASS="decl"-><A HREF="Text-ParserCombinators-TextParser.html#t%3AParse"->Parse</A-> Bool</TD-></TR-><TR-><TD CLASS="decl"-><A HREF="Text-ParserCombinators-TextParser.html#t%3AParse"->Parse</A-> Char</TD-></TR-><TR-><TD CLASS="decl"-><A HREF="Text-ParserCombinators-TextParser.html#t%3AParse"->Parse</A-> Double</TD-></TR-><TR-><TD CLASS="decl"-><A HREF="Text-ParserCombinators-TextParser.html#t%3AParse"->Parse</A-> Float</TD-></TR-><TR-><TD CLASS="decl"-><A HREF="Text-ParserCombinators-TextParser.html#t%3AParse"->Parse</A-> Int</TD-></TR-><TR-><TD CLASS="decl"-><A HREF="Text-ParserCombinators-TextParser.html#t%3AParse"->Parse</A-> Integer</TD-></TR-><TR-><TD CLASS="decl"-><A HREF="Text-ParserCombinators-TextParser.html#t%3AParse"->Parse</A-> Ordering</TD-></TR-><TR-><TD CLASS="decl"-><A HREF="Text-ParserCombinators-TextParser.html#t%3AParse"->Parse</A-> ()</TD-></TR-><TR-><TD CLASS="decl"->(<A HREF="Text-ParserCombinators-TextParser.html#t%3AParse"->Parse</A-> a, <A HREF="Text-ParserCombinators-TextParser.html#t%3AParse"->Parse</A-> b) => <A HREF="Text-ParserCombinators-TextParser.html#t%3AParse"->Parse</A-> (a, b)</TD-></TR-><TR-><TD CLASS="decl"->(<A HREF="Text-ParserCombinators-TextParser.html#t%3AParse"->Parse</A-> a, <A HREF="Text-ParserCombinators-TextParser.html#t%3AParse"->Parse</A-> b, <A HREF="Text-ParserCombinators-TextParser.html#t%3AParse"->Parse</A-> c) => <A HREF="Text-ParserCombinators-TextParser.html#t%3AParse"->Parse</A-> (a, b, c)</TD-></TR-><TR-><TD CLASS="decl"-><A HREF="Text-ParserCombinators-TextParser.html#t%3AParse"->Parse</A-> a => <A HREF="Text-ParserCombinators-TextParser.html#t%3AParse"->Parse</A-> (Maybe a)</TD-></TR-><TR-><TD CLASS="decl"-><A HREF="Text-ParserCombinators-TextParser.html#t%3AParse"->Parse</A-> a => <A HREF="Text-ParserCombinators-TextParser.html#t%3AParse"->Parse</A-> [a]</TD-></TR-><TR-><TD CLASS="decl"->(<A HREF="Text-ParserCombinators-TextParser.html#t%3AParse"->Parse</A-> a, <A HREF="Text-ParserCombinators-TextParser.html#t%3AParse"->Parse</A-> b) => <A HREF="Text-ParserCombinators-TextParser.html#t%3AParse"->Parse</A-> (Either a b)</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%3AparseByRead"-></A-><B->parseByRead</B-> :: Read a => String -> <A HREF="Text-ParserCombinators-TextParser.html#t%3ATextParser"->TextParser</A-> a</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/TextParser.html#parseByRead"->Source</A-></TD-></TR-></TABLE-></TD-></TR-><TR-><TD CLASS="doc"->If there already exists a Read instance for a type, then we can make- a Parser for it, but with only poor error-reporting.-</TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="section2"-><A NAME="2"->Combinators specific to string input, lexed haskell-style-</A-></TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="topdecl"-><TABLE CLASS="declbar"-><TR-><TD CLASS="declname"-><A NAME="v%3Aword"-></A-><B->word</B-> :: <A HREF="Text-ParserCombinators-TextParser.html#t%3ATextParser"->TextParser</A-> String</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/TextParser.html#word"->Source</A-></TD-></TR-></TABLE-></TD-></TR-><TR-><TD CLASS="doc"->One lexical chunk (Haskell-style lexing).-</TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="topdecl"-><TABLE CLASS="declbar"-><TR-><TD CLASS="declname"-><A NAME="v%3AisWord"-></A-><B->isWord</B-> :: String -> <A HREF="Text-ParserCombinators-TextParser.html#t%3ATextParser"->TextParser</A-> String</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/TextParser.html#isWord"->Source</A-></TD-></TR-></TABLE-></TD-></TR-><TR-><TD CLASS="doc"->Ensure that the next input word is a given string. (Note the input- is lexed as haskell, so wordbreaks at spaces, symbols, etc.)-</TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="topdecl"-><TABLE CLASS="declbar"-><TR-><TD CLASS="declname"-><A NAME="v%3AoptionalParens"-></A-><B->optionalParens</B-> :: <A HREF="Text-ParserCombinators-TextParser.html#t%3ATextParser"->TextParser</A-> a -> <A HREF="Text-ParserCombinators-TextParser.html#t%3ATextParser"->TextParser</A-> a</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/TextParser.html#optionalParens"->Source</A-></TD-></TR-></TABLE-></TD-></TR-><TR-><TD CLASS="doc"->Allow true string parens around an item.-</TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="topdecl"-><TABLE CLASS="declbar"-><TR-><TD CLASS="declname"-><A NAME="v%3Afield"-></A-><B->field</B-> :: <A HREF="Text-ParserCombinators-TextParser.html#t%3AParse"->Parse</A-> a => String -> <A HREF="Text-ParserCombinators-TextParser.html#t%3ATextParser"->TextParser</A-> a</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/TextParser.html#field"->Source</A-></TD-></TR-></TABLE-></TD-></TR-><TR-><TD CLASS="doc"->Deal with named field syntax.-</TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="topdecl"-><TABLE CLASS="declbar"-><TR-><TD CLASS="declname"-><A NAME="v%3Aconstructors"-></A-><B->constructors</B-> :: [(String, <A HREF="Text-ParserCombinators-TextParser.html#t%3ATextParser"->TextParser</A-> a)] -> <A HREF="Text-ParserCombinators-TextParser.html#t%3ATextParser"->TextParser</A-> a</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/TextParser.html#constructors"->Source</A-></TD-></TR-></TABLE-></TD-></TR-><TR-><TD CLASS="doc"->Parse one of a bunch of alternative constructors.-</TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="topdecl"-><TABLE CLASS="declbar"-><TR-><TD CLASS="declname"-><A NAME="v%3Aenumeration"-></A-><B->enumeration</B-> :: Show a => String -> [a] -> <A HREF="Text-ParserCombinators-TextParser.html#t%3ATextParser"->TextParser</A-> a</TD-><TD CLASS="declbut"-><A HREF="src/Text/ParserCombinators/TextParser.html#enumeration"->Source</A-></TD-></TR-></TABLE-></TD-></TR-><TR-><TD CLASS="doc"->Parse one of the given nullary constructors (an enumeration).-</TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="section2"-><A NAME="3"->Re-export all the more general combinators too-</A-></TD-></TR-><TR-><TD CLASS="s15"-></TD-></TR-><TR-><TD CLASS="decl"->module <A HREF="Text-ParserCombinators-Poly.html"->Text.ParserCombinators.Poly</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->
docs/HaXml/Text-XML-HaXml-TypeMapping.html view
@@ -209,21 +209,11 @@ ></TR ><TR ><TD CLASS="decl"-><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"-><TR-><TD CLASS="decl" ><SPAN CLASS="keyword" >data</SPAN > <A HREF="#t%3AConstr" >Constr</A-> </TD-></TR-><TR-><TD CLASS="body"-><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"-><TR-><TD CLASS="decl"->= <A HREF="#v%3AConstr"+> = <A HREF="#v%3AConstr" >Constr</A > String [<A HREF="Text-XML-HaXml-TypeMapping.html#t%3AHType" >HType</A@@ -232,20 +222,6 @@ >]</TD ></TR ><TR-><TD CLASS="decl"->| <A HREF="#v%3ASynonym"->Synonym</A-> <A HREF="Text-XML-HaXml-TypeMapping.html#t%3AHType"->HType</A-></TD-></TR-></TABLE-></TD-></TR-></TABLE-></TD-></TR-><TR ><TD CLASS="s8" ></TD ></TR@@ -1260,9 +1236,6 @@ variables occurring in the (second) list of real component types. If there are fieldnames, they are contained in the final list, and correspond one-to-one with the component types.- The Synonym alternative is for where the type-mapping from Haskell to- XML is user-defined rather than automatic. There, one might wish to- rename an existing XML type, without the addition of a constructor/tag. </TD ></TR ><TR@@ -1283,18 +1256,6 @@ >] [<A HREF="Text-XML-HaXml-TypeMapping.html#t%3AHType" >HType</A >]</TD-><TD CLASS="rdoc"-></TD-></TR-><TR-><TD CLASS="arg"-><A NAME="v%3ASynonym"-></A-><B->Synonym</B-> <A HREF="Text-XML-HaXml-TypeMapping.html#t%3AHType"->HType</A-></TD ><TD CLASS="rdoc" ></TD ></TR
docs/HaXml/Text-XML-HaXml-Types.html view
@@ -2048,6 +2048,12 @@ >Document</A ></TD ></TR+><TR+><TD CLASS="decl"+>??? i => Eq (<A HREF="Text-XML-HaXml-Types.html#t%3ADocument"+>Document</A+> i)</TD+></TR ></TABLE ></DIV ></TD@@ -2136,6 +2142,12 @@ ></TR ><TR ><TD CLASS="decl"+>??? i => Eq (<A HREF="Text-XML-HaXml-Types.html#t%3AElement"+>Element</A+> i)</TD+></TR+><TR+><TD CLASS="decl" ><A HREF="Text-XML-HaXml-Verbatim.html#t%3AVerbatim" >Verbatim</A > (<A HREF="Text-XML-HaXml-Types.html#t%3AElement"@@ -2195,8 +2207,7 @@ >Attribute</A >]</TD ><TD CLASS="rdoc"->intermediate for parsing-</TD+></TD ></TR ></TABLE ></TD@@ -2326,6 +2337,12 @@ ></TR ><TR ><TD CLASS="decl"+>(Eq i, ??? i) => Eq (<A HREF="Text-XML-HaXml-Types.html#t%3AContent"+>Content</A+> i)</TD+></TR+><TR+><TD CLASS="decl" ><A HREF="Text-XML-HaXml-Verbatim.html#t%3AVerbatim" >Verbatim</A > (<A HREF="Text-XML-HaXml-Types.html#t%3AContent"@@ -2510,9 +2527,28 @@ ></TABLE ></TD ></TR+><TR+><TD CLASS="section4"+><IMG SRC="minus.gif" CLASS="coll" ONCLICK="toggle(this,'i:Prolog')" ALT="show/hide"+> Instances</TD+></TR+><TR+><TD CLASS="body"+><DIV ID="i:Prolog" STYLE="display:block;"+><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0"+><TR+><TD CLASS="decl"+>Eq <A HREF="Text-XML-HaXml-Types.html#t%3AProlog"+>Prolog</A+></TD+></TR ></TABLE+></DIV ></TD ></TR+></TABLE+></TD+></TR ><TR ><TD CLASS="s15" ></TD@@ -2566,9 +2602,28 @@ ></TABLE ></TD ></TR+><TR+><TD CLASS="section4"+><IMG SRC="minus.gif" CLASS="coll" ONCLICK="toggle(this,'i:XMLDecl')" ALT="show/hide"+> Instances</TD+></TR+><TR+><TD CLASS="body"+><DIV ID="i:XMLDecl" STYLE="display:block;"+><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0"+><TR+><TD CLASS="decl"+>Eq <A HREF="Text-XML-HaXml-Types.html#t%3AXMLDecl"+>XMLDecl</A+></TD+></TR ></TABLE+></DIV ></TD ></TR+></TABLE+></TD+></TR ><TR ><TD CLASS="s15" ></TD@@ -2630,9 +2685,28 @@ ></TABLE ></TD ></TR+><TR+><TD CLASS="section4"+><IMG SRC="minus.gif" CLASS="coll" ONCLICK="toggle(this,'i:Misc')" ALT="show/hide"+> Instances</TD+></TR+><TR+><TD CLASS="body"+><DIV ID="i:Misc" STYLE="display:block;"+><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0"+><TR+><TD CLASS="decl"+>Eq <A HREF="Text-XML-HaXml-Types.html#t%3AMisc"+>Misc</A+></TD+></TR ></TABLE+></DIV ></TD ></TR+></TABLE+></TD+></TR ><TR ><TD CLASS="s15" ></TD@@ -2830,9 +2904,28 @@ ></TABLE ></TD ></TR+><TR+><TD CLASS="section4"+><IMG SRC="minus.gif" CLASS="coll" ONCLICK="toggle(this,'i:DocTypeDecl')" ALT="show/hide"+> Instances</TD+></TR+><TR+><TD CLASS="body"+><DIV ID="i:DocTypeDecl" STYLE="display:block;"+><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0"+><TR+><TD CLASS="decl"+>Eq <A HREF="Text-XML-HaXml-Types.html#t%3ADocTypeDecl"+>DocTypeDecl</A+></TD+></TR ></TABLE+></DIV ></TD ></TR+></TABLE+></TD+></TR ><TR ><TD CLASS="s15" ></TD@@ -2930,9 +3023,28 @@ ></TABLE ></TD ></TR+><TR+><TD CLASS="section4"+><IMG SRC="minus.gif" CLASS="coll" ONCLICK="toggle(this,'i:MarkupDecl')" ALT="show/hide"+> Instances</TD+></TR+><TR+><TD CLASS="body"+><DIV ID="i:MarkupDecl" STYLE="display:block;"+><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0"+><TR+><TD CLASS="decl"+>Eq <A HREF="Text-XML-HaXml-Types.html#t%3AMarkupDecl"+>MarkupDecl</A+></TD+></TR ></TABLE+></DIV ></TD ></TR+></TABLE+></TD+></TR ><TR ><TD CLASS="s15" ></TD@@ -2984,9 +3096,28 @@ ></TABLE ></TD ></TR+><TR+><TD CLASS="section4"+><IMG SRC="minus.gif" CLASS="coll" ONCLICK="toggle(this,'i:ExtSubset')" ALT="show/hide"+> Instances</TD+></TR+><TR+><TD CLASS="body"+><DIV ID="i:ExtSubset" STYLE="display:block;"+><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0"+><TR+><TD CLASS="decl"+>Eq <A HREF="Text-XML-HaXml-Types.html#t%3AExtSubset"+>ExtSubset</A+></TD+></TR ></TABLE+></DIV ></TD ></TR+></TABLE+></TD+></TR ><TR ><TD CLASS="s15" ></TD@@ -3048,9 +3179,28 @@ ></TABLE ></TD ></TR+><TR+><TD CLASS="section4"+><IMG SRC="minus.gif" CLASS="coll" ONCLICK="toggle(this,'i:ExtSubsetDecl')" ALT="show/hide"+> Instances</TD+></TR+><TR+><TD CLASS="body"+><DIV ID="i:ExtSubsetDecl" STYLE="display:block;"+><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0"+><TR+><TD CLASS="decl"+>Eq <A HREF="Text-XML-HaXml-Types.html#t%3AExtSubsetDecl"+>ExtSubsetDecl</A+></TD+></TR ></TABLE+></DIV ></TD ></TR+></TABLE+></TD+></TR ><TR ><TD CLASS="s15" ></TD@@ -3102,9 +3252,28 @@ ></TABLE ></TD ></TR+><TR+><TD CLASS="section4"+><IMG SRC="minus.gif" CLASS="coll" ONCLICK="toggle(this,'i:ElementDecl')" ALT="show/hide"+> Instances</TD+></TR+><TR+><TD CLASS="body"+><DIV ID="i:ElementDecl" STYLE="display:block;"+><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0"+><TR+><TD CLASS="decl"+>Eq <A HREF="Text-XML-HaXml-Types.html#t%3AElementDecl"+>ElementDecl</A+></TD+></TR ></TABLE+></DIV ></TD ></TR+></TABLE+></TD+></TR ><TR ><TD CLASS="s15" ></TD@@ -3186,9 +3355,28 @@ ></TABLE ></TD ></TR+><TR+><TD CLASS="section4"+><IMG SRC="minus.gif" CLASS="coll" ONCLICK="toggle(this,'i:ContentSpec')" ALT="show/hide"+> Instances</TD+></TR+><TR+><TD CLASS="body"+><DIV ID="i:ContentSpec" STYLE="display:block;"+><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0"+><TR+><TD CLASS="decl"+>Eq <A HREF="Text-XML-HaXml-Types.html#t%3AContentSpec"+>ContentSpec</A+></TD+></TR ></TABLE+></DIV ></TD ></TR+></TABLE+></TD+></TR ><TR ><TD CLASS="s15" ></TD@@ -3279,6 +3467,12 @@ ><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0" ><TR ><TD CLASS="decl"+>Eq <A HREF="Text-XML-HaXml-Types.html#t%3ACP"+>CP</A+></TD+></TR+><TR+><TD CLASS="decl" >Show <A HREF="Text-XML-HaXml-Types.html#t%3ACP" >CP</A ></TD@@ -3388,6 +3582,12 @@ ><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0" ><TR ><TD CLASS="decl"+>Eq <A HREF="Text-XML-HaXml-Types.html#t%3AModifier"+>Modifier</A+></TD+></TR+><TR+><TD CLASS="decl" >Show <A HREF="Text-XML-HaXml-Types.html#t%3AModifier" >Modifier</A ></TD@@ -3464,9 +3664,28 @@ ></TABLE ></TD ></TR+><TR+><TD CLASS="section4"+><IMG SRC="minus.gif" CLASS="coll" ONCLICK="toggle(this,'i:Mixed')" ALT="show/hide"+> Instances</TD+></TR+><TR+><TD CLASS="body"+><DIV ID="i:Mixed" STYLE="display:block;"+><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0"+><TR+><TD CLASS="decl"+>Eq <A HREF="Text-XML-HaXml-Types.html#t%3AMixed"+>Mixed</A+></TD+></TR ></TABLE+></DIV ></TD ></TR+></TABLE+></TD+></TR ><TR ><TD CLASS="s15" ></TD@@ -3529,9 +3748,28 @@ ></TABLE ></TD ></TR+><TR+><TD CLASS="section4"+><IMG SRC="minus.gif" CLASS="coll" ONCLICK="toggle(this,'i:AttListDecl')" ALT="show/hide"+> Instances</TD+></TR+><TR+><TD CLASS="body"+><DIV ID="i:AttListDecl" STYLE="display:block;"+><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0"+><TR+><TD CLASS="decl"+>Eq <A HREF="Text-XML-HaXml-Types.html#t%3AAttListDecl"+>AttListDecl</A+></TD+></TR ></TABLE+></DIV ></TD ></TR+></TABLE+></TD+></TR ><TR ><TD CLASS="s15" ></TD@@ -3585,9 +3823,28 @@ ></TABLE ></TD ></TR+><TR+><TD CLASS="section4"+><IMG SRC="minus.gif" CLASS="coll" ONCLICK="toggle(this,'i:AttDef')" ALT="show/hide"+> Instances</TD+></TR+><TR+><TD CLASS="body"+><DIV ID="i:AttDef" STYLE="display:block;"+><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0"+><TR+><TD CLASS="decl"+>Eq <A HREF="Text-XML-HaXml-Types.html#t%3AAttDef"+>AttDef</A+></TD+></TR ></TABLE+></DIV ></TD ></TR+></TABLE+></TD+></TR ><TR ><TD CLASS="s15" ></TD@@ -3659,9 +3916,28 @@ ></TABLE ></TD ></TR+><TR+><TD CLASS="section4"+><IMG SRC="minus.gif" CLASS="coll" ONCLICK="toggle(this,'i:AttType')" ALT="show/hide"+> Instances</TD+></TR+><TR+><TD CLASS="body"+><DIV ID="i:AttType" STYLE="display:block;"+><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0"+><TR+><TD CLASS="decl"+>Eq <A HREF="Text-XML-HaXml-Types.html#t%3AAttType"+>AttType</A+></TD+></TR ></TABLE+></DIV ></TD ></TR+></TABLE+></TD+></TR ><TR ><TD CLASS="s15" ></TD@@ -3769,9 +4045,28 @@ ></TABLE ></TD ></TR+><TR+><TD CLASS="section4"+><IMG SRC="minus.gif" CLASS="coll" ONCLICK="toggle(this,'i:TokenizedType')" ALT="show/hide"+> Instances</TD+></TR+><TR+><TD CLASS="body"+><DIV ID="i:TokenizedType" STYLE="display:block;"+><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0"+><TR+><TD CLASS="decl"+>Eq <A HREF="Text-XML-HaXml-Types.html#t%3ATokenizedType"+>TokenizedType</A+></TD+></TR ></TABLE+></DIV ></TD ></TR+></TABLE+></TD+></TR ><TR ><TD CLASS="s15" ></TD@@ -3833,9 +4128,28 @@ ></TABLE ></TD ></TR+><TR+><TD CLASS="section4"+><IMG SRC="minus.gif" CLASS="coll" ONCLICK="toggle(this,'i:EnumeratedType')" ALT="show/hide"+> Instances</TD+></TR+><TR+><TD CLASS="body"+><DIV ID="i:EnumeratedType" STYLE="display:block;"+><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0"+><TR+><TD CLASS="decl"+>Eq <A HREF="Text-XML-HaXml-Types.html#t%3AEnumeratedType"+>EnumeratedType</A+></TD+></TR ></TABLE+></DIV ></TD ></TR+></TABLE+></TD+></TR ><TR ><TD CLASS="s15" ></TD@@ -3959,9 +4273,28 @@ ></TABLE ></TD ></TR+><TR+><TD CLASS="section4"+><IMG SRC="minus.gif" CLASS="coll" ONCLICK="toggle(this,'i:DefaultDecl')" ALT="show/hide"+> Instances</TD+></TR+><TR+><TD CLASS="body"+><DIV ID="i:DefaultDecl" STYLE="display:block;"+><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0"+><TR+><TD CLASS="decl"+>Eq <A HREF="Text-XML-HaXml-Types.html#t%3ADefaultDecl"+>DefaultDecl</A+></TD+></TR ></TABLE+></DIV ></TD ></TR+></TABLE+></TD+></TR ><TR ><TD CLASS="s15" ></TD@@ -4009,9 +4342,28 @@ ></TABLE ></TD ></TR+><TR+><TD CLASS="section4"+><IMG SRC="minus.gif" CLASS="coll" ONCLICK="toggle(this,'i:FIXED')" ALT="show/hide"+> Instances</TD+></TR+><TR+><TD CLASS="body"+><DIV ID="i:FIXED" STYLE="display:block;"+><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0"+><TR+><TD CLASS="decl"+>Eq <A HREF="Text-XML-HaXml-Types.html#t%3AFIXED"+>FIXED</A+></TD+></TR ></TABLE+></DIV ></TD ></TR+></TABLE+></TD+></TR ><TR ><TD CLASS="s15" ></TD@@ -4084,9 +4436,28 @@ ></TABLE ></TD ></TR+><TR+><TD CLASS="section4"+><IMG SRC="minus.gif" CLASS="coll" ONCLICK="toggle(this,'i:ConditionalSect')" ALT="show/hide"+> Instances</TD+></TR+><TR+><TD CLASS="body"+><DIV ID="i:ConditionalSect" STYLE="display:block;"+><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0"+><TR+><TD CLASS="decl"+>Eq <A HREF="Text-XML-HaXml-Types.html#t%3AConditionalSect"+>ConditionalSect</A+></TD+></TR ></TABLE+></DIV ></TD ></TR+></TABLE+></TD+></TR ><TR ><TD CLASS="s15" ></TD@@ -4186,9 +4557,28 @@ ></TABLE ></TD ></TR+><TR+><TD CLASS="section4"+><IMG SRC="minus.gif" CLASS="coll" ONCLICK="toggle(this,'i:Ignore')" ALT="show/hide"+> Instances</TD+></TR+><TR+><TD CLASS="body"+><DIV ID="i:Ignore" STYLE="display:block;"+><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0"+><TR+><TD CLASS="decl"+>Eq <A HREF="Text-XML-HaXml-Types.html#t%3AIgnore"+>Ignore</A+></TD+></TR ></TABLE+></DIV ></TD ></TR+></TABLE+></TD+></TR ><TR ><TD CLASS="s15" ></TD@@ -4242,9 +4632,28 @@ ></TABLE ></TD ></TR+><TR+><TD CLASS="section4"+><IMG SRC="minus.gif" CLASS="coll" ONCLICK="toggle(this,'i:IgnoreSectContents')" ALT="show/hide"+> Instances</TD+></TR+><TR+><TD CLASS="body"+><DIV ID="i:IgnoreSectContents" STYLE="display:block;"+><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0"+><TR+><TD CLASS="decl"+>Eq <A HREF="Text-XML-HaXml-Types.html#t%3AIgnoreSectContents"+>IgnoreSectContents</A+></TD+></TR ></TABLE+></DIV ></TD ></TR+></TABLE+></TD+></TR ><TR ><TD CLASS="s15" ></TD@@ -4501,9 +4910,28 @@ ></TABLE ></TD ></TR+><TR+><TD CLASS="section4"+><IMG SRC="minus.gif" CLASS="coll" ONCLICK="toggle(this,'i:EntityDecl')" ALT="show/hide"+> Instances</TD+></TR+><TR+><TD CLASS="body"+><DIV ID="i:EntityDecl" STYLE="display:block;"+><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0"+><TR+><TD CLASS="decl"+>Eq <A HREF="Text-XML-HaXml-Types.html#t%3AEntityDecl"+>EntityDecl</A+></TD+></TR ></TABLE+></DIV ></TD ></TR+></TABLE+></TD+></TR ><TR ><TD CLASS="s15" ></TD@@ -4555,9 +4983,28 @@ ></TABLE ></TD ></TR+><TR+><TD CLASS="section4"+><IMG SRC="minus.gif" CLASS="coll" ONCLICK="toggle(this,'i:GEDecl')" ALT="show/hide"+> Instances</TD+></TR+><TR+><TD CLASS="body"+><DIV ID="i:GEDecl" STYLE="display:block;"+><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0"+><TR+><TD CLASS="decl"+>Eq <A HREF="Text-XML-HaXml-Types.html#t%3AGEDecl"+>GEDecl</A+></TD+></TR ></TABLE+></DIV ></TD ></TR+></TABLE+></TD+></TR ><TR ><TD CLASS="s15" ></TD@@ -4609,9 +5056,28 @@ ></TABLE ></TD ></TR+><TR+><TD CLASS="section4"+><IMG SRC="minus.gif" CLASS="coll" ONCLICK="toggle(this,'i:PEDecl')" ALT="show/hide"+> Instances</TD+></TR+><TR+><TD CLASS="body"+><DIV ID="i:PEDecl" STYLE="display:block;"+><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0"+><TR+><TD CLASS="decl"+>Eq <A HREF="Text-XML-HaXml-Types.html#t%3APEDecl"+>PEDecl</A+></TD+></TR ></TABLE+></DIV ></TD ></TR+></TABLE+></TD+></TR ><TR ><TD CLASS="s15" ></TD@@ -4675,9 +5141,28 @@ ></TABLE ></TD ></TR+><TR+><TD CLASS="section4"+><IMG SRC="minus.gif" CLASS="coll" ONCLICK="toggle(this,'i:EntityDef')" ALT="show/hide"+> Instances</TD+></TR+><TR+><TD CLASS="body"+><DIV ID="i:EntityDef" STYLE="display:block;"+><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0"+><TR+><TD CLASS="decl"+>Eq <A HREF="Text-XML-HaXml-Types.html#t%3AEntityDef"+>EntityDef</A+></TD+></TR ></TABLE+></DIV ></TD ></TR+></TABLE+></TD+></TR ><TR ><TD CLASS="s15" ></TD@@ -4750,6 +5235,12 @@ ><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0" ><TR ><TD CLASS="decl"+>Eq <A HREF="Text-XML-HaXml-Types.html#t%3APEDef"+>PEDef</A+></TD+></TR+><TR+><TD CLASS="decl" >Show <A HREF="Text-XML-HaXml-Types.html#t%3APEDef" >PEDef</A ></TD@@ -4835,6 +5326,12 @@ ><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0" ><TR ><TD CLASS="decl"+>Eq <A HREF="Text-XML-HaXml-Types.html#t%3AExternalID"+>ExternalID</A+></TD+></TR+><TR+><TD CLASS="decl" >Show <A HREF="Text-XML-HaXml-Types.html#t%3AExternalID" >ExternalID</A ></TD@@ -4895,9 +5392,28 @@ ></TABLE ></TD ></TR+><TR+><TD CLASS="section4"+><IMG SRC="minus.gif" CLASS="coll" ONCLICK="toggle(this,'i:NDataDecl')" ALT="show/hide"+> Instances</TD+></TR+><TR+><TD CLASS="body"+><DIV ID="i:NDataDecl" STYLE="display:block;"+><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0"+><TR+><TD CLASS="decl"+>Eq <A HREF="Text-XML-HaXml-Types.html#t%3ANDataDecl"+>NDataDecl</A+></TD+></TR ></TABLE+></DIV ></TD ></TR+></TABLE+></TD+></TR ><TR ><TD CLASS="s15" ></TD@@ -4949,9 +5465,28 @@ ></TABLE ></TD ></TR+><TR+><TD CLASS="section4"+><IMG SRC="minus.gif" CLASS="coll" ONCLICK="toggle(this,'i:TextDecl')" ALT="show/hide"+> Instances</TD+></TR+><TR+><TD CLASS="body"+><DIV ID="i:TextDecl" STYLE="display:block;"+><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0"+><TR+><TD CLASS="decl"+>Eq <A HREF="Text-XML-HaXml-Types.html#t%3ATextDecl"+>TextDecl</A+></TD+></TR ></TABLE+></DIV ></TD ></TR+></TABLE+></TD+></TR ><TR ><TD CLASS="s15" ></TD@@ -5003,9 +5538,28 @@ ></TABLE ></TD ></TR+><TR+><TD CLASS="section4"+><IMG SRC="minus.gif" CLASS="coll" ONCLICK="toggle(this,'i:ExtParsedEnt')" ALT="show/hide"+> Instances</TD+></TR+><TR+><TD CLASS="body"+><DIV ID="i:ExtParsedEnt" STYLE="display:block;"+><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0"+><TR+><TD CLASS="decl"+>??? i => Eq (<A HREF="Text-XML-HaXml-Types.html#t%3AExtParsedEnt"+>ExtParsedEnt</A+> i)</TD+></TR ></TABLE+></DIV ></TD ></TR+></TABLE+></TD+></TR ><TR ><TD CLASS="s15" ></TD@@ -5057,9 +5611,28 @@ ></TABLE ></TD ></TR+><TR+><TD CLASS="section4"+><IMG SRC="minus.gif" CLASS="coll" ONCLICK="toggle(this,'i:ExtPE')" ALT="show/hide"+> Instances</TD+></TR+><TR+><TD CLASS="body"+><DIV ID="i:ExtPE" STYLE="display:block;"+><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0"+><TR+><TD CLASS="decl"+>Eq <A HREF="Text-XML-HaXml-Types.html#t%3AExtPE"+>ExtPE</A+></TD+></TR ></TABLE+></DIV ></TD ></TR+></TABLE+></TD+></TR ><TR ><TD CLASS="s15" ></TD@@ -5113,9 +5686,28 @@ ></TABLE ></TD ></TR+><TR+><TD CLASS="section4"+><IMG SRC="minus.gif" CLASS="coll" ONCLICK="toggle(this,'i:NotationDecl')" ALT="show/hide"+> Instances</TD+></TR+><TR+><TD CLASS="body"+><DIV ID="i:NotationDecl" STYLE="display:block;"+><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0"+><TR+><TD CLASS="decl"+>Eq <A HREF="Text-XML-HaXml-Types.html#t%3ANotationDecl"+>NotationDecl</A+></TD+></TR ></TABLE+></DIV ></TD ></TR+></TABLE+></TD+></TR ><TR ><TD CLASS="s15" ></TD@@ -5165,9 +5757,28 @@ ></TABLE ></TD ></TR+><TR+><TD CLASS="section4"+><IMG SRC="minus.gif" CLASS="coll" ONCLICK="toggle(this,'i:PublicID')" ALT="show/hide"+> Instances</TD+></TR+><TR+><TD CLASS="body"+><DIV ID="i:PublicID" STYLE="display:block;"+><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0"+><TR+><TD CLASS="decl"+>Eq <A HREF="Text-XML-HaXml-Types.html#t%3APublicID"+>PublicID</A+></TD+></TR ></TABLE+></DIV ></TD ></TR+></TABLE+></TD+></TR ><TR ><TD CLASS="s15" ></TD@@ -5215,9 +5826,28 @@ ></TABLE ></TD ></TR+><TR+><TD CLASS="section4"+><IMG SRC="minus.gif" CLASS="coll" ONCLICK="toggle(this,'i:EncodingDecl')" ALT="show/hide"+> Instances</TD+></TR+><TR+><TD CLASS="body"+><DIV ID="i:EncodingDecl" STYLE="display:block;"+><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0"+><TR+><TD CLASS="decl"+>Eq <A HREF="Text-XML-HaXml-Types.html#t%3AEncodingDecl"+>EncodingDecl</A+></TD+></TR ></TABLE+></DIV ></TD ></TR+></TABLE+></TD+></TR ><TR ><TD CLASS="s15" ></TD@@ -5278,6 +5908,12 @@ ><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0" ><TR ><TD CLASS="decl"+>Eq <A HREF="Text-XML-HaXml-Types.html#t%3AEntityValue"+>EntityValue</A+></TD+></TR+><TR+><TD CLASS="decl" >Show <A HREF="Text-XML-HaXml-Types.html#t%3AEntityValue" >EntityValue</A ></TD@@ -5359,6 +5995,12 @@ ><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0" ><TR ><TD CLASS="decl"+>Eq <A HREF="Text-XML-HaXml-Types.html#t%3AEV"+>EV</A+></TD+></TR+><TR+><TD CLASS="decl" >Show <A HREF="Text-XML-HaXml-Types.html#t%3AEV" >EV</A ></TD@@ -5428,6 +6070,12 @@ ><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0" ><TR ><TD CLASS="decl"+>Eq <A HREF="Text-XML-HaXml-Types.html#t%3APubidLiteral"+>PubidLiteral</A+></TD+></TR+><TR+><TD CLASS="decl" >Show <A HREF="Text-XML-HaXml-Types.html#t%3APubidLiteral" >PubidLiteral</A ></TD@@ -5495,6 +6143,12 @@ ><TD CLASS="body" ><DIV ID="i:SystemLiteral" STYLE="display:block;" ><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0"+><TR+><TD CLASS="decl"+>Eq <A HREF="Text-XML-HaXml-Types.html#t%3ASystemLiteral"+>SystemLiteral</A+></TD+></TR ><TR ><TD CLASS="decl" >Show <A HREF="Text-XML-HaXml-Types.html#t%3ASystemLiteral"
docs/HaXml/Text-XML-HaXml-XmlContent.html view
@@ -1236,6 +1236,12 @@ >Document</A ></TD ></TR+><TR+><TD CLASS="decl"+>??? i => Eq (<A HREF="Text-XML-HaXml-XmlContent.html#t%3ADocument"+>Document</A+> i)</TD+></TR ></TABLE ></DIV ></TD@@ -1313,6 +1319,12 @@ ></TR ><TR ><TD CLASS="decl"+>??? i => Eq (<A HREF="Text-XML-HaXml-XmlContent.html#t%3AElement"+>Element</A+> i)</TD+></TR+><TR+><TD CLASS="decl" ><A HREF="Text-XML-HaXml-Verbatim.html#t%3AVerbatim" >Verbatim</A > (<A HREF="Text-XML-HaXml-XmlContent.html#t%3AElement"@@ -1372,8 +1384,7 @@ >Attribute</A >]</TD ><TD CLASS="rdoc"->intermediate for parsing-</TD+></TD ></TR ></TABLE ></TD@@ -1503,6 +1514,12 @@ ></TR ><TR ><TD CLASS="decl"+>(Eq i, ??? i) => Eq (<A HREF="Text-XML-HaXml-XmlContent.html#t%3AContent"+>Content</A+> i)</TD+></TR+><TR+><TD CLASS="decl" ><A HREF="Text-XML-HaXml-Verbatim.html#t%3AVerbatim" >Verbatim</A > (<A HREF="Text-XML-HaXml-XmlContent.html#t%3AContent"@@ -1674,6 +1691,25 @@ ></TD ></TR ></TABLE+></TD+></TR+><TR+><TD CLASS="section4"+><IMG SRC="minus.gif" CLASS="coll" ONCLICK="toggle(this,'i:Prolog')" ALT="show/hide"+> Instances</TD+></TR+><TR+><TD CLASS="body"+><DIV ID="i:Prolog" STYLE="display:block;"+><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0"+><TR+><TD CLASS="decl"+>Eq <A HREF="Text-XML-HaXml-XmlContent.html#t%3AProlog"+>Prolog</A+></TD+></TR+></TABLE+></DIV ></TD ></TR ></TABLE
− docs/HaXml/doc-index-43.html
@@ -1,198 +0,0 @@-<!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->HaXml (Index)</TITLE-><LINK HREF="haddock.css" REL="stylesheet" TYPE="text/css"-></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"->HaXml</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-><TABLE CELLPADDING="0" CELLSPACING="5"-><TR-><TD-><A HREF="doc-index-A.html"->A</A-></TD-><TD-><A HREF="doc-index-B.html"->B</A-></TD-><TD-><A HREF="doc-index-C.html"->C</A-></TD-><TD-><A HREF="doc-index-D.html"->D</A-></TD-><TD-><A HREF="doc-index-E.html"->E</A-></TD-><TD-><A HREF="doc-index-F.html"->F</A-></TD-><TD-><A HREF="doc-index-G.html"->G</A-></TD-><TD-><A HREF="doc-index-H.html"->H</A-></TD-><TD-><A HREF="doc-index-I.html"->I</A-></TD-><TD-><A HREF="doc-index-J.html"->J</A-></TD-><TD-><A HREF="doc-index-K.html"->K</A-></TD-><TD-><A HREF="doc-index-L.html"->L</A-></TD-><TD-><A HREF="doc-index-M.html"->M</A-></TD-><TD-><A HREF="doc-index-N.html"->N</A-></TD-><TD-><A HREF="doc-index-O.html"->O</A-></TD-><TD-><A HREF="doc-index-P.html"->P</A-></TD-><TD-><A HREF="doc-index-Q.html"->Q</A-></TD-><TD-><A HREF="doc-index-R.html"->R</A-></TD-><TD-><A HREF="doc-index-S.html"->S</A-></TD-><TD-><A HREF="doc-index-T.html"->T</A-></TD-><TD-><A HREF="doc-index-U.html"->U</A-></TD-><TD-><A HREF="doc-index-V.html"->V</A-></TD-><TD-><A HREF="doc-index-W.html"->W</A-></TD-><TD-><A HREF="doc-index-X.html"->X</A-></TD-><TD-><A HREF="doc-index-58.html"->:</A-></TD-><TD-><A HREF="doc-index-33.html"->!</A-></TD-><TD-><A HREF="doc-index-43.html"->+</A-></TD-><TD-><A HREF="doc-index-47.html"->/</A-></TD-><TD-><A HREF="doc-index-60.html"-><</A-></TD-><TD-><A HREF="doc-index-63.html"->?</A-></TD-><TD-><A HREF="doc-index-124.html"->|</A-></TD-></TR-></TABLE-></TD-></TR-><TR-><TD CLASS="section1"->Index (+)</TD-></TR-><TR-><TD-><TABLE CELLPADDING="0" CELLSPACING="5"-><TR-><TD CLASS="indexentry" COLSPAN="2"->+++</TD-></TR-><TR-><TD CLASS="indexannot"->1 (Function)</TD-><TD CLASS="indexlinks"-><A HREF="Text-ParserCombinators-HuttonMeijer.html#v%3A%2B%2B%2B"->Text.ParserCombinators.HuttonMeijer</A-></TD-></TR-><TR-><TD CLASS="indexannot"->2 (Function)</TD-><TD CLASS="indexlinks"-><A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#v%3A%2B%2B%2B"->Text.ParserCombinators.HuttonMeijerWallace</A-></TD-></TR-></TABLE-></TD-></TR-></TABLE-></BODY-></HTML->
− docs/HaXml/doc-index-J.html
@@ -1,186 +0,0 @@-<!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->HaXml (Index)</TITLE-><LINK HREF="haddock.css" REL="stylesheet" TYPE="text/css"-></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"->HaXml</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-><TABLE CELLPADDING="0" CELLSPACING="5"-><TR-><TD-><A HREF="doc-index-A.html"->A</A-></TD-><TD-><A HREF="doc-index-B.html"->B</A-></TD-><TD-><A HREF="doc-index-C.html"->C</A-></TD-><TD-><A HREF="doc-index-D.html"->D</A-></TD-><TD-><A HREF="doc-index-E.html"->E</A-></TD-><TD-><A HREF="doc-index-F.html"->F</A-></TD-><TD-><A HREF="doc-index-G.html"->G</A-></TD-><TD-><A HREF="doc-index-H.html"->H</A-></TD-><TD-><A HREF="doc-index-I.html"->I</A-></TD-><TD-><A HREF="doc-index-J.html"->J</A-></TD-><TD-><A HREF="doc-index-K.html"->K</A-></TD-><TD-><A HREF="doc-index-L.html"->L</A-></TD-><TD-><A HREF="doc-index-M.html"->M</A-></TD-><TD-><A HREF="doc-index-N.html"->N</A-></TD-><TD-><A HREF="doc-index-O.html"->O</A-></TD-><TD-><A HREF="doc-index-P.html"->P</A-></TD-><TD-><A HREF="doc-index-Q.html"->Q</A-></TD-><TD-><A HREF="doc-index-R.html"->R</A-></TD-><TD-><A HREF="doc-index-S.html"->S</A-></TD-><TD-><A HREF="doc-index-T.html"->T</A-></TD-><TD-><A HREF="doc-index-U.html"->U</A-></TD-><TD-><A HREF="doc-index-V.html"->V</A-></TD-><TD-><A HREF="doc-index-W.html"->W</A-></TD-><TD-><A HREF="doc-index-X.html"->X</A-></TD-><TD-><A HREF="doc-index-58.html"->:</A-></TD-><TD-><A HREF="doc-index-33.html"->!</A-></TD-><TD-><A HREF="doc-index-43.html"->+</A-></TD-><TD-><A HREF="doc-index-47.html"->/</A-></TD-><TD-><A HREF="doc-index-60.html"-><</A-></TD-><TD-><A HREF="doc-index-63.html"->?</A-></TD-><TD-><A HREF="doc-index-124.html"->|</A-></TD-></TR-></TABLE-></TD-></TR-><TR-><TD CLASS="section1"->Index (J)</TD-></TR-><TR-><TD-><TABLE CELLPADDING="0" CELLSPACING="5"-><TR-><TD CLASS="indexentry"->junk</TD-><TD CLASS="indexlinks"-><A HREF="Text-ParserCombinators-HuttonMeijer.html#v%3Ajunk"->Text.ParserCombinators.HuttonMeijer</A-></TD-></TR-></TABLE-></TD-></TR-></TABLE-></BODY-></HTML->
docs/HaXml/doc-index-S.html view
@@ -638,14 +638,6 @@ ></TD ></TR ><TR-><TD CLASS="indexentry"->Synonym</TD-><TD CLASS="indexlinks"-><A HREF="Text-XML-HaXml-TypeMapping.html#v%3ASynonym"->Text.XML.HaXml.TypeMapping</A->, Text.XML.HaXml.XmlContent</TD-></TR-><TR ><TD CLASS="indexentry" COLSPAN="2" >SystemLiteral</TD ></TR
− docs/HaXml/src/Text/ParserCombinators/HuttonMeijer.html
@@ -1,219 +0,0 @@-<pre><font color=Blue>-----------------------------------------------------------------------------</font>-<font color=Blue>-- |</font>-<font color=Blue>-- Module : Text.ParserCombinators.HuttonMeijer</font>-<font color=Blue>-- Copyright : Graham Hutton (University of Nottingham), Erik Meijer (University of Utrecht)</font>-<font color=Blue>-- Licence : BSD</font>-<font color=Blue>-- </font>-<font color=Blue>-- Maintainer : Malcolm Wallace <Malcolm.Wallace@cs.york.ac.uk></font>-<font color=Blue>-- Stability : Stable</font>-<font color=Blue>-- Portability : All</font>-<font color=Blue>--</font>-<font color=Blue>-- A LIBRARY OF MONADIC PARSER COMBINATORS</font>-<font color=Blue>-- </font>-<font color=Blue>-- 29th July 1996</font>-<font color=Blue>-- </font>-<font color=Blue>-- Graham Hutton Erik Meijer</font>-<font color=Blue>-- University of Nottingham University of Utrecht</font>-<font color=Blue>-- </font>-<font color=Blue>-- This Haskell script defines a library of parser combinators, and is</font>-<font color=Blue>-- taken from sections 1-6 of our article "Monadic Parser Combinators".</font>-<font color=Blue>-- Some changes to the library have been made in the move from Gofer</font>-<font color=Blue>-- to Haskell:</font>-<font color=Blue>-- </font>-<font color=Blue>-- * Do notation is used in place of monad comprehension notation;</font>-<font color=Blue>-- </font>-<font color=Blue>-- * The parser datatype is defined using "newtype", to avoid the overhead</font>-<font color=Blue>-- of tagging and untagging parsers with the P constructor.</font>-<font color=Blue>-----------------------------------------------------------------------------</font>---<font color=Green><u>module</u></font> Text<font color=Cyan>.</font>ParserCombinators<font color=Cyan>.</font>HuttonMeijer- <font color=Cyan>(</font>Parser<font color=Cyan>(</font><font color=Red>..</font><font color=Cyan>)</font><font color=Cyan>,</font> item<font color=Cyan>,</font> first<font color=Cyan>,</font> papply<font color=Cyan>,</font> <font color=Cyan>(</font><font color=Cyan>+++</font><font color=Cyan>)</font><font color=Cyan>,</font> sat<font color=Cyan>,</font> <font color=Blue>{-tok,-}</font> many<font color=Cyan>,</font> many1<font color=Cyan>,</font>- sepby<font color=Cyan>,</font> sepby1<font color=Cyan>,</font> chainl<font color=Cyan>,</font>- chainl1<font color=Cyan>,</font> chainr<font color=Cyan>,</font> chainr1<font color=Cyan>,</font> ops<font color=Cyan>,</font> bracket<font color=Cyan>,</font> char<font color=Cyan>,</font> digit<font color=Cyan>,</font> lower<font color=Cyan>,</font> upper<font color=Cyan>,</font>- letter<font color=Cyan>,</font> alphanum<font color=Cyan>,</font> string<font color=Cyan>,</font> ident<font color=Cyan>,</font> nat<font color=Cyan>,</font> int<font color=Cyan>,</font> spaces<font color=Cyan>,</font> comment<font color=Cyan>,</font> junk<font color=Cyan>,</font>- skip<font color=Cyan>,</font> token<font color=Cyan>,</font> natural<font color=Cyan>,</font> integer<font color=Cyan>,</font> symbol<font color=Cyan>,</font> identifier<font color=Cyan>)</font> <font color=Green><u>where</u></font>--<font color=Green><u>import</u></font> Char-<font color=Green><u>import</u></font> Monad--<font color=Green><u>infixr</u></font> <font color=Magenta>5</font> <font color=Cyan>+++</font>--<a name="Token"></a><font color=Green><u>type</u></font> Token <font color=Red>=</font> Char--<font color=Blue>---------------------------------------------------------</font>-<font color=Blue>-- | The parser monad</font>--<font color=Green><u>newtype</u></font> Parser a <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>[</font>Token<font color=Red>]</font> <font color=Red>-></font> <font color=Red>[</font><font color=Cyan>(</font>a<font color=Cyan>,</font><font color=Red>[</font>Token<font color=Red>]</font><font color=Cyan>)</font><font color=Red>]</font><font color=Cyan>)</font>--<font color=Green><u>instance</u></font> Functor Parser <font color=Green><u>where</u></font>- <font color=Blue>-- map :: (a -> b) -> (Parser a -> Parser b)</font>- fmap f <font color=Cyan>(</font>P p<font color=Cyan>)</font> <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>inp <font color=Red>-></font> <font color=Red>[</font><font color=Cyan>(</font>f v<font color=Cyan>,</font> out<font color=Cyan>)</font> <font color=Red>|</font> <font color=Cyan>(</font>v<font color=Cyan>,</font>out<font color=Cyan>)</font> <font color=Red><-</font> p inp<font color=Red>]</font><font color=Cyan>)</font>--<font color=Green><u>instance</u></font> Monad Parser <font color=Green><u>where</u></font>- <font color=Blue>-- return :: a -> Parser a</font>- return v <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>inp <font color=Red>-></font> <font color=Red>[</font><font color=Cyan>(</font>v<font color=Cyan>,</font>inp<font color=Cyan>)</font><font color=Red>]</font><font color=Cyan>)</font>-- <font color=Blue>-- >>= :: Parser a -> (a -> Parser b) -> Parser b</font>- <font color=Cyan>(</font>P p<font color=Cyan>)</font> <font color=Cyan>>>=</font> f <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>inp <font color=Red>-></font> concat <font color=Red>[</font>papply <font color=Cyan>(</font>f v<font color=Cyan>)</font> out <font color=Red>|</font> <font color=Cyan>(</font>v<font color=Cyan>,</font>out<font color=Cyan>)</font> <font color=Red><-</font> p inp<font color=Red>]</font><font color=Cyan>)</font>-- <font color=Blue>-- fail :: String -> Parser a</font>- fail <font color=Green><u>_</u></font> <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font><font color=Green><u>_</u></font> <font color=Red>-></font> <font color=Red>[</font><font color=Red>]</font><font color=Cyan>)</font>--<font color=Green><u>instance</u></font> MonadPlus Parser <font color=Green><u>where</u></font>- <font color=Blue>-- mzero :: Parser a</font>- mzero <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font><font color=Green><u>_</u></font> <font color=Red>-></font> <font color=Red>[</font><font color=Red>]</font><font color=Cyan>)</font>-- <font color=Blue>-- mplus :: Parser a -> Parser a -> Parser a</font>- <font color=Cyan>(</font>P p<font color=Cyan>)</font> <font color=Cyan>`mplus`</font> <font color=Cyan>(</font>P q<font color=Cyan>)</font> <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>inp <font color=Red>-></font> <font color=Cyan>(</font>p inp <font color=Cyan>++</font> q inp<font color=Cyan>)</font><font color=Cyan>)</font>--<font color=Blue>-- ------------------------------------------------------------</font>-<font color=Blue>-- * Other primitive parser combinators</font>-<font color=Blue>-- ------------------------------------------------------------</font>--item <font color=Red>::</font> Parser Token-<a name="item"></a>item <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>inp <font color=Red>-></font> <font color=Green><u>case</u></font> inp <font color=Green><u>of</u></font>- <font color=Red>[</font><font color=Red>]</font> <font color=Red>-></font> <font color=Red>[</font><font color=Red>]</font>- <font color=Cyan>(</font>x<font color=Red><b>:</b></font>xs<font color=Cyan>)</font> <font color=Red>-></font> <font color=Red>[</font><font color=Cyan>(</font>x<font color=Cyan>,</font>xs<font color=Cyan>)</font><font color=Red>]</font><font color=Cyan>)</font>--first <font color=Red>::</font> Parser a <font color=Red>-></font> Parser a-<a name="first"></a>first <font color=Cyan>(</font>P p<font color=Cyan>)</font> <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>inp <font color=Red>-></font> <font color=Green><u>case</u></font> p inp <font color=Green><u>of</u></font>- <font color=Red>[</font><font color=Red>]</font> <font color=Red>-></font> <font color=Red>[</font><font color=Red>]</font>- <font color=Cyan>(</font>x<font color=Red><b>:</b></font><font color=Green><u>_</u></font><font color=Cyan>)</font> <font color=Red>-></font> <font color=Red>[</font>x<font color=Red>]</font><font color=Cyan>)</font>--papply <font color=Red>::</font> Parser a <font color=Red>-></font> <font color=Red>[</font>Token<font color=Red>]</font> <font color=Red>-></font> <font color=Red>[</font><font color=Cyan>(</font>a<font color=Cyan>,</font><font color=Red>[</font>Token<font color=Red>]</font><font color=Cyan>)</font><font color=Red>]</font>-<a name="papply"></a>papply <font color=Cyan>(</font>P p<font color=Cyan>)</font> inp <font color=Red>=</font> p inp--<font color=Blue>-- ------------------------------------------------------------</font>-<font color=Blue>-- * Derived combinators</font>-<font color=Blue>-- ------------------------------------------------------------</font>--<a name="+++"></a><font color=Cyan>(</font><font color=Cyan>+++</font><font color=Cyan>)</font> <font color=Red>::</font> Parser a <font color=Red>-></font> Parser a <font color=Red>-></font> Parser a-<a name="p"></a>p <font color=Cyan>+++</font> q <font color=Red>=</font> first <font color=Cyan>(</font>p <font color=Cyan>`mplus`</font> q<font color=Cyan>)</font>--sat <font color=Red>::</font> <font color=Cyan>(</font>Token <font color=Red>-></font> Bool<font color=Cyan>)</font> <font color=Red>-></font> Parser Token-<a name="sat"></a>sat p <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font>x <font color=Red><-</font> item<font color=Cyan>;</font> <font color=Green><u>if</u></font> p x <font color=Green><u>then</u></font> return x <font color=Green><u>else</u></font> mzero<font color=Cyan>}</font>--<font color=Blue>--tok :: Token -> Parser Token</font>-<font color=Blue>--tok t = do {x <- item; if t==snd x then return t else mzero}</font>--many <font color=Red>::</font> Parser a <font color=Red>-></font> Parser <font color=Red>[</font>a<font color=Red>]</font>-<a name="many"></a>many p <font color=Red>=</font> many1 p <font color=Cyan>+++</font> return <font color=Red>[</font><font color=Red>]</font>-<font color=Blue>--many p = force (many1 p +++ return [])</font>--many1 <font color=Red>::</font> Parser a <font color=Red>-></font> Parser <font color=Red>[</font>a<font color=Red>]</font>-<a name="many1"></a>many1 p <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font>x <font color=Red><-</font> p<font color=Cyan>;</font> xs <font color=Red><-</font> many p<font color=Cyan>;</font> return <font color=Cyan>(</font>x<font color=Red><b>:</b></font>xs<font color=Cyan>)</font><font color=Cyan>}</font>--sepby <font color=Red>::</font> Parser a <font color=Red>-></font> Parser b <font color=Red>-></font> Parser <font color=Red>[</font>a<font color=Red>]</font>-<a name="sepby"></a>p <font color=Cyan>`sepby`</font> sep <font color=Red>=</font> <font color=Cyan>(</font>p <font color=Cyan>`sepby1`</font> sep<font color=Cyan>)</font> <font color=Cyan>+++</font> return <font color=Red>[</font><font color=Red>]</font>--sepby1 <font color=Red>::</font> Parser a <font color=Red>-></font> Parser b <font color=Red>-></font> Parser <font color=Red>[</font>a<font color=Red>]</font>-<a name="sepby1"></a>p <font color=Cyan>`sepby1`</font> sep <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font>x <font color=Red><-</font> p<font color=Cyan>;</font> xs <font color=Red><-</font> many <font color=Cyan>(</font><font color=Green><u>do</u></font> <font color=Cyan>{</font>sep<font color=Cyan>;</font> p<font color=Cyan>}</font><font color=Cyan>)</font><font color=Cyan>;</font> return <font color=Cyan>(</font>x<font color=Red><b>:</b></font>xs<font color=Cyan>)</font><font color=Cyan>}</font>--chainl <font color=Red>::</font> Parser a <font color=Red>-></font> Parser <font color=Cyan>(</font>a <font color=Red>-></font> a <font color=Red>-></font> a<font color=Cyan>)</font> <font color=Red>-></font> a <font color=Red>-></font> Parser a-<a name="chainl"></a>chainl p op v <font color=Red>=</font> <font color=Cyan>(</font>p <font color=Cyan>`chainl1`</font> op<font color=Cyan>)</font> <font color=Cyan>+++</font> return v--chainl1 <font color=Red>::</font> Parser a <font color=Red>-></font> Parser <font color=Cyan>(</font>a <font color=Red>-></font> a <font color=Red>-></font> a<font color=Cyan>)</font> <font color=Red>-></font> Parser a-<a name="chainl1"></a>p <font color=Cyan>`chainl1`</font> op <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font>x <font color=Red><-</font> p<font color=Cyan>;</font> rest x<font color=Cyan>}</font>- <font color=Green><u>where</u></font>- rest x <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font>f <font color=Red><-</font> op<font color=Cyan>;</font> y <font color=Red><-</font> p<font color=Cyan>;</font> rest <font color=Cyan>(</font>f x y<font color=Cyan>)</font><font color=Cyan>}</font>- <font color=Cyan>+++</font> return x--chainr <font color=Red>::</font> Parser a <font color=Red>-></font> Parser <font color=Cyan>(</font>a <font color=Red>-></font> a <font color=Red>-></font> a<font color=Cyan>)</font> <font color=Red>-></font> a <font color=Red>-></font> Parser a-<a name="chainr"></a>chainr p op v <font color=Red>=</font> <font color=Cyan>(</font>p <font color=Cyan>`chainr1`</font> op<font color=Cyan>)</font> <font color=Cyan>+++</font> return v--chainr1 <font color=Red>::</font> Parser a <font color=Red>-></font> Parser <font color=Cyan>(</font>a <font color=Red>-></font> a <font color=Red>-></font> a<font color=Cyan>)</font> <font color=Red>-></font> Parser a-<a name="chainr1"></a>p <font color=Cyan>`chainr1`</font> op <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font>x <font color=Red><-</font> p<font color=Cyan>;</font> rest x<font color=Cyan>}</font>- <font color=Green><u>where</u></font>- rest x <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font>f <font color=Red><-</font> op<font color=Cyan>;</font> y <font color=Red><-</font> p <font color=Cyan>`chainr1`</font> op<font color=Cyan>;</font> return <font color=Cyan>(</font>f x y<font color=Cyan>)</font><font color=Cyan>}</font>- <font color=Cyan>+++</font> return x--ops <font color=Red>::</font> <font color=Red>[</font><font color=Cyan>(</font>Parser a<font color=Cyan>,</font> b<font color=Cyan>)</font><font color=Red>]</font> <font color=Red>-></font> Parser b-<a name="ops"></a>ops xs <font color=Red>=</font> foldr1 <font color=Cyan>(</font><font color=Cyan>+++</font><font color=Cyan>)</font> <font color=Red>[</font><font color=Green><u>do</u></font> <font color=Cyan>{</font>p<font color=Cyan>;</font> return op<font color=Cyan>}</font> <font color=Red>|</font> <font color=Cyan>(</font>p<font color=Cyan>,</font>op<font color=Cyan>)</font> <font color=Red><-</font> xs<font color=Red>]</font>--bracket <font color=Red>::</font> Parser a <font color=Red>-></font> Parser b <font color=Red>-></font> Parser c <font color=Red>-></font> Parser b-<a name="bracket"></a>bracket open p close <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font>open<font color=Cyan>;</font> x <font color=Red><-</font> p<font color=Cyan>;</font> close<font color=Cyan>;</font> return x<font color=Cyan>}</font>--<font color=Blue>-- ------------------------------------------------------------</font>-<font color=Blue>-- * Useful parsers</font>-<font color=Blue>-- ------------------------------------------------------------</font>--char <font color=Red>::</font> Char <font color=Red>-></font> Parser Char-<a name="char"></a>char x <font color=Red>=</font> sat <font color=Cyan>(</font><font color=Red>\</font>y <font color=Red>-></font> x <font color=Cyan>==</font> y<font color=Cyan>)</font>--digit <font color=Red>::</font> Parser Char-<a name="digit"></a>digit <font color=Red>=</font> sat isDigit--lower <font color=Red>::</font> Parser Char-<a name="lower"></a>lower <font color=Red>=</font> sat isLower--upper <font color=Red>::</font> Parser Char-<a name="upper"></a>upper <font color=Red>=</font> sat isUpper--letter <font color=Red>::</font> Parser Char-<a name="letter"></a>letter <font color=Red>=</font> sat isAlpha--alphanum <font color=Red>::</font> Parser Char-<a name="alphanum"></a>alphanum <font color=Red>=</font> sat isAlphaNum <font color=Cyan>+++</font> char <font color=Magenta>'_'</font>--string <font color=Red>::</font> String <font color=Red>-></font> Parser String-<a name="string"></a>string <font color=Magenta>""</font> <font color=Red>=</font> return <font color=Magenta>""</font>-string <font color=Cyan>(</font>x<font color=Red><b>:</b></font>xs<font color=Cyan>)</font> <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font>char x<font color=Cyan>;</font> string xs<font color=Cyan>;</font> return <font color=Cyan>(</font>x<font color=Red><b>:</b></font>xs<font color=Cyan>)</font><font color=Cyan>}</font>--ident <font color=Red>::</font> Parser String-<a name="ident"></a>ident <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font>x <font color=Red><-</font> lower<font color=Cyan>;</font> xs <font color=Red><-</font> many alphanum<font color=Cyan>;</font> return <font color=Cyan>(</font>x<font color=Red><b>:</b></font>xs<font color=Cyan>)</font><font color=Cyan>}</font>--nat <font color=Red>::</font> Parser Int-<a name="nat"></a>nat <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font>x <font color=Red><-</font> digit<font color=Cyan>;</font> return <font color=Cyan>(</font>fromEnum x <font color=Blue>-</font> fromEnum <font color=Magenta>'0'</font><font color=Cyan>)</font><font color=Cyan>}</font> <font color=Cyan>`chainl1`</font> return op- <font color=Green><u>where</u></font>- m <font color=Cyan>`op`</font> n <font color=Red>=</font> <font color=Magenta>10</font><font color=Cyan>*</font>m <font color=Cyan>+</font> n--int <font color=Red>::</font> Parser Int-<a name="int"></a>int <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font>char <font color=Magenta>'-'</font><font color=Cyan>;</font> n <font color=Red><-</font> nat<font color=Cyan>;</font> return <font color=Cyan>(</font><font color=Blue>-</font>n<font color=Cyan>)</font><font color=Cyan>}</font> <font color=Cyan>+++</font> nat--<font color=Blue>-- ------------------------------------------------------------</font>-<font color=Blue>-- * Lexical combinators</font>-<font color=Blue>-- ------------------------------------------------------------</font>--spaces <font color=Red>::</font> Parser <font color=Cyan>(</font><font color=Cyan>)</font>-<a name="spaces"></a>spaces <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font>many1 <font color=Cyan>(</font>sat isSpace<font color=Cyan>)</font><font color=Cyan>;</font> return <font color=Cyan>(</font><font color=Cyan>)</font><font color=Cyan>}</font>--comment <font color=Red>::</font> Parser <font color=Cyan>(</font><font color=Cyan>)</font>-<font color=Blue>--comment = do {string "--"; many (sat (\x -> x /= '\n')); return ()}</font>-<font color=Blue>--comment = do </font>-<font color=Blue>-- _ <- string "--"</font>-<font color=Blue>-- _ <- many (sat (\x -> x /= '\n'))</font>-<font color=Blue>-- return ()</font>-<a name="comment"></a>comment <font color=Red>=</font> <font color=Green><u>do</u></font>- bracket <font color=Cyan>(</font>string <font color=Magenta>"/*"</font><font color=Cyan>)</font> <font color=Cyan>(</font>many item<font color=Cyan>)</font> <font color=Cyan>(</font>string <font color=Magenta>"*/"</font><font color=Cyan>)</font>- return <font color=Cyan>(</font><font color=Cyan>)</font>--junk <font color=Red>::</font> Parser <font color=Cyan>(</font><font color=Cyan>)</font>-<a name="junk"></a>junk <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font>many <font color=Cyan>(</font>spaces <font color=Cyan>+++</font> comment<font color=Cyan>)</font><font color=Cyan>;</font> return <font color=Cyan>(</font><font color=Cyan>)</font><font color=Cyan>}</font>--skip <font color=Red>::</font> Parser a <font color=Red>-></font> Parser a-<a name="skip"></a>skip p <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font>junk<font color=Cyan>;</font> p<font color=Cyan>}</font>--token <font color=Red>::</font> Parser a <font color=Red>-></font> Parser a-<a name="token"></a>token p <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font>v <font color=Red><-</font> p<font color=Cyan>;</font> junk<font color=Cyan>;</font> return v<font color=Cyan>}</font>--<font color=Blue>-- ------------------------------------------------------------</font>-<font color=Blue>-- * Token parsers</font>-<font color=Blue>-- ------------------------------------------------------------</font>--natural <font color=Red>::</font> Parser Int-<a name="natural"></a>natural <font color=Red>=</font> token nat--integer <font color=Red>::</font> Parser Int-<a name="integer"></a>integer <font color=Red>=</font> token int--symbol <font color=Red>::</font> String <font color=Red>-></font> Parser String-<a name="symbol"></a>symbol xs <font color=Red>=</font> token <font color=Cyan>(</font>string xs<font color=Cyan>)</font>--identifier <font color=Red>::</font> <font color=Red>[</font>String<font color=Red>]</font> <font color=Red>-></font> Parser String-<a name="identifier"></a>identifier ks <font color=Red>=</font> token <font color=Cyan>(</font><font color=Green><u>do</u></font> <font color=Cyan>{</font>x <font color=Red><-</font> ident<font color=Cyan>;</font>- <font color=Green><u>if</u></font> not <font color=Cyan>(</font>elem x ks<font color=Cyan>)</font> <font color=Green><u>then</u></font> return x- <font color=Green><u>else</u></font> return mzero<font color=Cyan>}</font><font color=Cyan>)</font>--<font color=Blue>------------------------------------------------------------------------------</font>-</pre>
− docs/HaXml/src/Text/ParserCombinators/HuttonMeijerWallace.html
@@ -1,298 +0,0 @@-<pre><font color=Cyan>{</font><font color=Blue>-----------------------------------------------------------------------------</font>-- A LIBRARY OF MONADIC PARSER COMBINATORS-- <font color=Magenta>29</font>th July <font color=Magenta>1996</font>-- Graham Hutton Erik Meijer- University <font color=Green><u>of</u></font> Nottingham University <font color=Green><u>of</u></font> Utrecht--This Haskell <font color=Magenta>1.3</font> script defines a library <font color=Green><u>of</u></font> parser combinators<font color=Cyan>,</font> and is taken-<a name="from"></a>from sections <font color=Magenta>1</font><font color=Blue>-</font><font color=Magenta>6</font> <font color=Green><u>of</u></font> our article <font color=Magenta>"Monadic Parser Combinators"</font><font color=Cyan>.</font> Some changes-<a name="to"></a>to the library have been made <font color=Green><u>in</u></font> the move from Gofer to Haskell<font color=Red><b>:</b></font>-- <font color=Cyan>*</font> Do notation is used <font color=Green><u>in</u></font> place <font color=Green><u>of</u></font> monad comprehension notation<font color=Cyan>;</font>-- <font color=Cyan>*</font> The parser datatype is defined using <font color=Magenta>"newtype"</font><font color=Cyan>,</font> to avoid the overhead- <font color=Green><u>of</u></font> tagging and untagging parsers with the P constructor<font color=Cyan>.</font>--<font color=Blue>------------------------------------------------------------------------------</font>-<font color=Cyan>**</font> Extended to allow a symbol table<font color=Cyan>/</font>state to be threaded through the monad<font color=Cyan>.</font>-<font color=Cyan>**</font> Extended to allow a parameterised token <font color=Green><u>type</u></font><font color=Cyan>,</font> rather than just strings<font color=Cyan>.</font>-<font color=Cyan>**</font> Extended to allow error<font color=Blue>-</font>reporting<font color=Cyan>.</font>--<font color=Cyan>(</font>Extensions<font color=Red><b>:</b></font> <font color=Magenta>1998</font><font color=Blue>-</font><font color=Magenta>2000</font> Malcolm<font color=Cyan>.</font>Wallace<font color=Red>@</font>cs<font color=Cyan>.</font>york<font color=Cyan>.</font>ac<font color=Cyan>.</font>uk<font color=Cyan>)</font>-<a name="------------------------------------------------------------------------------}"></a><font color=Cyan>(</font>More extensions<font color=Red><b>:</b></font> <font color=Magenta>2004</font> gk<font color=Blue>-</font>haskell<font color=Red>@</font>ninebynine<font color=Cyan>.</font>org<font color=Cyan>)</font>--<font color=Cyan>------------------------------------------------------------------------------}</font>--<font color=Blue>-- | This library of monadic parser combinators is based on the ones</font>-<font color=Blue>-- defined by Graham Hutton and Erik Meijer. It has been extended by</font>-<font color=Blue>-- Malcolm Wallace to use an abstract token type (no longer just a</font>-<font color=Blue>-- string) as input, and to incorporate a State Transformer monad, useful</font>-<font color=Blue>-- for symbol tables, macros, and so on. Basic facilities for error</font>-<font color=Blue>-- reporting have also been added, and later extended by Graham Klyne</font>-<font color=Blue>-- to return the errors through an @Either@ type, rather than just</font>-<font color=Blue>-- calling @error@.</font>--<font color=Green><u>module</u></font> Text<font color=Cyan>.</font>ParserCombinators<font color=Cyan>.</font>HuttonMeijerWallace- <font color=Cyan>(</font>- <font color=Blue>-- * The parser monad</font>- Parser<font color=Cyan>(</font><font color=Red>..</font><font color=Cyan>)</font>- <font color=Blue>-- * Primitive parser combinators</font>- <font color=Cyan>,</font> item<font color=Cyan>,</font> eof<font color=Cyan>,</font> papply<font color=Cyan>,</font> papply'- <font color=Blue>-- * Derived combinators</font>- <font color=Cyan>,</font> <font color=Cyan>(</font><font color=Cyan>+++</font><font color=Cyan>)</font><font color=Cyan>,</font> <font color=Blue>{-sat,-}</font> tok<font color=Cyan>,</font> nottok<font color=Cyan>,</font> many<font color=Cyan>,</font> many1- <font color=Cyan>,</font> sepby<font color=Cyan>,</font> sepby1<font color=Cyan>,</font> chainl<font color=Cyan>,</font> chainl1<font color=Cyan>,</font> chainr<font color=Cyan>,</font> chainr1<font color=Cyan>,</font> ops<font color=Cyan>,</font> bracket- <font color=Cyan>,</font> toEOF- <font color=Blue>-- * Error handling</font>- <font color=Cyan>,</font> elserror- <font color=Blue>-- * State handling</font>- <font color=Cyan>,</font> stupd<font color=Cyan>,</font> stquery<font color=Cyan>,</font> stget- <font color=Blue>-- * Re-parsing</font>- <font color=Cyan>,</font> reparse- <font color=Cyan>)</font> <font color=Green><u>where</u></font>--<font color=Green><u>import</u></font> Char-<font color=Green><u>import</u></font> Monad--<font color=Green><u>infixr</u></font> <font color=Magenta>5</font> <font color=Cyan>+++</font>--<font color=Blue>--- The parser monad ---------------------------------------------------------</font>--<a name="ParseResult"></a><font color=Green><u>type</u></font> ParseResult s t e a <font color=Red>=</font> Either e <font color=Red>[</font><font color=Cyan>(</font>a<font color=Cyan>,</font>s<font color=Cyan>,</font><font color=Red>[</font>Either e t<font color=Red>]</font><font color=Cyan>)</font><font color=Red>]</font>--<font color=Green><u>newtype</u></font> Parser s t e a <font color=Red>=</font> P <font color=Cyan>(</font> s <font color=Red>-></font> <font color=Red>[</font>Either e t<font color=Red>]</font> <font color=Red>-></font> ParseResult s t e a <font color=Cyan>)</font>- <font color=Blue>-- ^ The parser type is parametrised on the types of the state @s@,</font>- <font color=Blue>-- the input tokens @t@, error-type @e@, and the result value @a@.</font>- <font color=Blue>-- The state and remaining input are threaded through the monad.</font>--<font color=Green><u>instance</u></font> Functor <font color=Cyan>(</font>Parser s t e<font color=Cyan>)</font> <font color=Green><u>where</u></font>- <font color=Blue>-- fmap :: (a -> b) -> (Parser s t e a -> Parser s t e b)</font>- fmap f <font color=Cyan>(</font>P p<font color=Cyan>)</font> <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>st inp <font color=Red>-></font> <font color=Green><u>case</u></font> p st inp <font color=Green><u>of</u></font>- Right res <font color=Red>-></font> Right <font color=Red>[</font><font color=Cyan>(</font>f v<font color=Cyan>,</font> s<font color=Cyan>,</font> out<font color=Cyan>)</font> <font color=Red>|</font> <font color=Cyan>(</font>v<font color=Cyan>,</font>s<font color=Cyan>,</font>out<font color=Cyan>)</font> <font color=Red><-</font> res<font color=Red>]</font>- Left err <font color=Red>-></font> Left err- <font color=Cyan>)</font>--<font color=Green><u>instance</u></font> Monad <font color=Cyan>(</font>Parser s t e<font color=Cyan>)</font> <font color=Green><u>where</u></font>- <font color=Blue>-- return :: a -> Parser s t e a</font>- return v <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>st inp <font color=Red>-></font> Right <font color=Red>[</font><font color=Cyan>(</font>v<font color=Cyan>,</font>st<font color=Cyan>,</font>inp<font color=Cyan>)</font><font color=Red>]</font><font color=Cyan>)</font>- <font color=Blue>-- >>= :: Parser s t e a -> (a -> Parser s t e b) -> Parser s t e b</font>- <font color=Cyan>(</font>P p<font color=Cyan>)</font> <font color=Cyan>>>=</font> f <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>st inp <font color=Red>-></font> <font color=Green><u>case</u></font> p st inp <font color=Green><u>of</u></font>- Right res <font color=Red>-></font> foldr joinresults <font color=Cyan>(</font>Right <font color=Red>[</font><font color=Red>]</font><font color=Cyan>)</font>- <font color=Red>[</font> papply' <font color=Cyan>(</font>f v<font color=Cyan>)</font> s out <font color=Red>|</font> <font color=Cyan>(</font>v<font color=Cyan>,</font>s<font color=Cyan>,</font>out<font color=Cyan>)</font> <font color=Red><-</font> res <font color=Red>]</font>- Left err <font color=Red>-></font> Left err- <font color=Cyan>)</font>- <font color=Blue>-- fail :: String -> Parser s t e a</font>- fail err <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>st inp <font color=Red>-></font> Right <font color=Red>[</font><font color=Red>]</font><font color=Cyan>)</font>- <font color=Blue>-- I know it's counterintuitive, but we want no-parse, not an error.</font>--<font color=Green><u>instance</u></font> MonadPlus <font color=Cyan>(</font>Parser s t e<font color=Cyan>)</font> <font color=Green><u>where</u></font>- <font color=Blue>-- mzero :: Parser s t e a</font>- mzero <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>st inp <font color=Red>-></font> Right <font color=Red>[</font><font color=Red>]</font><font color=Cyan>)</font>- <font color=Blue>-- mplus :: Parser s t e a -> Parser s t e a -> Parser s t e a</font>- <font color=Cyan>(</font>P p<font color=Cyan>)</font> <font color=Cyan>`mplus`</font> <font color=Cyan>(</font>P q<font color=Cyan>)</font> <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>st inp <font color=Red>-></font> joinresults <font color=Cyan>(</font>p st inp<font color=Cyan>)</font> <font color=Cyan>(</font>q st inp<font color=Cyan>)</font><font color=Cyan>)</font>--<font color=Blue>-- joinresults ensures that explicitly raised errors are dominant,</font>-<font color=Blue>-- provided no parse has yet been found. The commented out code is</font>-<font color=Blue>-- a slightly stricter specification of the real code.</font>-joinresults <font color=Red>::</font> ParseResult s t e a <font color=Red>-></font> ParseResult s t e a <font color=Red>-></font> ParseResult s t e a-<font color=Blue>{--joinresults (Left p) (Left q) = Left p-joinresults (Left p) (Right _) = Left p-joinresults (Right []) (Left q) = Left q-joinresults (Right p) (Left q) = Right p-joinresults (Right p) (Right q) = Right (p++q)--}</font>-<a name="joinresults"></a>joinresults <font color=Cyan>(</font>Left p<font color=Cyan>)</font> q <font color=Red>=</font> Left p-joinresults <font color=Cyan>(</font>Right <font color=Red>[</font><font color=Red>]</font><font color=Cyan>)</font> q <font color=Red>=</font> q-joinresults <font color=Cyan>(</font>Right p<font color=Cyan>)</font> q <font color=Red>=</font> Right <font color=Cyan>(</font>p<font color=Cyan>++</font> <font color=Green><u>case</u></font> q <font color=Green><u>of</u></font> Left <font color=Green><u>_</u></font> <font color=Red>-></font> <font color=Red>[</font><font color=Red>]</font>- Right r <font color=Red>-></font> r<font color=Cyan>)</font>---<font color=Blue>--- Primitive parser combinators ---------------------------------------------</font>--<font color=Blue>-- | Deliver the first remaining token.</font>-item <font color=Red>::</font> Parser s t e t-<a name="item"></a>item <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>st inp <font color=Red>-></font> <font color=Green><u>case</u></font> inp <font color=Green><u>of</u></font>- <font color=Red>[</font><font color=Red>]</font> <font color=Red>-></font> Right <font color=Red>[</font><font color=Red>]</font>- <font color=Cyan>(</font>Left e<font color=Red><b>:</b></font> <font color=Green><u>_</u></font><font color=Cyan>)</font> <font color=Red>-></font> Left e- <font color=Cyan>(</font>Right x<font color=Red><b>:</b></font> xs<font color=Cyan>)</font> <font color=Red>-></font> Right <font color=Red>[</font><font color=Cyan>(</font>x<font color=Cyan>,</font>st<font color=Cyan>,</font>xs<font color=Cyan>)</font><font color=Red>]</font>- <font color=Cyan>)</font>--<font color=Blue>-- | Fail if end of input is not reached</font>-eof <font color=Red>::</font> Show p <font color=Red>=></font> Parser s <font color=Cyan>(</font>p<font color=Cyan>,</font>t<font color=Cyan>)</font> String <font color=Cyan>(</font><font color=Cyan>)</font>-<a name="eof"></a>eof <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>st inp <font color=Red>-></font> <font color=Green><u>case</u></font> inp <font color=Green><u>of</u></font>- <font color=Red>[</font><font color=Red>]</font> <font color=Red>-></font> Right <font color=Red>[</font><font color=Cyan>(</font><font color=Cyan>(</font><font color=Cyan>)</font><font color=Cyan>,</font>st<font color=Cyan>,</font><font color=Red>[</font><font color=Red>]</font><font color=Cyan>)</font><font color=Red>]</font>- <font color=Cyan>(</font>Left e<font color=Red><b>:</b></font><font color=Green><u>_</u></font><font color=Cyan>)</font> <font color=Red>-></font> Left e- <font color=Cyan>(</font>Right <font color=Cyan>(</font>p<font color=Cyan>,</font><font color=Green><u>_</u></font><font color=Cyan>)</font><font color=Red><b>:</b></font><font color=Green><u>_</u></font><font color=Cyan>)</font> <font color=Red>-></font> Left <font color=Cyan>(</font><font color=Magenta>"End of input expected at "</font>- <font color=Cyan>++</font>show p<font color=Cyan>++</font><font color=Magenta>"\n but found text"</font><font color=Cyan>)</font>- <font color=Cyan>)</font>--<font color=Blue>{---- | Ensure the value delivered by the parser is evaluated to WHNF.-force :: Parser s t e a -> Parser s t e a-force (P p) = P (\st inp -> let Right xs = p st inp- h = head xs in- h `seq` Right (h: tail xs)- )--- [[[GK]]] ^^^^^^--- WHNF = Weak Head Normal Form, meaning that it has no top-level redex.--- In this case, I think that means that the first element of the list--- is fully evaluated.------ NOTE: the original form of this function fails if there is no parse--- result for p st inp (head xs fails if xs is null), so the modified--- form can assume a Right value only.------ Why is this needed?--- It's not exported, and the only use of this I see is commented out.------------------------------------------}</font>---<font color=Blue>-- | Deliver the first parse result only, eliminating any backtracking.</font>-first <font color=Red>::</font> Parser s t e a <font color=Red>-></font> Parser s t e a-<a name="first"></a>first <font color=Cyan>(</font>P p<font color=Cyan>)</font> <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>st inp <font color=Red>-></font> <font color=Green><u>case</u></font> p st inp <font color=Green><u>of</u></font>- Right <font color=Cyan>(</font>x<font color=Red><b>:</b></font>xs<font color=Cyan>)</font> <font color=Red>-></font> Right <font color=Red>[</font>x<font color=Red>]</font>- otherwise <font color=Red>-></font> otherwise- <font color=Cyan>)</font>--<font color=Blue>-- | Apply the parser to some real input, given an initial state value.</font>-<font color=Blue>-- If the parser fails, raise 'error' to halt the program.</font>-<font color=Blue>-- (This is the original exported behaviour - to allow the caller to</font>-<font color=Blue>-- deal with the error differently, see @papply'@.)</font>-papply <font color=Red>::</font> Parser s t String a <font color=Red>-></font> s <font color=Red>-></font> <font color=Red>[</font>Either String t<font color=Red>]</font>- <font color=Red>-></font> <font color=Red>[</font><font color=Cyan>(</font>a<font color=Cyan>,</font>s<font color=Cyan>,</font><font color=Red>[</font>Either String t<font color=Red>]</font><font color=Cyan>)</font><font color=Red>]</font>-<a name="papply"></a>papply <font color=Cyan>(</font>P p<font color=Cyan>)</font> st inp <font color=Red>=</font> either error id <font color=Cyan>(</font>p st inp<font color=Cyan>)</font>--<font color=Blue>-- | Apply the parser to some real input, given an initial state value.</font>-<font color=Blue>-- If the parser fails, return a diagnostic message to the caller.</font>-papply' <font color=Red>::</font> Parser s t e a <font color=Red>-></font> s <font color=Red>-></font> <font color=Red>[</font>Either e t<font color=Red>]</font>- <font color=Red>-></font> Either e <font color=Red>[</font><font color=Cyan>(</font>a<font color=Cyan>,</font>s<font color=Cyan>,</font><font color=Red>[</font>Either e t<font color=Red>]</font><font color=Cyan>)</font><font color=Red>]</font>-<a name="papply'"></a>papply' <font color=Cyan>(</font>P p<font color=Cyan>)</font> st inp <font color=Red>=</font> p st inp--<font color=Blue>--- Derived combinators ------------------------------------------------------</font>--<font color=Blue>-- | A choice between parsers. Keep only the first success.</font>-<a name="+++"></a><font color=Cyan>(</font><font color=Cyan>+++</font><font color=Cyan>)</font> <font color=Red>::</font> Parser s t e a <font color=Red>-></font> Parser s t e a <font color=Red>-></font> Parser s t e a-<a name="p"></a>p <font color=Cyan>+++</font> q <font color=Red>=</font> first <font color=Cyan>(</font>p <font color=Cyan>`mplus`</font> q<font color=Cyan>)</font>--<font color=Blue>-- | Deliver the first token if it satisfies a predicate.</font>-sat <font color=Red>::</font> <font color=Cyan>(</font>t <font color=Red>-></font> Bool<font color=Cyan>)</font> <font color=Red>-></font> Parser s <font color=Cyan>(</font>p<font color=Cyan>,</font>t<font color=Cyan>)</font> e t-<a name="sat"></a>sat p <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font><font color=Cyan>(</font><font color=Green><u>_</u></font><font color=Cyan>,</font>x<font color=Cyan>)</font> <font color=Red><-</font> item<font color=Cyan>;</font> <font color=Green><u>if</u></font> p x <font color=Green><u>then</u></font> return x <font color=Green><u>else</u></font> mzero<font color=Cyan>}</font>--<font color=Blue>-- | Deliver the first token if it equals the argument.</font>-tok <font color=Red>::</font> Eq t <font color=Red>=></font> t <font color=Red>-></font> Parser s <font color=Cyan>(</font>p<font color=Cyan>,</font>t<font color=Cyan>)</font> e t-<a name="tok"></a>tok t <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font><font color=Cyan>(</font><font color=Green><u>_</u></font><font color=Cyan>,</font>x<font color=Cyan>)</font> <font color=Red><-</font> item<font color=Cyan>;</font> <font color=Green><u>if</u></font> x<font color=Cyan>==</font>t <font color=Green><u>then</u></font> return t <font color=Green><u>else</u></font> mzero<font color=Cyan>}</font>--<font color=Blue>-- | Deliver the first token if it does not equal the argument.</font>-nottok <font color=Red>::</font> Eq t <font color=Red>=></font> <font color=Red>[</font>t<font color=Red>]</font> <font color=Red>-></font> Parser s <font color=Cyan>(</font>p<font color=Cyan>,</font>t<font color=Cyan>)</font> e t-<a name="nottok"></a>nottok ts <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font><font color=Cyan>(</font><font color=Green><u>_</u></font><font color=Cyan>,</font>x<font color=Cyan>)</font> <font color=Red><-</font> item<font color=Cyan>;</font> <font color=Green><u>if</u></font> x <font color=Cyan>`notElem`</font> ts <font color=Green><u>then</u></font> return x- <font color=Green><u>else</u></font> mzero<font color=Cyan>}</font>--<font color=Blue>-- | Deliver zero or more values of @a@.</font>-many <font color=Red>::</font> Parser s t e a <font color=Red>-></font> Parser s t e <font color=Red>[</font>a<font color=Red>]</font>-<a name="many"></a>many p <font color=Red>=</font> many1 p <font color=Cyan>+++</font> return <font color=Red>[</font><font color=Red>]</font>-<font color=Blue>--many p = force (many1 p +++ return [])</font>--<font color=Blue>-- | Deliver one or more values of @a@.</font>-many1 <font color=Red>::</font> Parser s t e a <font color=Red>-></font> Parser s t e <font color=Red>[</font>a<font color=Red>]</font>-<a name="many1"></a>many1 p <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font>x <font color=Red><-</font> p<font color=Cyan>;</font> xs <font color=Red><-</font> many p<font color=Cyan>;</font> return <font color=Cyan>(</font>x<font color=Red><b>:</b></font>xs<font color=Cyan>)</font><font color=Cyan>}</font>--<font color=Blue>-- | Deliver zero or more values of @a@ separated by @b@'s.</font>-sepby <font color=Red>::</font> Parser s t e a <font color=Red>-></font> Parser s t e b <font color=Red>-></font> Parser s t e <font color=Red>[</font>a<font color=Red>]</font>-<a name="sepby"></a>p <font color=Cyan>`sepby`</font> sep <font color=Red>=</font> <font color=Cyan>(</font>p <font color=Cyan>`sepby1`</font> sep<font color=Cyan>)</font> <font color=Cyan>+++</font> return <font color=Red>[</font><font color=Red>]</font>--<font color=Blue>-- | Deliver one or more values of @a@ separated by @b@'s.</font>-sepby1 <font color=Red>::</font> Parser s t e a <font color=Red>-></font> Parser s t e b <font color=Red>-></font> Parser s t e <font color=Red>[</font>a<font color=Red>]</font>-<a name="sepby1"></a>p <font color=Cyan>`sepby1`</font> sep <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font>x <font color=Red><-</font> p<font color=Cyan>;</font> xs <font color=Red><-</font> many <font color=Cyan>(</font><font color=Green><u>do</u></font> <font color=Cyan>{</font>sep<font color=Cyan>;</font> p<font color=Cyan>}</font><font color=Cyan>)</font><font color=Cyan>;</font> return <font color=Cyan>(</font>x<font color=Red><b>:</b></font>xs<font color=Cyan>)</font><font color=Cyan>}</font>--chainl <font color=Red>::</font> Parser s t e a <font color=Red>-></font> Parser s t e <font color=Cyan>(</font>a<font color=Red>-></font>a<font color=Red>-></font>a<font color=Cyan>)</font> <font color=Red>-></font> a- <font color=Red>-></font> Parser s t e a-<a name="chainl"></a>chainl p op v <font color=Red>=</font> <font color=Cyan>(</font>p <font color=Cyan>`chainl1`</font> op<font color=Cyan>)</font> <font color=Cyan>+++</font> return v--chainl1 <font color=Red>::</font> Parser s t e a <font color=Red>-></font> Parser s t e <font color=Cyan>(</font>a<font color=Red>-></font>a<font color=Red>-></font>a<font color=Cyan>)</font> <font color=Red>-></font> Parser s t e a-<a name="chainl1"></a>p <font color=Cyan>`chainl1`</font> op <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font>x <font color=Red><-</font> p<font color=Cyan>;</font> rest x<font color=Cyan>}</font>- <font color=Green><u>where</u></font>- rest x <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font>f <font color=Red><-</font> op<font color=Cyan>;</font> y <font color=Red><-</font> p<font color=Cyan>;</font> rest <font color=Cyan>(</font>f x y<font color=Cyan>)</font><font color=Cyan>}</font>- <font color=Cyan>+++</font> return x--chainr <font color=Red>::</font> Parser s t e a <font color=Red>-></font> Parser s t e <font color=Cyan>(</font>a<font color=Red>-></font>a<font color=Red>-></font>a<font color=Cyan>)</font> <font color=Red>-></font> a- <font color=Red>-></font> Parser s t e a-<a name="chainr"></a>chainr p op v <font color=Red>=</font> <font color=Cyan>(</font>p <font color=Cyan>`chainr1`</font> op<font color=Cyan>)</font> <font color=Cyan>+++</font> return v--chainr1 <font color=Red>::</font> Parser s t e a <font color=Red>-></font> Parser s t e <font color=Cyan>(</font>a<font color=Red>-></font>a<font color=Red>-></font>a<font color=Cyan>)</font> <font color=Red>-></font> Parser s t e a-<a name="chainr1"></a>p <font color=Cyan>`chainr1`</font> op <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font>x <font color=Red><-</font> p<font color=Cyan>;</font> rest x<font color=Cyan>}</font>- <font color=Green><u>where</u></font>- rest x <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font> f <font color=Red><-</font> op- <font color=Cyan>;</font> y <font color=Red><-</font> p <font color=Cyan>`chainr1`</font> op- <font color=Cyan>;</font> return <font color=Cyan>(</font>f x y<font color=Cyan>)</font>- <font color=Cyan>}</font>- <font color=Cyan>+++</font> return x--ops <font color=Red>::</font> <font color=Red>[</font><font color=Cyan>(</font>Parser s t e a<font color=Cyan>,</font> b<font color=Cyan>)</font><font color=Red>]</font> <font color=Red>-></font> Parser s t e b-<a name="ops"></a>ops xs <font color=Red>=</font> foldr1 <font color=Cyan>(</font><font color=Cyan>+++</font><font color=Cyan>)</font> <font color=Red>[</font><font color=Green><u>do</u></font> <font color=Cyan>{</font>p<font color=Cyan>;</font> return op<font color=Cyan>}</font> <font color=Red>|</font> <font color=Cyan>(</font>p<font color=Cyan>,</font>op<font color=Cyan>)</font> <font color=Red><-</font> xs<font color=Red>]</font>--bracket <font color=Red>::</font> <font color=Cyan>(</font>Show p<font color=Cyan>,</font>Show t<font color=Cyan>)</font> <font color=Red>=></font>- Parser s <font color=Cyan>(</font>p<font color=Cyan>,</font>t<font color=Cyan>)</font> e a <font color=Red>-></font> Parser s <font color=Cyan>(</font>p<font color=Cyan>,</font>t<font color=Cyan>)</font> e b <font color=Red>-></font>- Parser s <font color=Cyan>(</font>p<font color=Cyan>,</font>t<font color=Cyan>)</font> e c <font color=Red>-></font> Parser s <font color=Cyan>(</font>p<font color=Cyan>,</font>t<font color=Cyan>)</font> e b-<a name="bracket"></a>bracket open p close <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font> open- <font color=Cyan>;</font> x <font color=Red><-</font> p- <font color=Cyan>;</font> close <font color=Blue>-- `elserror` "improperly matched construct";</font>- <font color=Cyan>;</font> return x- <font color=Cyan>}</font>--<font color=Blue>-- | Accept a complete parse of the input only, no partial parses.</font>-toEOF <font color=Red>::</font> Show p <font color=Red>=></font>- Parser s <font color=Cyan>(</font>p<font color=Cyan>,</font>t<font color=Cyan>)</font> String a <font color=Red>-></font> Parser s <font color=Cyan>(</font>p<font color=Cyan>,</font>t<font color=Cyan>)</font> String a-<a name="toEOF"></a>toEOF p <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font> x <font color=Red><-</font> p<font color=Cyan>;</font> eof<font color=Cyan>;</font> return x <font color=Cyan>}</font>---<font color=Blue>--- Error handling -----------------------------------------------------------</font>--<font color=Blue>-- | Return an error using the supplied diagnostic string, and a token type</font>-<font color=Blue>-- which includes position information.</font>-parseerror <font color=Red>::</font> <font color=Cyan>(</font>Show p<font color=Cyan>,</font>Show t<font color=Cyan>)</font> <font color=Red>=></font> String <font color=Red>-></font> Parser s <font color=Cyan>(</font>p<font color=Cyan>,</font>t<font color=Cyan>)</font> String a-<a name="parseerror"></a>parseerror err <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>st inp <font color=Red>-></font>- <font color=Green><u>case</u></font> inp <font color=Green><u>of</u></font>- <font color=Red>[</font><font color=Red>]</font> <font color=Red>-></font> Left <font color=Magenta>"Parse error: unexpected EOF\n"</font>- <font color=Cyan>(</font>Left e<font color=Red><b>:</b></font><font color=Green><u>_</u></font><font color=Cyan>)</font> <font color=Red>-></font> Left <font color=Cyan>(</font><font color=Magenta>"Lexical error: "</font><font color=Cyan>++</font>e<font color=Cyan>)</font>- <font color=Cyan>(</font>Right <font color=Cyan>(</font>p<font color=Cyan>,</font>t<font color=Cyan>)</font><font color=Red><b>:</b></font><font color=Green><u>_</u></font><font color=Cyan>)</font> <font color=Red>-></font>- Left <font color=Cyan>(</font><font color=Magenta>"Parse error: in "</font><font color=Cyan>++</font>show p<font color=Cyan>++</font><font color=Magenta>"\n "</font>- <font color=Cyan>++</font>err<font color=Cyan>++</font><font color=Magenta>"\n "</font><font color=Cyan>++</font><font color=Magenta>"Found "</font><font color=Cyan>++</font>show t<font color=Cyan>)</font>- <font color=Cyan>)</font>---<font color=Blue>-- | If the parser fails, generate an error message.</font>-elserror <font color=Red>::</font> <font color=Cyan>(</font>Show p<font color=Cyan>,</font>Show t<font color=Cyan>)</font> <font color=Red>=></font> Parser s <font color=Cyan>(</font>p<font color=Cyan>,</font>t<font color=Cyan>)</font> String a <font color=Red>-></font> String- <font color=Red>-></font> Parser s <font color=Cyan>(</font>p<font color=Cyan>,</font>t<font color=Cyan>)</font> String a-<a name="elserror"></a>p <font color=Cyan>`elserror`</font> s <font color=Red>=</font> p <font color=Cyan>+++</font> parseerror s--<font color=Blue>--- State handling -----------------------------------------------------------</font>--<font color=Blue>-- | Update the internal state.</font>-stupd <font color=Red>::</font> <font color=Cyan>(</font>s<font color=Red>-></font>s<font color=Cyan>)</font> <font color=Red>-></font> Parser s t e <font color=Cyan>(</font><font color=Cyan>)</font>-<a name="stupd"></a>stupd f <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>st inp<font color=Red>-></font> <font color=Blue>{-let newst = f st in newst `seq`-}</font>- Right <font color=Red>[</font><font color=Cyan>(</font><font color=Cyan>(</font><font color=Cyan>)</font><font color=Cyan>,</font> f st<font color=Cyan>,</font> inp<font color=Cyan>)</font><font color=Red>]</font><font color=Cyan>)</font>--<font color=Blue>-- | Query the internal state.</font>-stquery <font color=Red>::</font> <font color=Cyan>(</font>s<font color=Red>-></font>a<font color=Cyan>)</font> <font color=Red>-></font> Parser s t e a-<a name="stquery"></a>stquery f <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>st inp<font color=Red>-></font> Right <font color=Red>[</font><font color=Cyan>(</font>f st<font color=Cyan>,</font> st<font color=Cyan>,</font> inp<font color=Cyan>)</font><font color=Red>]</font><font color=Cyan>)</font>--<font color=Blue>-- | Deliver the entire internal state.</font>-stget <font color=Red>::</font> Parser s t e s-<a name="stget"></a>stget <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>st inp<font color=Red>-></font> Right <font color=Red>[</font><font color=Cyan>(</font>st<font color=Cyan>,</font> st<font color=Cyan>,</font> inp<font color=Cyan>)</font><font color=Red>]</font><font color=Cyan>)</font>---<font color=Blue>--- Push some tokens back onto the input stream and reparse ------------------</font>--<font color=Blue>-- | This is useful for recursively expanding macros. When the</font>-<font color=Blue>-- user-parser recognises a macro use, it can lookup the macro</font>-<font color=Blue>-- expansion from the parse state, lex it, and then stuff the</font>-<font color=Blue>-- lexed expansion back down into the parser.</font>-reparse <font color=Red>::</font> <font color=Red>[</font>Either e t<font color=Red>]</font> <font color=Red>-></font> Parser s t e <font color=Cyan>(</font><font color=Cyan>)</font>-<a name="reparse"></a>reparse ts <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>st inp<font color=Red>-></font> Right <font color=Red>[</font><font color=Cyan>(</font><font color=Cyan>(</font><font color=Cyan>)</font><font color=Cyan>,</font> st<font color=Cyan>,</font> ts<font color=Cyan>++</font>inp<font color=Cyan>)</font><font color=Red>]</font><font color=Cyan>)</font>--<font color=Blue>------------------------------------------------------------------------------</font>-</pre>
− docs/HaXml/src/Text/ParserCombinators/Poly.html
@@ -1,238 +0,0 @@-<pre><font color=Green><u>module</u></font> Text<font color=Cyan>.</font>ParserCombinators<font color=Cyan>.</font>Poly- <font color=Cyan>(</font> <font color=Blue>-- * A Parser datatype parameterised on arbitrary token type</font>- Parser<font color=Cyan>(</font>P<font color=Cyan>)</font> <font color=Blue>-- datatype, instance of: Functor, Monad</font>- <font color=Cyan>,</font> runParser <font color=Blue>-- :: Parser t a -> [t] -> (Either String a, [t])</font>- <font color=Cyan>,</font> failBad <font color=Blue>-- :: String -> Parser t a</font>- <font color=Cyan>,</font> commit <font color=Blue>-- :: Parser t a -> Parser t a</font>- <font color=Blue>-- * Combinators</font>- <font color=Blue>-- ** primitives</font>- <font color=Cyan>,</font> next <font color=Blue>-- :: Parser t t</font>- <font color=Cyan>,</font> satisfy <font color=Blue>-- :: (t->Bool) -> Parser t t</font>- <font color=Cyan>,</font> apply <font color=Blue>-- :: Parser t (a->b) -> Parser t a -> Parser t b</font>- <font color=Cyan>,</font> discard <font color=Blue>-- :: Parser t a -> Parser t b -> Parser t a</font>- <font color=Blue>-- ** error-handling</font>- <font color=Cyan>,</font> adjustErr <font color=Blue>-- :: Parser t a -> (String->String) -> Parser t a</font>- <font color=Cyan>,</font> adjustErrBad<font color=Blue>-- :: Parser t a -> (String->String) -> Parser t a</font>- <font color=Cyan>,</font> indent <font color=Blue>-- :: Int -> String -> String</font>- <font color=Blue>-- ** choices</font>- <font color=Cyan>,</font> onFail <font color=Blue>-- :: Parser t a -> Parser t a -> Parser t a</font>- <font color=Cyan>,</font> oneOf <font color=Blue>-- :: Show t => [Parser t a] -> Parser t a</font>- <font color=Cyan>,</font> oneOf' <font color=Blue>-- :: [(String,Parser t a)] -> Parser t a</font>- <font color=Cyan>,</font> optional <font color=Blue>-- :: Parser t a -> Parser t (Maybe a)</font>- <font color=Blue>-- ** sequences</font>- <font color=Cyan>,</font> many <font color=Blue>-- :: Parser t a -> Parser t [a]</font>- <font color=Cyan>,</font> many1 <font color=Blue>-- :: Parser t a -> Parser t [a]</font>- <font color=Cyan>,</font> sepBy <font color=Blue>-- :: Parser t a -> Parser t sep -> Parser t [a]</font>- <font color=Cyan>,</font> sepBy1 <font color=Blue>-- :: Parser t a -> Parser t sep -> Parser t [a]</font>- <font color=Cyan>,</font> bracketSep <font color=Blue>-- :: Parser t bra -> Parser t sep -> Parser t ket</font>- <font color=Blue>-- -> Parser t a -> Parser t [a]</font>- <font color=Cyan>,</font> bracket <font color=Blue>-- :: Parser t bra -> Parser t ket -> Parser t a</font>- <font color=Blue>-- -> Parser t a</font>- <font color=Cyan>,</font> manyFinally <font color=Blue>-- :: Parser t a -> Parser t z -> Parser t [a]</font>- <font color=Blue>-- ** re-parsing</font>- <font color=Cyan>,</font> reparse <font color=Blue>-- :: [t] -> Parser t ()</font>- <font color=Cyan>)</font> <font color=Green><u>where</u></font>---<font color=Blue>-- | The @Parser@ datatype is a fairly generic parsing monad with error</font>-<font color=Blue>-- reporting. It can be used for arbitrary token types, not just</font>-<font color=Blue>-- String input. (If you require a running state, use module PolyState</font>-<font color=Blue>-- instead)</font>-<font color=Green><u>newtype</u></font> Parser t a <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>[</font>t<font color=Red>]</font> <font color=Red>-></font> <font color=Cyan>(</font>EitherE String a<font color=Cyan>,</font> <font color=Red>[</font>t<font color=Red>]</font><font color=Cyan>)</font><font color=Cyan>)</font>--<font color=Blue>-- A return type like Either, that distinguishes not only between</font>-<font color=Blue>-- right and wrong answers, but also had gradations of wrongness.</font>-<a name="EitherE"></a><font color=Green><u>type</u></font> EitherE a b <font color=Red>=</font> Either <font color=Cyan>(</font>Bool<font color=Cyan>,</font>a<font color=Cyan>)</font> b--<font color=Blue>-- | Apply a parser to an input token sequence.</font>-runParser <font color=Red>::</font> Parser t a <font color=Red>-></font> <font color=Red>[</font>t<font color=Red>]</font> <font color=Red>-></font> <font color=Cyan>(</font>Either String a<font color=Cyan>,</font> <font color=Red>[</font>t<font color=Red>]</font><font color=Cyan>)</font>-<a name="runParser"></a>runParser <font color=Cyan>(</font>P p<font color=Cyan>)</font> <font color=Red>=</font>- <font color=Cyan>(</font><font color=Red>\</font> <font color=Cyan>(</font>e<font color=Cyan>,</font>ts<font color=Cyan>)</font><font color=Red>-></font> <font color=Cyan>(</font><font color=Green><u>case</u></font> e <font color=Green><u>of</u></font> <font color=Cyan>{</font>Left <font color=Cyan>(</font><font color=Green><u>_</u></font><font color=Cyan>,</font>m<font color=Cyan>)</font><font color=Red>-></font>Left m<font color=Cyan>;</font> Right m<font color=Red>-></font>Right m<font color=Cyan>}</font><font color=Cyan>,</font> ts<font color=Cyan>)</font> <font color=Cyan>)</font>- <font color=Cyan>.</font> p--<font color=Green><u>instance</u></font> Functor <font color=Cyan>(</font>Parser t<font color=Cyan>)</font> <font color=Green><u>where</u></font>- fmap f <font color=Cyan>(</font>P p<font color=Cyan>)</font> <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>ts<font color=Red>-></font> <font color=Green><u>case</u></font> p ts <font color=Green><u>of</u></font>- <font color=Cyan>(</font>Left msg<font color=Cyan>,</font> ts'<font color=Cyan>)</font> <font color=Red>-></font> <font color=Cyan>(</font>Left msg<font color=Cyan>,</font> ts'<font color=Cyan>)</font>- <font color=Cyan>(</font>Right x<font color=Cyan>,</font> ts'<font color=Cyan>)</font> <font color=Red>-></font> <font color=Cyan>(</font>Right <font color=Cyan>(</font>f x<font color=Cyan>)</font><font color=Cyan>,</font> ts'<font color=Cyan>)</font><font color=Cyan>)</font>-<font color=Green><u>instance</u></font> Monad <font color=Cyan>(</font>Parser t<font color=Cyan>)</font> <font color=Green><u>where</u></font>- return x <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>ts<font color=Red>-></font> <font color=Cyan>(</font>Right x<font color=Cyan>,</font> ts<font color=Cyan>)</font><font color=Cyan>)</font>- <font color=Cyan>(</font>P f<font color=Cyan>)</font> <font color=Cyan>>>=</font> g <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>ts<font color=Red>-></font> <font color=Green><u>case</u></font> f ts <font color=Green><u>of</u></font>- <font color=Cyan>(</font>Left msg<font color=Cyan>,</font> ts'<font color=Cyan>)</font> <font color=Red>-></font> <font color=Cyan>(</font>Left msg<font color=Cyan>,</font> ts'<font color=Cyan>)</font>- <font color=Cyan>(</font>Right x<font color=Cyan>,</font> ts'<font color=Cyan>)</font> <font color=Red>-></font> <font color=Green><u>let</u></font> <font color=Cyan>(</font>P g'<font color=Cyan>)</font> <font color=Red>=</font> g x <font color=Green><u>in</u></font> g' ts'<font color=Cyan>)</font>- fail e <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>ts<font color=Red>-></font> <font color=Cyan>(</font>Left <font color=Cyan>(</font>False<font color=Cyan>,</font>e<font color=Cyan>)</font><font color=Cyan>,</font> ts<font color=Cyan>)</font><font color=Cyan>)</font>--<font color=Blue>-- | When a simple fail is not strong enough, use failBad for emphasis.</font>-<font color=Blue>-- An emphasised (severe) error can propagate out through choice operators.</font>-failBad <font color=Red>::</font> String <font color=Red>-></font> Parser t a-<a name="failBad"></a>failBad msg <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>ts<font color=Red>-></font> <font color=Cyan>(</font>Left <font color=Cyan>(</font>True<font color=Cyan>,</font>msg<font color=Cyan>)</font><font color=Cyan>,</font> ts<font color=Cyan>)</font><font color=Cyan>)</font>--<font color=Blue>-- | Commit is a way of raising the severity of any errors found within</font>-<font color=Blue>-- its argument. Used in the middle of a parser definition, it means that</font>-<font color=Blue>-- any operations prior to commitment fail softly, but after commitment,</font>-<font color=Blue>-- they fail hard.</font>-commit <font color=Red>::</font> Parser t a <font color=Red>-></font> Parser t a-<a name="commit"></a>commit <font color=Cyan>(</font>P p<font color=Cyan>)</font> <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>ts<font color=Red>-></font> <font color=Green><u>case</u></font> p ts <font color=Green><u>of</u></font>- <font color=Cyan>(</font>Left <font color=Cyan>(</font><font color=Green><u>_</u></font><font color=Cyan>,</font>e<font color=Cyan>)</font><font color=Cyan>,</font> ts'<font color=Cyan>)</font> <font color=Red>-></font> <font color=Cyan>(</font>Left <font color=Cyan>(</font>True<font color=Cyan>,</font>e<font color=Cyan>)</font><font color=Cyan>,</font> ts'<font color=Cyan>)</font>- right <font color=Red>-></font> right <font color=Cyan>)</font>---<font color=Blue>-- Combinators</font>--<font color=Blue>-- | One token</font>-next <font color=Red>::</font> Parser t t-<a name="next"></a>next <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>ts<font color=Red>-></font> <font color=Green><u>case</u></font> ts <font color=Green><u>of</u></font>- <font color=Red>[</font><font color=Red>]</font> <font color=Red>-></font> <font color=Cyan>(</font>Left <font color=Cyan>(</font>False<font color=Cyan>,</font><font color=Magenta>"Ran out of input (EOF)"</font><font color=Cyan>)</font><font color=Cyan>,</font> <font color=Red>[</font><font color=Red>]</font><font color=Cyan>)</font>- <font color=Cyan>(</font>t<font color=Red><b>:</b></font>ts'<font color=Cyan>)</font> <font color=Red>-></font> <font color=Cyan>(</font>Right t<font color=Cyan>,</font> ts'<font color=Cyan>)</font> <font color=Cyan>)</font>--<font color=Blue>-- | One token satifying a predicate</font>-satisfy <font color=Red>::</font> <font color=Cyan>(</font>t<font color=Red>-></font>Bool<font color=Cyan>)</font> <font color=Red>-></font> Parser t t-<a name="satisfy"></a>satisfy p <font color=Red>=</font> <font color=Green><u>do</u></font><font color=Cyan>{</font> x <font color=Red><-</font> next- <font color=Cyan>;</font> <font color=Green><u>if</u></font> p x <font color=Green><u>then</u></font> return x <font color=Green><u>else</u></font> fail <font color=Magenta>"Parse.satisfy: failed"</font>- <font color=Cyan>}</font>--<font color=Green><u>infixl</u></font> <font color=Magenta>3</font> <font color=Cyan>`apply`</font>-<font color=Blue>-- | Apply a parsed function to a parsed value</font>-apply <font color=Red>::</font> Parser t <font color=Cyan>(</font>a<font color=Red>-></font>b<font color=Cyan>)</font> <font color=Red>-></font> Parser t a <font color=Red>-></font> Parser t b-<a name="apply"></a>pf <font color=Cyan>`apply`</font> px <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font> f <font color=Red><-</font> pf<font color=Cyan>;</font> x <font color=Red><-</font> px<font color=Cyan>;</font> return <font color=Cyan>(</font>f x<font color=Cyan>)</font> <font color=Cyan>}</font>--<font color=Green><u>infixl</u></font> <font color=Magenta>3</font> <font color=Cyan>`discard`</font>-<font color=Blue>-- | @x `discard` y@ parses both x and y, but discards the result of y</font>-discard <font color=Red>::</font> Parser t a <font color=Red>-></font> Parser t b <font color=Red>-></font> Parser t a-<a name="discard"></a>px <font color=Cyan>`discard`</font> py <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font> x <font color=Red><-</font> px<font color=Cyan>;</font> <font color=Green><u>_</u></font> <font color=Red><-</font> py<font color=Cyan>;</font> return x <font color=Cyan>}</font>--<font color=Blue>-- | @p `adjustErr` f@ applies the transformation @f@ to any error message</font>-<font color=Blue>-- generated in @p@, having no effect if @p@ succeeds.</font>-adjustErr <font color=Red>::</font> Parser t a <font color=Red>-></font> <font color=Cyan>(</font>String<font color=Red>-></font>String<font color=Cyan>)</font> <font color=Red>-></font> Parser t a-<a name="adjustErr"></a><font color=Cyan>(</font>P p<font color=Cyan>)</font> <font color=Cyan>`adjustErr`</font> f <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>ts<font color=Red>-></font> <font color=Green><u>case</u></font> p ts <font color=Green><u>of</u></font>- <font color=Cyan>(</font>Left <font color=Cyan>(</font>b<font color=Cyan>,</font>msg<font color=Cyan>)</font><font color=Cyan>,</font> ts'<font color=Cyan>)</font> <font color=Red>-></font> <font color=Cyan>(</font>Left <font color=Cyan>(</font>b<font color=Cyan>,</font><font color=Cyan>(</font>f msg<font color=Cyan>)</font><font color=Cyan>)</font><font color=Cyan>,</font> ts'<font color=Cyan>)</font>- right <font color=Red>-></font> right <font color=Cyan>)</font>--<font color=Blue>-- | @adjustErrBad@ is just like @adjustErr@ except it also raises the</font>-<font color=Blue>-- severity of the error.</font>-adjustErrBad <font color=Red>::</font> Parser t a <font color=Red>-></font> <font color=Cyan>(</font>String<font color=Red>-></font>String<font color=Cyan>)</font> <font color=Red>-></font> Parser t a-<a name="adjustErrBad"></a>p <font color=Cyan>`adjustErrBad`</font> f <font color=Red>=</font> commit <font color=Cyan>(</font>p <font color=Cyan>`adjustErr`</font> f<font color=Cyan>)</font>--<font color=Green><u>infixl</u></font> <font color=Magenta>6</font> <font color=Cyan>`onFail`</font> <font color=Blue>-- not sure about precedence 6?</font>-<font color=Blue>-- | @p `onFail` q@ means parse p unless p fails in which case parse q instead.</font>-<font color=Blue>-- Can be chained together to give multiple attempts to parse something.</font>-<font color=Blue>-- (Note that q could itself be a failing parser, e.g. to change the error</font>-<font color=Blue>-- message from that defined in p to something different.)</font>-<font color=Blue>-- However, a *severe* failure in p cannot be ignored.</font>-onFail <font color=Red>::</font> Parser t a <font color=Red>-></font> Parser t a <font color=Red>-></font> Parser t a-<a name="onFail"></a><font color=Cyan>(</font>P p<font color=Cyan>)</font> <font color=Cyan>`onFail`</font> <font color=Cyan>(</font>P q<font color=Cyan>)</font> <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>ts<font color=Red>-></font> <font color=Green><u>case</u></font> p ts <font color=Green><u>of</u></font>- r<font color=Red>@</font><font color=Cyan>(</font>Left <font color=Cyan>(</font>True<font color=Cyan>,</font><font color=Green><u>_</u></font><font color=Cyan>)</font><font color=Cyan>,</font> <font color=Green><u>_</u></font><font color=Cyan>)</font> <font color=Red>-></font> r- <font color=Cyan>(</font>Left <font color=Green><u>_</u></font><font color=Cyan>,</font> <font color=Green><u>_</u></font><font color=Cyan>)</font> <font color=Red>-></font> q ts- right <font color=Red>-></font> right <font color=Cyan>)</font>--<font color=Blue>-- | Parse the first alternative in the list that succeeds.</font>-oneOf <font color=Red>::</font> <font color=Red>[</font>Parser t a<font color=Red>]</font> <font color=Red>-></font> Parser t a-<a name="oneOf"></a>oneOf <font color=Red>[</font><font color=Red>]</font> <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font> n <font color=Red><-</font> next- <font color=Cyan>;</font> fail <font color=Cyan>(</font><font color=Magenta>"failed to parse any of the possible choices"</font><font color=Cyan>)</font>- <font color=Cyan>}</font>-<font color=Blue>--oneOf :: Show t => [Parser t a] -> Parser t a</font>-<font color=Blue>--oneOf [] = do { n <- next</font>-<font color=Blue>-- ; fail ("failed to parse any of the possible choices"</font>-<font color=Blue>-- ++"\n next token is "++show n)</font>-<font color=Blue>-- }</font>-oneOf <font color=Cyan>(</font>p<font color=Red><b>:</b></font>ps<font color=Cyan>)</font> <font color=Red>=</font> p <font color=Cyan>`onFail`</font> oneOf ps--<font color=Blue>-- | Parse the first alternative that succeeds, but if none succeed,</font>-<font color=Blue>-- report only the severe errors, and if none of those, then report</font>-<font color=Blue>-- all the soft errors.</font>-oneOf' <font color=Red>::</font> <font color=Red>[</font><font color=Cyan>(</font>String<font color=Cyan>,</font> Parser t a<font color=Cyan>)</font><font color=Red>]</font> <font color=Red>-></font> Parser t a-<a name="oneOf'"></a>oneOf' <font color=Red>=</font> accum <font color=Red>[</font><font color=Red>]</font>- <font color=Green><u>where</u></font> accum errs <font color=Red>[</font><font color=Red>]</font> <font color=Red>=</font>- <font color=Green><u>case</u></font> filter isBad errs <font color=Green><u>of</u></font>- <font color=Red>[</font><font color=Red>]</font> <font color=Red>-></font> fail <font color=Cyan>(</font><font color=Magenta>"failed to parse any of the possible choices:\n"</font>- <font color=Cyan>++</font>indent <font color=Magenta>2</font> <font color=Cyan>(</font>concatMap showErr <font color=Cyan>(</font>reverse errs<font color=Cyan>)</font><font color=Cyan>)</font><font color=Cyan>)</font>- <font color=Red>[</font><font color=Cyan>(</font><font color=Green><u>_</u></font><font color=Cyan>,</font><font color=Cyan>(</font><font color=Green><u>_</u></font><font color=Cyan>,</font>e<font color=Cyan>)</font><font color=Cyan>)</font><font color=Red>]</font> <font color=Red>-></font> failBad e- es <font color=Red>-></font> failBad <font color=Cyan>(</font><font color=Magenta>"one of the following failures occurred:\n"</font>- <font color=Cyan>++</font>indent <font color=Magenta>2</font> <font color=Cyan>(</font>concatMap showErr <font color=Cyan>(</font>reverse es<font color=Cyan>)</font><font color=Cyan>)</font><font color=Cyan>)</font>- accum errs <font color=Cyan>(</font><font color=Cyan>(</font>e<font color=Cyan>,</font>P p<font color=Cyan>)</font><font color=Red><b>:</b></font>ps<font color=Cyan>)</font> <font color=Red>=</font>- P <font color=Cyan>(</font><font color=Red>\</font>ts<font color=Red>-></font> <font color=Green><u>case</u></font> p ts <font color=Green><u>of</u></font>- <font color=Cyan>(</font>Left err<font color=Cyan>,</font><font color=Green><u>_</u></font><font color=Cyan>)</font> <font color=Red>-></font> <font color=Green><u>let</u></font> <font color=Cyan>(</font>P p<font color=Cyan>)</font> <font color=Red>=</font> accum <font color=Cyan>(</font><font color=Cyan>(</font>e<font color=Cyan>,</font>err<font color=Cyan>)</font><font color=Red><b>:</b></font>errs<font color=Cyan>)</font> ps- <font color=Green><u>in</u></font> p ts- right <font color=Red>-></font> right <font color=Cyan>)</font>- showErr <font color=Cyan>(</font>name<font color=Cyan>,</font><font color=Cyan>(</font><font color=Green><u>_</u></font><font color=Cyan>,</font>err<font color=Cyan>)</font><font color=Cyan>)</font> <font color=Red>=</font> name<font color=Cyan>++</font><font color=Magenta>":\n"</font><font color=Cyan>++</font>indent <font color=Magenta>2</font> err- isBad <font color=Cyan>(</font><font color=Green><u>_</u></font><font color=Cyan>,</font><font color=Cyan>(</font>b<font color=Cyan>,</font><font color=Green><u>_</u></font><font color=Cyan>)</font><font color=Cyan>)</font> <font color=Red>=</font> b--<font color=Blue>-- | Helper for formatting error messages: indents all lines by a fixed amount.</font>-indent <font color=Red>::</font> Int <font color=Red>-></font> String <font color=Red>-></font> String-<a name="indent"></a>indent n <font color=Red>=</font> unlines <font color=Cyan>.</font> map <font color=Cyan>(</font>replicate n <font color=Magenta>' '</font> <font color=Cyan>++</font><font color=Cyan>)</font> <font color=Cyan>.</font> lines--<font color=Blue>-- | 'optional' indicates whether the parser succeeded through the Maybe type.</font>-optional <font color=Red>::</font> Parser t a <font color=Red>-></font> Parser t <font color=Cyan>(</font>Maybe a<font color=Cyan>)</font>-<a name="optional"></a>optional p <font color=Red>=</font> fmap Just p <font color=Cyan>`onFail`</font> return Nothing--<font color=Blue>-- | 'many p' parses a list of elements with individual parser p.</font>-<font color=Blue>-- Cannot fail, since an empty list is a valid return value.</font>-many <font color=Red>::</font> Parser t a <font color=Red>-></font> Parser t <font color=Red>[</font>a<font color=Red>]</font>-<a name="many"></a>many p <font color=Red>=</font> many1 p <font color=Cyan>`onFail`</font> return <font color=Red>[</font><font color=Red>]</font>--<font color=Blue>-- | Parse a non-empty list of items.</font>-many1 <font color=Red>::</font> Parser t a <font color=Red>-></font> Parser t <font color=Red>[</font>a<font color=Red>]</font>-<a name="many1"></a>many1 p <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font> x <font color=Red><-</font> p <font color=Cyan>`adjustErr`</font> <font color=Cyan>(</font><font color=Cyan>(</font><font color=Magenta>"In a sequence:\n"</font><font color=Cyan>++</font><font color=Cyan>)</font><font color=Cyan>.</font> indent <font color=Magenta>2</font><font color=Cyan>)</font>- <font color=Cyan>;</font> xs <font color=Red><-</font> many p- <font color=Cyan>;</font> return <font color=Cyan>(</font>x<font color=Red><b>:</b></font>xs<font color=Cyan>)</font>- <font color=Cyan>}</font>-<font color=Blue>-- `adjustErr` ("When looking for a non-empty sequence:\n\t"++)</font>--<font color=Blue>-- | Parse a list of items separated by discarded junk.</font>-sepBy <font color=Red>::</font> Parser t a <font color=Red>-></font> Parser t sep <font color=Red>-></font> Parser t <font color=Red>[</font>a<font color=Red>]</font>-<a name="sepBy"></a>sepBy p sep <font color=Red>=</font> <font color=Green><u>do</u></font> sepBy1 p sep <font color=Cyan>`onFail`</font> return <font color=Red>[</font><font color=Red>]</font>--<font color=Blue>-- | Parse a non-empty list of items separated by discarded junk.</font>-sepBy1 <font color=Red>::</font> Parser t a <font color=Red>-></font> Parser t sep <font color=Red>-></font> Parser t <font color=Red>[</font>a<font color=Red>]</font>-<a name="sepBy1"></a>sepBy1 p sep <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font> x <font color=Red><-</font> p- <font color=Cyan>;</font> xs <font color=Red><-</font> many <font color=Cyan>(</font><font color=Green><u>do</u></font> <font color=Cyan>{</font>sep<font color=Cyan>;</font> p<font color=Cyan>}</font><font color=Cyan>)</font>- <font color=Cyan>;</font> return <font color=Cyan>(</font>x<font color=Red><b>:</b></font>xs<font color=Cyan>)</font>- <font color=Cyan>}</font>- <font color=Cyan>`adjustErr`</font> <font color=Cyan>(</font><font color=Magenta>"When looking for a non-empty sequence with separators:\n\t"</font><font color=Cyan>++</font><font color=Cyan>)</font>- -<font color=Blue>-- | Parse a list of items, discarding the start, end, and separator</font>-<font color=Blue>-- items.</font>-bracketSep <font color=Red>::</font> Parser t bra <font color=Red>-></font> Parser t sep <font color=Red>-></font> Parser t ket- <font color=Red>-></font> Parser t a <font color=Red>-></font> Parser t <font color=Red>[</font>a<font color=Red>]</font>-<a name="bracketSep"></a>bracketSep open sep close p <font color=Red>=</font>- <font color=Green><u>do</u></font> <font color=Cyan>{</font> open<font color=Cyan>;</font> close<font color=Cyan>;</font> return <font color=Red>[</font><font color=Red>]</font> <font color=Cyan>}</font>- <font color=Cyan>`onFail`</font>- <font color=Green><u>do</u></font> <font color=Cyan>{</font> open <font color=Cyan>`adjustErr`</font> <font color=Cyan>(</font><font color=Magenta>"Missing opening bracket:\n\t"</font><font color=Cyan>++</font><font color=Cyan>)</font>- <font color=Cyan>;</font> x <font color=Red><-</font> p <font color=Cyan>`adjustErr`</font> <font color=Cyan>(</font><font color=Magenta>"After first bracket in a group:\n\t"</font><font color=Cyan>++</font><font color=Cyan>)</font>- <font color=Cyan>;</font> xs <font color=Red><-</font> many <font color=Cyan>(</font><font color=Green><u>do</u></font> <font color=Cyan>{</font>sep<font color=Cyan>;</font> p<font color=Cyan>}</font><font color=Cyan>)</font>- <font color=Cyan>;</font> close <font color=Cyan>`adjustErrBad`</font> <font color=Cyan>(</font><font color=Magenta>"When looking for closing bracket:\n\t"</font><font color=Cyan>++</font><font color=Cyan>)</font>- <font color=Cyan>;</font> return <font color=Cyan>(</font>x<font color=Red><b>:</b></font>xs<font color=Cyan>)</font>- <font color=Cyan>}</font>--<font color=Blue>-- | Parse a bracketed item, discarding the brackets.</font>-bracket <font color=Red>::</font> Parser t bra <font color=Red>-></font> Parser t ket <font color=Red>-></font> Parser t a <font color=Red>-></font> Parser t a-<a name="bracket"></a>bracket open close p <font color=Red>=</font> <font color=Green><u>do</u></font>- <font color=Green><u>do</u></font> <font color=Cyan>{</font> open <font color=Cyan>`adjustErr`</font> <font color=Cyan>(</font><font color=Magenta>"Missing opening bracket:\n\t"</font><font color=Cyan>++</font><font color=Cyan>)</font>- <font color=Cyan>;</font> x <font color=Red><-</font> p- <font color=Cyan>;</font> close <font color=Cyan>`adjustErrBad`</font> <font color=Cyan>(</font><font color=Magenta>"Missing closing bracket:\n\t"</font><font color=Cyan>++</font><font color=Cyan>)</font>- <font color=Cyan>;</font> return x- <font color=Cyan>}</font>--<font color=Blue>-- | 'manyFinally e t' parses a possibly-empty sequence of e's,</font>-<font color=Blue>-- terminated by a t. Any parse failures could be due either to</font>-<font color=Blue>-- a badly-formed terminator or a badly-formed element, so raise</font>-<font color=Blue>-- both possible errors.</font>-manyFinally <font color=Red>::</font> Parser t a <font color=Red>-></font> Parser t z <font color=Red>-></font> Parser t <font color=Red>[</font>a<font color=Red>]</font>-<a name="manyFinally"></a>manyFinally p t <font color=Red>=</font>- <font color=Green><u>do</u></font> <font color=Cyan>{</font> xs <font color=Red><-</font> many p- <font color=Cyan>;</font> oneOf' <font color=Red>[</font> <font color=Cyan>(</font><font color=Magenta>"sequence terminator"</font><font color=Cyan>,</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font> t<font color=Cyan>;</font> return <font color=Cyan>(</font><font color=Cyan>)</font> <font color=Cyan>}</font> <font color=Cyan>)</font>- <font color=Cyan>,</font> <font color=Cyan>(</font><font color=Magenta>"item in a sequence"</font><font color=Cyan>,</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font> p<font color=Cyan>;</font> return <font color=Cyan>(</font><font color=Cyan>)</font> <font color=Cyan>}</font> <font color=Cyan>)</font>- <font color=Red>]</font>- <font color=Cyan>;</font> return xs- <font color=Cyan>}</font>--<font color=Blue>------------------------------------------------------------------------</font>-<font color=Blue>-- | Push some tokens back onto the front of the input stream and reparse.</font>-<font color=Blue>-- This is useful e.g. for recursively expanding macros. When the</font>-<font color=Blue>-- user-parser recognises a macro use, it can lookup the macro</font>-<font color=Blue>-- expansion from the parse state, lex it, and then stuff the</font>-<font color=Blue>-- lexed expansion back down into the parser.</font>-reparse <font color=Red>::</font> <font color=Red>[</font>t<font color=Red>]</font> <font color=Red>-></font> Parser t <font color=Cyan>(</font><font color=Cyan>)</font>-<a name="reparse"></a>reparse ts <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>inp<font color=Red>-></font> <font color=Cyan>(</font>Right <font color=Cyan>(</font><font color=Cyan>)</font><font color=Cyan>,</font> ts<font color=Cyan>++</font>inp<font color=Cyan>)</font><font color=Cyan>)</font>--<font color=Blue>------------------------------------------------------------------------</font>-</pre>
− docs/HaXml/src/Text/ParserCombinators/PolyLazy.html
@@ -1,261 +0,0 @@-<pre><font color=Green><u>module</u></font> Text<font color=Cyan>.</font>ParserCombinators<font color=Cyan>.</font>PolyLazy- <font color=Cyan>(</font> <font color=Blue>-- * A Parser datatype parameterised on arbitrary token type.</font>- <font color=Blue>-- Parsers do not return explicit failure. An exception is</font>- <font color=Blue>-- raised instead. This allows partial results to be returned</font>- <font color=Blue>-- before a full parse is complete.</font>- Parser<font color=Cyan>(</font>P<font color=Cyan>)</font> <font color=Blue>-- datatype, instance of: Functor, Monad</font>- <font color=Cyan>,</font> runParser <font color=Blue>-- :: Parser t a -> [t] -> (a, [t])</font>- <font color=Cyan>,</font> failBad <font color=Blue>-- :: String -> Parser t a</font>- <font color=Cyan>,</font> commit <font color=Blue>-- :: Parser t a -> Parser t a</font>- <font color=Blue>-- * Combinators</font>- <font color=Blue>-- ** primitives</font>- <font color=Cyan>,</font> next <font color=Blue>-- :: Parser t t</font>- <font color=Cyan>,</font> satisfy <font color=Blue>-- :: (t->Bool) -> Parser t t</font>- <font color=Cyan>,</font> apply <font color=Blue>-- :: Parser t (a->b) -> Parser t a -> Parser t b</font>- <font color=Cyan>,</font> discard <font color=Blue>-- :: Parser t a -> Parser t b -> Parser t a</font>- <font color=Blue>-- ** error-handling</font>- <font color=Cyan>,</font> adjustErr <font color=Blue>-- :: Parser t a -> (String->String) -> Parser t a</font>- <font color=Cyan>,</font> adjustErrBad<font color=Blue>-- :: Parser t a -> (String->String) -> Parser t a</font>- <font color=Cyan>,</font> indent <font color=Blue>-- :: Int -> String -> String</font>- <font color=Blue>-- ** choices</font>- <font color=Cyan>,</font> onFail <font color=Blue>-- :: Parser t a -> Parser t a -> Parser t a</font>- <font color=Cyan>,</font> oneOf <font color=Blue>-- :: Show t => [Parser t a] -> Parser t a</font>- <font color=Cyan>,</font> oneOf' <font color=Blue>-- :: [(String,Parser t a)] -> Parser t a</font>- <font color=Cyan>,</font> optional <font color=Blue>-- :: Parser t a -> Parser t (Maybe a)</font>- <font color=Blue>-- ** sequences</font>- <font color=Cyan>,</font> many <font color=Blue>-- :: Parser t a -> Parser t [a]</font>- <font color=Cyan>,</font> many1 <font color=Blue>-- :: Parser t a -> Parser t [a]</font>- <font color=Cyan>,</font> sepBy <font color=Blue>-- :: Parser t a -> Parser t sep -> Parser t [a]</font>- <font color=Cyan>,</font> sepBy1 <font color=Blue>-- :: Parser t a -> Parser t sep -> Parser t [a]</font>- <font color=Cyan>,</font> bracketSep <font color=Blue>-- :: Parser t bra -> Parser t sep -> Parser t ket</font>- <font color=Blue>-- -> Parser t a -> Parser t [a]</font>- <font color=Cyan>,</font> bracket <font color=Blue>-- :: Parser t bra -> Parser t ket -> Parser t a</font>- <font color=Blue>-- -> Parser t a</font>- <font color=Cyan>,</font> manyFinally <font color=Blue>-- :: Parser t a -> Parser t z -> Parser t [a]</font>- <font color=Blue>-- ** re-parsing</font>- <font color=Cyan>,</font> reparse <font color=Blue>-- :: [t] -> Parser t ()</font>- <font color=Cyan>)</font> <font color=Green><u>where</u></font>--<font color=Cyan>#</font><font color=Green><u>if</u></font> <b><font color=Magenta>__GLASGOW_HASKELL__</font></b>-<font color=Green><u>import</u></font> Control<font color=Cyan>.</font>Exception hiding <font color=Cyan>(</font>bracket<font color=Cyan>)</font>-throwE <font color=Red>::</font> String <font color=Red>-></font> a-<a name="throwE"></a>throwE msg <font color=Red>=</font> throw <font color=Cyan>(</font>ErrorCall msg<font color=Cyan>)</font>-<font color=Cyan>#</font><font color=Green><u>else</u></font>-throwE <font color=Red>::</font> String <font color=Red>-></font> a-throwE msg <font color=Red>=</font> error msg-<font color=Cyan>#</font>endif--<font color=Blue>-- | The @Parser@ datatype is a fairly generic parsing monad with error</font>-<font color=Blue>-- reporting. It can be used for arbitrary token types, not just</font>-<font color=Blue>-- String input. (If you require a running state, use module PolyState</font>-<font color=Blue>-- instead.)</font>-<font color=Green><u>newtype</u></font> Parser t a <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>[</font>t<font color=Red>]</font> <font color=Red>-></font> <font color=Cyan>(</font>Either String a<font color=Cyan>,</font> <font color=Red>[</font>t<font color=Red>]</font><font color=Cyan>)</font><font color=Cyan>)</font>--<font color=Blue>-- A return type like Either, that distinguishes not only between</font>-<font color=Blue>-- right and wrong answers, but also had gradations of wrongness.</font>-<font color=Blue>-- Not used in this library. !!!!!!!!!!!!!!!!!!!!!!!!!!!</font>-<a name="EitherE"></a><font color=Green><u>type</u></font> EitherE a b <font color=Red>=</font> Either <font color=Cyan>(</font>Bool<font color=Cyan>,</font>a<font color=Cyan>)</font> b--<font color=Blue>-- | Apply a parser to an input token sequence. The parser cannot return</font>-<font color=Blue>-- an error value explicitly, so errors raise an exception. Thus, results</font>-<font color=Blue>-- can be partial (lazily constructed, but containing undefined).</font>-runParser <font color=Red>::</font> Parser t a <font color=Red>-></font> <font color=Red>[</font>t<font color=Red>]</font> <font color=Red>-></font> <font color=Cyan>(</font>a<font color=Cyan>,</font> <font color=Red>[</font>t<font color=Red>]</font><font color=Cyan>)</font>-<a name="runParser"></a>runParser <font color=Cyan>(</font>P p<font color=Cyan>)</font> <font color=Red>=</font>- <font color=Cyan>(</font><font color=Red>\</font> <font color=Cyan>(</font>e<font color=Cyan>,</font>ts<font color=Cyan>)</font><font color=Red>-></font> <font color=Cyan>(</font><font color=Green><u>case</u></font> e <font color=Green><u>of</u></font> <font color=Cyan>{</font>Left m<font color=Red>-></font>throwE m<font color=Cyan>;</font> Right x<font color=Red>-></font>x<font color=Cyan>}</font><font color=Cyan>,</font> ts<font color=Cyan>)</font> <font color=Cyan>)</font>- <font color=Cyan>.</font> p--<font color=Green><u>instance</u></font> Functor <font color=Cyan>(</font>Parser t<font color=Cyan>)</font> <font color=Green><u>where</u></font>- fmap f <font color=Cyan>(</font>P p<font color=Cyan>)</font> <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>ts<font color=Red>-></font> <font color=Green><u>case</u></font> p ts <font color=Green><u>of</u></font>- <font color=Cyan>(</font>Left msg<font color=Cyan>,</font> ts'<font color=Cyan>)</font> <font color=Red>-></font> <font color=Cyan>(</font>Left msg<font color=Cyan>,</font> ts'<font color=Cyan>)</font>- <font color=Cyan>(</font>Right x<font color=Cyan>,</font> ts'<font color=Cyan>)</font> <font color=Red>-></font> <font color=Cyan>(</font>Right <font color=Cyan>(</font>f x<font color=Cyan>)</font><font color=Cyan>,</font> ts'<font color=Cyan>)</font><font color=Cyan>)</font>-<font color=Green><u>instance</u></font> Monad <font color=Cyan>(</font>Parser t<font color=Cyan>)</font> <font color=Green><u>where</u></font>- return x <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>ts<font color=Red>-></font> <font color=Cyan>(</font>Right x<font color=Cyan>,</font> ts<font color=Cyan>)</font><font color=Cyan>)</font>- <font color=Cyan>(</font>P f<font color=Cyan>)</font> <font color=Cyan>>>=</font> g <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>ts<font color=Red>-></font> <font color=Green><u>case</u></font> f ts <font color=Green><u>of</u></font>- <font color=Cyan>(</font>Left msg<font color=Cyan>,</font> ts'<font color=Cyan>)</font> <font color=Red>-></font> <font color=Cyan>(</font>Left msg<font color=Cyan>,</font> ts'<font color=Cyan>)</font>- <font color=Cyan>(</font>Right x<font color=Cyan>,</font> ts'<font color=Cyan>)</font> <font color=Red>-></font> <font color=Green><u>let</u></font> <font color=Cyan>(</font>P g'<font color=Cyan>)</font> <font color=Red>=</font> g x <font color=Green><u>in</u></font> g' ts'<font color=Cyan>)</font>- fail e <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>ts<font color=Red>-></font> <font color=Cyan>(</font>Left e<font color=Cyan>,</font> ts<font color=Cyan>)</font><font color=Cyan>)</font>--<font color=Blue>-- | Simple failure can be corrected, but when a simple fail is not strong</font>-<font color=Blue>-- enough, use failBad for emphasis. It guarantees parsing will</font>-<font color=Blue>-- terminate with an exception.</font>--failBad <font color=Red>::</font> String <font color=Red>-></font> Parser t a-<a name="failBad"></a>failBad msg <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>ts<font color=Red>-></font> <font color=Cyan>(</font>throwE msg<font color=Cyan>,</font> ts<font color=Cyan>)</font><font color=Cyan>)</font>--<font color=Blue>-- | Commit is a way of raising the severity of any errors found within</font>-<font color=Blue>-- its argument. Used in the middle of a parser definition, it means that</font>-<font color=Blue>-- any operations prior to commitment fail softly, but after commitment,</font>-<font color=Blue>-- they fail hard.</font>-commit <font color=Red>::</font> Parser t a <font color=Red>-></font> Parser t a-<a name="commit"></a>commit <font color=Cyan>(</font>P p<font color=Cyan>)</font> <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>ts<font color=Red>-></font> <font color=Green><u>case</u></font> p ts <font color=Green><u>of</u></font>- <font color=Cyan>(</font>Left e<font color=Cyan>,</font> ts'<font color=Cyan>)</font> <font color=Red>-></font> <font color=Cyan>(</font>throwE e<font color=Cyan>,</font> ts'<font color=Cyan>)</font>- right <font color=Red>-></font> right <font color=Cyan>)</font>---<font color=Blue>-- Combinators</font>--<font color=Blue>-- | One token</font>-next <font color=Red>::</font> Parser t t-<a name="next"></a>next <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>ts<font color=Red>-></font> <font color=Green><u>case</u></font> ts <font color=Green><u>of</u></font>- <font color=Red>[</font><font color=Red>]</font> <font color=Red>-></font> <font color=Cyan>(</font>Left <font color=Magenta>"Ran out of input (EOF)"</font><font color=Cyan>,</font> <font color=Red>[</font><font color=Red>]</font><font color=Cyan>)</font>- <font color=Cyan>(</font>t<font color=Red><b>:</b></font>ts'<font color=Cyan>)</font> <font color=Red>-></font> <font color=Cyan>(</font>Right t<font color=Cyan>,</font> ts'<font color=Cyan>)</font> <font color=Cyan>)</font>--<font color=Blue>-- | One token satifying a predicate</font>-satisfy <font color=Red>::</font> <font color=Cyan>(</font>t<font color=Red>-></font>Bool<font color=Cyan>)</font> <font color=Red>-></font> Parser t t-<a name="satisfy"></a>satisfy p <font color=Red>=</font> <font color=Green><u>do</u></font><font color=Cyan>{</font> x <font color=Red><-</font> next- <font color=Cyan>;</font> <font color=Green><u>if</u></font> p x <font color=Green><u>then</u></font> return x <font color=Green><u>else</u></font> fail <font color=Magenta>"Parse.satisfy: failed"</font>- <font color=Cyan>}</font>--<font color=Green><u>infixl</u></font> <font color=Magenta>3</font> <font color=Cyan>`apply`</font>-<font color=Blue>-- | Apply a parsed function to a parsed value</font>-apply <font color=Red>::</font> Parser t <font color=Cyan>(</font>a<font color=Red>-></font>b<font color=Cyan>)</font> <font color=Red>-></font> Parser t a <font color=Red>-></font> Parser t b-<font color=Blue>--pf `apply` px = do { f <- pf; x <- px; return (f x) }</font>-<font color=Blue>-- Needs to be lazier! Must not force the argument value too early. </font>-<a name="apply"></a><font color=Cyan>(</font>P pf<font color=Cyan>)</font> <font color=Cyan>`apply`</font> <font color=Cyan>(</font>P px<font color=Cyan>)</font> <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>ts<font color=Red>-></font>- <font color=Green><u>case</u></font> pf ts <font color=Green><u>of</u></font>- <font color=Cyan>(</font>Left msg<font color=Cyan>,</font> ts'<font color=Cyan>)</font> <font color=Red>-></font> <font color=Cyan>(</font>Left msg<font color=Cyan>,</font> ts'<font color=Cyan>)</font>- <font color=Cyan>(</font>Right f<font color=Cyan>,</font> ts'<font color=Cyan>)</font> <font color=Red>-></font> <font color=Green><u>let</u></font> <font color=Cyan>(</font>x'<font color=Cyan>,</font>ts''<font color=Cyan>)</font> <font color=Red>=</font> px ts'- x <font color=Red>=</font> <font color=Green><u>case</u></font> x' <font color=Green><u>of</u></font> <font color=Cyan>{</font> Right x <font color=Red>-></font> x<font color=Cyan>;</font> Left e <font color=Red>-></font> throwE e <font color=Cyan>}</font>- <font color=Green><u>in</u></font> <font color=Cyan>(</font>Right <font color=Cyan>(</font>f x<font color=Cyan>)</font><font color=Cyan>,</font> ts''<font color=Cyan>)</font> <font color=Cyan>)</font>--<font color=Green><u>infixl</u></font> <font color=Magenta>3</font> <font color=Cyan>`discard`</font>-<font color=Blue>-- | @x `discard` y@ parses both x and y, but discards the result of y</font>-discard <font color=Red>::</font> Parser t a <font color=Red>-></font> Parser t b <font color=Red>-></font> Parser t a-<a name="discard"></a>px <font color=Cyan>`discard`</font> py <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font> x <font color=Red><-</font> px<font color=Cyan>;</font> <font color=Green><u>_</u></font> <font color=Red><-</font> py<font color=Cyan>;</font> return x <font color=Cyan>}</font>--<font color=Blue>-- | @p `adjustErr` f@ applies the transformation @f@ to any error message</font>-<font color=Blue>-- generated in @p@, having no effect if @p@ succeeds.</font>-adjustErr <font color=Red>::</font> Parser t a <font color=Red>-></font> <font color=Cyan>(</font>String<font color=Red>-></font>String<font color=Cyan>)</font> <font color=Red>-></font> Parser t a-<a name="adjustErr"></a><font color=Cyan>(</font>P p<font color=Cyan>)</font> <font color=Cyan>`adjustErr`</font> f <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>ts<font color=Red>-></font> <font color=Green><u>case</u></font> p ts <font color=Green><u>of</u></font>- <font color=Cyan>(</font>Left msg<font color=Cyan>,</font> ts'<font color=Cyan>)</font> <font color=Red>-></font> <font color=Cyan>(</font>Left <font color=Cyan>(</font>f msg<font color=Cyan>)</font><font color=Cyan>,</font> ts'<font color=Cyan>)</font>- right <font color=Red>-></font> right <font color=Cyan>)</font>--<font color=Blue>-- | @adjustErrBad@ is just like @adjustErr@ except it also raises the</font>-<font color=Blue>-- severity of the error.</font>-adjustErrBad <font color=Red>::</font> Parser t a <font color=Red>-></font> <font color=Cyan>(</font>String<font color=Red>-></font>String<font color=Cyan>)</font> <font color=Red>-></font> Parser t a-<a name="adjustErrBad"></a>p <font color=Cyan>`adjustErrBad`</font> f <font color=Red>=</font> commit <font color=Cyan>(</font>p <font color=Cyan>`adjustErr`</font> f<font color=Cyan>)</font>--<font color=Green><u>infixl</u></font> <font color=Magenta>6</font> <font color=Cyan>`onFail`</font> <font color=Blue>-- not sure about precedence 6?</font>-<font color=Blue>-- | @p `onFail` q@ means parse p unless p fails in which case parse q instead.</font>-<font color=Blue>-- Can be chained together to give multiple attempts to parse something.</font>-<font color=Blue>-- (Note that q could itself be a failing parser, e.g. to change the error</font>-<font color=Blue>-- message from that defined in p to something different.)</font>-<font color=Blue>-- However, a *severe* failure in p cannot be ignored.</font>-onFail <font color=Red>::</font> Parser t a <font color=Red>-></font> Parser t a <font color=Red>-></font> Parser t a-<a name="onFail"></a><font color=Cyan>(</font>P p<font color=Cyan>)</font> <font color=Cyan>`onFail`</font> <font color=Cyan>(</font>P q<font color=Cyan>)</font> <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>ts<font color=Red>-></font> <font color=Green><u>case</u></font> p ts <font color=Green><u>of</u></font>- <font color=Cyan>(</font>Left <font color=Green><u>_</u></font><font color=Cyan>,</font> <font color=Green><u>_</u></font><font color=Cyan>)</font> <font color=Red>-></font> q ts- right <font color=Red>-></font> right <font color=Cyan>)</font>--<font color=Blue>-- | Parse the first alternative in the list that succeeds.</font>-oneOf <font color=Red>::</font> <font color=Red>[</font>Parser t a<font color=Red>]</font> <font color=Red>-></font> Parser t a-<a name="oneOf"></a>oneOf <font color=Red>[</font><font color=Red>]</font> <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font> n <font color=Red><-</font> next- <font color=Cyan>;</font> fail <font color=Cyan>(</font><font color=Magenta>"failed to parse any of the possible choices"</font><font color=Cyan>)</font>- <font color=Cyan>}</font>-<font color=Blue>--oneOf :: Show t => [Parser t a] -> Parser t a</font>-<font color=Blue>--oneOf [] = do { n <- next</font>-<font color=Blue>-- ; fail ("failed to parse any of the possible choices"</font>-<font color=Blue>-- ++"\n next token is "++show n)</font>-<font color=Blue>-- }</font>-oneOf <font color=Cyan>(</font>p<font color=Red><b>:</b></font>ps<font color=Cyan>)</font> <font color=Red>=</font> p <font color=Cyan>`onFail`</font> oneOf ps--<font color=Blue>-- | Parse the first alternative that succeeds, but if none succeed,</font>-<font color=Blue>-- report only the severe errors, and if none of those, then report</font>-<font color=Blue>-- all the soft errors.</font>-oneOf' <font color=Red>::</font> <font color=Red>[</font><font color=Cyan>(</font>String<font color=Cyan>,</font> Parser t a<font color=Cyan>)</font><font color=Red>]</font> <font color=Red>-></font> Parser t a-<a name="oneOf'"></a>oneOf' ps <font color=Red>=</font> accum <font color=Red>[</font><font color=Red>]</font> ps- <font color=Green><u>where</u></font> accum errs <font color=Red>[</font><font color=Red>]</font> <font color=Red>=</font>- <font color=Green><u>case</u></font> errs <font color=Green><u>of</u></font>- <font color=Red>[</font><font color=Red>]</font> <font color=Red>-></font> failBad <font color=Cyan>(</font><font color=Magenta>"internal failure in parser (oneOf'):\n"</font>- <font color=Cyan>++</font>indent <font color=Magenta>2</font> <font color=Cyan>(</font>show <font color=Cyan>(</font>map fst ps<font color=Cyan>)</font><font color=Cyan>)</font><font color=Cyan>)</font>- <font color=Red>[</font><font color=Cyan>(</font><font color=Green><u>_</u></font><font color=Cyan>,</font>e<font color=Cyan>)</font><font color=Red>]</font> <font color=Red>-></font> fail e- es <font color=Red>-></font> fail <font color=Cyan>(</font><font color=Magenta>"one of the following failures occurred:\n"</font>- <font color=Cyan>++</font>indent <font color=Magenta>2</font> <font color=Cyan>(</font>concatMap showErr <font color=Cyan>(</font>reverse es<font color=Cyan>)</font><font color=Cyan>)</font><font color=Cyan>)</font>- accum errs <font color=Cyan>(</font><font color=Cyan>(</font>e<font color=Cyan>,</font>P p<font color=Cyan>)</font><font color=Red><b>:</b></font>ps<font color=Cyan>)</font> <font color=Red>=</font>- P <font color=Cyan>(</font><font color=Red>\</font>ts<font color=Red>-></font> <font color=Green><u>case</u></font> p ts <font color=Green><u>of</u></font>- <font color=Cyan>(</font>Left err<font color=Cyan>,</font><font color=Green><u>_</u></font><font color=Cyan>)</font> <font color=Red>-></font> <font color=Green><u>let</u></font> <font color=Cyan>(</font>P p<font color=Cyan>)</font> <font color=Red>=</font> accum <font color=Cyan>(</font><font color=Cyan>(</font>e<font color=Cyan>,</font>err<font color=Cyan>)</font><font color=Red><b>:</b></font>errs<font color=Cyan>)</font> ps- <font color=Green><u>in</u></font> p ts- right <font color=Red>-></font> right <font color=Cyan>)</font>- showErr <font color=Cyan>(</font>name<font color=Cyan>,</font>err<font color=Cyan>)</font> <font color=Red>=</font> name<font color=Cyan>++</font><font color=Magenta>":\n"</font><font color=Cyan>++</font>indent <font color=Magenta>2</font> err--<font color=Blue>-- | Helper for formatting error messages: indents all lines by a fixed amount.</font>-indent <font color=Red>::</font> Int <font color=Red>-></font> String <font color=Red>-></font> String-<a name="indent"></a>indent n <font color=Red>=</font> unlines <font color=Cyan>.</font> map <font color=Cyan>(</font>replicate n <font color=Magenta>' '</font> <font color=Cyan>++</font><font color=Cyan>)</font> <font color=Cyan>.</font> lines--<font color=Blue>-- | 'optional' indicates whether the parser succeeded through the Maybe type.</font>-optional <font color=Red>::</font> Parser t a <font color=Red>-></font> Parser t <font color=Cyan>(</font>Maybe a<font color=Cyan>)</font>-<a name="optional"></a>optional p <font color=Red>=</font> fmap Just p <font color=Cyan>`onFail`</font> return Nothing--<font color=Blue>-- | 'many p' parses a list of elements with individual parser p.</font>-<font color=Blue>-- Cannot fail, since an empty list is a valid return value.</font>-many <font color=Red>::</font> Parser t a <font color=Red>-></font> Parser t <font color=Red>[</font>a<font color=Red>]</font>-<a name="many"></a>many p <font color=Red>=</font> many1 p <font color=Cyan>`onFail`</font> return <font color=Red>[</font><font color=Red>]</font>--<font color=Blue>-- | Parse a non-empty list of items.</font>-many1 <font color=Red>::</font> Parser t a <font color=Red>-></font> Parser t <font color=Red>[</font>a<font color=Red>]</font>-<a name="many1"></a>many1 p <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font> x <font color=Red><-</font> p <font color=Cyan>`adjustErr`</font> <font color=Cyan>(</font><font color=Cyan>(</font><font color=Magenta>"In a sequence:\n"</font><font color=Cyan>++</font><font color=Cyan>)</font><font color=Cyan>.</font> indent <font color=Magenta>2</font><font color=Cyan>)</font>- <font color=Cyan>;</font> xs <font color=Red><-</font> many p- <font color=Cyan>;</font> return <font color=Cyan>(</font>x<font color=Red><b>:</b></font>xs<font color=Cyan>)</font>- <font color=Cyan>}</font>-<font color=Blue>-- `adjustErr` ("When looking for a non-empty sequence:\n\t"++)</font>--<font color=Blue>-- | Parse a list of items separated by discarded junk.</font>-sepBy <font color=Red>::</font> Parser t a <font color=Red>-></font> Parser t sep <font color=Red>-></font> Parser t <font color=Red>[</font>a<font color=Red>]</font>-<a name="sepBy"></a>sepBy p sep <font color=Red>=</font> <font color=Green><u>do</u></font> sepBy1 p sep <font color=Cyan>`onFail`</font> return <font color=Red>[</font><font color=Red>]</font>--<font color=Blue>-- | Parse a non-empty list of items separated by discarded junk.</font>-sepBy1 <font color=Red>::</font> Parser t a <font color=Red>-></font> Parser t sep <font color=Red>-></font> Parser t <font color=Red>[</font>a<font color=Red>]</font>-<a name="sepBy1"></a>sepBy1 p sep <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font> x <font color=Red><-</font> p- <font color=Cyan>;</font> xs <font color=Red><-</font> many <font color=Cyan>(</font><font color=Green><u>do</u></font> <font color=Cyan>{</font>sep<font color=Cyan>;</font> p<font color=Cyan>}</font><font color=Cyan>)</font>- <font color=Cyan>;</font> return <font color=Cyan>(</font>x<font color=Red><b>:</b></font>xs<font color=Cyan>)</font>- <font color=Cyan>}</font>- <font color=Cyan>`adjustErr`</font> <font color=Cyan>(</font><font color=Magenta>"When looking for a non-empty sequence with separators:\n\t"</font><font color=Cyan>++</font><font color=Cyan>)</font>- -<font color=Blue>-- | Parse a list of items, discarding the start, end, and separator</font>-<font color=Blue>-- items.</font>-bracketSep <font color=Red>::</font> Parser t bra <font color=Red>-></font> Parser t sep <font color=Red>-></font> Parser t ket- <font color=Red>-></font> Parser t a <font color=Red>-></font> Parser t <font color=Red>[</font>a<font color=Red>]</font>-<a name="bracketSep"></a>bracketSep open sep close p <font color=Red>=</font>- <font color=Green><u>do</u></font> <font color=Cyan>{</font> open<font color=Cyan>;</font> close<font color=Cyan>;</font> return <font color=Red>[</font><font color=Red>]</font> <font color=Cyan>}</font>- <font color=Cyan>`onFail`</font>- <font color=Green><u>do</u></font> <font color=Cyan>{</font> open <font color=Cyan>`adjustErr`</font> <font color=Cyan>(</font><font color=Magenta>"Missing opening bracket:\n\t"</font><font color=Cyan>++</font><font color=Cyan>)</font>- <font color=Cyan>;</font> x <font color=Red><-</font> p <font color=Cyan>`adjustErr`</font> <font color=Cyan>(</font><font color=Magenta>"After first bracket in a group:\n\t"</font><font color=Cyan>++</font><font color=Cyan>)</font>- <font color=Cyan>;</font> xs <font color=Red><-</font> many <font color=Cyan>(</font><font color=Green><u>do</u></font> <font color=Cyan>{</font>sep<font color=Cyan>;</font> p<font color=Cyan>}</font><font color=Cyan>)</font>- <font color=Cyan>;</font> close <font color=Cyan>`adjustErrBad`</font> <font color=Cyan>(</font><font color=Magenta>"When looking for closing bracket:\n\t"</font><font color=Cyan>++</font><font color=Cyan>)</font>- <font color=Cyan>;</font> return <font color=Cyan>(</font>x<font color=Red><b>:</b></font>xs<font color=Cyan>)</font>- <font color=Cyan>}</font>--<font color=Blue>-- | Parse a bracketed item, discarding the brackets.</font>-bracket <font color=Red>::</font> Parser t bra <font color=Red>-></font> Parser t ket <font color=Red>-></font> Parser t a <font color=Red>-></font> Parser t a-<a name="bracket"></a>bracket open close p <font color=Red>=</font> <font color=Green><u>do</u></font>- <font color=Green><u>do</u></font> <font color=Cyan>{</font> open <font color=Cyan>`adjustErr`</font> <font color=Cyan>(</font><font color=Magenta>"Missing opening bracket:\n\t"</font><font color=Cyan>++</font><font color=Cyan>)</font>- <font color=Cyan>;</font> x <font color=Red><-</font> p- <font color=Cyan>;</font> close <font color=Cyan>`adjustErrBad`</font> <font color=Cyan>(</font><font color=Magenta>"Missing closing bracket:\n\t"</font><font color=Cyan>++</font><font color=Cyan>)</font>- <font color=Cyan>;</font> return x- <font color=Cyan>}</font>--<font color=Blue>-- | 'manyFinally e t' parses a possibly-empty sequence of e's,</font>-<font color=Blue>-- terminated by a t. Any parse failures could be due either to</font>-<font color=Blue>-- a badly-formed terminator or a badly-formed element, so raise</font>-<font color=Blue>-- both possible errors.</font>-manyFinally <font color=Red>::</font> Parser t a <font color=Red>-></font> Parser t z <font color=Red>-></font> Parser t <font color=Red>[</font>a<font color=Red>]</font>-<a name="manyFinally"></a>manyFinally pp<font color=Red>@</font><font color=Cyan>(</font>P p<font color=Cyan>)</font> pt<font color=Red>@</font><font color=Cyan>(</font>P t<font color=Cyan>)</font> <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>ts <font color=Red>-></font>- <font color=Green><u>case</u></font> p ts <font color=Green><u>of</u></font>- <font color=Cyan>(</font>Left e<font color=Cyan>,</font> <font color=Green><u>_</u></font><font color=Cyan>)</font> <font color=Red>-></font>- <font color=Green><u>case</u></font> t ts <font color=Green><u>of</u></font>- <font color=Cyan>(</font>Right <font color=Green><u>_</u></font><font color=Cyan>,</font> ts'<font color=Cyan>)</font> <font color=Red>-></font> <font color=Cyan>(</font>Right <font color=Red>[</font><font color=Red>]</font><font color=Cyan>,</font> ts'<font color=Cyan>)</font>- <font color=Cyan>(</font>Left e<font color=Cyan>,</font> ts'<font color=Cyan>)</font> <font color=Red>-></font> <font color=Cyan>(</font>Left e<font color=Cyan>,</font> ts'<font color=Cyan>)</font>- <font color=Cyan>(</font>Right x<font color=Cyan>,</font> ts'<font color=Cyan>)</font> <font color=Red>-></font>- <font color=Green><u>let</u></font> <font color=Cyan>(</font>tail<font color=Cyan>,</font>ts''<font color=Cyan>)</font> <font color=Red>=</font> runParser <font color=Cyan>(</font>manyFinally pp pt<font color=Cyan>)</font> ts'- <font color=Green><u>in</u></font> <font color=Cyan>(</font>Right <font color=Cyan>(</font>x<font color=Red><b>:</b></font>tail<font color=Cyan>)</font><font color=Cyan>,</font> ts''<font color=Cyan>)</font> <font color=Cyan>)</font>--<font color=Blue>------------------------------------------------------------------------</font>-<font color=Blue>-- | Push some tokens back onto the front of the input stream and reparse.</font>-<font color=Blue>-- This is useful e.g. for recursively expanding macros. When the</font>-<font color=Blue>-- user-parser recognises a macro use, it can lookup the macro</font>-<font color=Blue>-- expansion from the parse state, lex it, and then stuff the</font>-<font color=Blue>-- lexed expansion back down into the parser.</font>-reparse <font color=Red>::</font> <font color=Red>[</font>t<font color=Red>]</font> <font color=Red>-></font> Parser t <font color=Cyan>(</font><font color=Cyan>)</font>-<a name="reparse"></a>reparse ts <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>inp<font color=Red>-></font> <font color=Cyan>(</font>Right <font color=Cyan>(</font><font color=Cyan>)</font><font color=Cyan>,</font> ts<font color=Cyan>++</font>inp<font color=Cyan>)</font><font color=Cyan>)</font>--<font color=Blue>------------------------------------------------------------------------</font>-</pre>
− docs/HaXml/src/Text/ParserCombinators/PolyState.html
@@ -1,249 +0,0 @@-<pre><font color=Green><u>module</u></font> Text<font color=Cyan>.</font>ParserCombinators<font color=Cyan>.</font>PolyState- <font color=Cyan>(</font> <font color=Blue>-- * A Parser datatype parameterised on arbitrary token type and state type</font>- Parser<font color=Cyan>(</font>P<font color=Cyan>)</font> <font color=Blue>-- datatype, instance of: Functor, Monad</font>- <font color=Cyan>,</font> runParser <font color=Blue>-- :: Parser s t a -> s -> [t] -> (Either String a, s, [t])</font>- <font color=Cyan>,</font> failBad <font color=Blue>-- :: String -> Parser s t a</font>- <font color=Cyan>,</font> commit <font color=Blue>-- :: Parser s t a -> Parser s t a</font>- <font color=Blue>-- * Combinators</font>- <font color=Blue>-- ** primitives</font>- <font color=Cyan>,</font> next <font color=Blue>-- :: Parser s t t</font>- <font color=Cyan>,</font> satisfy <font color=Blue>-- :: (t->Bool) -> Parser s t t</font>- <font color=Cyan>,</font> apply <font color=Blue>-- :: Parser t (a->b) -> Parser s t a -> Parser s t b</font>- <font color=Cyan>,</font> discard <font color=Blue>-- :: Parser s t a -> Parser s t b -> Parser s t a</font>- <font color=Blue>-- ** error-handling</font>- <font color=Cyan>,</font> adjustErr <font color=Blue>-- :: Parser s t a -> (String->String) -> Parser s t a</font>- <font color=Cyan>,</font> adjustErrBad<font color=Blue>-- :: Parser s t a -> (String->String) -> Parser s t a</font>- <font color=Cyan>,</font> indent <font color=Blue>-- :: Int -> String -> String</font>- <font color=Blue>-- ** choices</font>- <font color=Cyan>,</font> onFail <font color=Blue>-- :: Parser s t a -> Parser s t a -> Parser s t a</font>- <font color=Cyan>,</font> oneOf <font color=Blue>-- :: [Parser s t a] -> Parser s t a</font>- <font color=Cyan>,</font> oneOf' <font color=Blue>-- :: [(String, Parser s t a)] -> Parser s t a</font>- <font color=Blue>-- ** sequences</font>- <font color=Cyan>,</font> many <font color=Blue>-- :: Parser s t a -> Parser s t [a]</font>- <font color=Cyan>,</font> many1 <font color=Blue>-- :: Parser s t a -> Parser s t [a]</font>- <font color=Cyan>,</font> sepBy <font color=Blue>-- :: Parser s t a -> Parser s t sep -> Parser s t [a]</font>- <font color=Cyan>,</font> sepBy1 <font color=Blue>-- :: Parser s t a -> Parser s t sep -> Parser s t [a]</font>- <font color=Cyan>,</font> bracketSep <font color=Blue>-- :: Parser s t bra -> Parser s t sep -> Parser s t ket</font>- <font color=Blue>-- -> Parser s t a -> Parser s t [a]</font>- <font color=Cyan>,</font> bracket <font color=Blue>-- :: Parser s t bra -> Parser s t ket -> Parser s t a</font>- <font color=Blue>-- -> Parser s t a</font>- <font color=Cyan>,</font> manyFinally <font color=Blue>-- :: Parser s t a -> Parser s t z -> Parser s t [a]</font>- <font color=Blue>-- ** state-handling</font>- <font color=Cyan>,</font> stUpdate <font color=Blue>-- :: (s->s) -> Parser s t ()</font>- <font color=Cyan>,</font> stQuery <font color=Blue>-- :: (s->a) -> Parser s t a</font>- <font color=Cyan>,</font> stGet <font color=Blue>-- :: Parser s t s</font>- <font color=Blue>-- ** re-parsing</font>- <font color=Cyan>,</font> reparse <font color=Blue>-- :: [t] -> Parser s t ()</font>- <font color=Cyan>)</font> <font color=Green><u>where</u></font>--<font color=Blue>-- | The @Parser@ datatype is a fairly generic parsing monad with error</font>-<font color=Blue>-- reporting and a running state. It can be used for arbitrary token</font>-<font color=Blue>-- types, not just String input.</font>-<font color=Green><u>newtype</u></font> Parser s t a <font color=Red>=</font> P <font color=Cyan>(</font>s <font color=Red>-></font> <font color=Red>[</font>t<font color=Red>]</font> <font color=Red>-></font> <font color=Cyan>(</font>EitherE String a<font color=Cyan>,</font> s<font color=Cyan>,</font> <font color=Red>[</font>t<font color=Red>]</font><font color=Cyan>)</font><font color=Cyan>)</font>--<font color=Blue>-- | A return type like Either, that distinguishes not only between</font>-<font color=Blue>-- right and wrong answers, but also had gradations of wrongness.</font>-<a name="EitherE"></a><font color=Green><u>type</u></font> EitherE a b <font color=Red>=</font> Either <font color=Cyan>(</font>Bool<font color=Cyan>,</font>a<font color=Cyan>)</font> b--<font color=Blue>-- | Apply a parser to an initial state and input token sequence.</font>-runParser <font color=Red>::</font> Parser s t a <font color=Red>-></font> s <font color=Red>-></font> <font color=Red>[</font>t<font color=Red>]</font> <font color=Red>-></font> <font color=Cyan>(</font>Either String a<font color=Cyan>,</font> s<font color=Cyan>,</font> <font color=Red>[</font>t<font color=Red>]</font><font color=Cyan>)</font>-<a name="runParser"></a>runParser <font color=Cyan>(</font>P p<font color=Cyan>)</font> s <font color=Red>=</font>- <font color=Cyan>(</font><font color=Red>\</font> <font color=Cyan>(</font>e<font color=Cyan>,</font>s<font color=Cyan>,</font>ts<font color=Cyan>)</font><font color=Red>-></font> <font color=Cyan>(</font><font color=Green><u>case</u></font> e <font color=Green><u>of</u></font> Left <font color=Cyan>(</font><font color=Green><u>_</u></font><font color=Cyan>,</font>m<font color=Cyan>)</font><font color=Red>-></font>Left m<font color=Cyan>;</font> Right m<font color=Red>-></font>Right m- <font color=Cyan>,</font>s<font color=Cyan>,</font>ts<font color=Cyan>)</font><font color=Cyan>)</font>- <font color=Cyan>.</font> p s--<font color=Green><u>instance</u></font> Functor <font color=Cyan>(</font>Parser s t<font color=Cyan>)</font> <font color=Green><u>where</u></font>- fmap f <font color=Cyan>(</font>P p<font color=Cyan>)</font> <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>s ts<font color=Red>-></font> <font color=Green><u>case</u></font> p s ts <font color=Green><u>of</u></font>- <font color=Cyan>(</font>Left msg<font color=Cyan>,</font> s'<font color=Cyan>,</font> ts'<font color=Cyan>)</font> <font color=Red>-></font> <font color=Cyan>(</font>Left msg<font color=Cyan>,</font> s'<font color=Cyan>,</font> ts'<font color=Cyan>)</font>- <font color=Cyan>(</font>Right x<font color=Cyan>,</font> s'<font color=Cyan>,</font> ts'<font color=Cyan>)</font> <font color=Red>-></font> <font color=Cyan>(</font>Right <font color=Cyan>(</font>f x<font color=Cyan>)</font><font color=Cyan>,</font> s'<font color=Cyan>,</font> ts'<font color=Cyan>)</font><font color=Cyan>)</font>-<font color=Green><u>instance</u></font> Monad <font color=Cyan>(</font>Parser s t<font color=Cyan>)</font> <font color=Green><u>where</u></font>- return x <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>s ts<font color=Red>-></font> <font color=Cyan>(</font>Right x<font color=Cyan>,</font> s<font color=Cyan>,</font> ts<font color=Cyan>)</font><font color=Cyan>)</font>- <font color=Cyan>(</font>P f<font color=Cyan>)</font> <font color=Cyan>>>=</font> g <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>s ts<font color=Red>-></font> <font color=Green><u>case</u></font> f s ts <font color=Green><u>of</u></font>- <font color=Cyan>(</font>Left msg<font color=Cyan>,</font> s'<font color=Cyan>,</font> ts'<font color=Cyan>)</font> <font color=Red>-></font> <font color=Cyan>(</font>Left msg<font color=Cyan>,</font> s'<font color=Cyan>,</font> ts'<font color=Cyan>)</font>- <font color=Cyan>(</font>Right x<font color=Cyan>,</font> s'<font color=Cyan>,</font> ts'<font color=Cyan>)</font> <font color=Red>-></font> <font color=Green><u>let</u></font> <font color=Cyan>(</font>P g'<font color=Cyan>)</font> <font color=Red>=</font> g x- <font color=Green><u>in</u></font> g' s' ts'<font color=Cyan>)</font>- fail msg <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>s ts<font color=Red>-></font> <font color=Cyan>(</font>Left <font color=Cyan>(</font>False<font color=Cyan>,</font>msg<font color=Cyan>)</font><font color=Cyan>,</font> s<font color=Cyan>,</font> ts<font color=Cyan>)</font><font color=Cyan>)</font>--<font color=Blue>-- | When a simple fail is not strong enough, use failBad for emphasis.</font>-<font color=Blue>-- An emphasised (severe) error can propagate out through choice operators.</font>-failBad <font color=Red>::</font> String <font color=Red>-></font> Parser s t a-<a name="failBad"></a>failBad msg <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>s ts<font color=Red>-></font> <font color=Cyan>(</font>Left <font color=Cyan>(</font>True<font color=Cyan>,</font>msg<font color=Cyan>)</font><font color=Cyan>,</font> s<font color=Cyan>,</font> ts<font color=Cyan>)</font><font color=Cyan>)</font>--<font color=Blue>-- | Commit is a way of raising the severity of any errors found within</font>-<font color=Blue>-- its argument. Used in the middle of a parser definition, it means that</font>-<font color=Blue>-- any operations prior to commitment fail softly, but after commitment,</font>-<font color=Blue>-- they fail hard.</font>-commit <font color=Red>::</font> Parser s t a <font color=Red>-></font> Parser s t a-<a name="commit"></a>commit <font color=Cyan>(</font>P p<font color=Cyan>)</font> <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>s ts<font color=Red>-></font> <font color=Green><u>case</u></font> p s ts <font color=Green><u>of</u></font>- <font color=Cyan>(</font>Left <font color=Cyan>(</font><font color=Green><u>_</u></font><font color=Cyan>,</font>e<font color=Cyan>)</font><font color=Cyan>,</font> s'<font color=Cyan>,</font> ts'<font color=Cyan>)</font> <font color=Red>-></font> <font color=Cyan>(</font>Left <font color=Cyan>(</font>True<font color=Cyan>,</font>e<font color=Cyan>)</font><font color=Cyan>,</font> s'<font color=Cyan>,</font> ts'<font color=Cyan>)</font>- right <font color=Red>-></font> right <font color=Cyan>)</font>--<font color=Blue>-- Combinators</font>--<font color=Blue>-- | One token</font>-next <font color=Red>::</font> Parser s t t-<a name="next"></a>next <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>s ts<font color=Red>-></font> <font color=Green><u>case</u></font> ts <font color=Green><u>of</u></font>- <font color=Red>[</font><font color=Red>]</font> <font color=Red>-></font> <font color=Cyan>(</font>Left <font color=Cyan>(</font>False<font color=Cyan>,</font><font color=Magenta>"Ran out of input (EOF)"</font><font color=Cyan>)</font><font color=Cyan>,</font> s<font color=Cyan>,</font> <font color=Red>[</font><font color=Red>]</font><font color=Cyan>)</font>- <font color=Cyan>(</font>t<font color=Red><b>:</b></font>ts'<font color=Cyan>)</font> <font color=Red>-></font> <font color=Cyan>(</font>Right t<font color=Cyan>,</font> s<font color=Cyan>,</font> ts'<font color=Cyan>)</font> <font color=Cyan>)</font>--<font color=Blue>-- | One token satifying a predicate</font>-satisfy <font color=Red>::</font> <font color=Cyan>(</font>t<font color=Red>-></font>Bool<font color=Cyan>)</font> <font color=Red>-></font> Parser s t t-<a name="satisfy"></a>satisfy p <font color=Red>=</font> <font color=Green><u>do</u></font><font color=Cyan>{</font> x <font color=Red><-</font> next- <font color=Cyan>;</font> <font color=Green><u>if</u></font> p x <font color=Green><u>then</u></font> return x <font color=Green><u>else</u></font> fail <font color=Magenta>"Parse.satisfy: failed"</font>- <font color=Cyan>}</font>--<font color=Green><u>infixl</u></font> <font color=Magenta>3</font> <font color=Cyan>`apply`</font>-<font color=Blue>-- | Apply a parsed function to a parsed value</font>-apply <font color=Red>::</font> Parser s t <font color=Cyan>(</font>a<font color=Red>-></font>b<font color=Cyan>)</font> <font color=Red>-></font> Parser s t a <font color=Red>-></font> Parser s t b-<a name="apply"></a>pf <font color=Cyan>`apply`</font> px <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font> f <font color=Red><-</font> pf<font color=Cyan>;</font> x <font color=Red><-</font> px<font color=Cyan>;</font> return <font color=Cyan>(</font>f x<font color=Cyan>)</font> <font color=Cyan>}</font>--<font color=Green><u>infixl</u></font> <font color=Magenta>3</font> <font color=Cyan>`discard`</font>-<font color=Blue>-- | @x `discard` y@ parses both x and y, but discards the result of y</font>-discard <font color=Red>::</font> Parser s t a <font color=Red>-></font> Parser s t b <font color=Red>-></font> Parser s t a-<a name="discard"></a>px <font color=Cyan>`discard`</font> py <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font> x <font color=Red><-</font> px<font color=Cyan>;</font> <font color=Green><u>_</u></font> <font color=Red><-</font> py<font color=Cyan>;</font> return x <font color=Cyan>}</font>--<font color=Blue>-- | @p `adjustErr` f@ applies the transformation @f@ to any error message</font>-<font color=Blue>-- generated in @p@, having no effect if @p@ succeeds.</font>-adjustErr <font color=Red>::</font> Parser s t a <font color=Red>-></font> <font color=Cyan>(</font>String<font color=Red>-></font>String<font color=Cyan>)</font> <font color=Red>-></font> Parser s t a-<a name="adjustErr"></a><font color=Cyan>(</font>P p<font color=Cyan>)</font> <font color=Cyan>`adjustErr`</font> f <font color=Red>=</font>- P <font color=Cyan>(</font><font color=Red>\</font>s ts<font color=Red>-></font> <font color=Green><u>case</u></font> p s ts <font color=Green><u>of</u></font>- <font color=Cyan>(</font>Left <font color=Cyan>(</font>b<font color=Cyan>,</font>msg<font color=Cyan>)</font><font color=Cyan>,</font> s'<font color=Cyan>,</font> ts'<font color=Cyan>)</font> <font color=Red>-></font> <font color=Cyan>(</font>Left <font color=Cyan>(</font>b<font color=Cyan>,</font><font color=Cyan>(</font>f msg<font color=Cyan>)</font><font color=Cyan>)</font><font color=Cyan>,</font> s<font color=Cyan>,</font> ts'<font color=Cyan>)</font>- right <font color=Red>-></font> right <font color=Cyan>)</font>--<font color=Blue>-- | @adjustErrBad@ is just like @adjustErr@ except it also raises the</font>-<font color=Blue>-- severity of the error.</font>-adjustErrBad <font color=Red>::</font> Parser s t a <font color=Red>-></font> <font color=Cyan>(</font>String<font color=Red>-></font>String<font color=Cyan>)</font> <font color=Red>-></font> Parser s t a-<font color=Blue>-- p `adjustErrBad` f = commit (p `adjustErr` f)</font>-<a name="adjustErrBad"></a><font color=Cyan>(</font>P p<font color=Cyan>)</font> <font color=Cyan>`adjustErrBad`</font> f <font color=Red>=</font>- P <font color=Cyan>(</font><font color=Red>\</font>s ts<font color=Red>-></font> <font color=Green><u>case</u></font> p s ts <font color=Green><u>of</u></font>- <font color=Cyan>(</font>Left <font color=Cyan>(</font><font color=Green><u>_</u></font><font color=Cyan>,</font>msg<font color=Cyan>)</font><font color=Cyan>,</font> s'<font color=Cyan>,</font> ts'<font color=Cyan>)</font> <font color=Red>-></font> <font color=Cyan>(</font>Left <font color=Cyan>(</font>True<font color=Cyan>,</font><font color=Cyan>(</font>f msg<font color=Cyan>)</font><font color=Cyan>)</font><font color=Cyan>,</font> s<font color=Cyan>,</font> ts'<font color=Cyan>)</font>- right <font color=Red>-></font> right <font color=Cyan>)</font>--<font color=Green><u>infixl</u></font> <font color=Magenta>6</font> <font color=Cyan>`onFail`</font> <font color=Blue>-- not sure about precedence 6?</font>-<font color=Blue>-- | @p `onFail` q@ means parse p unless p fails in which case parse q instead.</font>-<font color=Blue>-- Can be chained together to give multiple attempts to parse something.</font>-<font color=Blue>-- (Note that q could itself be a failing parser, e.g. to change the error</font>-<font color=Blue>-- message from that defined in p to something different.)</font>-<font color=Blue>-- However, a severe failure in p cannot be ignored.</font>-onFail <font color=Red>::</font> Parser s t a <font color=Red>-></font> Parser s t a <font color=Red>-></font> Parser s t a-<a name="onFail"></a><font color=Cyan>(</font>P p<font color=Cyan>)</font> <font color=Cyan>`onFail`</font> <font color=Cyan>(</font>P q<font color=Cyan>)</font> <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>s ts<font color=Red>-></font> <font color=Green><u>case</u></font> p s ts <font color=Green><u>of</u></font>- r<font color=Red>@</font><font color=Cyan>(</font>Left <font color=Cyan>(</font>True<font color=Cyan>,</font><font color=Green><u>_</u></font><font color=Cyan>)</font><font color=Cyan>,</font> <font color=Green><u>_</u></font><font color=Cyan>,</font> <font color=Green><u>_</u></font><font color=Cyan>)</font> <font color=Red>-></font> r- <font color=Cyan>(</font>Left <font color=Green><u>_</u></font><font color=Cyan>,</font> <font color=Green><u>_</u></font><font color=Cyan>,</font> <font color=Green><u>_</u></font><font color=Cyan>)</font> <font color=Red>-></font> q s ts- right <font color=Red>-></font> right <font color=Cyan>)</font>--<font color=Blue>-- | Parse the first alternative in the list that succeeds.</font>-oneOf <font color=Red>::</font> <font color=Red>[</font>Parser s t a<font color=Red>]</font> <font color=Red>-></font> Parser s t a-<a name="oneOf"></a>oneOf <font color=Red>[</font><font color=Red>]</font> <font color=Red>=</font> fail <font color=Cyan>(</font><font color=Magenta>"Failed to parse any of the possible choices"</font><font color=Cyan>)</font>-oneOf <font color=Cyan>(</font>p<font color=Red><b>:</b></font>ps<font color=Cyan>)</font> <font color=Red>=</font> p <font color=Cyan>`onFail`</font> oneOf ps--<font color=Blue>-- | Parse the first alternative that succeeds, but if none succeed,</font>-<font color=Blue>-- report only the severe errors, and if none of those, then report</font>-<font color=Blue>-- all the soft errors.</font>-oneOf' <font color=Red>::</font> <font color=Red>[</font><font color=Cyan>(</font>String<font color=Cyan>,</font> Parser s t a<font color=Cyan>)</font><font color=Red>]</font> <font color=Red>-></font> Parser s t a-<a name="oneOf'"></a>oneOf' <font color=Red>=</font> accum <font color=Red>[</font><font color=Red>]</font>- <font color=Green><u>where</u></font> accum errs <font color=Red>[</font><font color=Red>]</font> <font color=Red>=</font>- <font color=Green><u>case</u></font> filter isBad errs <font color=Green><u>of</u></font>- <font color=Red>[</font><font color=Red>]</font> <font color=Red>-></font> fail <font color=Cyan>(</font><font color=Magenta>"failed to parse any of the possible choices:\n"</font>- <font color=Cyan>++</font>indent <font color=Magenta>2</font> <font color=Cyan>(</font>concatMap showErr <font color=Cyan>(</font>reverse errs<font color=Cyan>)</font><font color=Cyan>)</font><font color=Cyan>)</font>- <font color=Red>[</font><font color=Cyan>(</font><font color=Green><u>_</u></font><font color=Cyan>,</font><font color=Cyan>(</font><font color=Green><u>_</u></font><font color=Cyan>,</font>e<font color=Cyan>)</font><font color=Cyan>)</font><font color=Red>]</font> <font color=Red>-></font> failBad e- es <font color=Red>-></font> failBad <font color=Cyan>(</font><font color=Magenta>"one of the following failures occurred:\n"</font>- <font color=Cyan>++</font>indent <font color=Magenta>2</font> <font color=Cyan>(</font>concatMap showErr <font color=Cyan>(</font>reverse es<font color=Cyan>)</font><font color=Cyan>)</font><font color=Cyan>)</font>- accum errs <font color=Cyan>(</font><font color=Cyan>(</font>e<font color=Cyan>,</font>P p<font color=Cyan>)</font><font color=Red><b>:</b></font>ps<font color=Cyan>)</font> <font color=Red>=</font>- P <font color=Cyan>(</font><font color=Red>\</font>u ts<font color=Red>-></font> <font color=Green><u>case</u></font> p u ts <font color=Green><u>of</u></font>- <font color=Cyan>(</font>Left err<font color=Cyan>,</font><font color=Green><u>_</u></font><font color=Cyan>,</font><font color=Green><u>_</u></font><font color=Cyan>)</font> <font color=Red>-></font> <font color=Green><u>let</u></font> <font color=Cyan>(</font>P p<font color=Cyan>)</font> <font color=Red>=</font> accum <font color=Cyan>(</font><font color=Cyan>(</font>e<font color=Cyan>,</font>err<font color=Cyan>)</font><font color=Red><b>:</b></font>errs<font color=Cyan>)</font> ps- <font color=Green><u>in</u></font> p u ts- right <font color=Red>-></font> right <font color=Cyan>)</font>- showErr <font color=Cyan>(</font>name<font color=Cyan>,</font><font color=Cyan>(</font><font color=Green><u>_</u></font><font color=Cyan>,</font>err<font color=Cyan>)</font><font color=Cyan>)</font> <font color=Red>=</font> name<font color=Cyan>++</font><font color=Magenta>":\n"</font><font color=Cyan>++</font>indent <font color=Magenta>2</font> err- isBad <font color=Cyan>(</font><font color=Green><u>_</u></font><font color=Cyan>,</font><font color=Cyan>(</font>b<font color=Cyan>,</font><font color=Green><u>_</u></font><font color=Cyan>)</font><font color=Cyan>)</font> <font color=Red>=</font> b--<font color=Blue>-- | Helper for formatting error messages: indents all lines by a fixed amount.</font>-indent <font color=Red>::</font> Int <font color=Red>-></font> String <font color=Red>-></font> String-<a name="indent"></a>indent n <font color=Red>=</font> unlines <font color=Cyan>.</font> map <font color=Cyan>(</font>replicate n <font color=Magenta>' '</font> <font color=Cyan>++</font><font color=Cyan>)</font> <font color=Cyan>.</font> lines--<font color=Blue>-- | 'many p' parses a list of elements with individual parser p.</font>-<font color=Blue>-- Cannot fail, since an empty list is a valid return value.</font>-many <font color=Red>::</font> Parser s t a <font color=Red>-></font> Parser s t <font color=Red>[</font>a<font color=Red>]</font>-<a name="many"></a>many p <font color=Red>=</font> many1 p <font color=Cyan>`onFail`</font> return <font color=Red>[</font><font color=Red>]</font>--<font color=Blue>-- | Parse a non-empty list of items.</font>-many1 <font color=Red>::</font> Parser s t a <font color=Red>-></font> Parser s t <font color=Red>[</font>a<font color=Red>]</font>-<a name="many1"></a>many1 p <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font> x <font color=Red><-</font> p <font color=Cyan>`adjustErr`</font> <font color=Cyan>(</font><font color=Cyan>(</font><font color=Magenta>"In a sequence:\n"</font><font color=Cyan>++</font><font color=Cyan>)</font><font color=Cyan>.</font> indent <font color=Magenta>2</font><font color=Cyan>)</font>- <font color=Cyan>;</font> xs <font color=Red><-</font> many p- <font color=Cyan>;</font> return <font color=Cyan>(</font>x<font color=Red><b>:</b></font>xs<font color=Cyan>)</font>- <font color=Cyan>}</font>-<font color=Blue>-- `adjustErr` ("When looking for a non-empty sequence:\n"++)</font>--<font color=Blue>-- | Parse a list of items separated by discarded junk.</font>-sepBy <font color=Red>::</font> Parser s t a <font color=Red>-></font> Parser s t sep <font color=Red>-></font> Parser s t <font color=Red>[</font>a<font color=Red>]</font>-<a name="sepBy"></a>sepBy p sep <font color=Red>=</font> <font color=Green><u>do</u></font> sepBy1 p sep <font color=Cyan>`onFail`</font> return <font color=Red>[</font><font color=Red>]</font>--<font color=Blue>-- | Parse a non-empty list of items separated by discarded junk.</font>-sepBy1 <font color=Red>::</font> Parser s t a <font color=Red>-></font> Parser s t sep <font color=Red>-></font> Parser s t <font color=Red>[</font>a<font color=Red>]</font>-<a name="sepBy1"></a>sepBy1 p sep <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font> x <font color=Red><-</font> p- <font color=Cyan>;</font> xs <font color=Red><-</font> many <font color=Cyan>(</font><font color=Green><u>do</u></font> <font color=Cyan>{</font>sep<font color=Cyan>;</font> p<font color=Cyan>}</font><font color=Cyan>)</font>- <font color=Cyan>;</font> return <font color=Cyan>(</font>x<font color=Red><b>:</b></font>xs<font color=Cyan>)</font>- <font color=Cyan>}</font>- <font color=Cyan>`adjustErr`</font> <font color=Cyan>(</font><font color=Magenta>"When looking for a non-empty sequence with separators:\n"</font><font color=Cyan>++</font><font color=Cyan>)</font>- -<font color=Blue>-- | Parse a list of items, discarding the start, end, and separator</font>-<font color=Blue>-- items.</font>-bracketSep <font color=Red>::</font> Parser s t bra <font color=Red>-></font> Parser s t sep <font color=Red>-></font> Parser s t ket- <font color=Red>-></font> Parser s t a <font color=Red>-></font> Parser s t <font color=Red>[</font>a<font color=Red>]</font>-<a name="bracketSep"></a>bracketSep open sep close p <font color=Red>=</font>- <font color=Green><u>do</u></font> <font color=Cyan>{</font> open<font color=Cyan>;</font> close<font color=Cyan>;</font> return <font color=Red>[</font><font color=Red>]</font> <font color=Cyan>}</font>- <font color=Cyan>`onFail`</font>- <font color=Green><u>do</u></font> <font color=Cyan>{</font> open <font color=Cyan>`adjustErr`</font> <font color=Cyan>(</font><font color=Magenta>"Missing opening bracket:\n"</font><font color=Cyan>++</font><font color=Cyan>)</font>- <font color=Cyan>;</font> x <font color=Red><-</font> p <font color=Cyan>`adjustErr`</font> <font color=Cyan>(</font><font color=Magenta>"After first bracket in a group:\n"</font><font color=Cyan>++</font><font color=Cyan>)</font>- <font color=Cyan>;</font> xs <font color=Red><-</font> many <font color=Cyan>(</font><font color=Green><u>do</u></font> <font color=Cyan>{</font>sep<font color=Cyan>;</font> p<font color=Cyan>}</font><font color=Cyan>)</font>- <font color=Cyan>;</font> close <font color=Cyan>`adjustErrBad`</font> <font color=Cyan>(</font><font color=Magenta>"When looking for closing bracket:\n"</font><font color=Cyan>++</font><font color=Cyan>)</font>- <font color=Cyan>;</font> return <font color=Cyan>(</font>x<font color=Red><b>:</b></font>xs<font color=Cyan>)</font>- <font color=Cyan>}</font>--<font color=Blue>-- | Parse a bracketed item, discarding the brackets.</font>-bracket <font color=Red>::</font> Parser s t bra <font color=Red>-></font> Parser s t ket <font color=Red>-></font> Parser s t a <font color=Red>-></font> Parser s t a-<a name="bracket"></a>bracket open close p <font color=Red>=</font> <font color=Green><u>do</u></font>- <font color=Green><u>do</u></font> <font color=Cyan>{</font> open <font color=Cyan>`adjustErr`</font> <font color=Cyan>(</font><font color=Magenta>"Missing opening bracket:\n"</font><font color=Cyan>++</font><font color=Cyan>)</font>- <font color=Cyan>;</font> x <font color=Red><-</font> p- <font color=Cyan>;</font> close <font color=Cyan>`adjustErrBad`</font> <font color=Cyan>(</font><font color=Magenta>"Missing closing bracket:\n"</font><font color=Cyan>++</font><font color=Cyan>)</font>- <font color=Cyan>;</font> return x- <font color=Cyan>}</font>--<font color=Blue>-- | 'manyFinally e t' parses a possibly-empty sequence of e's,</font>-<font color=Blue>-- terminated by a t. Any parse failures could be due either to</font>-<font color=Blue>-- a badly-formed terminator or a badly-formed element, so raise</font>-<font color=Blue>-- both possible errors.</font>-manyFinally <font color=Red>::</font> Parser s t a <font color=Red>-></font> Parser s t z <font color=Red>-></font> Parser s t <font color=Red>[</font>a<font color=Red>]</font>-<a name="manyFinally"></a>manyFinally p t <font color=Red>=</font>- <font color=Green><u>do</u></font> <font color=Cyan>{</font> xs <font color=Red><-</font> many p- <font color=Cyan>;</font> oneOf' <font color=Red>[</font> <font color=Cyan>(</font><font color=Magenta>"sequence terminator"</font><font color=Cyan>,</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font> t<font color=Cyan>;</font> return <font color=Cyan>(</font><font color=Cyan>)</font> <font color=Cyan>}</font> <font color=Cyan>)</font>- <font color=Cyan>,</font> <font color=Cyan>(</font><font color=Magenta>"item in a sequence"</font><font color=Cyan>,</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font> p<font color=Cyan>;</font> return <font color=Cyan>(</font><font color=Cyan>)</font> <font color=Cyan>}</font> <font color=Cyan>)</font>- <font color=Red>]</font>- <font color=Cyan>;</font> return xs- <font color=Cyan>}</font>--<font color=Blue>------------------------------------------------------------------------</font>-<font color=Blue>-- State handling</font>--<font color=Blue>-- | Update the internal state.</font>-stUpdate <font color=Red>::</font> <font color=Cyan>(</font>s<font color=Red>-></font>s<font color=Cyan>)</font> <font color=Red>-></font> Parser s t <font color=Cyan>(</font><font color=Cyan>)</font>-<a name="stUpdate"></a>stUpdate f <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>s ts<font color=Red>-></font> <font color=Cyan>(</font>Right <font color=Cyan>(</font><font color=Cyan>)</font><font color=Cyan>,</font> f s<font color=Cyan>,</font> ts<font color=Cyan>)</font><font color=Cyan>)</font>--<font color=Blue>-- | Query the internal state.</font>-stQuery <font color=Red>::</font> <font color=Cyan>(</font>s<font color=Red>-></font>a<font color=Cyan>)</font> <font color=Red>-></font> Parser s t a-<a name="stQuery"></a>stQuery f <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>s ts<font color=Red>-></font> <font color=Cyan>(</font>Right <font color=Cyan>(</font>f s<font color=Cyan>)</font><font color=Cyan>,</font> s<font color=Cyan>,</font> ts<font color=Cyan>)</font><font color=Cyan>)</font>--<font color=Blue>-- | Deliver the entire internal state.</font>-stGet <font color=Red>::</font> Parser s t s-<a name="stGet"></a>stGet <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>s ts<font color=Red>-></font> <font color=Cyan>(</font>Right s<font color=Cyan>,</font> s<font color=Cyan>,</font> ts<font color=Cyan>)</font><font color=Cyan>)</font>--<font color=Blue>------------------------------------------------------------------------</font>-<font color=Blue>-- | Push some tokens back onto the front of the input stream and reparse.</font>-<font color=Blue>-- This is useful e.g. for recursively expanding macros. When the</font>-<font color=Blue>-- user-parser recognises a macro use, it can lookup the macro</font>-<font color=Blue>-- expansion from the parse state, lex it, and then stuff the</font>-<font color=Blue>-- lexed expansion back down into the parser.</font>-reparse <font color=Red>::</font> <font color=Red>[</font>t<font color=Red>]</font> <font color=Red>-></font> Parser s t <font color=Cyan>(</font><font color=Cyan>)</font>-<a name="reparse"></a>reparse ts <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>s inp<font color=Red>-></font> <font color=Cyan>(</font>Right <font color=Cyan>(</font><font color=Cyan>)</font><font color=Cyan>,</font> s<font color=Cyan>,</font> ts<font color=Cyan>++</font>inp<font color=Cyan>)</font><font color=Cyan>)</font>--<font color=Blue>------------------------------------------------------------------------</font>-</pre>
− docs/HaXml/src/Text/ParserCombinators/PolyStateLazy.html
@@ -1,279 +0,0 @@-<pre><font color=Green><u>module</u></font> Text<font color=Cyan>.</font>ParserCombinators<font color=Cyan>.</font>PolyStateLazy- <font color=Cyan>(</font> <font color=Blue>-- * A Parser datatype parameterised on arbitrary token type and state type.</font>- <font color=Blue>-- Parsers do not return explicit failure. An exception is raised</font>- <font color=Blue>-- instead. This allows partial results to be returned before a</font>- <font color=Blue>-- full parse is complete.</font>- Parser<font color=Cyan>(</font>P<font color=Cyan>)</font> <font color=Blue>-- datatype, instance of: Functor, Monad</font>- <font color=Cyan>,</font> runParser <font color=Blue>-- :: Parser s t a -> s -> [t] -> (a, s, [t])</font>- <font color=Cyan>,</font> failBad <font color=Blue>-- :: String -> Parser s t a</font>- <font color=Cyan>,</font> commit <font color=Blue>-- :: Parser s t a -> Parser s t a</font>- <font color=Blue>-- * Combinators</font>- <font color=Blue>-- ** primitives</font>- <font color=Cyan>,</font> next <font color=Blue>-- :: Parser s t t</font>- <font color=Cyan>,</font> satisfy <font color=Blue>-- :: (t->Bool) -> Parser s t t</font>- <font color=Cyan>,</font> apply <font color=Blue>-- :: Parser t (a->b) -> Parser s t a -> Parser s t b</font>- <font color=Cyan>,</font> discard <font color=Blue>-- :: Parser s t a -> Parser s t b -> Parser s t a</font>- <font color=Blue>-- ** error-handling</font>- <font color=Cyan>,</font> adjustErr <font color=Blue>-- :: Parser s t a -> (String->String) -> Parser s t a</font>- <font color=Cyan>,</font> adjustErrBad<font color=Blue>-- :: Parser s t a -> (String->String) -> Parser s t a</font>- <font color=Cyan>,</font> indent <font color=Blue>-- :: Int -> String -> String</font>- <font color=Blue>-- ** choices</font>- <font color=Cyan>,</font> onFail <font color=Blue>-- :: Parser s t a -> Parser s t a -> Parser s t a</font>- <font color=Cyan>,</font> oneOf <font color=Blue>-- :: [Parser s t a] -> Parser s t a</font>- <font color=Cyan>,</font> oneOf' <font color=Blue>-- :: [(String, Parser s t a)] -> Parser s t a</font>- <font color=Cyan>,</font> optional <font color=Blue>-- :: Parser s t a -> Parser s t (Maybe a)</font>- <font color=Blue>-- ** sequences</font>- <font color=Cyan>,</font> many <font color=Blue>-- :: Parser s t a -> Parser s t [a]</font>- <font color=Cyan>,</font> many1 <font color=Blue>-- :: Parser s t a -> Parser s t [a]</font>- <font color=Cyan>,</font> sepBy <font color=Blue>-- :: Parser s t a -> Parser s t sep -> Parser s t [a]</font>- <font color=Cyan>,</font> sepBy1 <font color=Blue>-- :: Parser s t a -> Parser s t sep -> Parser s t [a]</font>- <font color=Cyan>,</font> bracketSep <font color=Blue>-- :: Parser s t bra -> Parser s t sep -> Parser s t ket</font>- <font color=Blue>-- -> Parser s t a -> Parser s t [a]</font>- <font color=Cyan>,</font> bracket <font color=Blue>-- :: Parser s t bra -> Parser s t ket -> Parser s t a</font>- <font color=Blue>-- -> Parser s t a</font>- <font color=Cyan>,</font> manyFinally <font color=Blue>-- :: Parser s t a -> Parser s t z -> Parser s t [a]</font>- <font color=Blue>-- ** state-handling</font>- <font color=Cyan>,</font> stUpdate <font color=Blue>-- :: (s->s) -> Parser s t ()</font>- <font color=Cyan>,</font> stQuery <font color=Blue>-- :: (s->a) -> Parser s t a</font>- <font color=Cyan>,</font> stGet <font color=Blue>-- :: Parser s t s</font>- <font color=Blue>-- ** re-parsing</font>- <font color=Cyan>,</font> reparse <font color=Blue>-- :: [t] -> Parser s t ()</font>- <font color=Cyan>)</font> <font color=Green><u>where</u></font>--<font color=Cyan>#</font><font color=Green><u>if</u></font> <b><font color=Magenta>__GLASGOW_HASKELL__</font></b>-<font color=Green><u>import</u></font> Control<font color=Cyan>.</font>Exception hiding <font color=Cyan>(</font>bracket<font color=Cyan>)</font>-throwE <font color=Red>::</font> String <font color=Red>-></font> a-<a name="throwE"></a>throwE msg <font color=Red>=</font> throw <font color=Cyan>(</font>ErrorCall msg<font color=Cyan>)</font>-<font color=Cyan>#</font><font color=Green><u>else</u></font>-throwE <font color=Red>::</font> String <font color=Red>-></font> a-throwE msg <font color=Red>=</font> error msg-<font color=Cyan>#</font>endif--<font color=Blue>-- | The @Parser@ datatype is a fairly generic parsing monad with error</font>-<font color=Blue>-- reporting and a running state. It can be used for arbitrary token</font>-<font color=Blue>-- types, not just String input.</font>-<font color=Green><u>newtype</u></font> Parser s t a <font color=Red>=</font> P <font color=Cyan>(</font>s <font color=Red>-></font> <font color=Red>[</font>t<font color=Red>]</font> <font color=Red>-></font> <font color=Cyan>(</font>Either String a<font color=Cyan>,</font> s<font color=Cyan>,</font> <font color=Red>[</font>t<font color=Red>]</font><font color=Cyan>)</font><font color=Cyan>)</font>--<font color=Blue>-- | A return type like Either, that distinguishes not only between</font>-<font color=Blue>-- right and wrong answers, but also had gradations of wrongness.</font>-<font color=Blue>-- Not used in this library. !!!!!!!!!!!!!!!!!!!!!!!!!!</font>-<a name="EitherE"></a><font color=Green><u>type</u></font> EitherE a b <font color=Red>=</font> Either <font color=Cyan>(</font>Bool<font color=Cyan>,</font>a<font color=Cyan>)</font> b--<font color=Blue>-- | Apply a parser to an initial state and input token sequence.</font>-<font color=Blue>-- The parser cannot return an error value explicitly, so errors</font>-<font color=Blue>-- raise an exception. Thus, results can be partial (lazily constructed,</font>-<font color=Blue>-- but containing undefined).</font>-runParser <font color=Red>::</font> Parser s t a <font color=Red>-></font> s <font color=Red>-></font> <font color=Red>[</font>t<font color=Red>]</font> <font color=Red>-></font> <font color=Cyan>(</font>a<font color=Cyan>,</font> s<font color=Cyan>,</font> <font color=Red>[</font>t<font color=Red>]</font><font color=Cyan>)</font>-<a name="runParser"></a>runParser <font color=Cyan>(</font>P p<font color=Cyan>)</font> s <font color=Red>=</font>- <font color=Cyan>(</font><font color=Red>\</font> <font color=Cyan>(</font>e<font color=Cyan>,</font>s<font color=Cyan>,</font>ts<font color=Cyan>)</font><font color=Red>-></font> <font color=Cyan>(</font><font color=Green><u>case</u></font> e <font color=Green><u>of</u></font> <font color=Cyan>{</font>Left m<font color=Red>-></font>throwE m<font color=Cyan>;</font> Right x<font color=Red>-></font>x<font color=Cyan>}</font><font color=Cyan>,</font> s<font color=Cyan>,</font> ts<font color=Cyan>)</font><font color=Cyan>)</font>- <font color=Cyan>.</font> p s--<font color=Green><u>instance</u></font> Functor <font color=Cyan>(</font>Parser s t<font color=Cyan>)</font> <font color=Green><u>where</u></font>- fmap f <font color=Cyan>(</font>P p<font color=Cyan>)</font> <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>s ts<font color=Red>-></font> <font color=Green><u>case</u></font> p s ts <font color=Green><u>of</u></font>- <font color=Cyan>(</font>Left msg<font color=Cyan>,</font> s'<font color=Cyan>,</font> ts'<font color=Cyan>)</font> <font color=Red>-></font> <font color=Cyan>(</font>Left msg<font color=Cyan>,</font> s'<font color=Cyan>,</font> ts'<font color=Cyan>)</font>- <font color=Cyan>(</font>Right x<font color=Cyan>,</font> s'<font color=Cyan>,</font> ts'<font color=Cyan>)</font> <font color=Red>-></font> <font color=Cyan>(</font>Right <font color=Cyan>(</font>f x<font color=Cyan>)</font><font color=Cyan>,</font> s'<font color=Cyan>,</font> ts'<font color=Cyan>)</font><font color=Cyan>)</font>-<font color=Green><u>instance</u></font> Monad <font color=Cyan>(</font>Parser s t<font color=Cyan>)</font> <font color=Green><u>where</u></font>- return x <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>s ts<font color=Red>-></font> <font color=Cyan>(</font>Right x<font color=Cyan>,</font> s<font color=Cyan>,</font> ts<font color=Cyan>)</font><font color=Cyan>)</font>- <font color=Cyan>(</font>P f<font color=Cyan>)</font> <font color=Cyan>>>=</font> g <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>s ts<font color=Red>-></font> <font color=Green><u>case</u></font> f s ts <font color=Green><u>of</u></font>- <font color=Cyan>(</font>Left msg<font color=Cyan>,</font> s'<font color=Cyan>,</font> ts'<font color=Cyan>)</font> <font color=Red>-></font> <font color=Cyan>(</font>Left msg<font color=Cyan>,</font> s'<font color=Cyan>,</font> ts'<font color=Cyan>)</font>- <font color=Cyan>(</font>Right x<font color=Cyan>,</font> s'<font color=Cyan>,</font> ts'<font color=Cyan>)</font> <font color=Red>-></font> <font color=Green><u>let</u></font> <font color=Cyan>(</font>P g'<font color=Cyan>)</font> <font color=Red>=</font> g x- <font color=Green><u>in</u></font> g' s' ts'<font color=Cyan>)</font>- fail msg <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>s ts<font color=Red>-></font> <font color=Cyan>(</font>Left msg<font color=Cyan>,</font> s<font color=Cyan>,</font> ts<font color=Cyan>)</font><font color=Cyan>)</font>--<font color=Blue>-- | Simple failure can be corrected, but when a simple fail is not strong</font>-<font color=Blue>-- enough, use failBad for emphasis. It guarantees parsing will terminate</font>-<font color=Blue>-- with an exception.</font>-failBad <font color=Red>::</font> String <font color=Red>-></font> Parser s t a-<a name="failBad"></a>failBad msg <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>s ts<font color=Red>-></font> <font color=Cyan>(</font>throwE msg<font color=Cyan>,</font> s<font color=Cyan>,</font> ts<font color=Cyan>)</font><font color=Cyan>)</font>--<font color=Blue>-- | Commit is a way of raising the severity of any errors found within</font>-<font color=Blue>-- its argument. Used in the middle of a parser definition, it means that</font>-<font color=Blue>-- any operations prior to commitment fail softly, but after commitment,</font>-<font color=Blue>-- they fail hard.</font>-commit <font color=Red>::</font> Parser s t a <font color=Red>-></font> Parser s t a-<a name="commit"></a>commit <font color=Cyan>(</font>P p<font color=Cyan>)</font> <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>s ts<font color=Red>-></font> <font color=Green><u>case</u></font> p s ts <font color=Green><u>of</u></font>- <font color=Cyan>(</font>Left e<font color=Cyan>,</font> s'<font color=Cyan>,</font> ts'<font color=Cyan>)</font> <font color=Red>-></font> <font color=Cyan>(</font>throwE e<font color=Cyan>,</font> s'<font color=Cyan>,</font> ts'<font color=Cyan>)</font>- right <font color=Red>-></font> right <font color=Cyan>)</font>--<font color=Blue>-- Combinators</font>--<font color=Blue>-- | One token</font>-next <font color=Red>::</font> Parser s t t-<a name="next"></a>next <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>s ts<font color=Red>-></font> <font color=Green><u>case</u></font> ts <font color=Green><u>of</u></font>- <font color=Red>[</font><font color=Red>]</font> <font color=Red>-></font> <font color=Cyan>(</font>Left <font color=Magenta>"Ran out of input (EOF)"</font><font color=Cyan>,</font> s<font color=Cyan>,</font> <font color=Red>[</font><font color=Red>]</font><font color=Cyan>)</font>- <font color=Cyan>(</font>t<font color=Red><b>:</b></font>ts'<font color=Cyan>)</font> <font color=Red>-></font> <font color=Cyan>(</font>Right t<font color=Cyan>,</font> s<font color=Cyan>,</font> ts'<font color=Cyan>)</font> <font color=Cyan>)</font>--<font color=Blue>-- | One token satifying a predicate</font>-satisfy <font color=Red>::</font> <font color=Cyan>(</font>t<font color=Red>-></font>Bool<font color=Cyan>)</font> <font color=Red>-></font> Parser s t t-<a name="satisfy"></a>satisfy p <font color=Red>=</font> <font color=Green><u>do</u></font><font color=Cyan>{</font> x <font color=Red><-</font> next- <font color=Cyan>;</font> <font color=Green><u>if</u></font> p x <font color=Green><u>then</u></font> return x <font color=Green><u>else</u></font> fail <font color=Magenta>"Parse.satisfy: failed"</font>- <font color=Cyan>}</font>--<font color=Green><u>infixl</u></font> <font color=Magenta>3</font> <font color=Cyan>`apply`</font>-<font color=Blue>-- | Apply a parsed function to a parsed value</font>-apply <font color=Red>::</font> Parser s t <font color=Cyan>(</font>a<font color=Red>-></font>b<font color=Cyan>)</font> <font color=Red>-></font> Parser s t a <font color=Red>-></font> Parser s t b-<font color=Blue>--pf `apply` px = do { f <- pf; x <- px; return (f x) }</font>-<font color=Blue>-- Needs to be lazier! Must not force the argument value too early.</font>-<a name="apply"></a><font color=Cyan>(</font>P pf<font color=Cyan>)</font> <font color=Cyan>`apply`</font> <font color=Cyan>(</font>P px<font color=Cyan>)</font> <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>s ts<font color=Red>-></font>- <font color=Green><u>case</u></font> pf s ts <font color=Green><u>of</u></font>- <font color=Cyan>(</font>Left msg<font color=Cyan>,</font> s'<font color=Cyan>,</font> ts'<font color=Cyan>)</font> <font color=Red>-></font> <font color=Cyan>(</font>Left msg<font color=Cyan>,</font> s'<font color=Cyan>,</font> ts'<font color=Cyan>)</font>- <font color=Cyan>(</font>Right f<font color=Cyan>,</font> s'<font color=Cyan>,</font> ts'<font color=Cyan>)</font> <font color=Red>-></font> <font color=Green><u>let</u></font> <font color=Cyan>(</font>x'<font color=Cyan>,</font>s''<font color=Cyan>,</font>ts''<font color=Cyan>)</font> <font color=Red>=</font> px s' ts'- x <font color=Red>=</font> <font color=Green><u>case</u></font> x' <font color=Green><u>of</u></font>- Right x <font color=Red>-></font> x- Left e <font color=Red>-></font> throwE e- <font color=Green><u>in</u></font> <font color=Cyan>(</font>Right <font color=Cyan>(</font>f x<font color=Cyan>)</font><font color=Cyan>,</font> s''<font color=Cyan>,</font> ts''<font color=Cyan>)</font><font color=Cyan>)</font>--<font color=Green><u>infixl</u></font> <font color=Magenta>3</font> <font color=Cyan>`discard`</font>-<font color=Blue>-- | @x `discard` y@ parses both x and y, but discards the result of y</font>-discard <font color=Red>::</font> Parser s t a <font color=Red>-></font> Parser s t b <font color=Red>-></font> Parser s t a-<a name="discard"></a>px <font color=Cyan>`discard`</font> py <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font> x <font color=Red><-</font> px<font color=Cyan>;</font> <font color=Green><u>_</u></font> <font color=Red><-</font> py<font color=Cyan>;</font> return x <font color=Cyan>}</font>--<font color=Blue>-- | @p `adjustErr` f@ applies the transformation @f@ to any error message</font>-<font color=Blue>-- generated in @p@, having no effect if @p@ succeeds.</font>-adjustErr <font color=Red>::</font> Parser s t a <font color=Red>-></font> <font color=Cyan>(</font>String<font color=Red>-></font>String<font color=Cyan>)</font> <font color=Red>-></font> Parser s t a-<a name="adjustErr"></a><font color=Cyan>(</font>P p<font color=Cyan>)</font> <font color=Cyan>`adjustErr`</font> f <font color=Red>=</font>- P <font color=Cyan>(</font><font color=Red>\</font>s ts<font color=Red>-></font> <font color=Green><u>case</u></font> p s ts <font color=Green><u>of</u></font>- <font color=Cyan>(</font>Left msg<font color=Cyan>,</font> s'<font color=Cyan>,</font> ts'<font color=Cyan>)</font> <font color=Red>-></font> <font color=Cyan>(</font>Left <font color=Cyan>(</font>f msg<font color=Cyan>)</font><font color=Cyan>,</font> s<font color=Cyan>,</font> ts'<font color=Cyan>)</font>- right <font color=Red>-></font> right <font color=Cyan>)</font>--<font color=Blue>-- | @adjustErrBad@ is just like @adjustErr@ except it also raises the</font>-<font color=Blue>-- severity of the error.</font>-adjustErrBad <font color=Red>::</font> Parser s t a <font color=Red>-></font> <font color=Cyan>(</font>String<font color=Red>-></font>String<font color=Cyan>)</font> <font color=Red>-></font> Parser s t a-<font color=Blue>-- p `adjustErrBad` f = commit (p `adjustErr` f)</font>-<a name="adjustErrBad"></a><font color=Cyan>(</font>P p<font color=Cyan>)</font> <font color=Cyan>`adjustErrBad`</font> f <font color=Red>=</font>- P <font color=Cyan>(</font><font color=Red>\</font>s ts<font color=Red>-></font> <font color=Green><u>case</u></font> p s ts <font color=Green><u>of</u></font>- <font color=Cyan>(</font>Left msg<font color=Cyan>,</font> s'<font color=Cyan>,</font> ts'<font color=Cyan>)</font> <font color=Red>-></font> <font color=Cyan>(</font>throwE <font color=Cyan>(</font>f msg<font color=Cyan>)</font><font color=Cyan>,</font> s<font color=Cyan>,</font> ts'<font color=Cyan>)</font>- right <font color=Red>-></font> right <font color=Cyan>)</font>--<font color=Green><u>infixl</u></font> <font color=Magenta>6</font> <font color=Cyan>`onFail`</font> <font color=Blue>-- not sure about precedence 6?</font>-<font color=Blue>-- | @p `onFail` q@ means parse p unless p fails in which case parse q instead.</font>-<font color=Blue>-- Can be chained together to give multiple attempts to parse something.</font>-<font color=Blue>-- (Note that q could itself be a failing parser, e.g. to change the error</font>-<font color=Blue>-- message from that defined in p to something different.)</font>-<font color=Blue>-- However, a *severe* failure in p cannot be ignored.</font>-onFail <font color=Red>::</font> Parser s t a <font color=Red>-></font> Parser s t a <font color=Red>-></font> Parser s t a-<a name="onFail"></a><font color=Cyan>(</font>P p<font color=Cyan>)</font> <font color=Cyan>`onFail`</font> <font color=Cyan>(</font>P q<font color=Cyan>)</font> <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>s ts<font color=Red>-></font> <font color=Green><u>case</u></font> p s ts <font color=Green><u>of</u></font>- <font color=Cyan>(</font>Left <font color=Green><u>_</u></font><font color=Cyan>,</font> <font color=Green><u>_</u></font><font color=Cyan>,</font> <font color=Green><u>_</u></font><font color=Cyan>)</font> <font color=Red>-></font> q s ts- right <font color=Red>-></font> right <font color=Cyan>)</font>--<font color=Blue>-- | Parse the first alternative in the list that succeeds.</font>-oneOf <font color=Red>::</font> <font color=Red>[</font>Parser s t a<font color=Red>]</font> <font color=Red>-></font> Parser s t a-<a name="oneOf"></a>oneOf <font color=Red>[</font><font color=Red>]</font> <font color=Red>=</font> fail <font color=Cyan>(</font><font color=Magenta>"Failed to parse any of the possible choices"</font><font color=Cyan>)</font>-oneOf <font color=Cyan>(</font>p<font color=Red><b>:</b></font>ps<font color=Cyan>)</font> <font color=Red>=</font> p <font color=Cyan>`onFail`</font> oneOf ps--<font color=Blue>-- | Parse the first alternative that succeeds, but if none succeed,</font>-<font color=Blue>-- report only the severe errors, and if none of those, then report</font>-<font color=Blue>-- all the soft errors.</font>-oneOf' <font color=Red>::</font> <font color=Red>[</font><font color=Cyan>(</font>String<font color=Cyan>,</font> Parser s t a<font color=Cyan>)</font><font color=Red>]</font> <font color=Red>-></font> Parser s t a-<a name="oneOf'"></a>oneOf' ps <font color=Red>=</font> accum <font color=Red>[</font><font color=Red>]</font> ps- <font color=Green><u>where</u></font> accum errs <font color=Red>[</font><font color=Red>]</font> <font color=Red>=</font>- <font color=Green><u>case</u></font> errs <font color=Green><u>of</u></font>- <font color=Red>[</font><font color=Red>]</font> <font color=Red>-></font> failBad <font color=Cyan>(</font><font color=Magenta>"internal failure in parser (oneOf'):\n"</font>- <font color=Cyan>++</font>indent <font color=Magenta>2</font> <font color=Cyan>(</font>show <font color=Cyan>(</font>map fst ps<font color=Cyan>)</font><font color=Cyan>)</font><font color=Cyan>)</font>- <font color=Red>[</font><font color=Cyan>(</font><font color=Green><u>_</u></font><font color=Cyan>,</font>e<font color=Cyan>)</font><font color=Red>]</font> <font color=Red>-></font> fail e- es <font color=Red>-></font> fail <font color=Cyan>(</font><font color=Magenta>"one of the following failures occurred:\n"</font>- <font color=Cyan>++</font>indent <font color=Magenta>2</font> <font color=Cyan>(</font>concatMap showErr <font color=Cyan>(</font>reverse es<font color=Cyan>)</font><font color=Cyan>)</font><font color=Cyan>)</font>- accum errs <font color=Cyan>(</font><font color=Cyan>(</font>e<font color=Cyan>,</font>P p<font color=Cyan>)</font><font color=Red><b>:</b></font>ps<font color=Cyan>)</font> <font color=Red>=</font>- P <font color=Cyan>(</font><font color=Red>\</font>u ts<font color=Red>-></font> <font color=Green><u>case</u></font> p u ts <font color=Green><u>of</u></font>- <font color=Cyan>(</font>Left err<font color=Cyan>,</font><font color=Green><u>_</u></font><font color=Cyan>,</font><font color=Green><u>_</u></font><font color=Cyan>)</font> <font color=Red>-></font> <font color=Green><u>let</u></font> <font color=Cyan>(</font>P p<font color=Cyan>)</font> <font color=Red>=</font> accum <font color=Cyan>(</font><font color=Cyan>(</font>e<font color=Cyan>,</font>err<font color=Cyan>)</font><font color=Red><b>:</b></font>errs<font color=Cyan>)</font> ps- <font color=Green><u>in</u></font> p u ts- right <font color=Red>-></font> right <font color=Cyan>)</font>- showErr <font color=Cyan>(</font>name<font color=Cyan>,</font>err<font color=Cyan>)</font> <font color=Red>=</font> name<font color=Cyan>++</font><font color=Magenta>":\n"</font><font color=Cyan>++</font>indent <font color=Magenta>2</font> err--<font color=Blue>-- | Helper for formatting error messages: indents all lines by a fixed amount.</font>-indent <font color=Red>::</font> Int <font color=Red>-></font> String <font color=Red>-></font> String-<a name="indent"></a>indent n <font color=Red>=</font> unlines <font color=Cyan>.</font> map <font color=Cyan>(</font>replicate n <font color=Magenta>' '</font> <font color=Cyan>++</font><font color=Cyan>)</font> <font color=Cyan>.</font> lines--<font color=Blue>-- | 'optional' indicates whether the parser succeeded through the Maybe type.</font>-optional <font color=Red>::</font> Parser s t a <font color=Red>-></font> Parser s t <font color=Cyan>(</font>Maybe a<font color=Cyan>)</font>-<a name="optional"></a>optional p <font color=Red>=</font> fmap Just p <font color=Cyan>`onFail`</font> return Nothing--<font color=Blue>-- | 'many p' parses a list of elements with individual parser p.</font>-<font color=Blue>-- Cannot fail, since an empty list is a valid return value.</font>-many <font color=Red>::</font> Parser s t a <font color=Red>-></font> Parser s t <font color=Red>[</font>a<font color=Red>]</font>-<a name="many"></a>many p <font color=Red>=</font> many1 p <font color=Cyan>`onFail`</font> return <font color=Red>[</font><font color=Red>]</font>--<font color=Blue>-- | Parse a non-empty list of items.</font>-many1 <font color=Red>::</font> Parser s t a <font color=Red>-></font> Parser s t <font color=Red>[</font>a<font color=Red>]</font>-<a name="many1"></a>many1 p <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font> x <font color=Red><-</font> p <font color=Cyan>`adjustErr`</font> <font color=Cyan>(</font><font color=Cyan>(</font><font color=Magenta>"In a sequence:\n"</font><font color=Cyan>++</font><font color=Cyan>)</font><font color=Cyan>.</font> indent <font color=Magenta>2</font><font color=Cyan>)</font>- <font color=Cyan>;</font> xs <font color=Red><-</font> many p- <font color=Cyan>;</font> return <font color=Cyan>(</font>x<font color=Red><b>:</b></font>xs<font color=Cyan>)</font>- <font color=Cyan>}</font>-<font color=Blue>-- `adjustErr` ("When looking for a non-empty sequence:\n"++)</font>--<font color=Blue>-- | Parse a list of items separated by discarded junk.</font>-sepBy <font color=Red>::</font> Parser s t a <font color=Red>-></font> Parser s t sep <font color=Red>-></font> Parser s t <font color=Red>[</font>a<font color=Red>]</font>-<a name="sepBy"></a>sepBy p sep <font color=Red>=</font> <font color=Green><u>do</u></font> sepBy1 p sep <font color=Cyan>`onFail`</font> return <font color=Red>[</font><font color=Red>]</font>--<font color=Blue>-- | Parse a non-empty list of items separated by discarded junk.</font>-sepBy1 <font color=Red>::</font> Parser s t a <font color=Red>-></font> Parser s t sep <font color=Red>-></font> Parser s t <font color=Red>[</font>a<font color=Red>]</font>-<a name="sepBy1"></a>sepBy1 p sep <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font> x <font color=Red><-</font> p- <font color=Cyan>;</font> xs <font color=Red><-</font> many <font color=Cyan>(</font><font color=Green><u>do</u></font> <font color=Cyan>{</font>sep<font color=Cyan>;</font> p<font color=Cyan>}</font><font color=Cyan>)</font>- <font color=Cyan>;</font> return <font color=Cyan>(</font>x<font color=Red><b>:</b></font>xs<font color=Cyan>)</font>- <font color=Cyan>}</font>- <font color=Cyan>`adjustErr`</font> <font color=Cyan>(</font><font color=Magenta>"When looking for a non-empty sequence with separators:\n"</font><font color=Cyan>++</font><font color=Cyan>)</font>- -<font color=Blue>-- | Parse a list of items, discarding the start, end, and separator</font>-<font color=Blue>-- items.</font>-bracketSep <font color=Red>::</font> Parser s t bra <font color=Red>-></font> Parser s t sep <font color=Red>-></font> Parser s t ket- <font color=Red>-></font> Parser s t a <font color=Red>-></font> Parser s t <font color=Red>[</font>a<font color=Red>]</font>-<a name="bracketSep"></a>bracketSep open sep close p <font color=Red>=</font>- <font color=Green><u>do</u></font> <font color=Cyan>{</font> open<font color=Cyan>;</font> close<font color=Cyan>;</font> return <font color=Red>[</font><font color=Red>]</font> <font color=Cyan>}</font>- <font color=Cyan>`onFail`</font>- <font color=Green><u>do</u></font> <font color=Cyan>{</font> open <font color=Cyan>`adjustErr`</font> <font color=Cyan>(</font><font color=Magenta>"Missing opening bracket:\n"</font><font color=Cyan>++</font><font color=Cyan>)</font>- <font color=Cyan>;</font> x <font color=Red><-</font> p <font color=Cyan>`adjustErr`</font> <font color=Cyan>(</font><font color=Magenta>"After first bracket in a group:\n"</font><font color=Cyan>++</font><font color=Cyan>)</font>- <font color=Cyan>;</font> xs <font color=Red><-</font> many <font color=Cyan>(</font><font color=Green><u>do</u></font> <font color=Cyan>{</font>sep<font color=Cyan>;</font> p<font color=Cyan>}</font><font color=Cyan>)</font>- <font color=Cyan>;</font> close <font color=Cyan>`adjustErrBad`</font> <font color=Cyan>(</font><font color=Magenta>"When looking for closing bracket:\n"</font><font color=Cyan>++</font><font color=Cyan>)</font>- <font color=Cyan>;</font> return <font color=Cyan>(</font>x<font color=Red><b>:</b></font>xs<font color=Cyan>)</font>- <font color=Cyan>}</font>--<font color=Blue>-- | Parse a bracketed item, discarding the brackets.</font>-bracket <font color=Red>::</font> Parser s t bra <font color=Red>-></font> Parser s t ket <font color=Red>-></font> Parser s t a <font color=Red>-></font> Parser s t a-<a name="bracket"></a>bracket open close p <font color=Red>=</font> <font color=Green><u>do</u></font>- <font color=Green><u>do</u></font> <font color=Cyan>{</font> open <font color=Cyan>`adjustErr`</font> <font color=Cyan>(</font><font color=Magenta>"Missing opening bracket:\n"</font><font color=Cyan>++</font><font color=Cyan>)</font>- <font color=Cyan>;</font> x <font color=Red><-</font> p- <font color=Cyan>;</font> close <font color=Cyan>`adjustErrBad`</font> <font color=Cyan>(</font><font color=Magenta>"Missing closing bracket:\n"</font><font color=Cyan>++</font><font color=Cyan>)</font>- <font color=Cyan>;</font> return x- <font color=Cyan>}</font>--<font color=Blue>-- | 'manyFinally e t' parses a possibly-empty sequence of e's,</font>-<font color=Blue>-- terminated by a t. Any parse failures could be due either to</font>-<font color=Blue>-- a badly-formed terminator or a badly-formed element, so raise</font>-<font color=Blue>-- both possible errors.</font>-manyFinally <font color=Red>::</font> Parser s t a <font color=Red>-></font> Parser s t z <font color=Red>-></font> Parser s t <font color=Red>[</font>a<font color=Red>]</font>-<a name="manyFinally"></a>manyFinally pp<font color=Red>@</font><font color=Cyan>(</font>P p<font color=Cyan>)</font> pt<font color=Red>@</font><font color=Cyan>(</font>P t<font color=Cyan>)</font> <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>s ts <font color=Red>-></font>- <font color=Green><u>case</u></font> p s ts <font color=Green><u>of</u></font>- <font color=Cyan>(</font>Left e<font color=Cyan>,</font> <font color=Green><u>_</u></font><font color=Cyan>,</font> <font color=Green><u>_</u></font><font color=Cyan>)</font> <font color=Red>-></font>- <font color=Green><u>case</u></font> t s ts <font color=Green><u>of</u></font>- <font color=Cyan>(</font>Right <font color=Green><u>_</u></font><font color=Cyan>,</font> s'<font color=Cyan>,</font> ts'<font color=Cyan>)</font> <font color=Red>-></font> <font color=Cyan>(</font>Right <font color=Red>[</font><font color=Red>]</font><font color=Cyan>,</font> s'<font color=Cyan>,</font> ts'<font color=Cyan>)</font>- <font color=Cyan>(</font>Left e<font color=Cyan>,</font> s'<font color=Cyan>,</font> ts'<font color=Cyan>)</font> <font color=Red>-></font> <font color=Cyan>(</font>Left e<font color=Cyan>,</font> s'<font color=Cyan>,</font> ts'<font color=Cyan>)</font>- <font color=Cyan>(</font>Right x<font color=Cyan>,</font> s'<font color=Cyan>,</font> ts'<font color=Cyan>)</font> <font color=Red>-></font>- <font color=Green><u>let</u></font> <font color=Cyan>(</font>tail<font color=Cyan>,</font>s''<font color=Cyan>,</font>ts''<font color=Cyan>)</font> <font color=Red>=</font> runParser <font color=Cyan>(</font>manyFinally pp pt<font color=Cyan>)</font> s' ts'- <font color=Green><u>in</u></font> <font color=Cyan>(</font>Right <font color=Cyan>(</font>x<font color=Red><b>:</b></font>tail<font color=Cyan>)</font><font color=Cyan>,</font> s''<font color=Cyan>,</font> ts''<font color=Cyan>)</font> <font color=Cyan>)</font>--<font color=Blue>------------------------------------------------------------------------</font>-<font color=Blue>-- State handling</font>--<font color=Blue>-- | Update the internal state.</font>-stUpdate <font color=Red>::</font> <font color=Cyan>(</font>s<font color=Red>-></font>s<font color=Cyan>)</font> <font color=Red>-></font> Parser s t <font color=Cyan>(</font><font color=Cyan>)</font>-<a name="stUpdate"></a>stUpdate f <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>s ts<font color=Red>-></font> <font color=Cyan>(</font>Right <font color=Cyan>(</font><font color=Cyan>)</font><font color=Cyan>,</font> f s<font color=Cyan>,</font> ts<font color=Cyan>)</font><font color=Cyan>)</font>--<font color=Blue>-- | Query the internal state.</font>-stQuery <font color=Red>::</font> <font color=Cyan>(</font>s<font color=Red>-></font>a<font color=Cyan>)</font> <font color=Red>-></font> Parser s t a-<a name="stQuery"></a>stQuery f <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>s ts<font color=Red>-></font> <font color=Cyan>(</font>Right <font color=Cyan>(</font>f s<font color=Cyan>)</font><font color=Cyan>,</font> s<font color=Cyan>,</font> ts<font color=Cyan>)</font><font color=Cyan>)</font>--<font color=Blue>-- | Deliver the entire internal state.</font>-stGet <font color=Red>::</font> Parser s t s-<a name="stGet"></a>stGet <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>s ts<font color=Red>-></font> <font color=Cyan>(</font>Right s<font color=Cyan>,</font> s<font color=Cyan>,</font> ts<font color=Cyan>)</font><font color=Cyan>)</font>--<font color=Blue>------------------------------------------------------------------------</font>-<font color=Blue>-- | Push some tokens back onto the front of the input stream and reparse.</font>-<font color=Blue>-- This is useful e.g. for recursively expanding macros. When the</font>-<font color=Blue>-- user-parser recognises a macro use, it can lookup the macro</font>-<font color=Blue>-- expansion from the parse state, lex it, and then stuff the</font>-<font color=Blue>-- lexed expansion back down into the parser.</font>-reparse <font color=Red>::</font> <font color=Red>[</font>t<font color=Red>]</font> <font color=Red>-></font> Parser s t <font color=Cyan>(</font><font color=Cyan>)</font>-<a name="reparse"></a>reparse ts <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>s inp<font color=Red>-></font> <font color=Cyan>(</font>Right <font color=Cyan>(</font><font color=Cyan>)</font><font color=Cyan>,</font> s<font color=Cyan>,</font> ts<font color=Cyan>++</font>inp<font color=Cyan>)</font><font color=Cyan>)</font>--<font color=Blue>------------------------------------------------------------------------</font>-</pre>
− docs/HaXml/src/Text/ParserCombinators/TextParser.html
@@ -1,166 +0,0 @@-<pre><font color=Green><u>module</u></font> Text<font color=Cyan>.</font>ParserCombinators<font color=Cyan>.</font>TextParser- <font color=Cyan>(</font> <font color=Blue>-- * The Parse class is a replacement for the Read class. It is a</font>- <font color=Blue>-- specialisation of the (poly) Parser monad for String input.</font>- TextParser <font color=Blue>-- synonym for Parser Char, i.e. string input, no state</font>- <font color=Cyan>,</font> Parse<font color=Cyan>(</font><font color=Red>..</font><font color=Cyan>)</font> <font color=Blue>-- instances: (), (a,b), (a,b,c), Maybe a, Either a, [a],</font>- <font color=Blue>-- Int, Integer, Float, Double, Char, Bool</font>- <font color=Cyan>,</font> parseByRead <font color=Blue>-- :: Read a => String -> TextParser a</font>- <font color=Blue>-- ** Combinators specific to string input, lexed haskell-style</font>- <font color=Cyan>,</font> word <font color=Blue>-- :: TextParser String</font>- <font color=Cyan>,</font> isWord <font color=Blue>-- :: String -> TextParser ()</font>- <font color=Cyan>,</font> optionalParens <font color=Blue>-- :: TextParser a -> TextParser a</font>- <font color=Cyan>,</font> field <font color=Blue>-- :: Parse a => String -> TextParser a</font>- <font color=Cyan>,</font> constructors<font color=Blue>-- :: [(String,TextParser a)] -> TextParser a</font>- <font color=Cyan>,</font> enumeration <font color=Blue>-- :: Show a => String -> [a] -> TextParser a</font>- <font color=Blue>-- ** Re-export all the more general combinators too</font>- <font color=Cyan>,</font> <font color=Green><u>module</u></font> Text<font color=Cyan>.</font>ParserCombinators<font color=Cyan>.</font>Poly- <font color=Cyan>)</font> <font color=Green><u>where</u></font>--<font color=Green><u>import</u></font> Char <font color=Cyan>(</font>isSpace<font color=Cyan>)</font>-<font color=Green><u>import</u></font> List <font color=Cyan>(</font>intersperse<font color=Cyan>)</font>-<font color=Green><u>import</u></font> Text<font color=Cyan>.</font>ParserCombinators<font color=Cyan>.</font>Poly--<font color=Blue>------------------------------------------------------------------------</font>--<font color=Blue>-- | A synonym for Parser Char, i.e. string input (no state)</font>-<a name="TextParser"></a><font color=Green><u>type</u></font> TextParser a <font color=Red>=</font> Parser Char a--<font color=Blue>-- | The class @Parse@ is a replacement for @Read@, operating over String input.</font>-<font color=Blue>-- Essentially, it permits better error messages for why something failed to</font>-<font color=Blue>-- parse. It is rather important that @parse@ can read back exactly what</font>-<font color=Blue>-- is generated by the corresponding instance of @show@.</font>-<a name="Parse"></a><font color=Green><u>class</u></font> Parse a <font color=Green><u>where</u></font>- parse <font color=Red>::</font> TextParser a- parseList <font color=Red>::</font> TextParser <font color=Red>[</font>a<font color=Red>]</font> <font color=Blue>-- only to distinguish [] and ""</font>- parseList <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font> isWord <font color=Magenta>"[]"</font><font color=Cyan>;</font> return <font color=Red>[</font><font color=Red>]</font> <font color=Cyan>}</font>- <font color=Cyan>`onFail`</font>- <font color=Green><u>do</u></font> <font color=Cyan>{</font> isWord <font color=Magenta>"["</font><font color=Cyan>;</font> isWord <font color=Magenta>"]"</font><font color=Cyan>;</font> return <font color=Red>[</font><font color=Red>]</font> <font color=Cyan>}</font>- <font color=Cyan>`onFail`</font>- bracketSep <font color=Cyan>(</font>isWord <font color=Magenta>"["</font><font color=Cyan>)</font> <font color=Cyan>(</font>isWord <font color=Magenta>","</font><font color=Cyan>)</font> <font color=Cyan>(</font>isWord <font color=Magenta>"]"</font><font color=Cyan>)</font> parse- <font color=Cyan>`adjustErr`</font> <font color=Cyan>(</font><font color=Magenta>"Expected a list, but\n"</font><font color=Cyan>++</font><font color=Cyan>)</font>--<font color=Blue>-- | If there already exists a Read instance for a type, then we can make</font>-<font color=Blue>-- a Parser for it, but with only poor error-reporting.</font>-parseByRead <font color=Red>::</font> Read a <font color=Red>=></font> String <font color=Red>-></font> TextParser a-<a name="parseByRead"></a>parseByRead name <font color=Red>=</font>- P <font color=Cyan>(</font><font color=Red>\</font>s<font color=Red>-></font> <font color=Green><u>case</u></font> reads s <font color=Green><u>of</u></font>- <font color=Red>[</font><font color=Red>]</font> <font color=Red>-></font> <font color=Cyan>(</font>Left <font color=Cyan>(</font>False<font color=Cyan>,</font><font color=Magenta>"no parse, expected a "</font><font color=Cyan>++</font>name<font color=Cyan>)</font><font color=Cyan>,</font> s<font color=Cyan>)</font>- <font color=Red>[</font><font color=Cyan>(</font>a<font color=Cyan>,</font>s'<font color=Cyan>)</font><font color=Red>]</font> <font color=Red>-></font> <font color=Cyan>(</font>Right a<font color=Cyan>,</font> s'<font color=Cyan>)</font>- <font color=Green><u>_</u></font> <font color=Red>-></font> <font color=Cyan>(</font>Left <font color=Cyan>(</font>False<font color=Cyan>,</font><font color=Magenta>"ambiguous parse, expected a "</font><font color=Cyan>++</font>name<font color=Cyan>)</font><font color=Cyan>,</font> s<font color=Cyan>)</font>- <font color=Cyan>)</font>--<font color=Blue>-- | One lexical chunk (Haskell-style lexing).</font>-word <font color=Red>::</font> TextParser String-<a name="word"></a>word <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>s<font color=Red>-></font> <font color=Green><u>case</u></font> lex s <font color=Green><u>of</u></font>- <font color=Red>[</font><font color=Red>]</font> <font color=Red>-></font> <font color=Cyan>(</font>Left <font color=Cyan>(</font>False<font color=Cyan>,</font><font color=Magenta>"no input? (impossible)"</font><font color=Cyan>)</font><font color=Cyan>,</font> s<font color=Cyan>)</font>- <font color=Red>[</font><font color=Cyan>(</font><font color=Magenta>""</font><font color=Cyan>,</font>s'<font color=Cyan>)</font><font color=Red>]</font> <font color=Red>-></font> <font color=Cyan>(</font>Left <font color=Cyan>(</font>False<font color=Cyan>,</font><font color=Magenta>"no input?"</font><font color=Cyan>)</font><font color=Cyan>,</font> s'<font color=Cyan>)</font>- <font color=Cyan>(</font><font color=Cyan>(</font>x<font color=Cyan>,</font>s'<font color=Cyan>)</font><font color=Red><b>:</b></font><font color=Green><u>_</u></font><font color=Cyan>)</font> <font color=Red>-></font> <font color=Cyan>(</font>Right x<font color=Cyan>,</font> s'<font color=Cyan>)</font> <font color=Cyan>)</font>--<font color=Blue>-- | Ensure that the next input word is a given string. (Note the input</font>-<font color=Blue>-- is lexed as haskell, so wordbreaks at spaces, symbols, etc.)</font>-isWord <font color=Red>::</font> String <font color=Red>-></font> TextParser String-<a name="isWord"></a>isWord w <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font> w' <font color=Red><-</font> word- <font color=Cyan>;</font> <font color=Green><u>if</u></font> w'<font color=Cyan>==</font>w <font color=Green><u>then</u></font> return w <font color=Green><u>else</u></font> fail <font color=Cyan>(</font><font color=Magenta>"expected "</font><font color=Cyan>++</font>w<font color=Cyan>++</font><font color=Magenta>" got "</font><font color=Cyan>++</font>w'<font color=Cyan>)</font>- <font color=Cyan>}</font>--<font color=Blue>-- | Allow true string parens around an item.</font>-optionalParens <font color=Red>::</font> TextParser a <font color=Red>-></font> TextParser a-<a name="optionalParens"></a>optionalParens p <font color=Red>=</font> bracket <font color=Cyan>(</font>isWord <font color=Magenta>"("</font><font color=Cyan>)</font> <font color=Cyan>(</font>isWord <font color=Magenta>")"</font><font color=Cyan>)</font> p <font color=Cyan>`onFail`</font> p--<font color=Blue>-- | Deal with named field syntax.</font>-field <font color=Red>::</font> Parse a <font color=Red>=></font> String <font color=Red>-></font> TextParser a-<a name="field"></a>field name <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font> isWord name<font color=Cyan>;</font> commit <font color=Cyan>$</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font> isWord <font color=Magenta>"="</font><font color=Cyan>;</font> parse <font color=Cyan>}</font> <font color=Cyan>}</font>--<font color=Blue>-- | Parse one of a bunch of alternative constructors.</font>-constructors <font color=Red>::</font> <font color=Red>[</font><font color=Cyan>(</font>String<font color=Cyan>,</font>TextParser a<font color=Cyan>)</font><font color=Red>]</font> <font color=Red>-></font> TextParser a-<a name="constructors"></a>constructors cs <font color=Red>=</font> oneOf' <font color=Cyan>(</font>map cons cs<font color=Cyan>)</font>- <font color=Green><u>where</u></font> cons <font color=Cyan>(</font>name<font color=Cyan>,</font>p<font color=Cyan>)</font> <font color=Red>=</font>- <font color=Cyan>(</font> name- <font color=Cyan>,</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font> isWord name- <font color=Cyan>;</font> p <font color=Cyan>`adjustErrBad`</font> <font color=Cyan>(</font><font color=Cyan>(</font><font color=Magenta>"got constructor, but within "</font>- <font color=Cyan>++</font>name<font color=Cyan>++</font><font color=Magenta>",\n"</font><font color=Cyan>)</font><font color=Cyan>++</font><font color=Cyan>)</font>- <font color=Cyan>}</font>- <font color=Cyan>)</font>--<font color=Blue>-- | Parse one of the given nullary constructors (an enumeration).</font>-enumeration <font color=Red>::</font> <font color=Cyan>(</font>Show a<font color=Cyan>)</font> <font color=Red>=></font> String <font color=Red>-></font> <font color=Red>[</font>a<font color=Red>]</font> <font color=Red>-></font> TextParser a-<a name="enumeration"></a>enumeration typ cs <font color=Red>=</font> oneOf <font color=Cyan>(</font>map <font color=Cyan>(</font><font color=Red>\</font>c<font color=Red>-></font> <font color=Green><u>do</u></font> <font color=Cyan>{</font> isWord <font color=Cyan>(</font>show c<font color=Cyan>)</font><font color=Cyan>;</font> return c <font color=Cyan>}</font><font color=Cyan>)</font> cs<font color=Cyan>)</font>- <font color=Cyan>`adjustErr`</font>- <font color=Cyan>(</font><font color=Cyan>++</font><font color=Cyan>(</font><font color=Magenta>"\n expected "</font><font color=Cyan>++</font>typ<font color=Cyan>++</font><font color=Magenta>" value ("</font><font color=Cyan>++</font>e<font color=Cyan>++</font><font color=Magenta>")"</font><font color=Cyan>)</font><font color=Cyan>)</font>- <font color=Green><u>where</u></font> e <font color=Red>=</font> concat <font color=Cyan>(</font>intersperse <font color=Magenta>", "</font> <font color=Cyan>(</font>map show <font color=Cyan>(</font>init cs<font color=Cyan>)</font><font color=Cyan>)</font><font color=Cyan>)</font>- <font color=Cyan>++</font> <font color=Magenta>", or "</font> <font color=Cyan>++</font> show <font color=Cyan>(</font>last cs<font color=Cyan>)</font>--<font color=Blue>------------------------------------------------------------------------</font>-<font color=Blue>-- Instances for all the Standard Prelude types.</font>--<font color=Blue>-- Basic types</font>-<font color=Green><u>instance</u></font> Parse Int <font color=Green><u>where</u></font>- parse <font color=Red>=</font> parseByRead <font color=Magenta>"Int"</font>-<font color=Green><u>instance</u></font> Parse Integer <font color=Green><u>where</u></font>- parse <font color=Red>=</font> parseByRead <font color=Magenta>"Integer"</font>-<font color=Green><u>instance</u></font> Parse Float <font color=Green><u>where</u></font>- parse <font color=Red>=</font> parseByRead <font color=Magenta>"Float"</font>-<font color=Green><u>instance</u></font> Parse Double <font color=Green><u>where</u></font>- parse <font color=Red>=</font> parseByRead <font color=Magenta>"Double"</font>-<font color=Green><u>instance</u></font> Parse Char <font color=Green><u>where</u></font>- parse <font color=Red>=</font> parseByRead <font color=Magenta>"Char"</font>- <font color=Blue>-- parseList = bracket (isWord "\"") (satisfy (=='"'))</font>- <font color=Blue>-- (many (satisfy (/='"')))</font>- <font color=Blue>-- not totally correct for strings...</font>- parseList <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font> w <font color=Red><-</font> word<font color=Cyan>;</font> <font color=Green><u>if</u></font> head w <font color=Cyan>==</font> <font color=Magenta>'"'</font> <font color=Green><u>then</u></font> return w- <font color=Green><u>else</u></font> fail <font color=Magenta>"not a string"</font> <font color=Cyan>}</font>--<font color=Green><u>instance</u></font> Parse Bool <font color=Green><u>where</u></font>- parse <font color=Red>=</font> enumeration <font color=Magenta>"Bool"</font> <font color=Red>[</font>False<font color=Cyan>,</font>True<font color=Red>]</font>--<font color=Green><u>instance</u></font> Parse Ordering <font color=Green><u>where</u></font>- parse <font color=Red>=</font> enumeration <font color=Magenta>"Ordering"</font> <font color=Red>[</font>LT<font color=Cyan>,</font>EQ<font color=Cyan>,</font>GT<font color=Red>]</font>--<font color=Blue>-- Structural types</font>-<font color=Green><u>instance</u></font> Parse <font color=Cyan>(</font><font color=Cyan>)</font> <font color=Green><u>where</u></font>- parse <font color=Red>=</font> P p- <font color=Green><u>where</u></font> p <font color=Red>[</font><font color=Red>]</font> <font color=Red>=</font> <font color=Cyan>(</font>Left <font color=Cyan>(</font>False<font color=Cyan>,</font><font color=Magenta>"no input: expected a ()"</font><font color=Cyan>)</font><font color=Cyan>,</font> <font color=Red>[</font><font color=Red>]</font><font color=Cyan>)</font>- p <font color=Cyan>(</font><font color=Magenta>'('</font><font color=Red><b>:</b></font>cs<font color=Cyan>)</font> <font color=Red>=</font> <font color=Green><u>case</u></font> dropWhile isSpace cs <font color=Green><u>of</u></font>- <font color=Cyan>(</font><font color=Magenta>')'</font><font color=Red><b>:</b></font>s<font color=Cyan>)</font> <font color=Red>-></font> <font color=Cyan>(</font>Right <font color=Cyan>(</font><font color=Cyan>)</font><font color=Cyan>,</font> s<font color=Cyan>)</font>- <font color=Green><u>_</u></font> <font color=Red>-></font> <font color=Cyan>(</font>Left <font color=Cyan>(</font>False<font color=Cyan>,</font><font color=Magenta>"Expected ) after ("</font><font color=Cyan>)</font><font color=Cyan>,</font> cs<font color=Cyan>)</font>- p <font color=Cyan>(</font>c<font color=Red><b>:</b></font>cs<font color=Cyan>)</font> <font color=Red>|</font> isSpace c <font color=Red>=</font> p cs- <font color=Red>|</font> otherwise <font color=Red>=</font> <font color=Cyan>(</font> Left <font color=Cyan>(</font>False<font color=Cyan>,</font><font color=Magenta>"Expected a (), got "</font><font color=Cyan>++</font>show c<font color=Cyan>)</font>- <font color=Cyan>,</font> <font color=Cyan>(</font>c<font color=Red><b>:</b></font>cs<font color=Cyan>)</font><font color=Cyan>)</font>--<font color=Green><u>instance</u></font> <font color=Cyan>(</font>Parse a<font color=Cyan>,</font> Parse b<font color=Cyan>)</font> <font color=Red>=></font> Parse <font color=Cyan>(</font>a<font color=Cyan>,</font>b<font color=Cyan>)</font> <font color=Green><u>where</u></font>- parse <font color=Red>=</font> <font color=Green><u>do</u></font><font color=Cyan>{</font> isWord <font color=Magenta>"("</font> <font color=Cyan>`adjustErr`</font> <font color=Cyan>(</font><font color=Magenta>"Opening a 2-tuple\n"</font><font color=Cyan>++</font><font color=Cyan>)</font>- <font color=Cyan>;</font> x <font color=Red><-</font> parse <font color=Cyan>`adjustErr`</font> <font color=Cyan>(</font><font color=Magenta>"In 1st item of a 2-tuple\n"</font><font color=Cyan>++</font><font color=Cyan>)</font>- <font color=Cyan>;</font> isWord <font color=Magenta>","</font> <font color=Cyan>`adjustErr`</font> <font color=Cyan>(</font><font color=Magenta>"Separating a 2-tuple\n"</font><font color=Cyan>++</font><font color=Cyan>)</font>- <font color=Cyan>;</font> y <font color=Red><-</font> parse <font color=Cyan>`adjustErr`</font> <font color=Cyan>(</font><font color=Magenta>"In 2nd item of a 2-tuple\n"</font><font color=Cyan>++</font><font color=Cyan>)</font>- <font color=Cyan>;</font> isWord <font color=Magenta>")"</font> <font color=Cyan>`adjustErr`</font> <font color=Cyan>(</font><font color=Magenta>"Closing a 2-tuple\n"</font><font color=Cyan>++</font><font color=Cyan>)</font>- <font color=Cyan>;</font> return <font color=Cyan>(</font>x<font color=Cyan>,</font>y<font color=Cyan>)</font> <font color=Cyan>}</font>--<font color=Green><u>instance</u></font> <font color=Cyan>(</font>Parse a<font color=Cyan>,</font> Parse b<font color=Cyan>,</font> Parse c<font color=Cyan>)</font> <font color=Red>=></font> Parse <font color=Cyan>(</font>a<font color=Cyan>,</font>b<font color=Cyan>,</font>c<font color=Cyan>)</font> <font color=Green><u>where</u></font>- parse <font color=Red>=</font> <font color=Green><u>do</u></font><font color=Cyan>{</font> isWord <font color=Magenta>"("</font> <font color=Cyan>`adjustErr`</font> <font color=Cyan>(</font><font color=Magenta>"Opening a 3-tuple\n"</font><font color=Cyan>++</font><font color=Cyan>)</font>- <font color=Cyan>;</font> x <font color=Red><-</font> parse <font color=Cyan>`adjustErr`</font> <font color=Cyan>(</font><font color=Magenta>"In 1st item of a 3-tuple\n"</font><font color=Cyan>++</font><font color=Cyan>)</font>- <font color=Cyan>;</font> isWord <font color=Magenta>","</font> <font color=Cyan>`adjustErr`</font> <font color=Cyan>(</font><font color=Magenta>"Separating(1) a 3-tuple\n"</font><font color=Cyan>++</font><font color=Cyan>)</font>- <font color=Cyan>;</font> y <font color=Red><-</font> parse <font color=Cyan>`adjustErr`</font> <font color=Cyan>(</font><font color=Magenta>"In 2nd item of a 3-tuple\n"</font><font color=Cyan>++</font><font color=Cyan>)</font>- <font color=Cyan>;</font> isWord <font color=Magenta>","</font> <font color=Cyan>`adjustErr`</font> <font color=Cyan>(</font><font color=Magenta>"Separating(2) a 3-tuple\n"</font><font color=Cyan>++</font><font color=Cyan>)</font>- <font color=Cyan>;</font> z <font color=Red><-</font> parse <font color=Cyan>`adjustErr`</font> <font color=Cyan>(</font><font color=Magenta>"In 3rd item of a 3-tuple\n"</font><font color=Cyan>++</font><font color=Cyan>)</font>- <font color=Cyan>;</font> isWord <font color=Magenta>")"</font> <font color=Cyan>`adjustErr`</font> <font color=Cyan>(</font><font color=Magenta>"Closing a 3-tuple\n"</font><font color=Cyan>++</font><font color=Cyan>)</font>- <font color=Cyan>;</font> return <font color=Cyan>(</font>x<font color=Cyan>,</font>y<font color=Cyan>,</font>z<font color=Cyan>)</font> <font color=Cyan>}</font>--<font color=Green><u>instance</u></font> Parse a <font color=Red>=></font> Parse <font color=Cyan>(</font>Maybe a<font color=Cyan>)</font> <font color=Green><u>where</u></font>- parse <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font> isWord <font color=Magenta>"Nothing"</font><font color=Cyan>;</font> return Nothing <font color=Cyan>}</font>- <font color=Cyan>`onFail`</font>- <font color=Green><u>do</u></font> <font color=Cyan>{</font> isWord <font color=Magenta>"Just"</font>- <font color=Cyan>;</font> fmap Just <font color=Cyan>$</font> optionalParens parse- <font color=Cyan>`adjustErrBad`</font> <font color=Cyan>(</font><font color=Magenta>"but within Just, "</font><font color=Cyan>++</font><font color=Cyan>)</font>- <font color=Cyan>}</font>- <font color=Cyan>`adjustErr`</font> <font color=Cyan>(</font><font color=Cyan>(</font><font color=Magenta>"expected a Maybe (Just or Nothing)\n"</font><font color=Cyan>++</font><font color=Cyan>)</font><font color=Cyan>.</font>indent <font color=Magenta>2</font><font color=Cyan>)</font>--<font color=Green><u>instance</u></font> <font color=Cyan>(</font>Parse a<font color=Cyan>,</font> Parse b<font color=Cyan>)</font> <font color=Red>=></font> Parse <font color=Cyan>(</font>Either a b<font color=Cyan>)</font> <font color=Green><u>where</u></font>- parse <font color=Red>=</font> constructors <font color=Red>[</font> <font color=Cyan>(</font><font color=Magenta>"Left"</font><font color=Cyan>,</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font> fmap Left <font color=Cyan>$</font> optionalParens parse <font color=Cyan>}</font> <font color=Cyan>)</font>- <font color=Cyan>,</font> <font color=Cyan>(</font><font color=Magenta>"Right"</font><font color=Cyan>,</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font> fmap Right <font color=Cyan>$</font> optionalParens parse <font color=Cyan>}</font> <font color=Cyan>)</font>- <font color=Red>]</font>--<font color=Green><u>instance</u></font> Parse a <font color=Red>=></font> Parse <font color=Red>[</font>a<font color=Red>]</font> <font color=Green><u>where</u></font>- parse <font color=Red>=</font> parseList--<font color=Blue>------------------------------------------------------------------------</font>-</pre>
docs/HaXml/src/Text/XML/HaXml/SAX.html view
@@ -14,7 +14,7 @@ <a name="(line12)"></a><font color=Green><u>import</u></font> Text<font color=Cyan>.</font>XML<font color=Cyan>.</font>HaXml<font color=Cyan>.</font>Types <a name="(line13)"></a><font color=Green><u>import</u></font> Text<font color=Cyan>.</font>XML<font color=Cyan>.</font>HaXml<font color=Cyan>.</font>Parse <a name="(line14)"></a><font color=Green><u>import</u></font> Text<font color=Cyan>.</font>XML<font color=Cyan>.</font>HaXml<font color=Cyan>.</font>Lex-<a name="(line15)"></a><font color=Green><u>import</u></font> Text<font color=Cyan>.</font>ParserCombinators<font color=Cyan>.</font>PolyState+<a name="(line15)"></a><font color=Green><u>import</u></font> Text<font color=Cyan>.</font>ParserCombinators<font color=Cyan>.</font>Poly<font color=Cyan>.</font>NoLeak<font color=Cyan>.</font>State <a name="(line16)"></a> <a name="(line17)"></a><a name="SaxElement"></a><font color=Green><u>data</u></font> SaxElement <a name="(line18)"></a> <font color=Red>=</font> SaxDocTypeDecl DocTypeDecl
docs/HaXml/src/Text/XML/HaXml/TypeMapping.html view
@@ -60,158 +60,150 @@ <a name="(line58)"></a><a name="Constr"></a><font color=Blue>-- variables occurring in the (second) list of real component types.</font> <a name="(line59)"></a><a name="Constr"></a><font color=Blue>-- If there are fieldnames, they are contained in the final list, and</font> <a name="(line60)"></a><a name="Constr"></a><font color=Blue>-- correspond one-to-one with the component types.</font>-<a name="(line61)"></a><a name="Constr"></a><font color=Blue>-- The Synonym alternative is for where the type-mapping from Haskell to</font>-<a name="(line62)"></a><a name="Constr"></a><font color=Blue>-- XML is user-defined rather than automatic. There, one might wish to</font>-<a name="(line63)"></a><a name="Constr"></a><font color=Blue>-- rename an existing XML type, without the addition of a constructor\/tag.</font>-<a name="(line64)"></a><a name="Constr"></a><font color=Green><u>data</u></font> Constr <font color=Red>=</font> Constr String <font color=Red>[</font>HType<font color=Red>]</font> <font color=Red>[</font>HType<font color=Red>]</font> <font color=Blue>-- (Maybe [String])</font>-<a name="(line65)"></a> <font color=Red>|</font> Synonym HType-<a name="(line66)"></a> <font color=Green><u>deriving</u></font> <font color=Cyan>(</font>Eq<font color=Cyan>,</font>Show<font color=Cyan>)</font>-<a name="(line67)"></a>-<a name="(line68)"></a><a name="showConstr"></a><font color=Blue>-- | Project the n'th constructor from an HType and convert it to a string</font>-<a name="(line69)"></a><font color=Blue>-- suitable for an XML tagname.</font>-<a name="(line70)"></a>showConstr <font color=Red>::</font> Int <font color=Red>-></font> HType <font color=Red>-></font> String-<a name="(line71)"></a>showConstr n <font color=Cyan>(</font>Defined <font color=Green><u>_</u></font> <font color=Green><u>_</u></font> cs<font color=Cyan>)</font> <font color=Red>=</font> flatConstr <font color=Cyan>(</font>cs<font color=Cyan>!!</font>n<font color=Cyan>)</font> <font color=Magenta>""</font>-<a name="(line72)"></a>showConstr n <font color=Green><u>_</u></font> <font color=Red>=</font> error <font color=Magenta>"no constructors for builtin types"</font>-<a name="(line73)"></a>-<a name="(line74)"></a><font color=Blue>------------------------------------------------------------------------</font>-<a name="(line75)"></a><font color=Blue>-- Some instances</font>-<a name="(line76)"></a><font color=Green><u>instance</u></font> HTypeable Bool <font color=Green><u>where</u></font>-<a name="(line77)"></a> toHType <font color=Green><u>_</u></font> <font color=Red>=</font> Prim <font color=Magenta>"Bool"</font> <font color=Magenta>"bool"</font>-<a name="(line78)"></a><font color=Green><u>instance</u></font> HTypeable Int <font color=Green><u>where</u></font>-<a name="(line79)"></a> toHType <font color=Green><u>_</u></font> <font color=Red>=</font> Prim <font color=Magenta>"Int"</font> <font color=Magenta>"int"</font>-<a name="(line80)"></a><font color=Green><u>instance</u></font> HTypeable Integer <font color=Green><u>where</u></font>-<a name="(line81)"></a> toHType <font color=Green><u>_</u></font> <font color=Red>=</font> Prim <font color=Magenta>"Integer"</font> <font color=Magenta>"integer"</font>-<a name="(line82)"></a><font color=Green><u>instance</u></font> HTypeable Float <font color=Green><u>where</u></font>-<a name="(line83)"></a> toHType <font color=Green><u>_</u></font> <font color=Red>=</font> Prim <font color=Magenta>"Float"</font> <font color=Magenta>"float"</font>-<a name="(line84)"></a><font color=Green><u>instance</u></font> HTypeable Double <font color=Green><u>where</u></font>-<a name="(line85)"></a> toHType <font color=Green><u>_</u></font> <font color=Red>=</font> Prim <font color=Magenta>"Double"</font> <font color=Magenta>"double"</font>-<a name="(line86)"></a><font color=Green><u>instance</u></font> HTypeable Char <font color=Green><u>where</u></font>-<a name="(line87)"></a> toHType <font color=Green><u>_</u></font> <font color=Red>=</font> Prim <font color=Magenta>"Char"</font> <font color=Magenta>"char"</font>-<a name="(line88)"></a>-<a name="(line89)"></a><font color=Green><u>instance</u></font> HTypeable () <font color=Green><u>where</u></font>-<a name="(line90)"></a> toHType <font color=Green><u>_</u></font> <font color=Red>=</font> Prim <font color=Magenta>"unit"</font> <font color=Magenta>"unit"</font>-<a name="(line91)"></a><font color=Green><u>instance</u></font> <font color=Cyan>(</font>HTypeable a<font color=Cyan>,</font> HTypeable b<font color=Cyan>)</font> <font color=Red>=></font> HTypeable <font color=Cyan>(</font>a<font color=Cyan>,</font>b<font color=Cyan>)</font> <font color=Green><u>where</u></font>-<a name="(line92)"></a> toHType p <font color=Red>=</font> Tuple <font color=Red>[</font>toHType a<font color=Cyan>,</font> toHType b<font color=Red>]</font>-<a name="(line93)"></a> <font color=Green><u>where</u></font> <font color=Cyan>(</font>a<font color=Cyan>,</font>b<font color=Cyan>)</font> <font color=Red>=</font> p-<a name="(line94)"></a><font color=Green><u>instance</u></font> <font color=Cyan>(</font>HTypeable a<font color=Cyan>,</font> HTypeable b<font color=Cyan>,</font> HTypeable c<font color=Cyan>)</font> <font color=Red>=></font> HTypeable <font color=Cyan>(</font>a<font color=Cyan>,</font>b<font color=Cyan>,</font>c<font color=Cyan>)</font> <font color=Green><u>where</u></font>-<a name="(line95)"></a> toHType p <font color=Red>=</font> Tuple <font color=Red>[</font>toHType a<font color=Cyan>,</font> toHType b<font color=Cyan>,</font> toHType c<font color=Red>]</font>-<a name="(line96)"></a> <font color=Green><u>where</u></font> <font color=Cyan>(</font>a<font color=Cyan>,</font>b<font color=Cyan>,</font>c<font color=Cyan>)</font> <font color=Red>=</font> p-<a name="(line97)"></a><font color=Green><u>instance</u></font> <font color=Cyan>(</font>HTypeable a<font color=Cyan>)</font> <font color=Red>=></font> HTypeable <font color=Cyan>(</font>Maybe a<font color=Cyan>)</font> <font color=Green><u>where</u></font>-<a name="(line98)"></a> toHType m <font color=Red>=</font> Maybe <font color=Cyan>(</font>toHType x<font color=Cyan>)</font> <font color=Green><u>where</u></font> <font color=Cyan>(</font>Just x<font color=Cyan>)</font> <font color=Red>=</font> m-<a name="(line99)"></a><font color=Green><u>instance</u></font> <font color=Cyan>(</font>HTypeable a<font color=Cyan>,</font> HTypeable b<font color=Cyan>)</font> <font color=Red>=></font> HTypeable <font color=Cyan>(</font>Either a b<font color=Cyan>)</font> <font color=Green><u>where</u></font>-<a name="(line100)"></a> toHType m <font color=Red>=</font> Defined <font color=Magenta>"Either"</font> <font color=Red>[</font>hx<font color=Cyan>,</font> hy<font color=Red>]</font>-<a name="(line101)"></a> <font color=Red>[</font> Constr <font color=Magenta>"Left"</font> <font color=Red>[</font>hx<font color=Red>]</font> <font color=Red>[</font>hx<font color=Red>]</font> <font color=Blue>{-Nothing-}</font>-<a name="(line102)"></a> <font color=Cyan>,</font> Constr <font color=Magenta>"Right"</font> <font color=Red>[</font>hy<font color=Red>]</font> <font color=Red>[</font>hy<font color=Red>]</font> <font color=Blue>{-Nothing-}</font><font color=Red>]</font>-<a name="(line103)"></a> <font color=Green><u>where</u></font> <font color=Cyan>(</font>Left x<font color=Cyan>)</font> <font color=Red>=</font> m-<a name="(line104)"></a> <font color=Cyan>(</font>Right y<font color=Cyan>)</font> <font color=Red>=</font> m-<a name="(line105)"></a> hx <font color=Red>=</font> toHType x-<a name="(line106)"></a> hy <font color=Red>=</font> toHType y-<a name="(line107)"></a>-<a name="(line108)"></a><font color=Green><u>instance</u></font> HTypeable a <font color=Red>=></font> HTypeable <font color=Red>[</font>a<font color=Red>]</font> <font color=Green><u>where</u></font>-<a name="(line109)"></a> toHType xs <font color=Red>=</font> <font color=Green><u>case</u></font> toHType x <font color=Green><u>of</u></font> <font color=Cyan>(</font>Prim <font color=Magenta>"Char"</font> <font color=Green><u>_</u></font><font color=Cyan>)</font> <font color=Red>-></font> String-<a name="(line110)"></a> <font color=Green><u>_</u></font> <font color=Red>-></font> List <font color=Cyan>(</font>toHType x<font color=Cyan>)</font>-<a name="(line111)"></a> <font color=Green><u>where</u></font> <font color=Cyan>(</font>x<font color=Red><b>:</b></font><font color=Green><u>_</u></font><font color=Cyan>)</font> <font color=Red>=</font> xs-<a name="(line112)"></a>-<a name="(line113)"></a><font color=Blue>------------------------------------------------------------------------</font>-<a name="(line114)"></a>-<a name="(line115)"></a><a name="toDTD"></a><font color=Blue>-- | 'toDTD' converts a concrete representation of the Haskell type of</font>-<a name="(line116)"></a><font color=Blue>-- a value (obtained by the method 'toHType') into a real DocTypeDecl.</font>-<a name="(line117)"></a><font color=Blue>-- It ensures that PERefs are defined before they are used, and that no</font>-<a name="(line118)"></a><font color=Blue>-- element or attribute-list is declared more than once.</font>-<a name="(line119)"></a>toDTD <font color=Red>::</font> HType <font color=Red>-></font> DocTypeDecl-<a name="(line120)"></a>toDTD ht <font color=Red>=</font>-<a name="(line121)"></a> DTD <font color=Cyan>(</font>toplevel ht<font color=Cyan>)</font> Nothing <font color=Cyan>(</font>macrosFirst <font color=Cyan>(</font>reverse <font color=Cyan>(</font>h2d True [] [] <font color=Red>[</font>ht<font color=Red>]</font><font color=Cyan>)</font><font color=Cyan>)</font><font color=Cyan>)</font>-<a name="(line122)"></a> <font color=Green><u>where</u></font>-<a name="(line123)"></a> macrosFirst <font color=Red>::</font> <font color=Red>[</font>MarkupDecl<font color=Red>]</font> <font color=Red>-></font> <font color=Red>[</font>MarkupDecl<font color=Red>]</font>-<a name="(line124)"></a> macrosFirst decls <font color=Red>=</font> concat <font color=Red>[</font>p<font color=Cyan>,</font> p'<font color=Red>]</font> <font color=Green><u>where</u></font> <font color=Cyan>(</font>p<font color=Cyan>,</font> p'<font color=Cyan>)</font> <font color=Red>=</font> partition f decls-<a name="(line125)"></a> f <font color=Cyan>(</font>Entity <font color=Green><u>_</u></font><font color=Cyan>)</font> <font color=Red>=</font> True-<a name="(line126)"></a> f <font color=Green><u>_</u></font> <font color=Red>=</font> False-<a name="(line127)"></a> toplevel ht<font color=Red>@</font><font color=Cyan>(</font>Defined <font color=Green><u>_</u></font> <font color=Green><u>_</u></font> <font color=Green><u>_</u></font><font color=Cyan>)</font> <font color=Red>=</font> showHType ht <font color=Magenta>"-XML"</font>-<a name="(line128)"></a> toplevel ht<font color=Red>@</font><font color=Green><u>_</u></font> <font color=Red>=</font> showHType ht <font color=Magenta>""</font>-<a name="(line129)"></a> c0 <font color=Red>=</font> False-<a name="(line130)"></a> h2d <font color=Red>::</font> Bool <font color=Red>-></font> <font color=Red>[</font>HType<font color=Red>]</font> <font color=Red>-></font> <font color=Red>[</font>Constr<font color=Red>]</font> <font color=Red>-></font> <font color=Red>[</font>HType<font color=Red>]</font> <font color=Red>-></font> <font color=Red>[</font>MarkupDecl<font color=Red>]</font>-<a name="(line131)"></a> <font color=Blue>-- toplevel? history history remainingwork result</font>-<a name="(line132)"></a> h2d c history chist [] <font color=Red>=</font> []-<a name="(line133)"></a> h2d c history chist <font color=Cyan>(</font>ht<font color=Red><b>:</b></font>hts<font color=Cyan>)</font> <font color=Red>=</font>-<a name="(line134)"></a> <font color=Green><u>if</u></font> ht <font color=Cyan>`elem`</font> history <font color=Green><u>then</u></font> h2d c0 history chist hts-<a name="(line135)"></a> <font color=Green><u>else</u></font>-<a name="(line136)"></a> <font color=Green><u>case</u></font> ht <font color=Green><u>of</u></font>-<a name="(line137)"></a> Maybe ht0 <font color=Red>-></font> declelem ht<font color=Red><b>:</b></font> h2d c0 <font color=Cyan>(</font>ht<font color=Red><b>:</b></font>history<font color=Cyan>)</font> chist <font color=Cyan>(</font>ht0<font color=Red><b>:</b></font>hts<font color=Cyan>)</font>-<a name="(line138)"></a> List ht0 <font color=Red>-></font> declelem ht<font color=Red><b>:</b></font> h2d c0 <font color=Cyan>(</font>ht<font color=Red><b>:</b></font>history<font color=Cyan>)</font> chist <font color=Cyan>(</font>ht0<font color=Red><b>:</b></font>hts<font color=Cyan>)</font>-<a name="(line139)"></a> Tuple hts0 <font color=Red>-></font> <font color=Cyan>(</font>c <font color=Cyan>?</font> <font color=Cyan>(</font>declelem ht<font color=Red><b>:</b></font><font color=Cyan>)</font><font color=Cyan>)</font>-<a name="(line140)"></a> <font color=Cyan>(</font>h2d c0 history chist <font color=Cyan>(</font>hts0<font color=Cyan>++</font>hts<font color=Cyan>)</font><font color=Cyan>)</font>-<a name="(line141)"></a> Prim s t <font color=Red>-></font> declprim ht <font color=Cyan>++</font> h2d c0 <font color=Cyan>(</font>ht<font color=Red><b>:</b></font>history<font color=Cyan>)</font> chist hts-<a name="(line142)"></a> String <font color=Red>-></font> declstring<font color=Red><b>:</b></font> h2d c0 <font color=Cyan>(</font>ht<font color=Red><b>:</b></font>history<font color=Cyan>)</font> chist hts-<a name="(line143)"></a> Defined s <font color=Green><u>_</u></font> cs <font color=Red>-></font>-<a name="(line144)"></a> <font color=Green><u>let</u></font> hts0 <font color=Red>=</font> concatMap grab cs <font color=Green><u>in</u></font>-<a name="(line145)"></a> <font color=Cyan>(</font>c <font color=Cyan>?</font> <font color=Cyan>(</font>decltopelem ht<font color=Red><b>:</b></font><font color=Cyan>)</font><font color=Cyan>)</font> <font color=Cyan>(</font>declmacro ht chist<font color=Cyan>)</font>-<a name="(line146)"></a> <font color=Cyan>++</font> h2d c0 <font color=Cyan>(</font>ht<font color=Red><b>:</b></font>history<font color=Cyan>)</font> <font color=Cyan>(</font>cs<font color=Cyan>++</font>chist<font color=Cyan>)</font> <font color=Cyan>(</font>hts0<font color=Cyan>++</font>hts<font color=Cyan>)</font>-<a name="(line147)"></a> declelem ht <font color=Red>=</font>-<a name="(line148)"></a> Element <font color=Cyan>(</font>ElementDecl <font color=Cyan>(</font>showHType ht <font color=Magenta>""</font><font color=Cyan>)</font> <font color=Cyan>(</font>ContentSpec <font color=Cyan>(</font>outerHtExpr ht<font color=Cyan>)</font><font color=Cyan>)</font><font color=Cyan>)</font>-<a name="(line149)"></a> decltopelem ht <font color=Red>=</font> <font color=Blue>-- hack to avoid peref at toplevel</font>-<a name="(line150)"></a> Element <font color=Cyan>(</font>ElementDecl <font color=Cyan>(</font>showHType ht <font color=Magenta>"-XML"</font><font color=Cyan>)</font> <font color=Cyan>(</font>ContentSpec <font color=Cyan>(</font>innerHtExpr ht None<font color=Cyan>)</font><font color=Cyan>)</font><font color=Cyan>)</font>-<a name="(line151)"></a> declmacro ht<font color=Red>@</font><font color=Cyan>(</font>Defined <font color=Green><u>_</u></font> <font color=Green><u>_</u></font> cs<font color=Cyan>)</font> chist <font color=Red>=</font>-<a name="(line152)"></a> Entity <font color=Cyan>(</font>EntityPEDecl <font color=Cyan>(</font>PEDecl <font color=Cyan>(</font>showHType ht <font color=Magenta>""</font><font color=Cyan>)</font> <font color=Cyan>(</font>PEDefEntityValue ev<font color=Cyan>)</font><font color=Cyan>)</font><font color=Cyan>)</font><font color=Red><b>:</b></font>-<a name="(line153)"></a> concatMap <font color=Cyan>(</font>declConstr chist<font color=Cyan>)</font> cs-<a name="(line154)"></a> <font color=Green><u>where</u></font> ev <font color=Red>=</font> EntityValue <font color=Red>[</font>EVString <font color=Cyan>(</font>render <font color=Cyan>(</font>PP<font color=Cyan>.</font>cp <font color=Cyan>(</font>outerHtExpr ht<font color=Cyan>)</font><font color=Cyan>)</font><font color=Cyan>)</font><font color=Red>]</font>-<a name="(line155)"></a> declConstr chist c<font color=Red>@</font><font color=Cyan>(</font>Constr s fv hts<font color=Cyan>)</font>-<a name="(line156)"></a> <font color=Red>|</font> c <font color=Cyan>`notElem`</font> chist <font color=Red>=</font>-<a name="(line157)"></a> <font color=Red>[</font>Element <font color=Cyan>(</font>ElementDecl <font color=Cyan>(</font>flatConstr c <font color=Magenta>""</font><font color=Cyan>)</font> <font color=Cyan>(</font>ContentSpec <font color=Cyan>(</font>constrHtExpr c<font color=Cyan>)</font><font color=Cyan>)</font><font color=Cyan>)</font><font color=Red>]</font>-<a name="(line158)"></a> <font color=Red>|</font> otherwise <font color=Red>=</font> [] -<a name="(line159)"></a> declConstr <font color=Green><u>_</u></font> <font color=Cyan>(</font>Synonym ht<font color=Cyan>)</font> <font color=Red>=</font> []-<a name="(line160)"></a> declprim <font color=Cyan>(</font>Prim s t<font color=Cyan>)</font> <font color=Red>=</font>-<a name="(line161)"></a> <font color=Red>[</font> Element <font color=Cyan>(</font>ElementDecl t EMPTY<font color=Cyan>)</font>-<a name="(line162)"></a> <font color=Cyan>,</font> AttList <font color=Cyan>(</font>AttListDecl t <font color=Red>[</font>AttDef <font color=Magenta>"value"</font> StringType REQUIRED<font color=Red>]</font><font color=Cyan>)</font><font color=Red>]</font>-<a name="(line163)"></a> declstring <font color=Red>=</font>-<a name="(line164)"></a> Element <font color=Cyan>(</font>ElementDecl <font color=Magenta>"string"</font> <font color=Cyan>(</font>Mixed PCDATA<font color=Cyan>)</font><font color=Cyan>)</font>-<a name="(line165)"></a> grab <font color=Cyan>(</font>Constr <font color=Green><u>_</u></font> <font color=Green><u>_</u></font> hts<font color=Cyan>)</font> <font color=Red>=</font> hts-<a name="(line166)"></a> grab <font color=Cyan>(</font>Synonym ht<font color=Cyan>)</font> <font color=Red>=</font> <font color=Red>[</font>ht<font color=Red>]</font>-<a name="(line167)"></a>-<a name="(line168)"></a><a name="?"></a><font color=Cyan>(</font><font color=Cyan>?</font><font color=Cyan>)</font> <font color=Red>::</font> Bool <font color=Red>-></font> <font color=Cyan>(</font>a<font color=Red>-></font>a<font color=Cyan>)</font> <font color=Red>-></font> <font color=Cyan>(</font>a<font color=Red>-></font>a<font color=Cyan>)</font>-<a name="(line169)"></a><a name="b"></a>b <font color=Cyan>?</font> f <font color=Red>|</font> b <font color=Red>=</font> f-<a name="(line170)"></a> <font color=Red>|</font> not b <font color=Red>=</font> id-<a name="(line171)"></a>-<a name="(line172)"></a><a name="showHType"></a><font color=Blue>-- Flatten an HType to a String suitable for an XML tagname.</font>-<a name="(line173)"></a>showHType <font color=Red>::</font> HType <font color=Red>-></font> ShowS-<a name="(line174)"></a>showHType <font color=Cyan>(</font>Maybe ht<font color=Cyan>)</font> <font color=Red>=</font> showString <font color=Magenta>"maybe-"</font> <font color=Cyan>.</font> showHType ht-<a name="(line175)"></a>showHType <font color=Cyan>(</font>List ht<font color=Cyan>)</font> <font color=Red>=</font> showString <font color=Magenta>"list-"</font> <font color=Cyan>.</font> showHType ht-<a name="(line176)"></a>showHType <font color=Cyan>(</font>Tuple hts<font color=Cyan>)</font> <font color=Red>=</font> showString <font color=Magenta>"tuple"</font> <font color=Cyan>.</font> shows <font color=Cyan>(</font>length hts<font color=Cyan>)</font>-<a name="(line177)"></a> <font color=Cyan>.</font> showChar <font color=Magenta>'-'</font>-<a name="(line178)"></a> <font color=Cyan>.</font> foldr1 <font color=Cyan>(</font><font color=Cyan>.</font><font color=Cyan>)</font> <font color=Cyan>(</font>intersperse <font color=Cyan>(</font>showChar <font color=Magenta>'-'</font><font color=Cyan>)</font>-<a name="(line179)"></a> <font color=Cyan>(</font>map showHType hts<font color=Cyan>)</font><font color=Cyan>)</font>-<a name="(line180)"></a>showHType <font color=Cyan>(</font>Prim s t<font color=Cyan>)</font> <font color=Red>=</font> showString t-<a name="(line181)"></a>showHType String <font color=Red>=</font> showString <font color=Magenta>"string"</font>-<a name="(line182)"></a>showHType <font color=Cyan>(</font>Defined s fv <font color=Green><u>_</u></font><font color=Cyan>)</font>-<a name="(line183)"></a> <font color=Red>=</font> showString s <font color=Cyan>.</font> <font color=Cyan>(</font><font color=Cyan>(</font>length fv <font color=Cyan>></font> <font color=Magenta>0</font><font color=Cyan>)</font> <font color=Cyan>?</font> <font color=Cyan>(</font>showChar <font color=Magenta>'-'</font><font color=Cyan>)</font><font color=Cyan>)</font>-<a name="(line184)"></a> <font color=Cyan>.</font> foldr <font color=Cyan>(</font><font color=Cyan>.</font><font color=Cyan>)</font> id <font color=Cyan>(</font>intersperse <font color=Cyan>(</font>showChar <font color=Magenta>'-'</font><font color=Cyan>)</font>-<a name="(line185)"></a> <font color=Cyan>(</font>map showHType fv<font color=Cyan>)</font><font color=Cyan>)</font>-<a name="(line186)"></a>-<a name="(line187)"></a><a name="flatConstr"></a>flatConstr <font color=Red>::</font> Constr <font color=Red>-></font> ShowS-<a name="(line188)"></a>flatConstr <font color=Cyan>(</font>Constr s fv <font color=Green><u>_</u></font><font color=Cyan>)</font>-<a name="(line189)"></a> <font color=Red>=</font> showString s <font color=Cyan>.</font> <font color=Cyan>(</font><font color=Cyan>(</font>length fv <font color=Cyan>></font> <font color=Magenta>0</font><font color=Cyan>)</font> <font color=Cyan>?</font> <font color=Cyan>(</font>showChar <font color=Magenta>'-'</font><font color=Cyan>)</font><font color=Cyan>)</font>-<a name="(line190)"></a> <font color=Cyan>.</font> foldr <font color=Cyan>(</font><font color=Cyan>.</font><font color=Cyan>)</font> id <font color=Cyan>(</font>intersperse <font color=Cyan>(</font>showChar <font color=Magenta>'-'</font><font color=Cyan>)</font> <font color=Cyan>(</font>map showHType fv<font color=Cyan>)</font><font color=Cyan>)</font>-<a name="(line191)"></a>flatConstr <font color=Cyan>(</font>Synonym ht<font color=Cyan>)</font> <font color=Red>=</font> id+<a name="(line61)"></a><a name="Constr"></a><font color=Green><u>data</u></font> Constr <font color=Red>=</font> Constr String <font color=Red>[</font>HType<font color=Red>]</font> <font color=Red>[</font>HType<font color=Red>]</font> <font color=Blue>-- (Maybe [String])</font>+<a name="(line62)"></a> <font color=Green><u>deriving</u></font> <font color=Cyan>(</font>Eq<font color=Cyan>,</font>Show<font color=Cyan>)</font>+<a name="(line63)"></a>+<a name="(line64)"></a><a name="showConstr"></a><font color=Blue>-- | Project the n'th constructor from an HType and convert it to a string</font>+<a name="(line65)"></a><font color=Blue>-- suitable for an XML tagname.</font>+<a name="(line66)"></a>showConstr <font color=Red>::</font> Int <font color=Red>-></font> HType <font color=Red>-></font> String+<a name="(line67)"></a>showConstr n <font color=Cyan>(</font>Defined <font color=Green><u>_</u></font> <font color=Green><u>_</u></font> cs<font color=Cyan>)</font> <font color=Red>=</font> flatConstr <font color=Cyan>(</font>cs<font color=Cyan>!!</font>n<font color=Cyan>)</font> <font color=Magenta>""</font>+<a name="(line68)"></a>showConstr n <font color=Green><u>_</u></font> <font color=Red>=</font> error <font color=Magenta>"no constructors for builtin types"</font>+<a name="(line69)"></a>+<a name="(line70)"></a><font color=Blue>------------------------------------------------------------------------</font>+<a name="(line71)"></a><font color=Blue>-- Some instances</font>+<a name="(line72)"></a><font color=Green><u>instance</u></font> HTypeable Bool <font color=Green><u>where</u></font>+<a name="(line73)"></a> toHType <font color=Green><u>_</u></font> <font color=Red>=</font> Prim <font color=Magenta>"Bool"</font> <font color=Magenta>"bool"</font>+<a name="(line74)"></a><font color=Green><u>instance</u></font> HTypeable Int <font color=Green><u>where</u></font>+<a name="(line75)"></a> toHType <font color=Green><u>_</u></font> <font color=Red>=</font> Prim <font color=Magenta>"Int"</font> <font color=Magenta>"int"</font>+<a name="(line76)"></a><font color=Green><u>instance</u></font> HTypeable Integer <font color=Green><u>where</u></font>+<a name="(line77)"></a> toHType <font color=Green><u>_</u></font> <font color=Red>=</font> Prim <font color=Magenta>"Integer"</font> <font color=Magenta>"integer"</font>+<a name="(line78)"></a><font color=Green><u>instance</u></font> HTypeable Float <font color=Green><u>where</u></font>+<a name="(line79)"></a> toHType <font color=Green><u>_</u></font> <font color=Red>=</font> Prim <font color=Magenta>"Float"</font> <font color=Magenta>"float"</font>+<a name="(line80)"></a><font color=Green><u>instance</u></font> HTypeable Double <font color=Green><u>where</u></font>+<a name="(line81)"></a> toHType <font color=Green><u>_</u></font> <font color=Red>=</font> Prim <font color=Magenta>"Double"</font> <font color=Magenta>"double"</font>+<a name="(line82)"></a><font color=Green><u>instance</u></font> HTypeable Char <font color=Green><u>where</u></font>+<a name="(line83)"></a> toHType <font color=Green><u>_</u></font> <font color=Red>=</font> Prim <font color=Magenta>"Char"</font> <font color=Magenta>"char"</font>+<a name="(line84)"></a>+<a name="(line85)"></a><font color=Green><u>instance</u></font> HTypeable () <font color=Green><u>where</u></font>+<a name="(line86)"></a> toHType <font color=Green><u>_</u></font> <font color=Red>=</font> Prim <font color=Magenta>"unit"</font> <font color=Magenta>"unit"</font>+<a name="(line87)"></a><font color=Green><u>instance</u></font> <font color=Cyan>(</font>HTypeable a<font color=Cyan>,</font> HTypeable b<font color=Cyan>)</font> <font color=Red>=></font> HTypeable <font color=Cyan>(</font>a<font color=Cyan>,</font>b<font color=Cyan>)</font> <font color=Green><u>where</u></font>+<a name="(line88)"></a> toHType p <font color=Red>=</font> Tuple <font color=Red>[</font>toHType a<font color=Cyan>,</font> toHType b<font color=Red>]</font>+<a name="(line89)"></a> <font color=Green><u>where</u></font> <font color=Cyan>(</font>a<font color=Cyan>,</font>b<font color=Cyan>)</font> <font color=Red>=</font> p+<a name="(line90)"></a><font color=Green><u>instance</u></font> <font color=Cyan>(</font>HTypeable a<font color=Cyan>,</font> HTypeable b<font color=Cyan>,</font> HTypeable c<font color=Cyan>)</font> <font color=Red>=></font> HTypeable <font color=Cyan>(</font>a<font color=Cyan>,</font>b<font color=Cyan>,</font>c<font color=Cyan>)</font> <font color=Green><u>where</u></font>+<a name="(line91)"></a> toHType p <font color=Red>=</font> Tuple <font color=Red>[</font>toHType a<font color=Cyan>,</font> toHType b<font color=Cyan>,</font> toHType c<font color=Red>]</font>+<a name="(line92)"></a> <font color=Green><u>where</u></font> <font color=Cyan>(</font>a<font color=Cyan>,</font>b<font color=Cyan>,</font>c<font color=Cyan>)</font> <font color=Red>=</font> p+<a name="(line93)"></a><font color=Green><u>instance</u></font> <font color=Cyan>(</font>HTypeable a<font color=Cyan>)</font> <font color=Red>=></font> HTypeable <font color=Cyan>(</font>Maybe a<font color=Cyan>)</font> <font color=Green><u>where</u></font>+<a name="(line94)"></a> toHType m <font color=Red>=</font> Maybe <font color=Cyan>(</font>toHType x<font color=Cyan>)</font> <font color=Green><u>where</u></font> <font color=Cyan>(</font>Just x<font color=Cyan>)</font> <font color=Red>=</font> m+<a name="(line95)"></a><font color=Green><u>instance</u></font> <font color=Cyan>(</font>HTypeable a<font color=Cyan>,</font> HTypeable b<font color=Cyan>)</font> <font color=Red>=></font> HTypeable <font color=Cyan>(</font>Either a b<font color=Cyan>)</font> <font color=Green><u>where</u></font>+<a name="(line96)"></a> toHType m <font color=Red>=</font> Defined <font color=Magenta>"Either"</font> <font color=Red>[</font>hx<font color=Cyan>,</font> hy<font color=Red>]</font>+<a name="(line97)"></a> <font color=Red>[</font> Constr <font color=Magenta>"Left"</font> <font color=Red>[</font>hx<font color=Red>]</font> <font color=Red>[</font>hx<font color=Red>]</font> <font color=Blue>{-Nothing-}</font>+<a name="(line98)"></a> <font color=Cyan>,</font> Constr <font color=Magenta>"Right"</font> <font color=Red>[</font>hy<font color=Red>]</font> <font color=Red>[</font>hy<font color=Red>]</font> <font color=Blue>{-Nothing-}</font><font color=Red>]</font>+<a name="(line99)"></a> <font color=Green><u>where</u></font> <font color=Cyan>(</font>Left x<font color=Cyan>)</font> <font color=Red>=</font> m+<a name="(line100)"></a> <font color=Cyan>(</font>Right y<font color=Cyan>)</font> <font color=Red>=</font> m+<a name="(line101)"></a> hx <font color=Red>=</font> toHType x+<a name="(line102)"></a> hy <font color=Red>=</font> toHType y+<a name="(line103)"></a>+<a name="(line104)"></a><font color=Green><u>instance</u></font> HTypeable a <font color=Red>=></font> HTypeable <font color=Red>[</font>a<font color=Red>]</font> <font color=Green><u>where</u></font>+<a name="(line105)"></a> toHType xs <font color=Red>=</font> <font color=Green><u>case</u></font> toHType x <font color=Green><u>of</u></font> <font color=Cyan>(</font>Prim <font color=Magenta>"Char"</font> <font color=Green><u>_</u></font><font color=Cyan>)</font> <font color=Red>-></font> String+<a name="(line106)"></a> <font color=Green><u>_</u></font> <font color=Red>-></font> List <font color=Cyan>(</font>toHType x<font color=Cyan>)</font>+<a name="(line107)"></a> <font color=Green><u>where</u></font> <font color=Cyan>(</font>x<font color=Red><b>:</b></font><font color=Green><u>_</u></font><font color=Cyan>)</font> <font color=Red>=</font> xs+<a name="(line108)"></a>+<a name="(line109)"></a><font color=Blue>------------------------------------------------------------------------</font>+<a name="(line110)"></a>+<a name="(line111)"></a><a name="toDTD"></a><font color=Blue>-- | 'toDTD' converts a concrete representation of the Haskell type of</font>+<a name="(line112)"></a><font color=Blue>-- a value (obtained by the method 'toHType') into a real DocTypeDecl.</font>+<a name="(line113)"></a><font color=Blue>-- It ensures that PERefs are defined before they are used, and that no</font>+<a name="(line114)"></a><font color=Blue>-- element or attribute-list is declared more than once.</font>+<a name="(line115)"></a>toDTD <font color=Red>::</font> HType <font color=Red>-></font> DocTypeDecl+<a name="(line116)"></a>toDTD ht <font color=Red>=</font>+<a name="(line117)"></a> DTD <font color=Cyan>(</font>toplevel ht<font color=Cyan>)</font> Nothing <font color=Cyan>(</font>macrosFirst <font color=Cyan>(</font>reverse <font color=Cyan>(</font>h2d True [] [] <font color=Red>[</font>ht<font color=Red>]</font><font color=Cyan>)</font><font color=Cyan>)</font><font color=Cyan>)</font>+<a name="(line118)"></a> <font color=Green><u>where</u></font>+<a name="(line119)"></a> macrosFirst <font color=Red>::</font> <font color=Red>[</font>MarkupDecl<font color=Red>]</font> <font color=Red>-></font> <font color=Red>[</font>MarkupDecl<font color=Red>]</font>+<a name="(line120)"></a> macrosFirst decls <font color=Red>=</font> concat <font color=Red>[</font>p<font color=Cyan>,</font> p'<font color=Red>]</font> <font color=Green><u>where</u></font> <font color=Cyan>(</font>p<font color=Cyan>,</font> p'<font color=Cyan>)</font> <font color=Red>=</font> partition f decls+<a name="(line121)"></a> f <font color=Cyan>(</font>Entity <font color=Green><u>_</u></font><font color=Cyan>)</font> <font color=Red>=</font> True+<a name="(line122)"></a> f <font color=Green><u>_</u></font> <font color=Red>=</font> False+<a name="(line123)"></a> toplevel ht<font color=Red>@</font><font color=Cyan>(</font>Defined <font color=Green><u>_</u></font> <font color=Green><u>_</u></font> <font color=Green><u>_</u></font><font color=Cyan>)</font> <font color=Red>=</font> showHType ht <font color=Magenta>"-XML"</font>+<a name="(line124)"></a> toplevel ht<font color=Red>@</font><font color=Green><u>_</u></font> <font color=Red>=</font> showHType ht <font color=Magenta>""</font>+<a name="(line125)"></a> c0 <font color=Red>=</font> False+<a name="(line126)"></a> h2d <font color=Red>::</font> Bool <font color=Red>-></font> <font color=Red>[</font>HType<font color=Red>]</font> <font color=Red>-></font> <font color=Red>[</font>Constr<font color=Red>]</font> <font color=Red>-></font> <font color=Red>[</font>HType<font color=Red>]</font> <font color=Red>-></font> <font color=Red>[</font>MarkupDecl<font color=Red>]</font>+<a name="(line127)"></a> <font color=Blue>-- toplevel? history history remainingwork result</font>+<a name="(line128)"></a> h2d c history chist [] <font color=Red>=</font> []+<a name="(line129)"></a> h2d c history chist <font color=Cyan>(</font>ht<font color=Red><b>:</b></font>hts<font color=Cyan>)</font> <font color=Red>=</font>+<a name="(line130)"></a> <font color=Green><u>if</u></font> ht <font color=Cyan>`elem`</font> history <font color=Green><u>then</u></font> h2d c0 history chist hts+<a name="(line131)"></a> <font color=Green><u>else</u></font>+<a name="(line132)"></a> <font color=Green><u>case</u></font> ht <font color=Green><u>of</u></font>+<a name="(line133)"></a> Maybe ht0 <font color=Red>-></font> declelem ht<font color=Red><b>:</b></font> h2d c0 <font color=Cyan>(</font>ht<font color=Red><b>:</b></font>history<font color=Cyan>)</font> chist <font color=Cyan>(</font>ht0<font color=Red><b>:</b></font>hts<font color=Cyan>)</font>+<a name="(line134)"></a> List ht0 <font color=Red>-></font> declelem ht<font color=Red><b>:</b></font> h2d c0 <font color=Cyan>(</font>ht<font color=Red><b>:</b></font>history<font color=Cyan>)</font> chist <font color=Cyan>(</font>ht0<font color=Red><b>:</b></font>hts<font color=Cyan>)</font>+<a name="(line135)"></a> Tuple hts0 <font color=Red>-></font> <font color=Cyan>(</font>c <font color=Cyan>?</font> <font color=Cyan>(</font>declelem ht<font color=Red><b>:</b></font><font color=Cyan>)</font><font color=Cyan>)</font>+<a name="(line136)"></a> <font color=Cyan>(</font>h2d c0 history chist <font color=Cyan>(</font>hts0<font color=Cyan>++</font>hts<font color=Cyan>)</font><font color=Cyan>)</font>+<a name="(line137)"></a> Prim s t <font color=Red>-></font> declprim ht <font color=Cyan>++</font> h2d c0 <font color=Cyan>(</font>ht<font color=Red><b>:</b></font>history<font color=Cyan>)</font> chist hts+<a name="(line138)"></a> String <font color=Red>-></font> declstring<font color=Red><b>:</b></font> h2d c0 <font color=Cyan>(</font>ht<font color=Red><b>:</b></font>history<font color=Cyan>)</font> chist hts+<a name="(line139)"></a> Defined s <font color=Green><u>_</u></font> cs <font color=Red>-></font>+<a name="(line140)"></a> <font color=Green><u>let</u></font> hts0 <font color=Red>=</font> concatMap grab cs <font color=Green><u>in</u></font>+<a name="(line141)"></a> <font color=Cyan>(</font>c <font color=Cyan>?</font> <font color=Cyan>(</font>decltopelem ht<font color=Red><b>:</b></font><font color=Cyan>)</font><font color=Cyan>)</font> <font color=Cyan>(</font>declmacro ht chist<font color=Cyan>)</font>+<a name="(line142)"></a> <font color=Cyan>++</font> h2d c0 <font color=Cyan>(</font>ht<font color=Red><b>:</b></font>history<font color=Cyan>)</font> <font color=Cyan>(</font>cs<font color=Cyan>++</font>chist<font color=Cyan>)</font> <font color=Cyan>(</font>hts0<font color=Cyan>++</font>hts<font color=Cyan>)</font>+<a name="(line143)"></a> declelem ht <font color=Red>=</font>+<a name="(line144)"></a> Element <font color=Cyan>(</font>ElementDecl <font color=Cyan>(</font>showHType ht <font color=Magenta>""</font><font color=Cyan>)</font> <font color=Cyan>(</font>ContentSpec <font color=Cyan>(</font>outerHtExpr ht<font color=Cyan>)</font><font color=Cyan>)</font><font color=Cyan>)</font>+<a name="(line145)"></a> decltopelem ht <font color=Red>=</font> <font color=Blue>-- hack to avoid peref at toplevel</font>+<a name="(line146)"></a> Element <font color=Cyan>(</font>ElementDecl <font color=Cyan>(</font>showHType ht <font color=Magenta>"-XML"</font><font color=Cyan>)</font> <font color=Cyan>(</font>ContentSpec <font color=Cyan>(</font>innerHtExpr ht None<font color=Cyan>)</font><font color=Cyan>)</font><font color=Cyan>)</font>+<a name="(line147)"></a> declmacro ht<font color=Red>@</font><font color=Cyan>(</font>Defined <font color=Green><u>_</u></font> <font color=Green><u>_</u></font> cs<font color=Cyan>)</font> chist <font color=Red>=</font>+<a name="(line148)"></a> Entity <font color=Cyan>(</font>EntityPEDecl <font color=Cyan>(</font>PEDecl <font color=Cyan>(</font>showHType ht <font color=Magenta>""</font><font color=Cyan>)</font> <font color=Cyan>(</font>PEDefEntityValue ev<font color=Cyan>)</font><font color=Cyan>)</font><font color=Cyan>)</font><font color=Red><b>:</b></font>+<a name="(line149)"></a> concatMap <font color=Cyan>(</font>declConstr chist<font color=Cyan>)</font> cs+<a name="(line150)"></a> <font color=Green><u>where</u></font> ev <font color=Red>=</font> EntityValue <font color=Red>[</font>EVString <font color=Cyan>(</font>render <font color=Cyan>(</font>PP<font color=Cyan>.</font>cp <font color=Cyan>(</font>outerHtExpr ht<font color=Cyan>)</font><font color=Cyan>)</font><font color=Cyan>)</font><font color=Red>]</font>+<a name="(line151)"></a> declConstr chist c<font color=Red>@</font><font color=Cyan>(</font>Constr s fv hts<font color=Cyan>)</font>+<a name="(line152)"></a> <font color=Red>|</font> c <font color=Cyan>`notElem`</font> chist <font color=Red>=</font>+<a name="(line153)"></a> <font color=Red>[</font>Element <font color=Cyan>(</font>ElementDecl <font color=Cyan>(</font>flatConstr c <font color=Magenta>""</font><font color=Cyan>)</font> <font color=Cyan>(</font>ContentSpec <font color=Cyan>(</font>constrHtExpr c<font color=Cyan>)</font><font color=Cyan>)</font><font color=Cyan>)</font><font color=Red>]</font>+<a name="(line154)"></a> <font color=Red>|</font> otherwise <font color=Red>=</font> [] +<a name="(line155)"></a> declprim <font color=Cyan>(</font>Prim s t<font color=Cyan>)</font> <font color=Red>=</font>+<a name="(line156)"></a> <font color=Red>[</font> Element <font color=Cyan>(</font>ElementDecl t EMPTY<font color=Cyan>)</font>+<a name="(line157)"></a> <font color=Cyan>,</font> AttList <font color=Cyan>(</font>AttListDecl t <font color=Red>[</font>AttDef <font color=Magenta>"value"</font> StringType REQUIRED<font color=Red>]</font><font color=Cyan>)</font><font color=Red>]</font>+<a name="(line158)"></a> declstring <font color=Red>=</font>+<a name="(line159)"></a> Element <font color=Cyan>(</font>ElementDecl <font color=Magenta>"string"</font> <font color=Cyan>(</font>Mixed PCDATA<font color=Cyan>)</font><font color=Cyan>)</font>+<a name="(line160)"></a> grab <font color=Cyan>(</font>Constr <font color=Green><u>_</u></font> <font color=Green><u>_</u></font> hts<font color=Cyan>)</font> <font color=Red>=</font> hts+<a name="(line161)"></a>+<a name="(line162)"></a><a name="?"></a><font color=Cyan>(</font><font color=Cyan>?</font><font color=Cyan>)</font> <font color=Red>::</font> Bool <font color=Red>-></font> <font color=Cyan>(</font>a<font color=Red>-></font>a<font color=Cyan>)</font> <font color=Red>-></font> <font color=Cyan>(</font>a<font color=Red>-></font>a<font color=Cyan>)</font>+<a name="(line163)"></a><a name="b"></a>b <font color=Cyan>?</font> f <font color=Red>|</font> b <font color=Red>=</font> f+<a name="(line164)"></a> <font color=Red>|</font> not b <font color=Red>=</font> id+<a name="(line165)"></a>+<a name="(line166)"></a><a name="showHType"></a><font color=Blue>-- Flatten an HType to a String suitable for an XML tagname.</font>+<a name="(line167)"></a>showHType <font color=Red>::</font> HType <font color=Red>-></font> ShowS+<a name="(line168)"></a>showHType <font color=Cyan>(</font>Maybe ht<font color=Cyan>)</font> <font color=Red>=</font> showString <font color=Magenta>"maybe-"</font> <font color=Cyan>.</font> showHType ht+<a name="(line169)"></a>showHType <font color=Cyan>(</font>List ht<font color=Cyan>)</font> <font color=Red>=</font> showString <font color=Magenta>"list-"</font> <font color=Cyan>.</font> showHType ht+<a name="(line170)"></a>showHType <font color=Cyan>(</font>Tuple hts<font color=Cyan>)</font> <font color=Red>=</font> showString <font color=Magenta>"tuple"</font> <font color=Cyan>.</font> shows <font color=Cyan>(</font>length hts<font color=Cyan>)</font>+<a name="(line171)"></a> <font color=Cyan>.</font> showChar <font color=Magenta>'-'</font>+<a name="(line172)"></a> <font color=Cyan>.</font> foldr1 <font color=Cyan>(</font><font color=Cyan>.</font><font color=Cyan>)</font> <font color=Cyan>(</font>intersperse <font color=Cyan>(</font>showChar <font color=Magenta>'-'</font><font color=Cyan>)</font>+<a name="(line173)"></a> <font color=Cyan>(</font>map showHType hts<font color=Cyan>)</font><font color=Cyan>)</font>+<a name="(line174)"></a>showHType <font color=Cyan>(</font>Prim s t<font color=Cyan>)</font> <font color=Red>=</font> showString t+<a name="(line175)"></a>showHType String <font color=Red>=</font> showString <font color=Magenta>"string"</font>+<a name="(line176)"></a>showHType <font color=Cyan>(</font>Defined s fv <font color=Green><u>_</u></font><font color=Cyan>)</font>+<a name="(line177)"></a> <font color=Red>=</font> showString s <font color=Cyan>.</font> <font color=Cyan>(</font><font color=Cyan>(</font>length fv <font color=Cyan>></font> <font color=Magenta>0</font><font color=Cyan>)</font> <font color=Cyan>?</font> <font color=Cyan>(</font>showChar <font color=Magenta>'-'</font><font color=Cyan>)</font><font color=Cyan>)</font>+<a name="(line178)"></a> <font color=Cyan>.</font> foldr <font color=Cyan>(</font><font color=Cyan>.</font><font color=Cyan>)</font> id <font color=Cyan>(</font>intersperse <font color=Cyan>(</font>showChar <font color=Magenta>'-'</font><font color=Cyan>)</font>+<a name="(line179)"></a> <font color=Cyan>(</font>map showHType fv<font color=Cyan>)</font><font color=Cyan>)</font>+<a name="(line180)"></a>+<a name="(line181)"></a><a name="flatConstr"></a>flatConstr <font color=Red>::</font> Constr <font color=Red>-></font> ShowS+<a name="(line182)"></a>flatConstr <font color=Cyan>(</font>Constr s fv <font color=Green><u>_</u></font><font color=Cyan>)</font>+<a name="(line183)"></a> <font color=Red>=</font> showString s <font color=Cyan>.</font> <font color=Cyan>(</font><font color=Cyan>(</font>length fv <font color=Cyan>></font> <font color=Magenta>0</font><font color=Cyan>)</font> <font color=Cyan>?</font> <font color=Cyan>(</font>showChar <font color=Magenta>'-'</font><font color=Cyan>)</font><font color=Cyan>)</font>+<a name="(line184)"></a> <font color=Cyan>.</font> foldr <font color=Cyan>(</font><font color=Cyan>.</font><font color=Cyan>)</font> id <font color=Cyan>(</font>intersperse <font color=Cyan>(</font>showChar <font color=Magenta>'-'</font><font color=Cyan>)</font> <font color=Cyan>(</font>map showHType fv<font color=Cyan>)</font><font color=Cyan>)</font>+<a name="(line185)"></a>+<a name="(line186)"></a><a name="outerHtExpr"></a>outerHtExpr <font color=Red>::</font> HType <font color=Red>-></font> CP+<a name="(line187)"></a>outerHtExpr <font color=Cyan>(</font>Maybe ht<font color=Cyan>)</font> <font color=Red>=</font> innerHtExpr ht Query+<a name="(line188)"></a>outerHtExpr <font color=Cyan>(</font>List ht<font color=Cyan>)</font> <font color=Red>=</font> innerHtExpr ht Star+<a name="(line189)"></a>outerHtExpr <font color=Cyan>(</font>Defined s fv cs<font color=Cyan>)</font> <font color=Red>=</font>+<a name="(line190)"></a> Choice <font color=Cyan>(</font>map <font color=Cyan>(</font><font color=Red>\</font>c<font color=Red>-></font>TagName <font color=Cyan>(</font>flatConstr c <font color=Magenta>""</font><font color=Cyan>)</font> None<font color=Cyan>)</font> cs<font color=Cyan>)</font> None+<a name="(line191)"></a>outerHtExpr ht <font color=Red>=</font> innerHtExpr ht None <a name="(line192)"></a>-<a name="(line193)"></a><a name="outerHtExpr"></a>outerHtExpr <font color=Red>::</font> HType <font color=Red>-></font> CP-<a name="(line194)"></a>outerHtExpr <font color=Cyan>(</font>Maybe ht<font color=Cyan>)</font> <font color=Red>=</font> innerHtExpr ht Query-<a name="(line195)"></a>outerHtExpr <font color=Cyan>(</font>List ht<font color=Cyan>)</font> <font color=Red>=</font> innerHtExpr ht Star-<a name="(line196)"></a>outerHtExpr <font color=Cyan>(</font>Defined s fv cs<font color=Cyan>)</font> <font color=Red>=</font>-<a name="(line197)"></a> Choice <font color=Cyan>(</font>map <font color=Cyan>(</font><font color=Red>\</font>c<font color=Red>-></font>TagName <font color=Cyan>(</font>flatConstr c <font color=Magenta>""</font><font color=Cyan>)</font> None<font color=Cyan>)</font> cs<font color=Cyan>)</font> None-<a name="(line198)"></a>outerHtExpr ht <font color=Red>=</font> innerHtExpr ht None-<a name="(line199)"></a>-<a name="(line200)"></a><a name="innerHtExpr"></a>innerHtExpr <font color=Red>::</font> HType <font color=Red>-></font> Modifier <font color=Red>-></font> CP-<a name="(line201)"></a>innerHtExpr <font color=Cyan>(</font>Prim s t<font color=Cyan>)</font> m <font color=Red>=</font> TagName t m-<a name="(line202)"></a>innerHtExpr <font color=Cyan>(</font>Tuple hts<font color=Cyan>)</font> m <font color=Red>=</font> Seq <font color=Cyan>(</font>map <font color=Cyan>(</font><font color=Red>\</font>c<font color=Red>-></font> innerHtExpr c None<font color=Cyan>)</font> hts<font color=Cyan>)</font> m-<a name="(line203)"></a>innerHtExpr ht<font color=Red>@</font><font color=Cyan>(</font>Defined s hts cs<font color=Cyan>)</font> m <font color=Red>=</font> <font color=Blue>-- CPPE (showHType ht "") (outerHtExpr ht)</font>-<a name="(line204)"></a> TagName <font color=Cyan>(</font><font color=Magenta>'%'</font><font color=Red><b>:</b></font> showHType ht <font color=Magenta>";"</font><font color=Cyan>)</font> m-<a name="(line205)"></a> <font color=Blue>-- ***HACK!!!***</font>-<a name="(line206)"></a>innerHtExpr ht m <font color=Red>=</font> TagName <font color=Cyan>(</font>showHType ht <font color=Magenta>""</font><font color=Cyan>)</font> m-<a name="(line207)"></a>-<a name="(line208)"></a><a name="constrHtExpr"></a>constrHtExpr <font color=Red>::</font> Constr <font color=Red>-></font> CP-<a name="(line209)"></a>constrHtExpr <font color=Cyan>(</font>Constr s fv []<font color=Cyan>)</font> <font color=Red>=</font> TagName <font color=Magenta>"EMPTY"</font> None <font color=Blue>-- ***HACK!!!***</font>-<a name="(line210)"></a>constrHtExpr <font color=Cyan>(</font>Constr s fv hts<font color=Cyan>)</font> <font color=Red>=</font> innerHtExpr <font color=Cyan>(</font>Tuple hts<font color=Cyan>)</font> None-<a name="(line211)"></a>constrHtExpr <font color=Cyan>(</font>Synonym ht<font color=Cyan>)</font> <font color=Red>=</font> outerHtExpr ht-<a name="(line212)"></a>-<a name="(line213)"></a><font color=Blue>------------------------------------------------------------------------</font>+<a name="(line193)"></a><a name="innerHtExpr"></a>innerHtExpr <font color=Red>::</font> HType <font color=Red>-></font> Modifier <font color=Red>-></font> CP+<a name="(line194)"></a>innerHtExpr <font color=Cyan>(</font>Prim s t<font color=Cyan>)</font> m <font color=Red>=</font> TagName t m+<a name="(line195)"></a>innerHtExpr <font color=Cyan>(</font>Tuple hts<font color=Cyan>)</font> m <font color=Red>=</font> Seq <font color=Cyan>(</font>map <font color=Cyan>(</font><font color=Red>\</font>c<font color=Red>-></font> innerHtExpr c None<font color=Cyan>)</font> hts<font color=Cyan>)</font> m+<a name="(line196)"></a>innerHtExpr ht<font color=Red>@</font><font color=Cyan>(</font>Defined s hts cs<font color=Cyan>)</font> m <font color=Red>=</font> <font color=Blue>-- CPPE (showHType ht "") (outerHtExpr ht)</font>+<a name="(line197)"></a> TagName <font color=Cyan>(</font><font color=Magenta>'%'</font><font color=Red><b>:</b></font> showHType ht <font color=Magenta>";"</font><font color=Cyan>)</font> m+<a name="(line198)"></a> <font color=Blue>-- ***HACK!!!***</font>+<a name="(line199)"></a>innerHtExpr ht m <font color=Red>=</font> TagName <font color=Cyan>(</font>showHType ht <font color=Magenta>""</font><font color=Cyan>)</font> m+<a name="(line200)"></a>+<a name="(line201)"></a><a name="constrHtExpr"></a>constrHtExpr <font color=Red>::</font> Constr <font color=Red>-></font> CP+<a name="(line202)"></a>constrHtExpr <font color=Cyan>(</font>Constr s fv []<font color=Cyan>)</font> <font color=Red>=</font> TagName <font color=Magenta>"EMPTY"</font> None <font color=Blue>-- ***HACK!!!***</font>+<a name="(line203)"></a>constrHtExpr <font color=Cyan>(</font>Constr s fv hts<font color=Cyan>)</font> <font color=Red>=</font> innerHtExpr <font color=Cyan>(</font>Tuple hts<font color=Cyan>)</font> None+<a name="(line204)"></a>+<a name="(line205)"></a><font color=Blue>------------------------------------------------------------------------</font> </pre> </html>
docs/HaXml/src/Text/XML/HaXml/Types.html view
@@ -111,168 +111,184 @@ <a name="(line109)"></a> <font color=Cyan>)</font> <font color=Green><u>where</u></font> <a name="(line110)"></a> <a name="(line111)"></a>-<a name="(line112)"></a>-<a name="(line113)"></a><font color=Blue>{- A simple symbol table for storing macros whilst parsing. -}</font>-<a name="(line114)"></a>-<a name="(line115)"></a><a name="SymTab"></a><font color=Green><u>type</u></font> SymTab a <font color=Red>=</font> <font color=Red>[</font><font color=Cyan>(</font>String<font color=Cyan>,</font>a<font color=Cyan>)</font><font color=Red>]</font>-<a name="(line116)"></a>-<a name="(line117)"></a><a name="emptyST"></a>emptyST <font color=Red>::</font> SymTab a-<a name="(line118)"></a>emptyST <font color=Red>=</font> []-<a name="(line119)"></a>-<a name="(line120)"></a><a name="addST"></a>addST <font color=Red>::</font> String <font color=Red>-></font> a <font color=Red>-></font> SymTab a <font color=Red>-></font> SymTab a-<a name="(line121)"></a>addST n v <font color=Red>=</font> <font color=Cyan>(</font><font color=Cyan>(</font>n<font color=Cyan>,</font>v<font color=Cyan>)</font><font color=Red><b>:</b></font><font color=Cyan>)</font>-<a name="(line122)"></a>-<a name="(line123)"></a><a name="lookupST"></a>lookupST <font color=Red>::</font> String <font color=Red>-></font> SymTab a <font color=Red>-></font> Maybe a-<a name="(line124)"></a>lookupST <font color=Red>=</font> lookup+<a name="(line112)"></a><font color=Blue>{- A simple symbol table for storing macros whilst parsing. -}</font>+<a name="(line113)"></a>+<a name="(line114)"></a><a name="SymTab"></a><font color=Green><u>type</u></font> SymTab a <font color=Red>=</font> <font color=Red>[</font><font color=Cyan>(</font>String<font color=Cyan>,</font>a<font color=Cyan>)</font><font color=Red>]</font>+<a name="(line115)"></a>+<a name="(line116)"></a><a name="emptyST"></a>emptyST <font color=Red>::</font> SymTab a+<a name="(line117)"></a>emptyST <font color=Red>=</font> []+<a name="(line118)"></a>+<a name="(line119)"></a><a name="addST"></a>addST <font color=Red>::</font> String <font color=Red>-></font> a <font color=Red>-></font> SymTab a <font color=Red>-></font> SymTab a+<a name="(line120)"></a>addST n v <font color=Red>=</font> <font color=Cyan>(</font><font color=Cyan>(</font>n<font color=Cyan>,</font>v<font color=Cyan>)</font><font color=Red><b>:</b></font><font color=Cyan>)</font>+<a name="(line121)"></a>+<a name="(line122)"></a><a name="lookupST"></a>lookupST <font color=Red>::</font> String <font color=Red>-></font> SymTab a <font color=Red>-></font> Maybe a+<a name="(line123)"></a>lookupST <font color=Red>=</font> lookup+<a name="(line124)"></a> <a name="(line125)"></a> <a name="(line126)"></a>-<a name="(line127)"></a>-<a name="(line128)"></a><font color=Blue>{- XML types start here -}</font>-<a name="(line129)"></a>-<a name="(line130)"></a><a name="Document"></a><font color=Blue>-- | The symbol table stored in a document holds all its general entity</font>-<a name="(line131)"></a><a name="Document"></a><font color=Blue>-- reference definitions.</font>-<a name="(line132)"></a><a name="Document"></a><font color=Green><u>data</u></font> Document i <font color=Red>=</font> Document Prolog <font color=Cyan>(</font>SymTab EntityDef<font color=Cyan>)</font> <font color=Cyan>(</font>Element i<font color=Cyan>)</font> <font color=Red>[</font>Misc<font color=Red>]</font>-<a name="(line133)"></a><a name="Prolog"></a><font color=Green><u>data</u></font> Prolog <font color=Red>=</font> Prolog <font color=Cyan>(</font>Maybe XMLDecl<font color=Cyan>)</font> <font color=Red>[</font>Misc<font color=Red>]</font> <font color=Cyan>(</font>Maybe DocTypeDecl<font color=Cyan>)</font> <font color=Red>[</font>Misc<font color=Red>]</font>-<a name="(line134)"></a><a name="XMLDecl"></a><font color=Green><u>data</u></font> XMLDecl <font color=Red>=</font> XMLDecl VersionInfo <font color=Cyan>(</font>Maybe EncodingDecl<font color=Cyan>)</font> <font color=Cyan>(</font>Maybe SDDecl<font color=Cyan>)</font> -<a name="(line135)"></a><a name="Misc"></a><font color=Green><u>data</u></font> Misc <font color=Red>=</font> Comment Comment-<a name="(line136)"></a> <font color=Red>|</font> PI ProcessingInstruction-<a name="(line137)"></a> -<a name="(line138)"></a><a name="ProcessingInstruction"></a><font color=Green><u>type</u></font> ProcessingInstruction <font color=Red>=</font> <font color=Cyan>(</font>PITarget<font color=Cyan>,</font>String<font color=Cyan>)</font>-<a name="(line139)"></a>-<a name="(line140)"></a><a name="SDDecl"></a><font color=Green><u>type</u></font> SDDecl <font color=Red>=</font> Bool -<a name="(line141)"></a><a name="VersionInfo"></a><font color=Green><u>type</u></font> VersionInfo <font color=Red>=</font> String -<a name="(line142)"></a><a name="Comment"></a><font color=Green><u>type</u></font> Comment <font color=Red>=</font> String -<a name="(line143)"></a><a name="PITarget"></a><font color=Green><u>type</u></font> PITarget <font color=Red>=</font> String -<a name="(line144)"></a>-<a name="(line145)"></a><a name="DocTypeDecl"></a><font color=Green><u>data</u></font> DocTypeDecl <font color=Red>=</font> DTD Name <font color=Cyan>(</font>Maybe ExternalID<font color=Cyan>)</font> <font color=Red>[</font>MarkupDecl<font color=Red>]</font> -<a name="(line146)"></a><a name="MarkupDecl"></a><font color=Green><u>data</u></font> MarkupDecl <font color=Red>=</font> Element ElementDecl-<a name="(line147)"></a> <font color=Red>|</font> AttList AttListDecl-<a name="(line148)"></a> <font color=Red>|</font> Entity EntityDecl-<a name="(line149)"></a> <font color=Red>|</font> Notation NotationDecl-<a name="(line150)"></a> <font color=Red>|</font> MarkupMisc Misc-<a name="(line151)"></a>-<a name="(line152)"></a><a name="ExtSubset"></a><font color=Green><u>data</u></font> ExtSubset <font color=Red>=</font> ExtSubset <font color=Cyan>(</font>Maybe TextDecl<font color=Cyan>)</font> <font color=Red>[</font>ExtSubsetDecl<font color=Red>]</font> -<a name="(line153)"></a><a name="ExtSubsetDecl"></a><font color=Green><u>data</u></font> ExtSubsetDecl <font color=Red>=</font> ExtMarkupDecl MarkupDecl-<a name="(line154)"></a> <font color=Red>|</font> ExtConditionalSect ConditionalSect+<a name="(line127)"></a><font color=Blue>{- XML types start here -}</font>+<a name="(line128)"></a>+<a name="(line129)"></a><a name="Document"></a><font color=Blue>-- | The symbol table stored in a document holds all its general entity</font>+<a name="(line130)"></a><a name="Document"></a><font color=Blue>-- reference definitions.</font>+<a name="(line131)"></a><a name="Document"></a><font color=Green><u>data</u></font> Document i <font color=Red>=</font> Document Prolog <font color=Cyan>(</font>SymTab EntityDef<font color=Cyan>)</font> <font color=Cyan>(</font>Element i<font color=Cyan>)</font> <font color=Red>[</font>Misc<font color=Red>]</font>+<a name="(line132)"></a> <font color=Green><u>deriving</u></font> Eq+<a name="(line133)"></a><a name="Prolog"></a><font color=Green><u>data</u></font> Prolog <font color=Red>=</font> Prolog <font color=Cyan>(</font>Maybe XMLDecl<font color=Cyan>)</font> <font color=Red>[</font>Misc<font color=Red>]</font> <font color=Cyan>(</font>Maybe DocTypeDecl<font color=Cyan>)</font> <font color=Red>[</font>Misc<font color=Red>]</font>+<a name="(line134)"></a> <font color=Green><u>deriving</u></font> Eq+<a name="(line135)"></a><a name="XMLDecl"></a><font color=Green><u>data</u></font> XMLDecl <font color=Red>=</font> XMLDecl VersionInfo <font color=Cyan>(</font>Maybe EncodingDecl<font color=Cyan>)</font> <font color=Cyan>(</font>Maybe SDDecl<font color=Cyan>)</font>+<a name="(line136)"></a> <font color=Green><u>deriving</u></font> Eq+<a name="(line137)"></a><a name="Misc"></a><font color=Green><u>data</u></font> Misc <font color=Red>=</font> Comment Comment+<a name="(line138)"></a> <font color=Red>|</font> PI ProcessingInstruction +<a name="(line139)"></a> <font color=Green><u>deriving</u></font> Eq+<a name="(line140)"></a> +<a name="(line141)"></a><a name="ProcessingInstruction"></a><font color=Green><u>type</u></font> ProcessingInstruction <font color=Red>=</font> <font color=Cyan>(</font>PITarget<font color=Cyan>,</font>String<font color=Cyan>)</font>+<a name="(line142)"></a>+<a name="(line143)"></a><a name="SDDecl"></a><font color=Green><u>type</u></font> SDDecl <font color=Red>=</font> Bool +<a name="(line144)"></a><a name="VersionInfo"></a><font color=Green><u>type</u></font> VersionInfo <font color=Red>=</font> String +<a name="(line145)"></a><a name="Comment"></a><font color=Green><u>type</u></font> Comment <font color=Red>=</font> String +<a name="(line146)"></a><a name="PITarget"></a><font color=Green><u>type</u></font> PITarget <font color=Red>=</font> String +<a name="(line147)"></a>+<a name="(line148)"></a><a name="DocTypeDecl"></a><font color=Green><u>data</u></font> DocTypeDecl <font color=Red>=</font> DTD Name <font color=Cyan>(</font>Maybe ExternalID<font color=Cyan>)</font> <font color=Red>[</font>MarkupDecl<font color=Red>]</font> <font color=Green><u>deriving</u></font> Eq+<a name="(line149)"></a><a name="MarkupDecl"></a><font color=Green><u>data</u></font> MarkupDecl <font color=Red>=</font> Element ElementDecl+<a name="(line150)"></a> <font color=Red>|</font> AttList AttListDecl+<a name="(line151)"></a> <font color=Red>|</font> Entity EntityDecl+<a name="(line152)"></a> <font color=Red>|</font> Notation NotationDecl+<a name="(line153)"></a> <font color=Red>|</font> MarkupMisc Misc+<a name="(line154)"></a> <font color=Green><u>deriving</u></font> Eq <a name="(line155)"></a>-<a name="(line156)"></a><a name="Element"></a><font color=Green><u>data</u></font> Element i <font color=Red>=</font> Elem Name <font color=Red>[</font>Attribute<font color=Red>]</font> <font color=Red>[</font>Content i<font color=Red>]</font>-<a name="(line157)"></a><a name="ElemTag"></a><font color=Green><u>data</u></font> ElemTag <font color=Red>=</font> ElemTag Name <font color=Red>[</font>Attribute<font color=Red>]</font> <font color=Blue>-- ^ intermediate for parsing</font>-<a name="(line158)"></a><a name="Attribute"></a><font color=Green><u>type</u></font> Attribute <font color=Red>=</font> <font color=Cyan>(</font>Name<font color=Cyan>,</font> AttValue<font color=Cyan>)</font>-<a name="(line159)"></a><a name="Content"></a><font color=Green><u>data</u></font> Content i <font color=Red>=</font> CElem <font color=Cyan>(</font>Element i<font color=Cyan>)</font> i-<a name="(line160)"></a> <font color=Red>|</font> CString Bool CharData i-<a name="(line161)"></a> <font color=Blue>-- ^ bool is whether whitespace is significant</font>-<a name="(line162)"></a> <font color=Red>|</font> CRef Reference i-<a name="(line163)"></a> <font color=Red>|</font> CMisc Misc i-<a name="(line164)"></a>-<a name="(line165)"></a><a name="info"></a>info <font color=Cyan>(</font>CElem <font color=Green><u>_</u></font> i<font color=Cyan>)</font> <font color=Red>=</font> i-<a name="(line166)"></a>info <font color=Cyan>(</font>CString <font color=Green><u>_</u></font> <font color=Green><u>_</u></font> i<font color=Cyan>)</font> <font color=Red>=</font> i-<a name="(line167)"></a>info <font color=Cyan>(</font>CRef <font color=Green><u>_</u></font> i<font color=Cyan>)</font> <font color=Red>=</font> i-<a name="(line168)"></a>info <font color=Cyan>(</font>CMisc <font color=Green><u>_</u></font> i<font color=Cyan>)</font> <font color=Red>=</font> i-<a name="(line169)"></a>-<a name="(line170)"></a><font color=Green><u>instance</u></font> Functor Document <font color=Green><u>where</u></font>-<a name="(line171)"></a> fmap f <font color=Cyan>(</font>Document p st e ms<font color=Cyan>)</font> <font color=Red>=</font> Document p st <font color=Cyan>(</font>fmap f e<font color=Cyan>)</font> ms-<a name="(line172)"></a><font color=Green><u>instance</u></font> Functor Element <font color=Green><u>where</u></font>-<a name="(line173)"></a> fmap f <font color=Cyan>(</font>Elem t <font color=Green><u>as</u></font> cs<font color=Cyan>)</font> <font color=Red>=</font> Elem t <font color=Green><u>as</u></font> <font color=Cyan>(</font>map <font color=Cyan>(</font>fmap f<font color=Cyan>)</font> cs<font color=Cyan>)</font>-<a name="(line174)"></a><font color=Green><u>instance</u></font> Functor Content <font color=Green><u>where</u></font>-<a name="(line175)"></a> fmap f <font color=Cyan>(</font>CElem e i<font color=Cyan>)</font> <font color=Red>=</font> CElem <font color=Cyan>(</font>fmap f e<font color=Cyan>)</font> <font color=Cyan>(</font>f i<font color=Cyan>)</font>-<a name="(line176)"></a> fmap f <font color=Cyan>(</font>CString b s i<font color=Cyan>)</font> <font color=Red>=</font> CString b s <font color=Cyan>(</font>f i<font color=Cyan>)</font>-<a name="(line177)"></a> fmap f <font color=Cyan>(</font>CRef r i<font color=Cyan>)</font> <font color=Red>=</font> CRef r <font color=Cyan>(</font>f i<font color=Cyan>)</font>-<a name="(line178)"></a> fmap f <font color=Cyan>(</font>CMisc m i<font color=Cyan>)</font> <font color=Red>=</font> CMisc m <font color=Cyan>(</font>f i<font color=Cyan>)</font>-<a name="(line179)"></a>-<a name="(line180)"></a><a name="ElementDecl"></a><font color=Green><u>data</u></font> ElementDecl <font color=Red>=</font> ElementDecl Name ContentSpec-<a name="(line181)"></a><a name="ContentSpec"></a><font color=Green><u>data</u></font> ContentSpec <font color=Red>=</font> EMPTY-<a name="(line182)"></a> <font color=Red>|</font> ANY-<a name="(line183)"></a> <font color=Red>|</font> Mixed Mixed-<a name="(line184)"></a> <font color=Red>|</font> ContentSpec CP-<a name="(line185)"></a><a name="CP"></a><font color=Green><u>data</u></font> CP <font color=Red>=</font> TagName Name Modifier-<a name="(line186)"></a> <font color=Red>|</font> Choice <font color=Red>[</font>CP<font color=Red>]</font> Modifier-<a name="(line187)"></a> <font color=Red>|</font> Seq <font color=Red>[</font>CP<font color=Red>]</font> Modifier -<a name="(line188)"></a><a name="Modifier"></a><font color=Green><u>data</u></font> Modifier <font color=Red>=</font> None <font color=Blue>-- ^ Just One</font>-<a name="(line189)"></a> <font color=Red>|</font> Query <font color=Blue>-- ^ Zero Or One</font>-<a name="(line190)"></a> <font color=Red>|</font> Star <font color=Blue>-- ^ Zero Or More</font>-<a name="(line191)"></a> <font color=Red>|</font> Plus <font color=Blue>-- ^ One Or More </font>-<a name="(line192)"></a><a name="Mixed"></a><font color=Green><u>data</u></font> Mixed <font color=Red>=</font> PCDATA-<a name="(line193)"></a> <font color=Red>|</font> PCDATAplus <font color=Red>[</font>Name<font color=Red>]</font> -<a name="(line194)"></a>-<a name="(line195)"></a><a name="AttListDecl"></a><font color=Green><u>data</u></font> AttListDecl <font color=Red>=</font> AttListDecl Name <font color=Red>[</font>AttDef<font color=Red>]</font>-<a name="(line196)"></a><a name="AttDef"></a><font color=Green><u>data</u></font> AttDef <font color=Red>=</font> AttDef Name AttType DefaultDecl -<a name="(line197)"></a><a name="AttType"></a><font color=Green><u>data</u></font> AttType <font color=Red>=</font> StringType-<a name="(line198)"></a> <font color=Red>|</font> TokenizedType TokenizedType-<a name="(line199)"></a> <font color=Red>|</font> EnumeratedType EnumeratedType -<a name="(line200)"></a><a name="TokenizedType"></a><font color=Green><u>data</u></font> TokenizedType <font color=Red>=</font> ID-<a name="(line201)"></a> <font color=Red>|</font> IDREF-<a name="(line202)"></a> <font color=Red>|</font> IDREFS-<a name="(line203)"></a> <font color=Red>|</font> ENTITY-<a name="(line204)"></a> <font color=Red>|</font> ENTITIES-<a name="(line205)"></a> <font color=Red>|</font> NMTOKEN-<a name="(line206)"></a> <font color=Red>|</font> NMTOKENS -<a name="(line207)"></a><a name="EnumeratedType"></a><font color=Green><u>data</u></font> EnumeratedType <font color=Red>=</font> NotationType NotationType-<a name="(line208)"></a> <font color=Red>|</font> Enumeration Enumeration -<a name="(line209)"></a><a name="NotationType"></a><font color=Green><u>type</u></font> NotationType <font color=Red>=</font> <font color=Red>[</font>Name<font color=Red>]</font> <font color=Blue>-- nonempty list</font>-<a name="(line210)"></a><a name="Enumeration"></a><font color=Green><u>type</u></font> Enumeration <font color=Red>=</font> <font color=Red>[</font>NmToken<font color=Red>]</font> <font color=Blue>-- nonempty list</font>-<a name="(line211)"></a><a name="DefaultDecl"></a><font color=Green><u>data</u></font> DefaultDecl <font color=Red>=</font> REQUIRED-<a name="(line212)"></a> <font color=Red>|</font> IMPLIED-<a name="(line213)"></a> <font color=Red>|</font> DefaultTo AttValue <font color=Cyan>(</font>Maybe FIXED<font color=Cyan>)</font> -<a name="(line214)"></a><a name="FIXED"></a><font color=Green><u>data</u></font> FIXED <font color=Red>=</font> FIXED -<a name="(line215)"></a>-<a name="(line216)"></a><a name="ConditionalSect"></a><font color=Green><u>data</u></font> ConditionalSect <font color=Red>=</font> IncludeSect IncludeSect-<a name="(line217)"></a> <font color=Red>|</font> IgnoreSect IgnoreSect -<a name="(line218)"></a><a name="IncludeSect"></a><font color=Green><u>type</u></font> IncludeSect <font color=Red>=</font> <font color=Red>[</font>ExtSubsetDecl<font color=Red>]</font>-<a name="(line219)"></a><a name="IgnoreSect"></a><font color=Green><u>type</u></font> IgnoreSect <font color=Red>=</font> <font color=Red>[</font>IgnoreSectContents<font color=Red>]</font>-<a name="(line220)"></a><a name="Ignore"></a><font color=Green><u>data</u></font> Ignore <font color=Red>=</font> Ignore-<a name="(line221)"></a><a name="IgnoreSectContents"></a><font color=Green><u>data</u></font> IgnoreSectContents <font color=Red>=</font> IgnoreSectContents Ignore <font color=Red>[</font><font color=Cyan>(</font>IgnoreSectContents<font color=Cyan>,</font>Ignore<font color=Cyan>)</font><font color=Red>]</font> -<a name="(line222)"></a>-<a name="(line223)"></a><a name="Reference"></a><font color=Green><u>data</u></font> Reference <font color=Red>=</font> RefEntity EntityRef-<a name="(line224)"></a> <font color=Red>|</font> RefChar CharRef -<a name="(line225)"></a> <font color=Green><u>deriving</u></font> <font color=Cyan>(</font>Eq<font color=Cyan>,</font> Show<font color=Cyan>)</font>-<a name="(line226)"></a><a name="EntityRef"></a><font color=Green><u>type</u></font> EntityRef <font color=Red>=</font> Name -<a name="(line227)"></a><a name="CharRef"></a><font color=Green><u>type</u></font> CharRef <font color=Red>=</font> Int-<a name="(line228)"></a><a name="PEReference"></a><font color=Green><u>type</u></font> PEReference <font color=Red>=</font> Name +<a name="(line156)"></a><a name="ExtSubset"></a><font color=Green><u>data</u></font> ExtSubset <font color=Red>=</font> ExtSubset <font color=Cyan>(</font>Maybe TextDecl<font color=Cyan>)</font> <font color=Red>[</font>ExtSubsetDecl<font color=Red>]</font> <font color=Green><u>deriving</u></font> Eq+<a name="(line157)"></a><a name="ExtSubsetDecl"></a><font color=Green><u>data</u></font> ExtSubsetDecl <font color=Red>=</font> ExtMarkupDecl MarkupDecl+<a name="(line158)"></a> <font color=Red>|</font> ExtConditionalSect ConditionalSect+<a name="(line159)"></a> <font color=Green><u>deriving</u></font> Eq+<a name="(line160)"></a>+<a name="(line161)"></a><a name="Element"></a><font color=Green><u>data</u></font> Element i <font color=Red>=</font> Elem Name <font color=Red>[</font>Attribute<font color=Red>]</font> <font color=Red>[</font>Content i<font color=Red>]</font> <font color=Green><u>deriving</u></font> Eq+<a name="(line162)"></a> <font color=Blue>-- intermediate for parsing</font>+<a name="(line163)"></a><a name="ElemTag"></a><font color=Green><u>data</u></font> ElemTag <font color=Red>=</font> ElemTag Name <font color=Red>[</font>Attribute<font color=Red>]</font>+<a name="(line164)"></a><a name="Attribute"></a><font color=Green><u>type</u></font> Attribute <font color=Red>=</font> <font color=Cyan>(</font>Name<font color=Cyan>,</font> AttValue<font color=Cyan>)</font>+<a name="(line165)"></a><a name="Content"></a><font color=Green><u>data</u></font> Content i <font color=Red>=</font> CElem <font color=Cyan>(</font>Element i<font color=Cyan>)</font> i+<a name="(line166)"></a> <font color=Red>|</font> CString Bool CharData i+<a name="(line167)"></a> <font color=Blue>-- ^ bool is whether whitespace is significant</font>+<a name="(line168)"></a> <font color=Red>|</font> CRef Reference i+<a name="(line169)"></a> <font color=Red>|</font> CMisc Misc i+<a name="(line170)"></a> <font color=Green><u>deriving</u></font> Eq+<a name="(line171)"></a><a name="info"></a>info <font color=Cyan>(</font>CElem <font color=Green><u>_</u></font> i<font color=Cyan>)</font> <font color=Red>=</font> i+<a name="(line172)"></a>info <font color=Cyan>(</font>CString <font color=Green><u>_</u></font> <font color=Green><u>_</u></font> i<font color=Cyan>)</font> <font color=Red>=</font> i+<a name="(line173)"></a>info <font color=Cyan>(</font>CRef <font color=Green><u>_</u></font> i<font color=Cyan>)</font> <font color=Red>=</font> i+<a name="(line174)"></a>info <font color=Cyan>(</font>CMisc <font color=Green><u>_</u></font> i<font color=Cyan>)</font> <font color=Red>=</font> i+<a name="(line175)"></a>+<a name="(line176)"></a><font color=Green><u>instance</u></font> Functor Document <font color=Green><u>where</u></font>+<a name="(line177)"></a> fmap f <font color=Cyan>(</font>Document p st e ms<font color=Cyan>)</font> <font color=Red>=</font> Document p st <font color=Cyan>(</font>fmap f e<font color=Cyan>)</font> ms+<a name="(line178)"></a><font color=Green><u>instance</u></font> Functor Element <font color=Green><u>where</u></font>+<a name="(line179)"></a> fmap f <font color=Cyan>(</font>Elem t <font color=Green><u>as</u></font> cs<font color=Cyan>)</font> <font color=Red>=</font> Elem t <font color=Green><u>as</u></font> <font color=Cyan>(</font>map <font color=Cyan>(</font>fmap f<font color=Cyan>)</font> cs<font color=Cyan>)</font>+<a name="(line180)"></a><font color=Green><u>instance</u></font> Functor Content <font color=Green><u>where</u></font>+<a name="(line181)"></a> fmap f <font color=Cyan>(</font>CElem e i<font color=Cyan>)</font> <font color=Red>=</font> CElem <font color=Cyan>(</font>fmap f e<font color=Cyan>)</font> <font color=Cyan>(</font>f i<font color=Cyan>)</font>+<a name="(line182)"></a> fmap f <font color=Cyan>(</font>CString b s i<font color=Cyan>)</font> <font color=Red>=</font> CString b s <font color=Cyan>(</font>f i<font color=Cyan>)</font>+<a name="(line183)"></a> fmap f <font color=Cyan>(</font>CRef r i<font color=Cyan>)</font> <font color=Red>=</font> CRef r <font color=Cyan>(</font>f i<font color=Cyan>)</font>+<a name="(line184)"></a> fmap f <font color=Cyan>(</font>CMisc m i<font color=Cyan>)</font> <font color=Red>=</font> CMisc m <font color=Cyan>(</font>f i<font color=Cyan>)</font>+<a name="(line185)"></a>+<a name="(line186)"></a><a name="ElementDecl"></a><font color=Green><u>data</u></font> ElementDecl <font color=Red>=</font> ElementDecl Name ContentSpec <font color=Green><u>deriving</u></font> Eq+<a name="(line187)"></a><a name="ContentSpec"></a><font color=Green><u>data</u></font> ContentSpec <font color=Red>=</font> EMPTY+<a name="(line188)"></a> <font color=Red>|</font> ANY+<a name="(line189)"></a> <font color=Red>|</font> Mixed Mixed+<a name="(line190)"></a> <font color=Red>|</font> ContentSpec CP+<a name="(line191)"></a> <font color=Green><u>deriving</u></font> Eq+<a name="(line192)"></a><a name="CP"></a><font color=Blue>-- FIXME: What is TagName here? Seems to be in disagreement with XML spec.</font>+<a name="(line193)"></a><a name="CP"></a><font color=Green><u>data</u></font> CP <font color=Red>=</font> TagName Name Modifier+<a name="(line194)"></a> <font color=Red>|</font> Choice <font color=Red>[</font>CP<font color=Red>]</font> Modifier+<a name="(line195)"></a> <font color=Red>|</font> Seq <font color=Red>[</font>CP<font color=Red>]</font> Modifier +<a name="(line196)"></a> <font color=Green><u>deriving</u></font> Eq+<a name="(line197)"></a><a name="Modifier"></a><font color=Green><u>data</u></font> Modifier <font color=Red>=</font> None <font color=Blue>-- ^ Just One</font>+<a name="(line198)"></a> <font color=Red>|</font> Query <font color=Blue>-- ^ Zero Or One</font>+<a name="(line199)"></a> <font color=Red>|</font> Star <font color=Blue>-- ^ Zero Or More</font>+<a name="(line200)"></a> <font color=Red>|</font> Plus <font color=Blue>-- ^ One Or More </font>+<a name="(line201)"></a> <font color=Green><u>deriving</u></font> Eq+<a name="(line202)"></a><a name="Mixed"></a><font color=Green><u>data</u></font> Mixed <font color=Red>=</font> PCDATA+<a name="(line203)"></a> <font color=Red>|</font> PCDATAplus <font color=Red>[</font>Name<font color=Red>]</font> +<a name="(line204)"></a> <font color=Green><u>deriving</u></font> Eq+<a name="(line205)"></a><a name="AttListDecl"></a><font color=Green><u>data</u></font> AttListDecl <font color=Red>=</font> AttListDecl Name <font color=Red>[</font>AttDef<font color=Red>]</font> <font color=Green><u>deriving</u></font> Eq+<a name="(line206)"></a><a name="AttDef"></a><font color=Green><u>data</u></font> AttDef <font color=Red>=</font> AttDef Name AttType DefaultDecl <font color=Green><u>deriving</u></font> Eq+<a name="(line207)"></a><a name="AttType"></a><font color=Green><u>data</u></font> AttType <font color=Red>=</font> StringType+<a name="(line208)"></a> <font color=Red>|</font> TokenizedType TokenizedType+<a name="(line209)"></a> <font color=Red>|</font> EnumeratedType EnumeratedType +<a name="(line210)"></a> <font color=Green><u>deriving</u></font> Eq+<a name="(line211)"></a><a name="TokenizedType"></a><font color=Green><u>data</u></font> TokenizedType <font color=Red>=</font> ID+<a name="(line212)"></a> <font color=Red>|</font> IDREF+<a name="(line213)"></a> <font color=Red>|</font> IDREFS+<a name="(line214)"></a> <font color=Red>|</font> ENTITY+<a name="(line215)"></a> <font color=Red>|</font> ENTITIES+<a name="(line216)"></a> <font color=Red>|</font> NMTOKEN+<a name="(line217)"></a> <font color=Red>|</font> NMTOKENS +<a name="(line218)"></a> <font color=Green><u>deriving</u></font> Eq+<a name="(line219)"></a><a name="EnumeratedType"></a><font color=Green><u>data</u></font> EnumeratedType <font color=Red>=</font> NotationType NotationType+<a name="(line220)"></a> <font color=Red>|</font> Enumeration Enumeration +<a name="(line221)"></a> <font color=Green><u>deriving</u></font> Eq+<a name="(line222)"></a><a name="NotationType"></a><font color=Green><u>type</u></font> NotationType <font color=Red>=</font> <font color=Red>[</font>Name<font color=Red>]</font> <font color=Blue>-- nonempty list</font>+<a name="(line223)"></a><a name="Enumeration"></a><font color=Green><u>type</u></font> Enumeration <font color=Red>=</font> <font color=Red>[</font>NmToken<font color=Red>]</font> <font color=Blue>-- nonempty list</font>+<a name="(line224)"></a><a name="DefaultDecl"></a><font color=Green><u>data</u></font> DefaultDecl <font color=Red>=</font> REQUIRED+<a name="(line225)"></a> <font color=Red>|</font> IMPLIED+<a name="(line226)"></a> <font color=Red>|</font> DefaultTo AttValue <font color=Cyan>(</font>Maybe FIXED<font color=Cyan>)</font> +<a name="(line227)"></a> <font color=Green><u>deriving</u></font> Eq+<a name="(line228)"></a><a name="FIXED"></a><font color=Green><u>data</u></font> FIXED <font color=Red>=</font> FIXED <font color=Green><u>deriving</u></font> Eq <a name="(line229)"></a>-<a name="(line230)"></a><a name="EntityDecl"></a><font color=Green><u>data</u></font> EntityDecl <font color=Red>=</font> EntityGEDecl GEDecl-<a name="(line231)"></a> <font color=Red>|</font> EntityPEDecl PEDecl -<a name="(line232)"></a><a name="GEDecl"></a><font color=Green><u>data</u></font> GEDecl <font color=Red>=</font> GEDecl Name EntityDef -<a name="(line233)"></a><a name="PEDecl"></a><font color=Green><u>data</u></font> PEDecl <font color=Red>=</font> PEDecl Name PEDef -<a name="(line234)"></a><a name="EntityDef"></a><font color=Green><u>data</u></font> EntityDef <font color=Red>=</font> DefEntityValue EntityValue-<a name="(line235)"></a> <font color=Red>|</font> DefExternalID ExternalID <font color=Cyan>(</font>Maybe NDataDecl<font color=Cyan>)</font> -<a name="(line236)"></a><a name="PEDef"></a><font color=Green><u>data</u></font> PEDef <font color=Red>=</font> PEDefEntityValue EntityValue-<a name="(line237)"></a> <font color=Red>|</font> PEDefExternalID ExternalID <font color=Green><u>deriving</u></font> <font color=Cyan>(</font>Show<font color=Cyan>)</font>-<a name="(line238)"></a><a name="ExternalID"></a><font color=Green><u>data</u></font> ExternalID <font color=Red>=</font> SYSTEM SystemLiteral-<a name="(line239)"></a> <font color=Red>|</font> PUBLIC PubidLiteral SystemLiteral <font color=Green><u>deriving</u></font> <font color=Cyan>(</font>Show<font color=Cyan>)</font>-<a name="(line240)"></a><a name="NDataDecl"></a><font color=Green><u>newtype</u></font> NDataDecl <font color=Red>=</font> NDATA Name -<a name="(line241)"></a>-<a name="(line242)"></a><a name="TextDecl"></a><font color=Green><u>data</u></font> TextDecl <font color=Red>=</font> TextDecl <font color=Cyan>(</font>Maybe VersionInfo<font color=Cyan>)</font> EncodingDecl -<a name="(line243)"></a><a name="ExtParsedEnt"></a><font color=Green><u>data</u></font> ExtParsedEnt i <font color=Red>=</font> ExtParsedEnt <font color=Cyan>(</font>Maybe TextDecl<font color=Cyan>)</font> <font color=Cyan>(</font>Content i<font color=Cyan>)</font>-<a name="(line244)"></a><a name="ExtPE"></a><font color=Green><u>data</u></font> ExtPE <font color=Red>=</font> ExtPE <font color=Cyan>(</font>Maybe TextDecl<font color=Cyan>)</font> <font color=Red>[</font>ExtSubsetDecl<font color=Red>]</font>-<a name="(line245)"></a>-<a name="(line246)"></a><a name="NotationDecl"></a><font color=Green><u>data</u></font> NotationDecl <font color=Red>=</font> NOTATION Name <font color=Cyan>(</font>Either ExternalID PublicID<font color=Cyan>)</font> -<a name="(line247)"></a><a name="PublicID"></a><font color=Green><u>newtype</u></font> PublicID <font color=Red>=</font> PUBLICID PubidLiteral -<a name="(line248)"></a><a name="EncodingDecl"></a><font color=Green><u>newtype</u></font> EncodingDecl <font color=Red>=</font> EncodingDecl String -<a name="(line249)"></a>-<a name="(line250)"></a><a name="Name"></a><font color=Green><u>type</u></font> Name <font color=Red>=</font> String <font color=Blue>-- non-empty string</font>-<a name="(line251)"></a><a name="Names"></a><font color=Green><u>type</u></font> Names <font color=Red>=</font> <font color=Red>[</font>Name<font color=Red>]</font> <font color=Blue>-- non-empty list</font>-<a name="(line252)"></a><a name="NmToken"></a><font color=Green><u>type</u></font> NmToken <font color=Red>=</font> String <font color=Blue>-- non-empty string</font>-<a name="(line253)"></a><a name="NmTokens"></a><font color=Green><u>type</u></font> NmTokens <font color=Red>=</font> <font color=Red>[</font>NmToken<font color=Red>]</font> <font color=Blue>-- non-empty list</font>-<a name="(line254)"></a>-<a name="(line255)"></a><a name="AttValue"></a><font color=Green><u>data</u></font> AttValue <font color=Red>=</font> AttValue <font color=Red>[</font>Either String Reference<font color=Red>]</font>-<a name="(line256)"></a> <font color=Green><u>deriving</u></font> Eq-<a name="(line257)"></a><font color=Green><u>instance</u></font> Show AttValue <font color=Green><u>where</u></font>-<a name="(line258)"></a> show <font color=Cyan>(</font>AttValue v<font color=Cyan>)</font> <font color=Red>=</font> concatMap decode v-<a name="(line259)"></a> <font color=Green><u>where</u></font>-<a name="(line260)"></a> decode <font color=Cyan>(</font>Left v<font color=Cyan>)</font> <font color=Red>=</font> v-<a name="(line261)"></a> decode <font color=Cyan>(</font>Right <font color=Cyan>(</font>RefEntity ent<font color=Cyan>)</font><font color=Cyan>)</font> <font color=Red>=</font> <font color=Magenta>"&"</font><font color=Cyan>++</font>ent<font color=Cyan>++</font><font color=Magenta>";"</font>-<a name="(line262)"></a> decode <font color=Cyan>(</font>Right <font color=Cyan>(</font>RefChar cref<font color=Cyan>)</font><font color=Cyan>)</font> <font color=Red>=</font> <font color=Magenta>"&"</font><font color=Cyan>++</font>show cref<font color=Cyan>++</font><font color=Magenta>";"</font>-<a name="(line263)"></a>-<a name="(line264)"></a><a name="EntityValue"></a><font color=Green><u>data</u></font> EntityValue <font color=Red>=</font> EntityValue <font color=Red>[</font>EV<font color=Red>]</font> <font color=Green><u>deriving</u></font> <font color=Cyan>(</font>Show<font color=Cyan>)</font>-<a name="(line265)"></a><a name="EV"></a><font color=Green><u>data</u></font> EV <font color=Red>=</font> EVString String-<a name="(line266)"></a> <font color=Blue>-- -- | EVPERef PEReference</font>-<a name="(line267)"></a> <font color=Red>|</font> EVRef Reference <font color=Green><u>deriving</u></font> <font color=Cyan>(</font>Show<font color=Cyan>)</font>-<a name="(line268)"></a><a name="PubidLiteral"></a><font color=Green><u>newtype</u></font> PubidLiteral <font color=Red>=</font> PubidLiteral String <font color=Green><u>deriving</u></font> <font color=Cyan>(</font>Show<font color=Cyan>)</font>-<a name="(line269)"></a><a name="SystemLiteral"></a><font color=Green><u>newtype</u></font> SystemLiteral <font color=Red>=</font> SystemLiteral String <font color=Green><u>deriving</u></font> <font color=Cyan>(</font>Show<font color=Cyan>)</font>-<a name="(line270)"></a><a name="CharData"></a><font color=Green><u>type</u></font> CharData <font color=Red>=</font> String -<a name="(line271)"></a><a name="CDSect"></a><font color=Green><u>type</u></font> CDSect <font color=Red>=</font> CharData-<a name="(line272)"></a>-<a name="(line273)"></a><font color=Green><u>instance</u></font> Eq ElemTag <font color=Green><u>where</u></font>-<a name="(line274)"></a> <font color=Cyan>(</font>ElemTag n <font color=Green><u>_</u></font><font color=Cyan>)</font> <font color=Cyan>==</font> <font color=Cyan>(</font>ElemTag m <font color=Green><u>_</u></font><font color=Cyan>)</font> <font color=Red>=</font> n<font color=Cyan>==</font>m+<a name="(line230)"></a><a name="ConditionalSect"></a><font color=Green><u>data</u></font> ConditionalSect <font color=Red>=</font> IncludeSect IncludeSect+<a name="(line231)"></a> <font color=Red>|</font> IgnoreSect IgnoreSect +<a name="(line232)"></a> <font color=Green><u>deriving</u></font> Eq+<a name="(line233)"></a><a name="IncludeSect"></a><font color=Green><u>type</u></font> IncludeSect <font color=Red>=</font> <font color=Red>[</font>ExtSubsetDecl<font color=Red>]</font>+<a name="(line234)"></a><a name="IgnoreSect"></a><font color=Green><u>type</u></font> IgnoreSect <font color=Red>=</font> <font color=Red>[</font>IgnoreSectContents<font color=Red>]</font>+<a name="(line235)"></a><a name="Ignore"></a><font color=Green><u>data</u></font> Ignore <font color=Red>=</font> Ignore <font color=Green><u>deriving</u></font> Eq+<a name="(line236)"></a><a name="IgnoreSectContents"></a><font color=Green><u>data</u></font> IgnoreSectContents <font color=Red>=</font> IgnoreSectContents Ignore <font color=Red>[</font><font color=Cyan>(</font>IgnoreSectContents<font color=Cyan>,</font>Ignore<font color=Cyan>)</font><font color=Red>]</font> <font color=Green><u>deriving</u></font> Eq+<a name="(line237)"></a>+<a name="(line238)"></a><a name="Reference"></a><font color=Green><u>data</u></font> Reference <font color=Red>=</font> RefEntity EntityRef+<a name="(line239)"></a> <font color=Red>|</font> RefChar CharRef +<a name="(line240)"></a> <font color=Green><u>deriving</u></font> <font color=Cyan>(</font>Eq<font color=Cyan>,</font>Show<font color=Cyan>)</font>+<a name="(line241)"></a><a name="EntityRef"></a><font color=Green><u>type</u></font> EntityRef <font color=Red>=</font> Name +<a name="(line242)"></a><a name="CharRef"></a><font color=Green><u>type</u></font> CharRef <font color=Red>=</font> Int+<a name="(line243)"></a><a name="PEReference"></a><font color=Green><u>type</u></font> PEReference <font color=Red>=</font> Name +<a name="(line244)"></a>+<a name="(line245)"></a><a name="EntityDecl"></a><font color=Green><u>data</u></font> EntityDecl <font color=Red>=</font> EntityGEDecl GEDecl+<a name="(line246)"></a> <font color=Red>|</font> EntityPEDecl PEDecl +<a name="(line247)"></a> <font color=Green><u>deriving</u></font> Eq+<a name="(line248)"></a><a name="GEDecl"></a><font color=Green><u>data</u></font> GEDecl <font color=Red>=</font> GEDecl Name EntityDef <font color=Green><u>deriving</u></font> Eq+<a name="(line249)"></a><a name="PEDecl"></a><font color=Green><u>data</u></font> PEDecl <font color=Red>=</font> PEDecl Name PEDef <font color=Green><u>deriving</u></font> Eq+<a name="(line250)"></a><a name="EntityDef"></a><font color=Green><u>data</u></font> EntityDef <font color=Red>=</font> DefEntityValue EntityValue +<a name="(line251)"></a> <font color=Red>|</font> DefExternalID ExternalID <font color=Cyan>(</font>Maybe NDataDecl<font color=Cyan>)</font> +<a name="(line252)"></a> <font color=Green><u>deriving</u></font> Eq+<a name="(line253)"></a><a name="PEDef"></a><font color=Green><u>data</u></font> PEDef <font color=Red>=</font> PEDefEntityValue EntityValue+<a name="(line254)"></a> <font color=Red>|</font> PEDefExternalID ExternalID <font color=Green><u>deriving</u></font> <font color=Cyan>(</font>Eq<font color=Cyan>,</font>Show<font color=Cyan>)</font>+<a name="(line255)"></a><a name="ExternalID"></a><font color=Green><u>data</u></font> ExternalID <font color=Red>=</font> SYSTEM SystemLiteral+<a name="(line256)"></a> <font color=Red>|</font> PUBLIC PubidLiteral SystemLiteral <font color=Green><u>deriving</u></font> <font color=Cyan>(</font>Eq<font color=Cyan>,</font>Show<font color=Cyan>)</font>+<a name="(line257)"></a><a name="NDataDecl"></a><font color=Green><u>newtype</u></font> NDataDecl <font color=Red>=</font> NDATA Name <font color=Green><u>deriving</u></font> Eq+<a name="(line258)"></a>+<a name="(line259)"></a><a name="TextDecl"></a><font color=Green><u>data</u></font> TextDecl <font color=Red>=</font> TextDecl <font color=Cyan>(</font>Maybe VersionInfo<font color=Cyan>)</font> EncodingDecl <font color=Green><u>deriving</u></font> Eq+<a name="(line260)"></a><a name="ExtParsedEnt"></a><font color=Green><u>data</u></font> ExtParsedEnt i <font color=Red>=</font> ExtParsedEnt <font color=Cyan>(</font>Maybe TextDecl<font color=Cyan>)</font> <font color=Cyan>(</font>Content i<font color=Cyan>)</font> <font color=Green><u>deriving</u></font> Eq+<a name="(line261)"></a><a name="ExtPE"></a><font color=Green><u>data</u></font> ExtPE <font color=Red>=</font> ExtPE <font color=Cyan>(</font>Maybe TextDecl<font color=Cyan>)</font> <font color=Red>[</font>ExtSubsetDecl<font color=Red>]</font> <font color=Green><u>deriving</u></font> Eq+<a name="(line262)"></a>+<a name="(line263)"></a><a name="NotationDecl"></a><font color=Green><u>data</u></font> NotationDecl <font color=Red>=</font> NOTATION Name <font color=Cyan>(</font>Either ExternalID PublicID<font color=Cyan>)</font> <font color=Green><u>deriving</u></font> Eq+<a name="(line264)"></a><a name="PublicID"></a><font color=Green><u>newtype</u></font> PublicID <font color=Red>=</font> PUBLICID PubidLiteral <font color=Green><u>deriving</u></font> Eq+<a name="(line265)"></a><a name="EncodingDecl"></a><font color=Green><u>newtype</u></font> EncodingDecl <font color=Red>=</font> EncodingDecl String <font color=Green><u>deriving</u></font> Eq+<a name="(line266)"></a>+<a name="(line267)"></a><a name="Name"></a><font color=Green><u>type</u></font> Name <font color=Red>=</font> String <font color=Blue>-- non-empty string</font>+<a name="(line268)"></a><a name="Names"></a><font color=Green><u>type</u></font> Names <font color=Red>=</font> <font color=Red>[</font>Name<font color=Red>]</font> <font color=Blue>-- non-empty list</font>+<a name="(line269)"></a><a name="NmToken"></a><font color=Green><u>type</u></font> NmToken <font color=Red>=</font> String <font color=Blue>-- non-empty string</font>+<a name="(line270)"></a><a name="NmTokens"></a><font color=Green><u>type</u></font> NmTokens <font color=Red>=</font> <font color=Red>[</font>NmToken<font color=Red>]</font> <font color=Blue>-- non-empty list</font>+<a name="(line271)"></a>+<a name="(line272)"></a><a name="AttValue"></a><font color=Green><u>data</u></font> AttValue <font color=Red>=</font> AttValue <font color=Red>[</font>Either String Reference<font color=Red>]</font> <font color=Green><u>deriving</u></font> Eq+<a name="(line273)"></a><font color=Green><u>instance</u></font> Show AttValue <font color=Green><u>where</u></font>+<a name="(line274)"></a> show <font color=Cyan>(</font>AttValue v<font color=Cyan>)</font> <font color=Red>=</font> concatMap decode v+<a name="(line275)"></a> <font color=Green><u>where</u></font>+<a name="(line276)"></a> decode <font color=Cyan>(</font>Left v<font color=Cyan>)</font> <font color=Red>=</font> v+<a name="(line277)"></a> decode <font color=Cyan>(</font>Right <font color=Cyan>(</font>RefEntity ent<font color=Cyan>)</font><font color=Cyan>)</font> <font color=Red>=</font> <font color=Magenta>"&"</font><font color=Cyan>++</font>ent<font color=Cyan>++</font><font color=Magenta>";"</font>+<a name="(line278)"></a> decode <font color=Cyan>(</font>Right <font color=Cyan>(</font>RefChar cref<font color=Cyan>)</font><font color=Cyan>)</font> <font color=Red>=</font> <font color=Magenta>"&"</font><font color=Cyan>++</font>show cref<font color=Cyan>++</font><font color=Magenta>";"</font>+<a name="(line279)"></a>+<a name="(line280)"></a><a name="EntityValue"></a><font color=Green><u>data</u></font> EntityValue <font color=Red>=</font> EntityValue <font color=Red>[</font>EV<font color=Red>]</font> <font color=Green><u>deriving</u></font> <font color=Cyan>(</font>Eq<font color=Cyan>,</font>Show<font color=Cyan>)</font>+<a name="(line281)"></a><a name="EV"></a><font color=Green><u>data</u></font> EV <font color=Red>=</font> EVString String+<a name="(line282)"></a> <font color=Blue>-- -- | EVPERef PEReference</font>+<a name="(line283)"></a> <font color=Red>|</font> EVRef Reference <font color=Green><u>deriving</u></font> <font color=Cyan>(</font>Eq<font color=Cyan>,</font>Show<font color=Cyan>)</font>+<a name="(line284)"></a><a name="PubidLiteral"></a><font color=Green><u>newtype</u></font> PubidLiteral <font color=Red>=</font> PubidLiteral String <font color=Green><u>deriving</u></font> <font color=Cyan>(</font>Eq<font color=Cyan>,</font>Show<font color=Cyan>)</font>+<a name="(line285)"></a><a name="SystemLiteral"></a><font color=Green><u>newtype</u></font> SystemLiteral <font color=Red>=</font> SystemLiteral String <font color=Green><u>deriving</u></font> <font color=Cyan>(</font>Eq<font color=Cyan>,</font>Show<font color=Cyan>)</font>+<a name="(line286)"></a><a name="CharData"></a><font color=Green><u>type</u></font> CharData <font color=Red>=</font> String +<a name="(line287)"></a><a name="CDSect"></a><font color=Green><u>type</u></font> CDSect <font color=Red>=</font> CharData+<a name="(line288)"></a>+<a name="(line289)"></a><font color=Green><u>instance</u></font> Eq ElemTag <font color=Green><u>where</u></font>+<a name="(line290)"></a> <font color=Cyan>(</font>ElemTag n <font color=Green><u>_</u></font><font color=Cyan>)</font> <font color=Cyan>==</font> <font color=Cyan>(</font>ElemTag m <font color=Green><u>_</u></font><font color=Cyan>)</font> <font color=Red>=</font> n<font color=Cyan>==</font>m </pre> </html>
docs/HaXml/src/Text/XML/HaXml/Xtract/Parse.html view
@@ -13,408 +13,409 @@ <a name="(line11)"></a><font color=Green><u>import</u></font> Text<font color=Cyan>.</font>XML<font color=Cyan>.</font>HaXml<font color=Cyan>.</font>Xtract<font color=Cyan>.</font>Lex <a name="(line12)"></a><font color=Green><u>import</u></font> Text<font color=Cyan>.</font>XML<font color=Cyan>.</font>HaXml<font color=Cyan>.</font>Xtract<font color=Cyan>.</font>Combinators <font color=Green><u>as</u></font> D <a name="(line13)"></a><font color=Green><u>import</u></font> Text<font color=Cyan>.</font>XML<font color=Cyan>.</font>HaXml<font color=Cyan>.</font>Combinators <font color=Green><u>as</u></font> C-<a name="(line14)"></a><font color=Green><u>import</u></font> List<font color=Cyan>(</font>isPrefixOf<font color=Cyan>)</font>-<a name="(line15)"></a><font color=Green><u>import</u></font> Text<font color=Cyan>.</font>XML<font color=Cyan>.</font>HaXml<font color=Cyan>.</font>Escape <font color=Cyan>(</font>xmlUnEscapeContent<font color=Cyan>,</font>stdXmlEscaper<font color=Cyan>)</font>-<a name="(line16)"></a>-<a name="(line17)"></a><a name="unescape"></a><font color=Blue>-- output transformer - to ensure that text/references are glued together</font>-<a name="(line18)"></a>unescape <font color=Red>=</font> xmlUnEscapeContent stdXmlEscaper-<a name="(line19)"></a>+<a name="(line14)"></a><font color=Green><u>import</u></font> Text<font color=Cyan>.</font>XML<font color=Cyan>.</font>HaXml<font color=Cyan>.</font>Types <font color=Cyan>(</font>Content<font color=Cyan>)</font>+<a name="(line15)"></a><font color=Green><u>import</u></font> List<font color=Cyan>(</font>isPrefixOf<font color=Cyan>)</font>+<a name="(line16)"></a><font color=Green><u>import</u></font> Text<font color=Cyan>.</font>XML<font color=Cyan>.</font>HaXml<font color=Cyan>.</font>Escape <font color=Cyan>(</font>xmlUnEscapeContent<font color=Cyan>,</font>stdXmlEscaper<font color=Cyan>)</font>+<a name="(line17)"></a>+<a name="(line18)"></a><a name="unescape"></a><font color=Blue>-- output transformer - to ensure that text/references are glued together</font>+<a name="(line19)"></a>unescape <font color=Red>=</font> xmlUnEscapeContent stdXmlEscaper <a name="(line20)"></a>-<a name="(line21)"></a><a name="xtract"></a><font color=Blue>-- | To convert an Xtract query into an ordinary HaXml combinator expression.</font>-<a name="(line22)"></a><font color=Blue>-- First arg is a tag-transformation function (e.g. map toLower) applied</font>-<a name="(line23)"></a><font color=Blue>--- before matching. Second arg is the query string.</font>-<a name="(line24)"></a>xtract <font color=Red>::</font> <font color=Cyan>(</font>String<font color=Red>-></font>String<font color=Cyan>)</font> <font color=Red>-></font> String <font color=Red>-></font> CFilter i-<a name="(line25)"></a>xtract f query-<a name="(line26)"></a> <font color=Red>|</font> interiorRef lexedQ <font color=Red>=</font> dfilter <font color=Cyan>(</font>parseXtract lexedQ<font color=Cyan>)</font>-<a name="(line27)"></a> <font color=Red>|</font> otherwise <font color=Red>=</font> cfilter <font color=Cyan>(</font>parseXtract lexedQ<font color=Cyan>)</font>-<a name="(line28)"></a> <font color=Green><u>where</u></font>-<a name="(line29)"></a> lexedQ <font color=Red>=</font> lexXtract f query-<a name="(line30)"></a> <font color=Blue>-- test whether query has interior reference to doc root</font>-<a name="(line31)"></a> interiorRef <font color=Cyan>(</font>Right <font color=Cyan>(</font><font color=Green><u>_</u></font><font color=Cyan>,</font>Symbol s<font color=Cyan>)</font><font color=Red><b>:</b></font> Right <font color=Cyan>(</font><font color=Green><u>_</u></font><font color=Cyan>,</font>Symbol <font color=Magenta>"//"</font><font color=Cyan>)</font><font color=Red><b>:</b></font> <font color=Green><u>_</u></font><font color=Cyan>)</font>-<a name="(line32)"></a> <font color=Red>|</font> s <font color=Cyan>`elem`</font> predicateIntro <font color=Red>=</font> True-<a name="(line33)"></a> interiorRef <font color=Cyan>(</font>Right <font color=Cyan>(</font><font color=Green><u>_</u></font><font color=Cyan>,</font>Symbol s<font color=Cyan>)</font><font color=Red><b>:</b></font> Right <font color=Cyan>(</font><font color=Green><u>_</u></font><font color=Cyan>,</font>Symbol <font color=Magenta>"/"</font><font color=Cyan>)</font><font color=Red><b>:</b></font> <font color=Green><u>_</u></font><font color=Cyan>)</font>-<a name="(line34)"></a> <font color=Red>|</font> s <font color=Cyan>`elem`</font> predicateIntro <font color=Red>=</font> True-<a name="(line35)"></a> interiorRef <font color=Cyan>(</font><font color=Green><u>_</u></font> <font color=Red><b>:</b></font> rest<font color=Cyan>)</font> <font color=Red>=</font> interiorRef rest-<a name="(line36)"></a> interiorRef [] <font color=Red>=</font> False-<a name="(line37)"></a> predicateIntro <font color=Red>=</font> <font color=Red>[</font> <font color=Magenta>"["</font><font color=Cyan>,</font> <font color=Magenta>"("</font>-<a name="(line38)"></a> <font color=Cyan>,</font> <font color=Magenta>"&"</font><font color=Cyan>,</font> <font color=Magenta>"|"</font><font color=Cyan>,</font> <font color=Magenta>"~"</font>-<a name="(line39)"></a> <font color=Cyan>,</font> <font color=Magenta>"="</font><font color=Cyan>,</font> <font color=Magenta>"!="</font><font color=Cyan>,</font> <font color=Magenta>"<"</font><font color=Cyan>,</font> <font color=Magenta>"<="</font><font color=Cyan>,</font> <font color=Magenta>">"</font><font color=Cyan>,</font> <font color=Magenta>">="</font>-<a name="(line40)"></a> <font color=Cyan>,</font> <font color=Magenta>".=."</font><font color=Cyan>,</font><font color=Magenta>".!=."</font><font color=Cyan>,</font><font color=Magenta>".<."</font><font color=Cyan>,</font><font color=Magenta>".<=."</font><font color=Cyan>,</font><font color=Magenta>".>."</font><font color=Cyan>,</font><font color=Magenta>".>=."</font> <font color=Red>]</font>-<a name="(line41)"></a>-<a name="(line42)"></a><a name="parseXtract"></a><font color=Blue>-- | The cool thing is that the Xtract command parser directly builds</font>-<a name="(line43)"></a><font color=Blue>-- a higher-order 'DFilter' (see "Text.XML.HaXml.Xtract.Combinators")</font>-<a name="(line44)"></a><font color=Blue>-- which can be applied to an XML document without further ado.</font>-<a name="(line45)"></a><font color=Blue>-- (@parseXtract@ halts the program if a parse error is found.)</font>-<a name="(line46)"></a>parseXtract <font color=Red>::</font> <font color=Red>[</font>Token<font color=Red>]</font> <font color=Red>-></font> DFilter i-<a name="(line47)"></a>parseXtract <font color=Red>=</font> either error id <font color=Cyan>.</font> parseXtract'-<a name="(line48)"></a>-<a name="(line49)"></a><a name="parseXtract'"></a><font color=Blue>-- | @parseXtract'@ returns error messages through the Either type.</font>-<a name="(line50)"></a>parseXtract' <font color=Red>::</font> <font color=Red>[</font>Token<font color=Red>]</font> <font color=Red>-></font> Either String <font color=Cyan>(</font>DFilter i<font color=Cyan>)</font>-<a name="(line51)"></a>parseXtract' <font color=Red>=</font> fst <font color=Cyan>.</font> runParser <font color=Cyan>(</font>aquery liftLocal<font color=Cyan>)</font>-<a name="(line52)"></a>-<a name="(line53)"></a><a name="XParser"></a><font color=Blue>---- Auxiliary Parsing Functions ----</font>-<a name="(line54)"></a><a name="XParser"></a><font color=Green><u>type</u></font> XParser a <font color=Red>=</font> Parser <font color=Cyan>(</font>Either String <font color=Cyan>(</font>Posn<font color=Cyan>,</font>TokenT<font color=Cyan>)</font><font color=Cyan>)</font> a-<a name="(line55)"></a>-<a name="(line56)"></a><a name="string"></a>string <font color=Red>::</font> XParser String-<a name="(line57)"></a>string <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>inp <font color=Red>-></font> <font color=Green><u>case</u></font> inp <font color=Green><u>of</u></font>-<a name="(line58)"></a> <font color=Cyan>(</font>Left err<font color=Red><b>:</b></font> <font color=Green><u>_</u></font><font color=Cyan>)</font> <font color=Red>-></font> <font color=Cyan>(</font>Left <font color=Cyan>(</font>False<font color=Cyan>,</font>err<font color=Cyan>)</font><font color=Cyan>,</font> inp<font color=Cyan>)</font>-<a name="(line59)"></a> <font color=Cyan>(</font>Right <font color=Cyan>(</font>p<font color=Cyan>,</font>TokString n<font color=Cyan>)</font><font color=Red><b>:</b></font>ts<font color=Cyan>)</font> <font color=Red>-></font> <font color=Cyan>(</font>Right n<font color=Cyan>,</font> ts<font color=Cyan>)</font>-<a name="(line60)"></a> ts <font color=Red>-></font> <font color=Cyan>(</font>Left <font color=Cyan>(</font>False<font color=Cyan>,</font><font color=Magenta>"expected a string"</font><font color=Cyan>)</font><font color=Cyan>,</font> ts<font color=Cyan>)</font> <font color=Cyan>)</font>-<a name="(line61)"></a><a name="number"></a>number <font color=Red>::</font> XParser Integer-<a name="(line62)"></a>number <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>inp <font color=Red>-></font> <font color=Green><u>case</u></font> inp <font color=Green><u>of</u></font>-<a name="(line63)"></a> <font color=Cyan>(</font>Left err<font color=Red><b>:</b></font> <font color=Green><u>_</u></font><font color=Cyan>)</font> <font color=Red>-></font> <font color=Cyan>(</font>Left <font color=Cyan>(</font>False<font color=Cyan>,</font>err<font color=Cyan>)</font><font color=Cyan>,</font> inp<font color=Cyan>)</font>-<a name="(line64)"></a> <font color=Cyan>(</font>Right <font color=Cyan>(</font>p<font color=Cyan>,</font>TokNum n<font color=Cyan>)</font><font color=Red><b>:</b></font>ts<font color=Cyan>)</font> <font color=Red>-></font> <font color=Cyan>(</font>Right n<font color=Cyan>,</font> ts<font color=Cyan>)</font>-<a name="(line65)"></a> ts <font color=Red>-></font> <font color=Cyan>(</font>Left <font color=Cyan>(</font>False<font color=Cyan>,</font><font color=Magenta>"expected a number"</font><font color=Cyan>)</font><font color=Cyan>,</font> ts<font color=Cyan>)</font> <font color=Cyan>)</font>-<a name="(line66)"></a><a name="symbol"></a>symbol <font color=Red>::</font> String <font color=Red>-></font> XParser ()-<a name="(line67)"></a>symbol s <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>inp <font color=Red>-></font> <font color=Green><u>case</u></font> inp <font color=Green><u>of</u></font>-<a name="(line68)"></a> <font color=Cyan>(</font>Left err<font color=Red><b>:</b></font> <font color=Green><u>_</u></font><font color=Cyan>)</font> <font color=Red>-></font> <font color=Cyan>(</font>Left <font color=Cyan>(</font>False<font color=Cyan>,</font>err<font color=Cyan>)</font><font color=Cyan>,</font> inp<font color=Cyan>)</font>-<a name="(line69)"></a> <font color=Cyan>(</font>Right <font color=Cyan>(</font>p<font color=Cyan>,</font> Symbol n<font color=Cyan>)</font><font color=Red><b>:</b></font>ts<font color=Cyan>)</font> <font color=Red>|</font> n<font color=Cyan>==</font>s <font color=Red>-></font> <font color=Cyan>(</font>Right ()<font color=Cyan>,</font> ts<font color=Cyan>)</font>-<a name="(line70)"></a> ts <font color=Red>-></font> <font color=Cyan>(</font>Left <font color=Cyan>(</font>False<font color=Cyan>,</font><font color=Magenta>"expected symbol "</font><font color=Cyan>++</font>s<font color=Cyan>)</font><font color=Cyan>,</font> ts<font color=Cyan>)</font> <font color=Cyan>)</font>-<a name="(line71)"></a>-<a name="(line72)"></a><a name="quote"></a>quote <font color=Red>=</font> oneOf <font color=Red>[</font> symbol <font color=Magenta>"'"</font><font color=Cyan>,</font> symbol <font color=Magenta>"\""</font> <font color=Red>]</font>-<a name="(line73)"></a>-<a name="(line74)"></a><a name="pam"></a>pam fs x <font color=Red>=</font> <font color=Red>[</font> f x <font color=Red>|</font> f <font color=Red><-</font> fs <font color=Red>]</font>-<a name="(line75)"></a>+<a name="(line21)"></a>+<a name="(line22)"></a><a name="xtract"></a><font color=Blue>-- | To convert an Xtract query into an ordinary HaXml combinator expression.</font>+<a name="(line23)"></a><font color=Blue>-- First arg is a tag-transformation function (e.g. map toLower) applied</font>+<a name="(line24)"></a><font color=Blue>--- before matching. Second arg is the query string.</font>+<a name="(line25)"></a>xtract <font color=Red>::</font> <font color=Cyan>(</font>String<font color=Red>-></font>String<font color=Cyan>)</font> <font color=Red>-></font> String <font color=Red>-></font> CFilter i+<a name="(line26)"></a>xtract f query+<a name="(line27)"></a> <font color=Red>|</font> interiorRef lexedQ <font color=Red>=</font> dfilter <font color=Cyan>(</font>parseXtract lexedQ<font color=Cyan>)</font>+<a name="(line28)"></a> <font color=Red>|</font> otherwise <font color=Red>=</font> cfilter <font color=Cyan>(</font>parseXtract lexedQ<font color=Cyan>)</font>+<a name="(line29)"></a> <font color=Green><u>where</u></font>+<a name="(line30)"></a> lexedQ <font color=Red>=</font> lexXtract f query+<a name="(line31)"></a> <font color=Blue>-- test whether query has interior reference to doc root</font>+<a name="(line32)"></a> interiorRef <font color=Cyan>(</font>Right <font color=Cyan>(</font><font color=Green><u>_</u></font><font color=Cyan>,</font>Symbol s<font color=Cyan>)</font><font color=Red><b>:</b></font> Right <font color=Cyan>(</font><font color=Green><u>_</u></font><font color=Cyan>,</font>Symbol <font color=Magenta>"//"</font><font color=Cyan>)</font><font color=Red><b>:</b></font> <font color=Green><u>_</u></font><font color=Cyan>)</font>+<a name="(line33)"></a> <font color=Red>|</font> s <font color=Cyan>`elem`</font> predicateIntro <font color=Red>=</font> True+<a name="(line34)"></a> interiorRef <font color=Cyan>(</font>Right <font color=Cyan>(</font><font color=Green><u>_</u></font><font color=Cyan>,</font>Symbol s<font color=Cyan>)</font><font color=Red><b>:</b></font> Right <font color=Cyan>(</font><font color=Green><u>_</u></font><font color=Cyan>,</font>Symbol <font color=Magenta>"/"</font><font color=Cyan>)</font><font color=Red><b>:</b></font> <font color=Green><u>_</u></font><font color=Cyan>)</font>+<a name="(line35)"></a> <font color=Red>|</font> s <font color=Cyan>`elem`</font> predicateIntro <font color=Red>=</font> True+<a name="(line36)"></a> interiorRef <font color=Cyan>(</font><font color=Green><u>_</u></font> <font color=Red><b>:</b></font> rest<font color=Cyan>)</font> <font color=Red>=</font> interiorRef rest+<a name="(line37)"></a> interiorRef [] <font color=Red>=</font> False+<a name="(line38)"></a> predicateIntro <font color=Red>=</font> <font color=Red>[</font> <font color=Magenta>"["</font><font color=Cyan>,</font> <font color=Magenta>"("</font>+<a name="(line39)"></a> <font color=Cyan>,</font> <font color=Magenta>"&"</font><font color=Cyan>,</font> <font color=Magenta>"|"</font><font color=Cyan>,</font> <font color=Magenta>"~"</font>+<a name="(line40)"></a> <font color=Cyan>,</font> <font color=Magenta>"="</font><font color=Cyan>,</font> <font color=Magenta>"!="</font><font color=Cyan>,</font> <font color=Magenta>"<"</font><font color=Cyan>,</font> <font color=Magenta>"<="</font><font color=Cyan>,</font> <font color=Magenta>">"</font><font color=Cyan>,</font> <font color=Magenta>">="</font>+<a name="(line41)"></a> <font color=Cyan>,</font> <font color=Magenta>".=."</font><font color=Cyan>,</font><font color=Magenta>".!=."</font><font color=Cyan>,</font><font color=Magenta>".<."</font><font color=Cyan>,</font><font color=Magenta>".<=."</font><font color=Cyan>,</font><font color=Magenta>".>."</font><font color=Cyan>,</font><font color=Magenta>".>=."</font> <font color=Red>]</font>+<a name="(line42)"></a>+<a name="(line43)"></a><a name="parseXtract"></a><font color=Blue>-- | The cool thing is that the Xtract command parser directly builds</font>+<a name="(line44)"></a><font color=Blue>-- a higher-order 'DFilter' (see "Text.XML.HaXml.Xtract.Combinators")</font>+<a name="(line45)"></a><font color=Blue>-- which can be applied to an XML document without further ado.</font>+<a name="(line46)"></a><font color=Blue>-- (@parseXtract@ halts the program if a parse error is found.)</font>+<a name="(line47)"></a>parseXtract <font color=Red>::</font> <font color=Red>[</font>Token<font color=Red>]</font> <font color=Red>-></font> DFilter i+<a name="(line48)"></a>parseXtract <font color=Red>=</font> either error id <font color=Cyan>.</font> parseXtract'+<a name="(line49)"></a>+<a name="(line50)"></a><a name="parseXtract'"></a><font color=Blue>-- | @parseXtract'@ returns error messages through the Either type.</font>+<a name="(line51)"></a>parseXtract' <font color=Red>::</font> <font color=Red>[</font>Token<font color=Red>]</font> <font color=Red>-></font> Either String <font color=Cyan>(</font>DFilter i<font color=Cyan>)</font>+<a name="(line52)"></a>parseXtract' <font color=Red>=</font> fst <font color=Cyan>.</font> runParser <font color=Cyan>(</font>aquery liftLocal<font color=Cyan>)</font>+<a name="(line53)"></a>+<a name="(line54)"></a><a name="XParser"></a><font color=Blue>---- Auxiliary Parsing Functions ----</font>+<a name="(line55)"></a><a name="XParser"></a><font color=Green><u>type</u></font> XParser a <font color=Red>=</font> Parser <font color=Cyan>(</font>Either String <font color=Cyan>(</font>Posn<font color=Cyan>,</font>TokenT<font color=Cyan>)</font><font color=Cyan>)</font> a+<a name="(line56)"></a>+<a name="(line57)"></a><a name="string"></a>string <font color=Red>::</font> XParser String+<a name="(line58)"></a>string <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>inp <font color=Red>-></font> <font color=Green><u>case</u></font> inp <font color=Green><u>of</u></font>+<a name="(line59)"></a> <font color=Cyan>(</font>Left err<font color=Red><b>:</b></font> <font color=Green><u>_</u></font><font color=Cyan>)</font> <font color=Red>-></font> <font color=Cyan>(</font>Left <font color=Cyan>(</font>False<font color=Cyan>,</font>err<font color=Cyan>)</font><font color=Cyan>,</font> inp<font color=Cyan>)</font>+<a name="(line60)"></a> <font color=Cyan>(</font>Right <font color=Cyan>(</font>p<font color=Cyan>,</font>TokString n<font color=Cyan>)</font><font color=Red><b>:</b></font>ts<font color=Cyan>)</font> <font color=Red>-></font> <font color=Cyan>(</font>Right n<font color=Cyan>,</font> ts<font color=Cyan>)</font>+<a name="(line61)"></a> ts <font color=Red>-></font> <font color=Cyan>(</font>Left <font color=Cyan>(</font>False<font color=Cyan>,</font><font color=Magenta>"expected a string"</font><font color=Cyan>)</font><font color=Cyan>,</font> ts<font color=Cyan>)</font> <font color=Cyan>)</font>+<a name="(line62)"></a><a name="number"></a>number <font color=Red>::</font> XParser Integer+<a name="(line63)"></a>number <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>inp <font color=Red>-></font> <font color=Green><u>case</u></font> inp <font color=Green><u>of</u></font>+<a name="(line64)"></a> <font color=Cyan>(</font>Left err<font color=Red><b>:</b></font> <font color=Green><u>_</u></font><font color=Cyan>)</font> <font color=Red>-></font> <font color=Cyan>(</font>Left <font color=Cyan>(</font>False<font color=Cyan>,</font>err<font color=Cyan>)</font><font color=Cyan>,</font> inp<font color=Cyan>)</font>+<a name="(line65)"></a> <font color=Cyan>(</font>Right <font color=Cyan>(</font>p<font color=Cyan>,</font>TokNum n<font color=Cyan>)</font><font color=Red><b>:</b></font>ts<font color=Cyan>)</font> <font color=Red>-></font> <font color=Cyan>(</font>Right n<font color=Cyan>,</font> ts<font color=Cyan>)</font>+<a name="(line66)"></a> ts <font color=Red>-></font> <font color=Cyan>(</font>Left <font color=Cyan>(</font>False<font color=Cyan>,</font><font color=Magenta>"expected a number"</font><font color=Cyan>)</font><font color=Cyan>,</font> ts<font color=Cyan>)</font> <font color=Cyan>)</font>+<a name="(line67)"></a><a name="symbol"></a>symbol <font color=Red>::</font> String <font color=Red>-></font> XParser ()+<a name="(line68)"></a>symbol s <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>inp <font color=Red>-></font> <font color=Green><u>case</u></font> inp <font color=Green><u>of</u></font>+<a name="(line69)"></a> <font color=Cyan>(</font>Left err<font color=Red><b>:</b></font> <font color=Green><u>_</u></font><font color=Cyan>)</font> <font color=Red>-></font> <font color=Cyan>(</font>Left <font color=Cyan>(</font>False<font color=Cyan>,</font>err<font color=Cyan>)</font><font color=Cyan>,</font> inp<font color=Cyan>)</font>+<a name="(line70)"></a> <font color=Cyan>(</font>Right <font color=Cyan>(</font>p<font color=Cyan>,</font> Symbol n<font color=Cyan>)</font><font color=Red><b>:</b></font>ts<font color=Cyan>)</font> <font color=Red>|</font> n<font color=Cyan>==</font>s <font color=Red>-></font> <font color=Cyan>(</font>Right ()<font color=Cyan>,</font> ts<font color=Cyan>)</font>+<a name="(line71)"></a> ts <font color=Red>-></font> <font color=Cyan>(</font>Left <font color=Cyan>(</font>False<font color=Cyan>,</font><font color=Magenta>"expected symbol "</font><font color=Cyan>++</font>s<font color=Cyan>)</font><font color=Cyan>,</font> ts<font color=Cyan>)</font> <font color=Cyan>)</font>+<a name="(line72)"></a>+<a name="(line73)"></a><a name="quote"></a>quote <font color=Red>=</font> oneOf <font color=Red>[</font> symbol <font color=Magenta>"'"</font><font color=Cyan>,</font> symbol <font color=Magenta>"\""</font> <font color=Red>]</font>+<a name="(line74)"></a>+<a name="(line75)"></a><a name="pam"></a>pam fs x <font color=Red>=</font> <font color=Red>[</font> f x <font color=Red>|</font> f <font color=Red><-</font> fs <font color=Red>]</font> <a name="(line76)"></a>-<a name="(line77)"></a><font color=Blue>{--- original Xtract grammar -----<a name="(line78)"></a> query = string tagname-<a name="(line79)"></a> | string * tagname prefix-<a name="(line80)"></a> | * string tagname suffix-<a name="(line81)"></a> | * any element-<a name="(line82)"></a> | - chardata-<a name="(line83)"></a> | ( query )-<a name="(line84)"></a> | query / query parent/child relationship-<a name="(line85)"></a> | query // query deep inside-<a name="(line86)"></a> | query + query union of queries-<a name="(line87)"></a> | query [predicate]-<a name="(line88)"></a> | query [positions]-<a name="(line89)"></a>-<a name="(line90)"></a> predicate = quattr has attribute-<a name="(line91)"></a> | quattr op ' string ' attribute has value-<a name="(line92)"></a> | quattr op " string " attribute has value-<a name="(line93)"></a> | quattr op quattr attribute value comparison (lexical)-<a name="(line94)"></a> | quattr nop integer attribute has value (numerical)-<a name="(line95)"></a> | quattr nop quattr attribute value comparison (numerical)-<a name="(line96)"></a> | ( predicate ) bracketting-<a name="(line97)"></a> | predicate & predicate logical and-<a name="(line98)"></a> | predicate | predicate logical or-<a name="(line99)"></a> | ~ predicate logical not-<a name="(line100)"></a>-<a name="(line101)"></a> attribute = @ string has attribute-<a name="(line102)"></a> | query / @ string child has attribute-<a name="(line103)"></a> | - has textual content-<a name="(line104)"></a> | query / - child has textual content-<a name="(line105)"></a>-<a name="(line106)"></a> quattr = query-<a name="(line107)"></a> | attribute-<a name="(line108)"></a>-<a name="(line109)"></a> op = = equal to-<a name="(line110)"></a> | != not equal to-<a name="(line111)"></a> | < less than-<a name="(line112)"></a> | <= less than or equal to-<a name="(line113)"></a> | > greater than-<a name="(line114)"></a> | >= greater than or equal to-<a name="(line115)"></a>-<a name="(line116)"></a> nop = .=. equal to-<a name="(line117)"></a> | .!=. not equal to-<a name="(line118)"></a> | .<. less than-<a name="(line119)"></a> | .<=. less than or equal to-<a name="(line120)"></a> | .>. greater than-<a name="(line121)"></a> | .>=. greater than or equal to-<a name="(line122)"></a>-<a name="(line123)"></a> positions = position {, positions} multiple positions-<a name="(line124)"></a> | position - position ranges-<a name="(line125)"></a>-<a name="(line126)"></a> position = integer numbering is from 0 upwards-<a name="(line127)"></a> | $ last-<a name="(line128)"></a>+<a name="(line77)"></a>+<a name="(line78)"></a><font color=Blue>{--- original Xtract grammar ----+<a name="(line79)"></a> query = string tagname+<a name="(line80)"></a> | string * tagname prefix+<a name="(line81)"></a> | * string tagname suffix+<a name="(line82)"></a> | * any element+<a name="(line83)"></a> | - chardata+<a name="(line84)"></a> | ( query )+<a name="(line85)"></a> | query / query parent/child relationship+<a name="(line86)"></a> | query // query deep inside+<a name="(line87)"></a> | query + query union of queries+<a name="(line88)"></a> | query [predicate]+<a name="(line89)"></a> | query [positions]+<a name="(line90)"></a>+<a name="(line91)"></a> predicate = quattr has attribute+<a name="(line92)"></a> | quattr op ' string ' attribute has value+<a name="(line93)"></a> | quattr op " string " attribute has value+<a name="(line94)"></a> | quattr op quattr attribute value comparison (lexical)+<a name="(line95)"></a> | quattr nop integer attribute has value (numerical)+<a name="(line96)"></a> | quattr nop quattr attribute value comparison (numerical)+<a name="(line97)"></a> | ( predicate ) bracketting+<a name="(line98)"></a> | predicate & predicate logical and+<a name="(line99)"></a> | predicate | predicate logical or+<a name="(line100)"></a> | ~ predicate logical not+<a name="(line101)"></a>+<a name="(line102)"></a> attribute = @ string has attribute+<a name="(line103)"></a> | query / @ string child has attribute+<a name="(line104)"></a> | - has textual content+<a name="(line105)"></a> | query / - child has textual content+<a name="(line106)"></a>+<a name="(line107)"></a> quattr = query+<a name="(line108)"></a> | attribute+<a name="(line109)"></a>+<a name="(line110)"></a> op = = equal to+<a name="(line111)"></a> | != not equal to+<a name="(line112)"></a> | < less than+<a name="(line113)"></a> | <= less than or equal to+<a name="(line114)"></a> | > greater than+<a name="(line115)"></a> | >= greater than or equal to+<a name="(line116)"></a>+<a name="(line117)"></a> nop = .=. equal to+<a name="(line118)"></a> | .!=. not equal to+<a name="(line119)"></a> | .<. less than+<a name="(line120)"></a> | .<=. less than or equal to+<a name="(line121)"></a> | .>. greater than+<a name="(line122)"></a> | .>=. greater than or equal to+<a name="(line123)"></a>+<a name="(line124)"></a> positions = position {, positions} multiple positions+<a name="(line125)"></a> | position - position ranges+<a name="(line126)"></a>+<a name="(line127)"></a> position = integer numbering is from 0 upwards+<a name="(line128)"></a> | $ last <a name="(line129)"></a>-<a name="(line130)"></a>---- transformed grammar (removing left recursion)-<a name="(line131)"></a> aquery = ./ tquery -- current context-<a name="(line132)"></a> | tquery -- also current context-<a name="(line133)"></a> | / tquery -- root context-<a name="(line134)"></a> | // tquery -- deep context from root-<a name="(line135)"></a>-<a name="(line136)"></a> tquery = ( tquery ) xquery-<a name="(line137)"></a> | tag xquery-<a name="(line138)"></a> | - -- fixes original grammar ("-/*" is incorrect)-<a name="(line139)"></a> -<a name="(line140)"></a> tag = string *-<a name="(line141)"></a> | string-<a name="(line142)"></a> | * string-<a name="(line143)"></a> | *-<a name="(line144)"></a> -<a name="(line145)"></a> xquery = / tquery-<a name="(line146)"></a> | // tquery-<a name="(line147)"></a> | / @ string -- new: print attribute value-<a name="(line148)"></a> | + tquery-<a name="(line149)"></a> | [ tpredicate ] xquery-<a name="(line150)"></a> | [ positions ] xquery-<a name="(line151)"></a> | lambda-<a name="(line152)"></a>-<a name="(line153)"></a> tpredicate = vpredicate upredicate-<a name="(line154)"></a> upredicate = & tpredicate-<a name="(line155)"></a> | | tpredicate-<a name="(line156)"></a> | lambda-<a name="(line157)"></a> vpredicate = ( tpredicate )-<a name="(line158)"></a> | ~ tpredicate-<a name="(line159)"></a> | tattribute-<a name="(line160)"></a>-<a name="(line161)"></a> tattribute = aquery uattribute-<a name="(line162)"></a> | @ string vattribute-<a name="(line163)"></a> uattribute = / @ string vattribute-<a name="(line164)"></a> | vattribute-<a name="(line165)"></a> vattribute = op wattribute-<a name="(line166)"></a> | op ' string '-<a name="(line167)"></a> | nop wattribute-<a name="(line168)"></a> | nop integer-<a name="(line169)"></a> | lambda-<a name="(line170)"></a> wattribute = @ string-<a name="(line171)"></a> | aquery / @ string-<a name="(line172)"></a> | aquery-<a name="(line173)"></a>-<a name="(line174)"></a> positions = simplepos commapos-<a name="(line175)"></a> simplepos = integer range-<a name="(line176)"></a> | $-<a name="(line177)"></a> range = - integer-<a name="(line178)"></a> | - $-<a name="(line179)"></a> | lambda-<a name="(line180)"></a> commapos = , simplepos commapos-<a name="(line181)"></a> | lambda-<a name="(line182)"></a>-<a name="(line183)"></a> op = =-<a name="(line184)"></a> | !=-<a name="(line185)"></a> | <-<a name="(line186)"></a> | <=-<a name="(line187)"></a> | >-<a name="(line188)"></a> | >=-<a name="(line189)"></a>-<a name="(line190)"></a> nop = .=.-<a name="(line191)"></a> | .!=.-<a name="(line192)"></a> | .<.-<a name="(line193)"></a> | .<=.-<a name="(line194)"></a> | .>.-<a name="(line195)"></a> | .>=.-<a name="(line196)"></a>-}</font>-<a name="(line197)"></a>-<a name="(line198)"></a><a name="bracket"></a>bracket <font color=Red>::</font> XParser a <font color=Red>-></font> XParser a-<a name="(line199)"></a>bracket p <font color=Red>=</font>-<a name="(line200)"></a> <font color=Green><u>do</u></font> symbol <font color=Magenta>"("</font>-<a name="(line201)"></a> x <font color=Red><-</font> p-<a name="(line202)"></a> symbol <font color=Magenta>")"</font>-<a name="(line203)"></a> return x-<a name="(line204)"></a>+<a name="(line130)"></a>+<a name="(line131)"></a>---- transformed grammar (removing left recursion)+<a name="(line132)"></a> aquery = ./ tquery -- current context+<a name="(line133)"></a> | tquery -- also current context+<a name="(line134)"></a> | / tquery -- root context+<a name="(line135)"></a> | // tquery -- deep context from root+<a name="(line136)"></a>+<a name="(line137)"></a> tquery = ( tquery ) xquery+<a name="(line138)"></a> | tag xquery+<a name="(line139)"></a> | - -- fixes original grammar ("-/*" is incorrect)+<a name="(line140)"></a> +<a name="(line141)"></a> tag = string *+<a name="(line142)"></a> | string+<a name="(line143)"></a> | * string+<a name="(line144)"></a> | *+<a name="(line145)"></a> +<a name="(line146)"></a> xquery = / tquery+<a name="(line147)"></a> | // tquery+<a name="(line148)"></a> | / @ string -- new: print attribute value+<a name="(line149)"></a> | + tquery+<a name="(line150)"></a> | [ tpredicate ] xquery+<a name="(line151)"></a> | [ positions ] xquery+<a name="(line152)"></a> | lambda+<a name="(line153)"></a>+<a name="(line154)"></a> tpredicate = vpredicate upredicate+<a name="(line155)"></a> upredicate = & tpredicate+<a name="(line156)"></a> | | tpredicate+<a name="(line157)"></a> | lambda+<a name="(line158)"></a> vpredicate = ( tpredicate )+<a name="(line159)"></a> | ~ tpredicate+<a name="(line160)"></a> | tattribute+<a name="(line161)"></a>+<a name="(line162)"></a> tattribute = aquery uattribute+<a name="(line163)"></a> | @ string vattribute+<a name="(line164)"></a> uattribute = / @ string vattribute+<a name="(line165)"></a> | vattribute+<a name="(line166)"></a> vattribute = op wattribute+<a name="(line167)"></a> | op ' string '+<a name="(line168)"></a> | nop wattribute+<a name="(line169)"></a> | nop integer+<a name="(line170)"></a> | lambda+<a name="(line171)"></a> wattribute = @ string+<a name="(line172)"></a> | aquery / @ string+<a name="(line173)"></a> | aquery+<a name="(line174)"></a>+<a name="(line175)"></a> positions = simplepos commapos+<a name="(line176)"></a> simplepos = integer range+<a name="(line177)"></a> | $+<a name="(line178)"></a> range = - integer+<a name="(line179)"></a> | - $+<a name="(line180)"></a> | lambda+<a name="(line181)"></a> commapos = , simplepos commapos+<a name="(line182)"></a> | lambda+<a name="(line183)"></a>+<a name="(line184)"></a> op = =+<a name="(line185)"></a> | !=+<a name="(line186)"></a> | <+<a name="(line187)"></a> | <=+<a name="(line188)"></a> | >+<a name="(line189)"></a> | >=+<a name="(line190)"></a>+<a name="(line191)"></a> nop = .=.+<a name="(line192)"></a> | .!=.+<a name="(line193)"></a> | .<.+<a name="(line194)"></a> | .<=.+<a name="(line195)"></a> | .>.+<a name="(line196)"></a> | .>=.+<a name="(line197)"></a>-}</font>+<a name="(line198)"></a>+<a name="(line199)"></a><a name="bracket"></a>bracket <font color=Red>::</font> XParser a <font color=Red>-></font> XParser a+<a name="(line200)"></a>bracket p <font color=Red>=</font>+<a name="(line201)"></a> <font color=Green><u>do</u></font> symbol <font color=Magenta>"("</font>+<a name="(line202)"></a> x <font color=Red><-</font> p+<a name="(line203)"></a> symbol <font color=Magenta>")"</font>+<a name="(line204)"></a> return x <a name="(line205)"></a>-<a name="(line206)"></a><font color=Blue>---- Xtract parsers ----</font>-<a name="(line207)"></a>-<a name="(line208)"></a><a name="aquery"></a><font color=Blue>-- aquery chooses to search from the root, or only in local context</font>-<a name="(line209)"></a>aquery <font color=Red>::</font> <font color=Cyan>(</font><font color=Cyan>(</font>CFilter i<font color=Red>-></font>CFilter i<font color=Cyan>)</font> <font color=Red>-></font> <font color=Cyan>(</font>DFilter i<font color=Red>-></font>DFilter i<font color=Cyan>)</font><font color=Cyan>)</font>-<a name="(line210)"></a> <font color=Red>-></font> XParser <font color=Cyan>(</font>DFilter i<font color=Cyan>)</font>-<a name="(line211)"></a>aquery lift <font color=Red>=</font> oneOf-<a name="(line212)"></a> <font color=Red>[</font> <font color=Green><u>do</u></font> symbol <font color=Magenta>"//"</font>-<a name="(line213)"></a> tquery <font color=Red>[</font>lift C<font color=Cyan>.</font>multi<font color=Red>]</font>-<a name="(line214)"></a> <font color=Cyan>,</font> <font color=Green><u>do</u></font> symbol <font color=Magenta>"/"</font>-<a name="(line215)"></a> tquery <font color=Red>[</font>lift id<font color=Red>]</font>-<a name="(line216)"></a> <font color=Cyan>,</font> <font color=Green><u>do</u></font> symbol <font color=Magenta>"./"</font>-<a name="(line217)"></a> tquery <font color=Red>[</font><font color=Cyan>(</font>local C<font color=Cyan>.</font>keep D<font color=Cyan>./></font><font color=Cyan>)</font><font color=Red>]</font>-<a name="(line218)"></a> <font color=Cyan>,</font> <font color=Green><u>do</u></font> tquery <font color=Red>[</font><font color=Cyan>(</font>local C<font color=Cyan>.</font>keep D<font color=Cyan>./></font><font color=Cyan>)</font><font color=Red>]</font>-<a name="(line219)"></a> <font color=Red>]</font>-<a name="(line220)"></a>-<a name="(line221)"></a><a name="tquery"></a>tquery <font color=Red>::</font> <font color=Red>[</font>DFilter i<font color=Red>-></font>DFilter i<font color=Red>]</font> <font color=Red>-></font> XParser <font color=Cyan>(</font>DFilter i<font color=Cyan>)</font>-<a name="(line222)"></a>tquery [] <font color=Red>=</font> tquery <font color=Red>[</font>id<font color=Red>]</font>-<a name="(line223)"></a>tquery <font color=Cyan>(</font>qf<font color=Red><b>:</b></font>cxt<font color=Cyan>)</font> <font color=Red>=</font> oneOf-<a name="(line224)"></a> <font color=Red>[</font> <font color=Green><u>do</u></font> q <font color=Red><-</font> bracket <font color=Cyan>(</font>tquery <font color=Cyan>(</font>qf<font color=Red><b>:</b></font>qf<font color=Red><b>:</b></font>cxt<font color=Cyan>)</font><font color=Cyan>)</font>-<a name="(line225)"></a> xquery cxt q-<a name="(line226)"></a> <font color=Cyan>,</font> <font color=Green><u>do</u></font> q <font color=Red><-</font> xtag-<a name="(line227)"></a> xquery cxt <font color=Cyan>(</font>qf <font color=Cyan>(</font><font color=Cyan>(</font>unescape <font color=Cyan>.</font><font color=Cyan>)</font><font color=Cyan>.</font>q<font color=Cyan>)</font><font color=Cyan>)</font> <font color=Blue>-- glue inners texts together</font>-<a name="(line228)"></a> <font color=Cyan>,</font> <font color=Green><u>do</u></font> symbol <font color=Magenta>"-"</font>-<a name="(line229)"></a> return <font color=Cyan>(</font>qf <font color=Cyan>(</font>local C<font color=Cyan>.</font>txt<font color=Cyan>)</font><font color=Cyan>)</font>-<a name="(line230)"></a> <font color=Red>]</font>-<a name="(line231)"></a>-<a name="(line232)"></a><a name="xtag"></a>xtag <font color=Red>::</font> XParser <font color=Cyan>(</font>DFilter i<font color=Cyan>)</font>-<a name="(line233)"></a>xtag <font color=Red>=</font> oneOf-<a name="(line234)"></a> <font color=Red>[</font> <font color=Green><u>do</u></font> s <font color=Red><-</font> string-<a name="(line235)"></a> symbol <font color=Magenta>"*"</font>-<a name="(line236)"></a> return <font color=Cyan>(</font>local <font color=Cyan>(</font>C<font color=Cyan>.</font>tagWith <font color=Cyan>(</font>s <font color=Cyan>`isPrefixOf`</font><font color=Cyan>)</font><font color=Cyan>)</font><font color=Cyan>)</font>-<a name="(line237)"></a> <font color=Cyan>,</font> <font color=Green><u>do</u></font> s <font color=Red><-</font> string-<a name="(line238)"></a> return <font color=Cyan>(</font>local <font color=Cyan>(</font>C<font color=Cyan>.</font>tag s<font color=Cyan>)</font><font color=Cyan>)</font>-<a name="(line239)"></a> <font color=Cyan>,</font> <font color=Green><u>do</u></font> symbol <font color=Magenta>"*"</font>-<a name="(line240)"></a> s <font color=Red><-</font> string-<a name="(line241)"></a> return <font color=Cyan>(</font>local <font color=Cyan>(</font>C<font color=Cyan>.</font>tagWith <font color=Cyan>(</font><font color=Cyan>(</font><font color=Cyan>(</font>reverse s<font color=Cyan>)</font> <font color=Cyan>`isPrefixOf`</font><font color=Cyan>)</font> <font color=Cyan>.</font> reverse<font color=Cyan>)</font><font color=Cyan>)</font><font color=Cyan>)</font>-<a name="(line242)"></a> <font color=Cyan>,</font> <font color=Green><u>do</u></font> symbol <font color=Magenta>"*"</font>-<a name="(line243)"></a> return <font color=Cyan>(</font>local C<font color=Cyan>.</font>elm<font color=Cyan>)</font>-<a name="(line244)"></a> <font color=Red>]</font>-<a name="(line245)"></a>+<a name="(line206)"></a>+<a name="(line207)"></a><font color=Blue>---- Xtract parsers ----</font>+<a name="(line208)"></a>+<a name="(line209)"></a><a name="aquery"></a><font color=Blue>-- aquery chooses to search from the root, or only in local context</font>+<a name="(line210)"></a>aquery <font color=Red>::</font> <font color=Cyan>(</font><font color=Cyan>(</font>CFilter i<font color=Red>-></font>CFilter i<font color=Cyan>)</font> <font color=Red>-></font> <font color=Cyan>(</font>DFilter i<font color=Red>-></font>DFilter i<font color=Cyan>)</font><font color=Cyan>)</font>+<a name="(line211)"></a> <font color=Red>-></font> XParser <font color=Cyan>(</font>DFilter i<font color=Cyan>)</font>+<a name="(line212)"></a>aquery lift <font color=Red>=</font> oneOf+<a name="(line213)"></a> <font color=Red>[</font> <font color=Green><u>do</u></font> symbol <font color=Magenta>"//"</font>+<a name="(line214)"></a> tquery <font color=Red>[</font>lift C<font color=Cyan>.</font>multi<font color=Red>]</font>+<a name="(line215)"></a> <font color=Cyan>,</font> <font color=Green><u>do</u></font> symbol <font color=Magenta>"/"</font>+<a name="(line216)"></a> tquery <font color=Red>[</font>lift id<font color=Red>]</font>+<a name="(line217)"></a> <font color=Cyan>,</font> <font color=Green><u>do</u></font> symbol <font color=Magenta>"./"</font>+<a name="(line218)"></a> tquery <font color=Red>[</font><font color=Cyan>(</font>local C<font color=Cyan>.</font>keep D<font color=Cyan>./></font><font color=Cyan>)</font><font color=Red>]</font>+<a name="(line219)"></a> <font color=Cyan>,</font> <font color=Green><u>do</u></font> tquery <font color=Red>[</font><font color=Cyan>(</font>local C<font color=Cyan>.</font>keep D<font color=Cyan>./></font><font color=Cyan>)</font><font color=Red>]</font>+<a name="(line220)"></a> <font color=Red>]</font>+<a name="(line221)"></a>+<a name="(line222)"></a><a name="tquery"></a>tquery <font color=Red>::</font> <font color=Red>[</font>DFilter i<font color=Red>-></font>DFilter i<font color=Red>]</font> <font color=Red>-></font> XParser <font color=Cyan>(</font>DFilter i<font color=Cyan>)</font>+<a name="(line223)"></a>tquery [] <font color=Red>=</font> tquery <font color=Red>[</font>id<font color=Red>]</font>+<a name="(line224)"></a>tquery <font color=Cyan>(</font>qf<font color=Red><b>:</b></font>cxt<font color=Cyan>)</font> <font color=Red>=</font> oneOf+<a name="(line225)"></a> <font color=Red>[</font> <font color=Green><u>do</u></font> q <font color=Red><-</font> bracket <font color=Cyan>(</font>tquery <font color=Cyan>(</font>qf<font color=Red><b>:</b></font>qf<font color=Red><b>:</b></font>cxt<font color=Cyan>)</font><font color=Cyan>)</font>+<a name="(line226)"></a> xquery cxt q+<a name="(line227)"></a> <font color=Cyan>,</font> <font color=Green><u>do</u></font> q <font color=Red><-</font> xtag+<a name="(line228)"></a> xquery cxt <font color=Cyan>(</font>qf <font color=Cyan>(</font><font color=Cyan>(</font>unescape <font color=Cyan>.</font><font color=Cyan>)</font><font color=Cyan>.</font>q<font color=Cyan>)</font><font color=Cyan>)</font> <font color=Blue>-- glue inners texts together</font>+<a name="(line229)"></a> <font color=Cyan>,</font> <font color=Green><u>do</u></font> symbol <font color=Magenta>"-"</font>+<a name="(line230)"></a> return <font color=Cyan>(</font>qf <font color=Cyan>(</font>local C<font color=Cyan>.</font>txt<font color=Cyan>)</font><font color=Cyan>)</font>+<a name="(line231)"></a> <font color=Red>]</font>+<a name="(line232)"></a>+<a name="(line233)"></a><a name="xtag"></a>xtag <font color=Red>::</font> XParser <font color=Cyan>(</font>DFilter i<font color=Cyan>)</font>+<a name="(line234)"></a>xtag <font color=Red>=</font> oneOf+<a name="(line235)"></a> <font color=Red>[</font> <font color=Green><u>do</u></font> s <font color=Red><-</font> string+<a name="(line236)"></a> symbol <font color=Magenta>"*"</font>+<a name="(line237)"></a> return <font color=Cyan>(</font>local <font color=Cyan>(</font>C<font color=Cyan>.</font>tagWith <font color=Cyan>(</font>s <font color=Cyan>`isPrefixOf`</font><font color=Cyan>)</font><font color=Cyan>)</font><font color=Cyan>)</font>+<a name="(line238)"></a> <font color=Cyan>,</font> <font color=Green><u>do</u></font> s <font color=Red><-</font> string+<a name="(line239)"></a> return <font color=Cyan>(</font>local <font color=Cyan>(</font>C<font color=Cyan>.</font>tag s<font color=Cyan>)</font><font color=Cyan>)</font>+<a name="(line240)"></a> <font color=Cyan>,</font> <font color=Green><u>do</u></font> symbol <font color=Magenta>"*"</font>+<a name="(line241)"></a> s <font color=Red><-</font> string+<a name="(line242)"></a> return <font color=Cyan>(</font>local <font color=Cyan>(</font>C<font color=Cyan>.</font>tagWith <font color=Cyan>(</font><font color=Cyan>(</font><font color=Cyan>(</font>reverse s<font color=Cyan>)</font> <font color=Cyan>`isPrefixOf`</font><font color=Cyan>)</font> <font color=Cyan>.</font> reverse<font color=Cyan>)</font><font color=Cyan>)</font><font color=Cyan>)</font>+<a name="(line243)"></a> <font color=Cyan>,</font> <font color=Green><u>do</u></font> symbol <font color=Magenta>"*"</font>+<a name="(line244)"></a> return <font color=Cyan>(</font>local C<font color=Cyan>.</font>elm<font color=Cyan>)</font>+<a name="(line245)"></a> <font color=Red>]</font> <a name="(line246)"></a>-<a name="(line247)"></a><a name="xquery"></a>xquery <font color=Red>::</font> <font color=Red>[</font>DFilter i<font color=Red>-></font>DFilter i<font color=Red>]</font> <font color=Red>-></font> DFilter i <font color=Red>-></font> XParser <font color=Cyan>(</font>DFilter i<font color=Cyan>)</font>-<a name="(line248)"></a>xquery cxt q1 <font color=Red>=</font> oneOf-<a name="(line249)"></a> <font color=Red>[</font> <font color=Green><u>do</u></font> symbol <font color=Magenta>"/"</font>-<a name="(line250)"></a> <font color=Cyan>(</font> <font color=Green><u>do</u></font> symbol <font color=Magenta>"@"</font>-<a name="(line251)"></a> attr <font color=Red><-</font> string-<a name="(line252)"></a> return <font color=Cyan>(</font>D<font color=Cyan>.</font>iffind attr <font color=Cyan>(</font><font color=Red>\</font>s<font color=Red>-></font>local <font color=Cyan>(</font>C<font color=Cyan>.</font>literal s<font color=Cyan>)</font><font color=Cyan>)</font> D<font color=Cyan>.</font>none <font color=Cyan>`</font>D<font color=Cyan>.</font>o<font color=Cyan>`</font> q1<font color=Cyan>)</font>-<a name="(line253)"></a> <font color=Cyan>`onFail`</font>-<a name="(line254)"></a> tquery <font color=Cyan>(</font><font color=Cyan>(</font>q1 D<font color=Cyan>./></font><font color=Cyan>)</font><font color=Red><b>:</b></font>cxt<font color=Cyan>)</font> <font color=Cyan>)</font>-<a name="(line255)"></a> <font color=Cyan>,</font> <font color=Green><u>do</u></font> symbol <font color=Magenta>"//"</font>-<a name="(line256)"></a> tquery <font color=Cyan>(</font><font color=Cyan>(</font><font color=Red>\</font>q2<font color=Red>-></font> <font color=Cyan>(</font>liftLocal C<font color=Cyan>.</font>multi<font color=Cyan>)</font> q2-<a name="(line257)"></a> <font color=Cyan>`</font>D<font color=Cyan>.</font>o<font color=Cyan>`</font> local C<font color=Cyan>.</font>children <font color=Cyan>`</font>D<font color=Cyan>.</font>o<font color=Cyan>`</font> q1<font color=Cyan>)</font><font color=Red><b>:</b></font>cxt<font color=Cyan>)</font>-<a name="(line258)"></a> <font color=Cyan>,</font> <font color=Green><u>do</u></font> symbol <font color=Magenta>"+"</font>-<a name="(line259)"></a> q2 <font color=Red><-</font> tquery cxt-<a name="(line260)"></a> return <font color=Cyan>(</font>D<font color=Cyan>.</font>cat <font color=Red>[</font>q1<font color=Cyan>,</font>q2<font color=Red>]</font><font color=Cyan>)</font>-<a name="(line261)"></a> <font color=Cyan>,</font> <font color=Green><u>do</u></font> symbol <font color=Magenta>"["</font>-<a name="(line262)"></a> is <font color=Red><-</font> iindex <font color=Blue>-- now extended to multiple indexes</font>-<a name="(line263)"></a> symbol <font color=Magenta>"]"</font>-<a name="(line264)"></a> xquery cxt <font color=Cyan>(</font><font color=Red>\</font>xml<font color=Red>-></font> concat <font color=Cyan>.</font> pam is <font color=Cyan>.</font> q1 xml<font color=Cyan>)</font>-<a name="(line265)"></a> <font color=Cyan>,</font> <font color=Green><u>do</u></font> symbol <font color=Magenta>"["</font>-<a name="(line266)"></a> p <font color=Red><-</font> tpredicate-<a name="(line267)"></a> symbol <font color=Magenta>"]"</font>-<a name="(line268)"></a> xquery cxt <font color=Cyan>(</font>q1 <font color=Cyan>`</font>D<font color=Cyan>.</font>with<font color=Cyan>`</font> p<font color=Cyan>)</font>-<a name="(line269)"></a> <font color=Cyan>,</font> return q1-<a name="(line270)"></a> <font color=Red>]</font>-<a name="(line271)"></a>-<a name="(line272)"></a><a name="tpredicate"></a>tpredicate <font color=Red>::</font> XParser <font color=Cyan>(</font>DFilter i<font color=Cyan>)</font>-<a name="(line273)"></a>tpredicate <font color=Red>=</font>-<a name="(line274)"></a> <font color=Green><u>do</u></font> p <font color=Red><-</font> vpredicate-<a name="(line275)"></a> f <font color=Red><-</font> upredicate-<a name="(line276)"></a> return <font color=Cyan>(</font>f p<font color=Cyan>)</font>-<a name="(line277)"></a>-<a name="(line278)"></a><a name="upredicate"></a>upredicate <font color=Red>::</font> XParser <font color=Cyan>(</font>DFilter i<font color=Red>-></font>DFilter i<font color=Cyan>)</font>-<a name="(line279)"></a>upredicate <font color=Red>=</font> oneOf-<a name="(line280)"></a> <font color=Red>[</font> <font color=Green><u>do</u></font> symbol <font color=Magenta>"&"</font>-<a name="(line281)"></a> p2 <font color=Red><-</font> tpredicate-<a name="(line282)"></a> return <font color=Cyan>(</font><font color=Cyan>`</font>D<font color=Cyan>.</font>o<font color=Cyan>`</font> p2<font color=Cyan>)</font>-<a name="(line283)"></a> <font color=Cyan>,</font> <font color=Green><u>do</u></font> symbol <font color=Magenta>"|"</font>-<a name="(line284)"></a> p2 <font color=Red><-</font> tpredicate-<a name="(line285)"></a> return <font color=Cyan>(</font>D<font color=Cyan>.|>|</font> p2<font color=Cyan>)</font>-<a name="(line286)"></a> <font color=Cyan>,</font> return id-<a name="(line287)"></a> <font color=Red>]</font>-<a name="(line288)"></a>-<a name="(line289)"></a><a name="vpredicate"></a>vpredicate <font color=Red>::</font> XParser <font color=Cyan>(</font>DFilter i<font color=Cyan>)</font>-<a name="(line290)"></a>vpredicate <font color=Red>=</font> oneOf-<a name="(line291)"></a> <font color=Red>[</font> <font color=Green><u>do</u></font> bracket tpredicate-<a name="(line292)"></a> <font color=Cyan>,</font> <font color=Green><u>do</u></font> symbol <font color=Magenta>"~"</font>-<a name="(line293)"></a> p <font color=Red><-</font> tpredicate-<a name="(line294)"></a> return <font color=Cyan>(</font>local C<font color=Cyan>.</font>keep <font color=Cyan>`</font>D<font color=Cyan>.</font>without<font color=Cyan>`</font> p<font color=Cyan>)</font>-<a name="(line295)"></a> <font color=Cyan>,</font> <font color=Green><u>do</u></font> tattribute-<a name="(line296)"></a> <font color=Red>]</font>-<a name="(line297)"></a>-<a name="(line298)"></a><a name="tattribute"></a>tattribute <font color=Red>::</font> XParser <font color=Cyan>(</font>DFilter i<font color=Cyan>)</font>-<a name="(line299)"></a>tattribute <font color=Red>=</font> oneOf-<a name="(line300)"></a> <font color=Red>[</font> <font color=Green><u>do</u></font> q <font color=Red><-</font> aquery liftGlobal-<a name="(line301)"></a> uattribute q-<a name="(line302)"></a> <font color=Cyan>,</font> <font color=Green><u>do</u></font> symbol <font color=Magenta>"@"</font>-<a name="(line303)"></a> s <font color=Red><-</font> string-<a name="(line304)"></a> vattribute <font color=Cyan>(</font>local C<font color=Cyan>.</font>keep<font color=Cyan>,</font> local <font color=Cyan>(</font>C<font color=Cyan>.</font>attr s<font color=Cyan>)</font><font color=Cyan>,</font> D<font color=Cyan>.</font>iffind s<font color=Cyan>)</font>-<a name="(line305)"></a> <font color=Red>]</font>-<a name="(line306)"></a>-<a name="(line307)"></a><a name="uattribute"></a>uattribute <font color=Red>::</font> DFilter i <font color=Red>-></font> XParser <font color=Cyan>(</font>DFilter i<font color=Cyan>)</font>-<a name="(line308)"></a>uattribute q <font color=Red>=</font> oneOf-<a name="(line309)"></a> <font color=Red>[</font> <font color=Green><u>do</u></font> symbol <font color=Magenta>"/"</font>-<a name="(line310)"></a> symbol <font color=Magenta>"@"</font>-<a name="(line311)"></a> s <font color=Red><-</font> string-<a name="(line312)"></a> vattribute <font color=Cyan>(</font>q<font color=Cyan>,</font> local <font color=Cyan>(</font>C<font color=Cyan>.</font>attr s<font color=Cyan>)</font><font color=Cyan>,</font> D<font color=Cyan>.</font>iffind s<font color=Cyan>)</font>-<a name="(line313)"></a> <font color=Cyan>,</font> <font color=Green><u>do</u></font> vattribute <font color=Cyan>(</font>q<font color=Cyan>,</font> local C<font color=Cyan>.</font>keep<font color=Cyan>,</font> D<font color=Cyan>.</font>ifTxt<font color=Cyan>)</font>-<a name="(line314)"></a> <font color=Red>]</font>-<a name="(line315)"></a>-<a name="(line316)"></a><a name="vattribute"></a>vattribute <font color=Red>::</font> <font color=Cyan>(</font>DFilter i<font color=Cyan>,</font> DFilter i<font color=Cyan>,</font> <font color=Cyan>(</font>String<font color=Red>-></font>DFilter i<font color=Cyan>)</font><font color=Red>-></font>DFilter i<font color=Red>-></font>DFilter i<font color=Cyan>)</font>-<a name="(line317)"></a> <font color=Red>-></font> XParser <font color=Cyan>(</font>DFilter i<font color=Cyan>)</font>-<a name="(line318)"></a>vattribute <font color=Cyan>(</font>q<font color=Cyan>,</font>a<font color=Cyan>,</font>iffn<font color=Cyan>)</font> <font color=Red>=</font> oneOf-<a name="(line319)"></a> <font color=Red>[</font> <font color=Green><u>do</u></font> cmp <font color=Red><-</font> op-<a name="(line320)"></a> quote-<a name="(line321)"></a> s2 <font color=Red><-</font> string-<a name="(line322)"></a> quote-<a name="(line323)"></a> return <font color=Cyan>(</font><font color=Cyan>(</font>iffn <font color=Cyan>(</font><font color=Red>\</font>s1<font color=Red>-></font><font color=Green><u>if</u></font> cmp s1 s2 <font color=Green><u>then</u></font> D<font color=Cyan>.</font>keep <font color=Green><u>else</u></font> D<font color=Cyan>.</font>none<font color=Cyan>)</font> D<font color=Cyan>.</font>none<font color=Cyan>)</font>-<a name="(line324)"></a> <font color=Cyan>`</font>D<font color=Cyan>.</font>o<font color=Cyan>`</font> q<font color=Cyan>)</font>-<a name="(line325)"></a> <font color=Cyan>,</font> <font color=Green><u>do</u></font> cmp <font color=Red><-</font> op-<a name="(line326)"></a> <font color=Cyan>(</font>q2<font color=Cyan>,</font>iffn2<font color=Cyan>)</font> <font color=Red><-</font> wattribute-<a name="(line327)"></a> return <font color=Cyan>(</font><font color=Cyan>(</font>iffn <font color=Cyan>(</font><font color=Red>\</font>s1<font color=Red>-></font> iffn2 <font color=Cyan>(</font><font color=Red>\</font>s2<font color=Red>-></font> <font color=Green><u>if</u></font> cmp s1 s2 <font color=Green><u>then</u></font> D<font color=Cyan>.</font>keep <font color=Green><u>else</u></font> D<font color=Cyan>.</font>none<font color=Cyan>)</font>-<a name="(line328)"></a> D<font color=Cyan>.</font>none<font color=Cyan>)</font>-<a name="(line329)"></a> D<font color=Cyan>.</font>none<font color=Cyan>)</font> <font color=Cyan>`</font>D<font color=Cyan>.</font>o<font color=Cyan>`</font> q<font color=Cyan>)</font>-<a name="(line330)"></a> <font color=Cyan>,</font> <font color=Green><u>do</u></font> cmp <font color=Red><-</font> nop-<a name="(line331)"></a> n <font color=Red><-</font> number-<a name="(line332)"></a> return <font color=Cyan>(</font><font color=Cyan>(</font>iffn <font color=Cyan>(</font><font color=Red>\</font>s<font color=Red>-></font><font color=Green><u>if</u></font> cmp <font color=Cyan>(</font>read s<font color=Cyan>)</font> n <font color=Green><u>then</u></font> D<font color=Cyan>.</font>keep <font color=Green><u>else</u></font> D<font color=Cyan>.</font>none<font color=Cyan>)</font> D<font color=Cyan>.</font>none<font color=Cyan>)</font>-<a name="(line333)"></a> <font color=Cyan>`</font>D<font color=Cyan>.</font>o<font color=Cyan>`</font> q<font color=Cyan>)</font>-<a name="(line334)"></a> <font color=Cyan>,</font> <font color=Green><u>do</u></font> cmp <font color=Red><-</font> nop-<a name="(line335)"></a> <font color=Cyan>(</font>q2<font color=Cyan>,</font>iffn2<font color=Cyan>)</font> <font color=Red><-</font> wattribute-<a name="(line336)"></a> return <font color=Cyan>(</font><font color=Cyan>(</font>iffn <font color=Cyan>(</font><font color=Red>\</font>s1<font color=Red>-></font> iffn2 <font color=Cyan>(</font><font color=Red>\</font>s2<font color=Red>-></font> <font color=Green><u>if</u></font> cmp <font color=Cyan>(</font>read s1<font color=Cyan>)</font> <font color=Cyan>(</font>read s2<font color=Cyan>)</font> <font color=Green><u>then</u></font> D<font color=Cyan>.</font>keep-<a name="(line337)"></a> <font color=Green><u>else</u></font> D<font color=Cyan>.</font>none<font color=Cyan>)</font>-<a name="(line338)"></a> D<font color=Cyan>.</font>none<font color=Cyan>)</font>-<a name="(line339)"></a> D<font color=Cyan>.</font>none<font color=Cyan>)</font> <font color=Cyan>`</font>D<font color=Cyan>.</font>o<font color=Cyan>`</font> q<font color=Cyan>)</font>-<a name="(line340)"></a> <font color=Cyan>,</font> <font color=Green><u>do</u></font> return <font color=Cyan>(</font><font color=Cyan>(</font>a <font color=Cyan>`</font>D<font color=Cyan>.</font>o<font color=Cyan>`</font> q<font color=Cyan>)</font><font color=Cyan>)</font>-<a name="(line341)"></a> <font color=Red>]</font>-<a name="(line342)"></a>-<a name="(line343)"></a><a name="wattribute"></a>wattribute <font color=Red>::</font> XParser <font color=Cyan>(</font>DFilter i<font color=Cyan>,</font> <font color=Cyan>(</font>String<font color=Red>-></font>DFilter i<font color=Cyan>)</font><font color=Red>-></font>DFilter i<font color=Red>-></font>DFilter i<font color=Cyan>)</font>-<a name="(line344)"></a>wattribute <font color=Red>=</font> oneOf-<a name="(line345)"></a> <font color=Red>[</font> <font color=Green><u>do</u></font> symbol <font color=Magenta>"@"</font>-<a name="(line346)"></a> s <font color=Red><-</font> string-<a name="(line347)"></a> return <font color=Cyan>(</font>D<font color=Cyan>.</font>keep<font color=Cyan>,</font> D<font color=Cyan>.</font>iffind s<font color=Cyan>)</font>-<a name="(line348)"></a> <font color=Cyan>,</font> <font color=Green><u>do</u></font> q <font color=Red><-</font> aquery liftGlobal-<a name="(line349)"></a> symbol <font color=Magenta>"/"</font>-<a name="(line350)"></a> symbol <font color=Magenta>"@"</font>-<a name="(line351)"></a> s <font color=Red><-</font> string-<a name="(line352)"></a> return <font color=Cyan>(</font>q<font color=Cyan>,</font> D<font color=Cyan>.</font>iffind s<font color=Cyan>)</font>-<a name="(line353)"></a> <font color=Cyan>,</font> <font color=Green><u>do</u></font> q <font color=Red><-</font> aquery liftGlobal-<a name="(line354)"></a> return <font color=Cyan>(</font>q<font color=Cyan>,</font> D<font color=Cyan>.</font>ifTxt<font color=Cyan>)</font>-<a name="(line355)"></a> <font color=Red>]</font>-<a name="(line356)"></a>+<a name="(line247)"></a>+<a name="(line248)"></a><a name="xquery"></a>xquery <font color=Red>::</font> <font color=Red>[</font>DFilter i<font color=Red>-></font>DFilter i<font color=Red>]</font> <font color=Red>-></font> DFilter i <font color=Red>-></font> XParser <font color=Cyan>(</font>DFilter i<font color=Cyan>)</font>+<a name="(line249)"></a>xquery cxt q1 <font color=Red>=</font> oneOf+<a name="(line250)"></a> <font color=Red>[</font> <font color=Green><u>do</u></font> symbol <font color=Magenta>"/"</font>+<a name="(line251)"></a> <font color=Cyan>(</font> <font color=Green><u>do</u></font> symbol <font color=Magenta>"@"</font>+<a name="(line252)"></a> attr <font color=Red><-</font> string+<a name="(line253)"></a> return <font color=Cyan>(</font>D<font color=Cyan>.</font>iffind attr <font color=Cyan>(</font><font color=Red>\</font>s<font color=Red>-></font>local <font color=Cyan>(</font>C<font color=Cyan>.</font>literal s<font color=Cyan>)</font><font color=Cyan>)</font> D<font color=Cyan>.</font>none <font color=Cyan>`</font>D<font color=Cyan>.</font>o<font color=Cyan>`</font> q1<font color=Cyan>)</font>+<a name="(line254)"></a> <font color=Cyan>`onFail`</font>+<a name="(line255)"></a> tquery <font color=Cyan>(</font><font color=Cyan>(</font>q1 D<font color=Cyan>./></font><font color=Cyan>)</font><font color=Red><b>:</b></font>cxt<font color=Cyan>)</font> <font color=Cyan>)</font>+<a name="(line256)"></a> <font color=Cyan>,</font> <font color=Green><u>do</u></font> symbol <font color=Magenta>"//"</font>+<a name="(line257)"></a> tquery <font color=Cyan>(</font><font color=Cyan>(</font><font color=Red>\</font>q2<font color=Red>-></font> <font color=Cyan>(</font>liftLocal C<font color=Cyan>.</font>multi<font color=Cyan>)</font> q2+<a name="(line258)"></a> <font color=Cyan>`</font>D<font color=Cyan>.</font>o<font color=Cyan>`</font> local C<font color=Cyan>.</font>children <font color=Cyan>`</font>D<font color=Cyan>.</font>o<font color=Cyan>`</font> q1<font color=Cyan>)</font><font color=Red><b>:</b></font>cxt<font color=Cyan>)</font>+<a name="(line259)"></a> <font color=Cyan>,</font> <font color=Green><u>do</u></font> symbol <font color=Magenta>"+"</font>+<a name="(line260)"></a> q2 <font color=Red><-</font> tquery cxt+<a name="(line261)"></a> return <font color=Cyan>(</font>D<font color=Cyan>.</font>cat <font color=Red>[</font>q1<font color=Cyan>,</font>q2<font color=Red>]</font><font color=Cyan>)</font>+<a name="(line262)"></a> <font color=Cyan>,</font> <font color=Green><u>do</u></font> symbol <font color=Magenta>"["</font>+<a name="(line263)"></a> is <font color=Red><-</font> iindex <font color=Blue>-- now extended to multiple indexes</font>+<a name="(line264)"></a> symbol <font color=Magenta>"]"</font>+<a name="(line265)"></a> xquery cxt <font color=Cyan>(</font><font color=Red>\</font>xml<font color=Red>-></font> concat <font color=Cyan>.</font> pam is <font color=Cyan>.</font> q1 xml<font color=Cyan>)</font>+<a name="(line266)"></a> <font color=Cyan>,</font> <font color=Green><u>do</u></font> symbol <font color=Magenta>"["</font>+<a name="(line267)"></a> p <font color=Red><-</font> tpredicate+<a name="(line268)"></a> symbol <font color=Magenta>"]"</font>+<a name="(line269)"></a> xquery cxt <font color=Cyan>(</font>q1 <font color=Cyan>`</font>D<font color=Cyan>.</font>with<font color=Cyan>`</font> p<font color=Cyan>)</font>+<a name="(line270)"></a> <font color=Cyan>,</font> return q1+<a name="(line271)"></a> <font color=Red>]</font>+<a name="(line272)"></a>+<a name="(line273)"></a><a name="tpredicate"></a>tpredicate <font color=Red>::</font> XParser <font color=Cyan>(</font>DFilter i<font color=Cyan>)</font>+<a name="(line274)"></a>tpredicate <font color=Red>=</font>+<a name="(line275)"></a> <font color=Green><u>do</u></font> p <font color=Red><-</font> vpredicate+<a name="(line276)"></a> f <font color=Red><-</font> upredicate+<a name="(line277)"></a> return <font color=Cyan>(</font>f p<font color=Cyan>)</font>+<a name="(line278)"></a>+<a name="(line279)"></a><a name="upredicate"></a>upredicate <font color=Red>::</font> XParser <font color=Cyan>(</font>DFilter i<font color=Red>-></font>DFilter i<font color=Cyan>)</font>+<a name="(line280)"></a>upredicate <font color=Red>=</font> oneOf+<a name="(line281)"></a> <font color=Red>[</font> <font color=Green><u>do</u></font> symbol <font color=Magenta>"&"</font>+<a name="(line282)"></a> p2 <font color=Red><-</font> tpredicate+<a name="(line283)"></a> return <font color=Cyan>(</font><font color=Cyan>`</font>D<font color=Cyan>.</font>o<font color=Cyan>`</font> p2<font color=Cyan>)</font>+<a name="(line284)"></a> <font color=Cyan>,</font> <font color=Green><u>do</u></font> symbol <font color=Magenta>"|"</font>+<a name="(line285)"></a> p2 <font color=Red><-</font> tpredicate+<a name="(line286)"></a> return <font color=Cyan>(</font>D<font color=Cyan>.|>|</font> p2<font color=Cyan>)</font>+<a name="(line287)"></a> <font color=Cyan>,</font> return id+<a name="(line288)"></a> <font color=Red>]</font>+<a name="(line289)"></a>+<a name="(line290)"></a><a name="vpredicate"></a>vpredicate <font color=Red>::</font> XParser <font color=Cyan>(</font>DFilter i<font color=Cyan>)</font>+<a name="(line291)"></a>vpredicate <font color=Red>=</font> oneOf+<a name="(line292)"></a> <font color=Red>[</font> <font color=Green><u>do</u></font> bracket tpredicate+<a name="(line293)"></a> <font color=Cyan>,</font> <font color=Green><u>do</u></font> symbol <font color=Magenta>"~"</font>+<a name="(line294)"></a> p <font color=Red><-</font> tpredicate+<a name="(line295)"></a> return <font color=Cyan>(</font>local C<font color=Cyan>.</font>keep <font color=Cyan>`</font>D<font color=Cyan>.</font>without<font color=Cyan>`</font> p<font color=Cyan>)</font>+<a name="(line296)"></a> <font color=Cyan>,</font> <font color=Green><u>do</u></font> tattribute+<a name="(line297)"></a> <font color=Red>]</font>+<a name="(line298)"></a>+<a name="(line299)"></a><a name="tattribute"></a>tattribute <font color=Red>::</font> XParser <font color=Cyan>(</font>DFilter i<font color=Cyan>)</font>+<a name="(line300)"></a>tattribute <font color=Red>=</font> oneOf+<a name="(line301)"></a> <font color=Red>[</font> <font color=Green><u>do</u></font> q <font color=Red><-</font> aquery liftGlobal+<a name="(line302)"></a> uattribute q+<a name="(line303)"></a> <font color=Cyan>,</font> <font color=Green><u>do</u></font> symbol <font color=Magenta>"@"</font>+<a name="(line304)"></a> s <font color=Red><-</font> string+<a name="(line305)"></a> vattribute <font color=Cyan>(</font>local C<font color=Cyan>.</font>keep<font color=Cyan>,</font> local <font color=Cyan>(</font>C<font color=Cyan>.</font>attr s<font color=Cyan>)</font><font color=Cyan>,</font> D<font color=Cyan>.</font>iffind s<font color=Cyan>)</font>+<a name="(line306)"></a> <font color=Red>]</font>+<a name="(line307)"></a>+<a name="(line308)"></a><a name="uattribute"></a>uattribute <font color=Red>::</font> DFilter i <font color=Red>-></font> XParser <font color=Cyan>(</font>DFilter i<font color=Cyan>)</font>+<a name="(line309)"></a>uattribute q <font color=Red>=</font> oneOf+<a name="(line310)"></a> <font color=Red>[</font> <font color=Green><u>do</u></font> symbol <font color=Magenta>"/"</font>+<a name="(line311)"></a> symbol <font color=Magenta>"@"</font>+<a name="(line312)"></a> s <font color=Red><-</font> string+<a name="(line313)"></a> vattribute <font color=Cyan>(</font>q<font color=Cyan>,</font> local <font color=Cyan>(</font>C<font color=Cyan>.</font>attr s<font color=Cyan>)</font><font color=Cyan>,</font> D<font color=Cyan>.</font>iffind s<font color=Cyan>)</font>+<a name="(line314)"></a> <font color=Cyan>,</font> <font color=Green><u>do</u></font> vattribute <font color=Cyan>(</font>q<font color=Cyan>,</font> local C<font color=Cyan>.</font>keep<font color=Cyan>,</font> D<font color=Cyan>.</font>ifTxt<font color=Cyan>)</font>+<a name="(line315)"></a> <font color=Red>]</font>+<a name="(line316)"></a>+<a name="(line317)"></a><a name="vattribute"></a>vattribute <font color=Red>::</font> <font color=Cyan>(</font>DFilter i<font color=Cyan>,</font> DFilter i<font color=Cyan>,</font> <font color=Cyan>(</font>String<font color=Red>-></font>DFilter i<font color=Cyan>)</font><font color=Red>-></font>DFilter i<font color=Red>-></font>DFilter i<font color=Cyan>)</font>+<a name="(line318)"></a> <font color=Red>-></font> XParser <font color=Cyan>(</font>DFilter i<font color=Cyan>)</font>+<a name="(line319)"></a>vattribute <font color=Cyan>(</font>q<font color=Cyan>,</font>a<font color=Cyan>,</font>iffn<font color=Cyan>)</font> <font color=Red>=</font> oneOf+<a name="(line320)"></a> <font color=Red>[</font> <font color=Green><u>do</u></font> cmp <font color=Red><-</font> op+<a name="(line321)"></a> quote+<a name="(line322)"></a> s2 <font color=Red><-</font> string+<a name="(line323)"></a> quote+<a name="(line324)"></a> return <font color=Cyan>(</font><font color=Cyan>(</font>iffn <font color=Cyan>(</font><font color=Red>\</font>s1<font color=Red>-></font><font color=Green><u>if</u></font> cmp s1 s2 <font color=Green><u>then</u></font> D<font color=Cyan>.</font>keep <font color=Green><u>else</u></font> D<font color=Cyan>.</font>none<font color=Cyan>)</font> D<font color=Cyan>.</font>none<font color=Cyan>)</font>+<a name="(line325)"></a> <font color=Cyan>`</font>D<font color=Cyan>.</font>o<font color=Cyan>`</font> q<font color=Cyan>)</font>+<a name="(line326)"></a> <font color=Cyan>,</font> <font color=Green><u>do</u></font> cmp <font color=Red><-</font> op+<a name="(line327)"></a> <font color=Cyan>(</font>q2<font color=Cyan>,</font>iffn2<font color=Cyan>)</font> <font color=Red><-</font> wattribute+<a name="(line328)"></a> return <font color=Cyan>(</font><font color=Cyan>(</font>iffn <font color=Cyan>(</font><font color=Red>\</font>s1<font color=Red>-></font> iffn2 <font color=Cyan>(</font><font color=Red>\</font>s2<font color=Red>-></font> <font color=Green><u>if</u></font> cmp s1 s2 <font color=Green><u>then</u></font> D<font color=Cyan>.</font>keep <font color=Green><u>else</u></font> D<font color=Cyan>.</font>none<font color=Cyan>)</font>+<a name="(line329)"></a> D<font color=Cyan>.</font>none<font color=Cyan>)</font>+<a name="(line330)"></a> D<font color=Cyan>.</font>none<font color=Cyan>)</font> <font color=Cyan>`</font>D<font color=Cyan>.</font>o<font color=Cyan>`</font> q<font color=Cyan>)</font>+<a name="(line331)"></a> <font color=Cyan>,</font> <font color=Green><u>do</u></font> cmp <font color=Red><-</font> nop+<a name="(line332)"></a> n <font color=Red><-</font> number+<a name="(line333)"></a> return <font color=Cyan>(</font><font color=Cyan>(</font>iffn <font color=Cyan>(</font><font color=Red>\</font>s<font color=Red>-></font><font color=Green><u>if</u></font> cmp <font color=Cyan>(</font>read s<font color=Cyan>)</font> n <font color=Green><u>then</u></font> D<font color=Cyan>.</font>keep <font color=Green><u>else</u></font> D<font color=Cyan>.</font>none<font color=Cyan>)</font> D<font color=Cyan>.</font>none<font color=Cyan>)</font>+<a name="(line334)"></a> <font color=Cyan>`</font>D<font color=Cyan>.</font>o<font color=Cyan>`</font> q<font color=Cyan>)</font>+<a name="(line335)"></a> <font color=Cyan>,</font> <font color=Green><u>do</u></font> cmp <font color=Red><-</font> nop+<a name="(line336)"></a> <font color=Cyan>(</font>q2<font color=Cyan>,</font>iffn2<font color=Cyan>)</font> <font color=Red><-</font> wattribute+<a name="(line337)"></a> return <font color=Cyan>(</font><font color=Cyan>(</font>iffn <font color=Cyan>(</font><font color=Red>\</font>s1<font color=Red>-></font> iffn2 <font color=Cyan>(</font><font color=Red>\</font>s2<font color=Red>-></font> <font color=Green><u>if</u></font> cmp <font color=Cyan>(</font>read s1<font color=Cyan>)</font> <font color=Cyan>(</font>read s2<font color=Cyan>)</font> <font color=Green><u>then</u></font> D<font color=Cyan>.</font>keep+<a name="(line338)"></a> <font color=Green><u>else</u></font> D<font color=Cyan>.</font>none<font color=Cyan>)</font>+<a name="(line339)"></a> D<font color=Cyan>.</font>none<font color=Cyan>)</font>+<a name="(line340)"></a> D<font color=Cyan>.</font>none<font color=Cyan>)</font> <font color=Cyan>`</font>D<font color=Cyan>.</font>o<font color=Cyan>`</font> q<font color=Cyan>)</font>+<a name="(line341)"></a> <font color=Cyan>,</font> <font color=Green><u>do</u></font> return <font color=Cyan>(</font><font color=Cyan>(</font>a <font color=Cyan>`</font>D<font color=Cyan>.</font>o<font color=Cyan>`</font> q<font color=Cyan>)</font><font color=Cyan>)</font>+<a name="(line342)"></a> <font color=Red>]</font>+<a name="(line343)"></a>+<a name="(line344)"></a><a name="wattribute"></a>wattribute <font color=Red>::</font> XParser <font color=Cyan>(</font>DFilter i<font color=Cyan>,</font> <font color=Cyan>(</font>String<font color=Red>-></font>DFilter i<font color=Cyan>)</font><font color=Red>-></font>DFilter i<font color=Red>-></font>DFilter i<font color=Cyan>)</font>+<a name="(line345)"></a>wattribute <font color=Red>=</font> oneOf+<a name="(line346)"></a> <font color=Red>[</font> <font color=Green><u>do</u></font> symbol <font color=Magenta>"@"</font>+<a name="(line347)"></a> s <font color=Red><-</font> string+<a name="(line348)"></a> return <font color=Cyan>(</font>D<font color=Cyan>.</font>keep<font color=Cyan>,</font> D<font color=Cyan>.</font>iffind s<font color=Cyan>)</font>+<a name="(line349)"></a> <font color=Cyan>,</font> <font color=Green><u>do</u></font> q <font color=Red><-</font> aquery liftGlobal+<a name="(line350)"></a> symbol <font color=Magenta>"/"</font>+<a name="(line351)"></a> symbol <font color=Magenta>"@"</font>+<a name="(line352)"></a> s <font color=Red><-</font> string+<a name="(line353)"></a> return <font color=Cyan>(</font>q<font color=Cyan>,</font> D<font color=Cyan>.</font>iffind s<font color=Cyan>)</font>+<a name="(line354)"></a> <font color=Cyan>,</font> <font color=Green><u>do</u></font> q <font color=Red><-</font> aquery liftGlobal+<a name="(line355)"></a> return <font color=Cyan>(</font>q<font color=Cyan>,</font> D<font color=Cyan>.</font>ifTxt<font color=Cyan>)</font>+<a name="(line356)"></a> <font color=Red>]</font> <a name="(line357)"></a>-<a name="(line358)"></a><a name="iindex"></a>iindex <font color=Red>::</font> XParser <font color=Red>[</font><font color=Red>[</font>a<font color=Red>]</font><font color=Red>-></font><font color=Red>[</font>a<font color=Red>]</font><font color=Red>]</font>-<a name="(line359)"></a>iindex <font color=Red>=</font>-<a name="(line360)"></a> <font color=Green><u>do</u></font> i <font color=Red><-</font> simpleindex-<a name="(line361)"></a> is <font color=Red><-</font> idxcomma-<a name="(line362)"></a> return <font color=Cyan>(</font>i<font color=Red><b>:</b></font>is<font color=Cyan>)</font>-<a name="(line363)"></a>-<a name="(line364)"></a><a name="simpleindex"></a>simpleindex <font color=Red>::</font> XParser <font color=Cyan>(</font><font color=Red>[</font>a<font color=Red>]</font><font color=Red>-></font><font color=Red>[</font>a<font color=Red>]</font><font color=Cyan>)</font>-<a name="(line365)"></a>simpleindex <font color=Red>=</font> oneOf-<a name="(line366)"></a> <font color=Red>[</font> <font color=Green><u>do</u></font> n <font color=Red><-</font> number-<a name="(line367)"></a> r <font color=Red><-</font> rrange n-<a name="(line368)"></a> return r-<a name="(line369)"></a> <font color=Cyan>,</font> <font color=Green><u>do</u></font> symbol <font color=Magenta>"$"</font>-<a name="(line370)"></a> return <font color=Cyan>(</font>C<font color=Cyan>.</font>keep <font color=Cyan>.</font> last<font color=Cyan>)</font>-<a name="(line371)"></a> <font color=Red>]</font>-<a name="(line372)"></a>-<a name="(line373)"></a><a name="rrange"></a>rrange<font color=Cyan>,</font> numberdollar <font color=Red>::</font> Integer <font color=Red>-></font> XParser <font color=Cyan>(</font><font color=Red>[</font>a<font color=Red>]</font><font color=Red>-></font><font color=Red>[</font>a<font color=Red>]</font><font color=Cyan>)</font>-<a name="(line374)"></a>rrange n1 <font color=Red>=</font> oneOf-<a name="(line375)"></a> <font color=Red>[</font> <font color=Green><u>do</u></font> symbol <font color=Magenta>"-"</font>-<a name="(line376)"></a> numberdollar n1-<a name="(line377)"></a> <font color=Cyan>,</font> return <font color=Cyan>(</font>C<font color=Cyan>.</font>keep<font color=Cyan>.</font><font color=Cyan>(</font><font color=Cyan>!!</font><font color=Cyan>(</font>fromInteger n1<font color=Cyan>)</font><font color=Cyan>)</font><font color=Cyan>)</font>-<a name="(line378)"></a> <font color=Red>]</font>-<a name="(line379)"></a>-<a name="(line380)"></a><a name="numberdollar"></a>numberdollar n1 <font color=Red>=</font> oneOf-<a name="(line381)"></a> <font color=Red>[</font> <font color=Green><u>do</u></font> n2 <font color=Red><-</font> number-<a name="(line382)"></a> return <font color=Cyan>(</font>take <font color=Cyan>(</font>fromInteger <font color=Cyan>(</font><font color=Magenta>1</font><font color=Cyan>+</font>n2<font color=Blue>-</font>n1<font color=Cyan>)</font><font color=Cyan>)</font> <font color=Cyan>.</font> drop <font color=Cyan>(</font>fromInteger n1<font color=Cyan>)</font><font color=Cyan>)</font>-<a name="(line383)"></a> <font color=Cyan>,</font> <font color=Green><u>do</u></font> symbol <font color=Magenta>"$"</font>-<a name="(line384)"></a> return <font color=Cyan>(</font>drop <font color=Cyan>(</font>fromInteger n1<font color=Cyan>)</font><font color=Cyan>)</font>-<a name="(line385)"></a> <font color=Red>]</font>-<a name="(line386)"></a>-<a name="(line387)"></a><a name="idxcomma"></a>idxcomma <font color=Red>::</font> XParser <font color=Red>[</font><font color=Red>[</font>a<font color=Red>]</font><font color=Red>-></font><font color=Red>[</font>a<font color=Red>]</font><font color=Red>]</font>-<a name="(line388)"></a>idxcomma <font color=Red>=</font> oneOf-<a name="(line389)"></a> <font color=Red>[</font> <font color=Green><u>do</u></font> symbol <font color=Magenta>","</font>-<a name="(line390)"></a> r <font color=Red><-</font> simpleindex-<a name="(line391)"></a> rs <font color=Red><-</font> idxcomma-<a name="(line392)"></a> return <font color=Cyan>(</font>r<font color=Red><b>:</b></font>rs<font color=Cyan>)</font>-<a name="(line393)"></a> <font color=Cyan>,</font> return []-<a name="(line394)"></a> <font color=Red>]</font>-<a name="(line395)"></a>+<a name="(line358)"></a>+<a name="(line359)"></a><a name="iindex"></a>iindex <font color=Red>::</font> XParser <font color=Red>[</font><font color=Red>[</font>a<font color=Red>]</font><font color=Red>-></font><font color=Red>[</font>a<font color=Red>]</font><font color=Red>]</font>+<a name="(line360)"></a>iindex <font color=Red>=</font>+<a name="(line361)"></a> <font color=Green><u>do</u></font> i <font color=Red><-</font> simpleindex+<a name="(line362)"></a> is <font color=Red><-</font> idxcomma+<a name="(line363)"></a> return <font color=Cyan>(</font>i<font color=Red><b>:</b></font>is<font color=Cyan>)</font>+<a name="(line364)"></a>+<a name="(line365)"></a><a name="simpleindex"></a>simpleindex <font color=Red>::</font> XParser <font color=Cyan>(</font><font color=Red>[</font>a<font color=Red>]</font><font color=Red>-></font><font color=Red>[</font>a<font color=Red>]</font><font color=Cyan>)</font>+<a name="(line366)"></a>simpleindex <font color=Red>=</font> oneOf+<a name="(line367)"></a> <font color=Red>[</font> <font color=Green><u>do</u></font> n <font color=Red><-</font> number+<a name="(line368)"></a> r <font color=Red><-</font> rrange n+<a name="(line369)"></a> return r+<a name="(line370)"></a> <font color=Cyan>,</font> <font color=Green><u>do</u></font> symbol <font color=Magenta>"$"</font>+<a name="(line371)"></a> return <font color=Cyan>(</font>C<font color=Cyan>.</font>keep <font color=Cyan>.</font> last<font color=Cyan>)</font>+<a name="(line372)"></a> <font color=Red>]</font>+<a name="(line373)"></a>+<a name="(line374)"></a><a name="rrange"></a>rrange<font color=Cyan>,</font> numberdollar <font color=Red>::</font> Integer <font color=Red>-></font> XParser <font color=Cyan>(</font><font color=Red>[</font>a<font color=Red>]</font><font color=Red>-></font><font color=Red>[</font>a<font color=Red>]</font><font color=Cyan>)</font>+<a name="(line375)"></a>rrange n1 <font color=Red>=</font> oneOf+<a name="(line376)"></a> <font color=Red>[</font> <font color=Green><u>do</u></font> symbol <font color=Magenta>"-"</font>+<a name="(line377)"></a> numberdollar n1+<a name="(line378)"></a> <font color=Cyan>,</font> return <font color=Cyan>(</font>C<font color=Cyan>.</font>keep<font color=Cyan>.</font><font color=Cyan>(</font><font color=Cyan>!!</font><font color=Cyan>(</font>fromInteger n1<font color=Cyan>)</font><font color=Cyan>)</font><font color=Cyan>)</font>+<a name="(line379)"></a> <font color=Red>]</font>+<a name="(line380)"></a>+<a name="(line381)"></a><a name="numberdollar"></a>numberdollar n1 <font color=Red>=</font> oneOf+<a name="(line382)"></a> <font color=Red>[</font> <font color=Green><u>do</u></font> n2 <font color=Red><-</font> number+<a name="(line383)"></a> return <font color=Cyan>(</font>take <font color=Cyan>(</font>fromInteger <font color=Cyan>(</font><font color=Magenta>1</font><font color=Cyan>+</font>n2<font color=Blue>-</font>n1<font color=Cyan>)</font><font color=Cyan>)</font> <font color=Cyan>.</font> drop <font color=Cyan>(</font>fromInteger n1<font color=Cyan>)</font><font color=Cyan>)</font>+<a name="(line384)"></a> <font color=Cyan>,</font> <font color=Green><u>do</u></font> symbol <font color=Magenta>"$"</font>+<a name="(line385)"></a> return <font color=Cyan>(</font>drop <font color=Cyan>(</font>fromInteger n1<font color=Cyan>)</font><font color=Cyan>)</font>+<a name="(line386)"></a> <font color=Red>]</font>+<a name="(line387)"></a>+<a name="(line388)"></a><a name="idxcomma"></a>idxcomma <font color=Red>::</font> XParser <font color=Red>[</font><font color=Red>[</font>a<font color=Red>]</font><font color=Red>-></font><font color=Red>[</font>a<font color=Red>]</font><font color=Red>]</font>+<a name="(line389)"></a>idxcomma <font color=Red>=</font> oneOf+<a name="(line390)"></a> <font color=Red>[</font> <font color=Green><u>do</u></font> symbol <font color=Magenta>","</font>+<a name="(line391)"></a> r <font color=Red><-</font> simpleindex+<a name="(line392)"></a> rs <font color=Red><-</font> idxcomma+<a name="(line393)"></a> return <font color=Cyan>(</font>r<font color=Red><b>:</b></font>rs<font color=Cyan>)</font>+<a name="(line394)"></a> <font color=Cyan>,</font> return []+<a name="(line395)"></a> <font color=Red>]</font> <a name="(line396)"></a>-<a name="(line397)"></a><a name="op"></a>op <font color=Red>::</font> XParser <font color=Cyan>(</font>String<font color=Red>-></font>String<font color=Red>-></font>Bool<font color=Cyan>)</font>-<a name="(line398)"></a>op <font color=Red>=</font> oneOf-<a name="(line399)"></a> <font color=Red>[</font> <font color=Green><u>do</u></font> symbol <font color=Magenta>"="</font><font color=Cyan>;</font> return <font color=Cyan>(</font><font color=Cyan>==</font><font color=Cyan>)</font>-<a name="(line400)"></a> <font color=Cyan>,</font> <font color=Green><u>do</u></font> symbol <font color=Magenta>"!="</font><font color=Cyan>;</font> return <font color=Cyan>(</font><font color=Cyan>/=</font><font color=Cyan>)</font>-<a name="(line401)"></a> <font color=Cyan>,</font> <font color=Green><u>do</u></font> symbol <font color=Magenta>"<"</font><font color=Cyan>;</font> return <font color=Cyan>(</font><font color=Cyan><</font><font color=Cyan>)</font>-<a name="(line402)"></a> <font color=Cyan>,</font> <font color=Green><u>do</u></font> symbol <font color=Magenta>"<="</font><font color=Cyan>;</font> return <font color=Cyan>(</font><font color=Cyan><=</font><font color=Cyan>)</font>-<a name="(line403)"></a> <font color=Cyan>,</font> <font color=Green><u>do</u></font> symbol <font color=Magenta>">"</font><font color=Cyan>;</font> return <font color=Cyan>(</font><font color=Cyan>></font><font color=Cyan>)</font>-<a name="(line404)"></a> <font color=Cyan>,</font> <font color=Green><u>do</u></font> symbol <font color=Magenta>">="</font><font color=Cyan>;</font> return <font color=Cyan>(</font><font color=Cyan>>=</font><font color=Cyan>)</font>-<a name="(line405)"></a> <font color=Red>]</font>-<a name="(line406)"></a>-<a name="(line407)"></a><a name="nop"></a>nop <font color=Red>::</font> XParser <font color=Cyan>(</font>Integer<font color=Red>-></font>Integer<font color=Red>-></font>Bool<font color=Cyan>)</font>-<a name="(line408)"></a>nop <font color=Red>=</font> oneOf-<a name="(line409)"></a> <font color=Red>[</font> <font color=Green><u>do</u></font> symbol <font color=Magenta>".=."</font><font color=Cyan>;</font> return <font color=Cyan>(</font><font color=Cyan>==</font><font color=Cyan>)</font>-<a name="(line410)"></a> <font color=Cyan>,</font> <font color=Green><u>do</u></font> symbol <font color=Magenta>".!=."</font><font color=Cyan>;</font> return <font color=Cyan>(</font><font color=Cyan>/=</font><font color=Cyan>)</font>-<a name="(line411)"></a> <font color=Cyan>,</font> <font color=Green><u>do</u></font> symbol <font color=Magenta>".<."</font><font color=Cyan>;</font> return <font color=Cyan>(</font><font color=Cyan><</font><font color=Cyan>)</font>-<a name="(line412)"></a> <font color=Cyan>,</font> <font color=Green><u>do</u></font> symbol <font color=Magenta>".<=."</font><font color=Cyan>;</font> return <font color=Cyan>(</font><font color=Cyan><=</font><font color=Cyan>)</font>-<a name="(line413)"></a> <font color=Cyan>,</font> <font color=Green><u>do</u></font> symbol <font color=Magenta>".>."</font><font color=Cyan>;</font> return <font color=Cyan>(</font><font color=Cyan>></font><font color=Cyan>)</font>-<a name="(line414)"></a> <font color=Cyan>,</font> <font color=Green><u>do</u></font> symbol <font color=Magenta>".>=."</font><font color=Cyan>;</font> return <font color=Cyan>(</font><font color=Cyan>>=</font><font color=Cyan>)</font>-<a name="(line415)"></a> <font color=Red>]</font>-<a name="(line416)"></a>+<a name="(line397)"></a>+<a name="(line398)"></a><a name="op"></a>op <font color=Red>::</font> XParser <font color=Cyan>(</font>String<font color=Red>-></font>String<font color=Red>-></font>Bool<font color=Cyan>)</font>+<a name="(line399)"></a>op <font color=Red>=</font> oneOf+<a name="(line400)"></a> <font color=Red>[</font> <font color=Green><u>do</u></font> symbol <font color=Magenta>"="</font><font color=Cyan>;</font> return <font color=Cyan>(</font><font color=Cyan>==</font><font color=Cyan>)</font>+<a name="(line401)"></a> <font color=Cyan>,</font> <font color=Green><u>do</u></font> symbol <font color=Magenta>"!="</font><font color=Cyan>;</font> return <font color=Cyan>(</font><font color=Cyan>/=</font><font color=Cyan>)</font>+<a name="(line402)"></a> <font color=Cyan>,</font> <font color=Green><u>do</u></font> symbol <font color=Magenta>"<"</font><font color=Cyan>;</font> return <font color=Cyan>(</font><font color=Cyan><</font><font color=Cyan>)</font>+<a name="(line403)"></a> <font color=Cyan>,</font> <font color=Green><u>do</u></font> symbol <font color=Magenta>"<="</font><font color=Cyan>;</font> return <font color=Cyan>(</font><font color=Cyan><=</font><font color=Cyan>)</font>+<a name="(line404)"></a> <font color=Cyan>,</font> <font color=Green><u>do</u></font> symbol <font color=Magenta>">"</font><font color=Cyan>;</font> return <font color=Cyan>(</font><font color=Cyan>></font><font color=Cyan>)</font>+<a name="(line405)"></a> <font color=Cyan>,</font> <font color=Green><u>do</u></font> symbol <font color=Magenta>">="</font><font color=Cyan>;</font> return <font color=Cyan>(</font><font color=Cyan>>=</font><font color=Cyan>)</font>+<a name="(line406)"></a> <font color=Red>]</font>+<a name="(line407)"></a>+<a name="(line408)"></a><a name="nop"></a>nop <font color=Red>::</font> XParser <font color=Cyan>(</font>Integer<font color=Red>-></font>Integer<font color=Red>-></font>Bool<font color=Cyan>)</font>+<a name="(line409)"></a>nop <font color=Red>=</font> oneOf+<a name="(line410)"></a> <font color=Red>[</font> <font color=Green><u>do</u></font> symbol <font color=Magenta>".=."</font><font color=Cyan>;</font> return <font color=Cyan>(</font><font color=Cyan>==</font><font color=Cyan>)</font>+<a name="(line411)"></a> <font color=Cyan>,</font> <font color=Green><u>do</u></font> symbol <font color=Magenta>".!=."</font><font color=Cyan>;</font> return <font color=Cyan>(</font><font color=Cyan>/=</font><font color=Cyan>)</font>+<a name="(line412)"></a> <font color=Cyan>,</font> <font color=Green><u>do</u></font> symbol <font color=Magenta>".<."</font><font color=Cyan>;</font> return <font color=Cyan>(</font><font color=Cyan><</font><font color=Cyan>)</font>+<a name="(line413)"></a> <font color=Cyan>,</font> <font color=Green><u>do</u></font> symbol <font color=Magenta>".<=."</font><font color=Cyan>;</font> return <font color=Cyan>(</font><font color=Cyan><=</font><font color=Cyan>)</font>+<a name="(line414)"></a> <font color=Cyan>,</font> <font color=Green><u>do</u></font> symbol <font color=Magenta>".>."</font><font color=Cyan>;</font> return <font color=Cyan>(</font><font color=Cyan>></font><font color=Cyan>)</font>+<a name="(line415)"></a> <font color=Cyan>,</font> <font color=Green><u>do</u></font> symbol <font color=Magenta>".>=."</font><font color=Cyan>;</font> return <font color=Cyan>(</font><font color=Cyan>>=</font><font color=Cyan>)</font>+<a name="(line416)"></a> <font color=Red>]</font>+<a name="(line417)"></a> </pre> </html>
docs/index.html view
@@ -132,10 +132,10 @@ <center><h3><a name="download">Downloads</a></h3></center> <p> <b>Development versions:</b><br>-HaXml-1.19, release date 2007.10.23<br>+HaXml-1.19.1, release date 2007.11.01<br> By HTTP:-<a href="http://www.cs.york.ac.uk/fp/HaXml-devel/HaXml-1.19.tar.gz">.tar.gz</a>,-<a href="http://www.cs.york.ac.uk/fp/HaXml-devel/HaXml-1.19.zip">.zip</a>.+<a href="http://www.cs.york.ac.uk/fp/HaXml-devel/HaXml-1.19.1.tar.gz">.tar.gz</a>,+<a href="http://www.cs.york.ac.uk/fp/HaXml-devel/HaXml-1.19.1.zip">.zip</a>. <br> By FTP: <a href="ftp://ftp.cs.york.ac.uk/pub/haskell/HaXml/">@@ -202,6 +202,7 @@ <center><h3><a name="news">Recent news</a></h3></center> <p>+Version 1.19.1 fixes a build error in 1.19. Version 1.19 improved the lazy XML parsing, and fixed some space leaks in the XtractLazy tool.
− examples/GXL.hs
@@ -1,641 +0,0 @@-module GXL where--import Text.XML.HaXml.XmlContent-import Text.XML.HaXml.OneOfN---{-Type decls-}--data Gxl = Gxl Gxl_Attrs [Graph]- deriving (Eq,Show)-data Gxl_Attrs = Gxl_Attrs- { gxlXmlns'xlink :: (Defaultable String)- } deriving (Eq,Show)-data Type = Type- { typeXlink'type :: (Defaultable Type_xlink'type)- , typeXlink'href :: String- } deriving (Eq,Show)-data Type_xlink'type = Type_xlink'type_simple- deriving (Eq,Show)-data Graph = Graph Graph_Attrs (Maybe Type) [Attr]- [(OneOf3 Node Edge Rel)]- deriving (Eq,Show)-data Graph_Attrs = Graph_Attrs- { graphId :: String- , graphRole :: (Maybe String)- , graphEdgeids :: (Defaultable Graph_edgeids)- , graphHypergraph :: (Defaultable Graph_hypergraph)- , graphEdgemode :: (Defaultable Graph_edgemode)- } deriving (Eq,Show)-data Graph_edgeids = Graph_edgeids_true | Graph_edgeids_false- deriving (Eq,Show)-data Graph_hypergraph = Graph_hypergraph_true | - Graph_hypergraph_false- deriving (Eq,Show)-data Graph_edgemode = Graph_edgemode_directed | - Graph_edgemode_undirected | Graph_edgemode_defaultdirected | - Graph_edgemode_defaultundirected- deriving (Eq,Show)-data Node = Node Node_Attrs (Maybe Type) [Attr] [Graph]- deriving (Eq,Show)-data Node_Attrs = Node_Attrs- { nodeId :: String- } deriving (Eq,Show)-data Edge = Edge Edge_Attrs (Maybe Type) [Attr] [Graph]- deriving (Eq,Show)-data Edge_Attrs = Edge_Attrs- { edgeId :: (Maybe String)- , edgeFrom :: String- , edgeTo :: String- , edgeFromorder :: (Maybe String)- , edgeToorder :: (Maybe String)- , edgeIsdirected :: (Maybe Edge_isdirected)- } deriving (Eq,Show)-data Edge_isdirected = Edge_isdirected_true | - Edge_isdirected_false- deriving (Eq,Show)-data Rel = Rel Rel_Attrs (Maybe Type) [Attr] [Graph] [Relend]- deriving (Eq,Show)-data Rel_Attrs = Rel_Attrs- { relId :: (Maybe String)- , relIsdirected :: (Maybe Rel_isdirected)- } deriving (Eq,Show)-data Rel_isdirected = Rel_isdirected_true | Rel_isdirected_false- deriving (Eq,Show)-data Relend = Relend Relend_Attrs [Attr]- deriving (Eq,Show)-data Relend_Attrs = Relend_Attrs- { relendTarget :: String- , relendRole :: (Maybe String)- , relendDirection :: (Maybe Relend_direction)- , relendStartorder :: (Maybe String)- , relendEndorder :: (Maybe String)- } deriving (Eq,Show)-data Relend_direction = Relend_direction_in | - Relend_direction_out | Relend_direction_none- deriving (Eq,Show)-data Attr = Attr Attr_Attrs [Attr]- (OneOf10 Locator Bool AInt AFloat AString Enum Seq Set Bag Tup)- deriving (Eq,Show)-data Attr_Attrs = Attr_Attrs- { attrId :: (Maybe String)- , attrName :: String- , attrKind :: (Maybe String)- } deriving (Eq,Show)-data Locator = Locator- { locatorXlink'type :: (Defaultable Locator_xlink'type)- , locatorXlink'href :: String- } deriving (Eq,Show)-data Locator_xlink'type = Locator_xlink'type_simple- deriving (Eq,Show)-newtype Bool = Bool String deriving (Eq,Show)-newtype AInt = AInt String deriving (Eq,Show)-newtype AFloat = AFloat String deriving (Eq,Show)-newtype AString = AString String deriving (Eq,Show)-newtype Enum = Enum String deriving (Eq,Show)-newtype Seq = Seq [Seq_] deriving (Eq,Show)-data Seq_ = Seq_Locator Locator- | Seq_Bool Bool- | Seq_AInt AInt- | Seq_AFloat AFloat- | Seq_AString AString- | Seq_Enum Enum- | Seq_Seq Seq- | Seq_Set Set- | Seq_Bag Bag- | Seq_Tup Tup- deriving (Eq,Show)-newtype Set = Set [Set_] deriving (Eq,Show)-data Set_ = Set_Locator Locator- | Set_Bool Bool- | Set_AInt AInt- | Set_AFloat AFloat- | Set_AString AString- | Set_Enum Enum- | Set_Seq Seq- | Set_Set Set- | Set_Bag Bag- | Set_Tup Tup- deriving (Eq,Show)-newtype Bag = Bag [Bag_] deriving (Eq,Show)-data Bag_ = Bag_Locator Locator- | Bag_Bool Bool- | Bag_AInt AInt- | Bag_AFloat AFloat- | Bag_AString AString- | Bag_Enum Enum- | Bag_Seq Seq- | Bag_Set Set- | Bag_Bag Bag- | Bag_Tup Tup- deriving (Eq,Show)-newtype Tup = Tup [Tup_] deriving (Eq,Show)-data Tup_ = Tup_Locator Locator- | Tup_Bool Bool- | Tup_AInt AInt- | Tup_AFloat AFloat- | Tup_AString AString- | Tup_Enum Enum- | Tup_Seq Seq- | Tup_Set Set- | Tup_Bag Bag- | Tup_Tup Tup- deriving (Eq,Show)---{-Instance decls-}--instance HTypeable Gxl where- toHType x = Defined "gxl" [] []-instance XmlContent Gxl where- toContents (Gxl as a) =- [CElem (Elem "gxl" (toAttrs as) (concatMap toContents a)) ()]- parseContents = do- { e@(Elem _ as _) <- element ["gxl"]- ; interior e $ return (Gxl (fromAttrs as))- `apply` many parseContents- } `adjustErr` ("in <gxl>, "++)-instance XmlAttributes Gxl_Attrs where- fromAttrs as =- Gxl_Attrs- { gxlXmlns'xlink = defaultA fromAttrToStr "http://www.w3.org/1999/xlink" "xmlns:xlink" as- }- toAttrs v = catMaybes - [ defaultToAttr toAttrFrStr "xmlns:xlink" (gxlXmlns'xlink v)- ]--instance HTypeable Type where- toHType x = Defined "type" [] []-instance XmlContent Type where- toContents as =- [CElem (Elem "type" (toAttrs as) []) ()]- parseContents = do- { (Elem _ as []) <- element ["type"]- ; return (fromAttrs as)- } `adjustErr` ("in <type>, "++)-instance XmlAttributes Type where- fromAttrs as =- Type- { typeXlink'type = defaultA fromAttrToTyp Type_xlink'type_simple "xlink:type" as- , typeXlink'href = definiteA fromAttrToStr "type" "xlink:href" as- }- toAttrs v = catMaybes - [ defaultToAttr toAttrFrTyp "xlink:type" (typeXlink'type v)- , toAttrFrStr "xlink:href" (typeXlink'href v)- ]--instance XmlAttrType Type_xlink'type where- fromAttrToTyp n (n',v)- | n==n' = translate (attr2str v)- | otherwise = Nothing- where translate "simple" = Just Type_xlink'type_simple- translate _ = Nothing- toAttrFrTyp n Type_xlink'type_simple = Just (n, str2attr "simple")--instance HTypeable Graph where- toHType x = Defined "graph" [] []-instance XmlContent Graph where- toContents (Graph as a b c) =- [CElem (Elem "graph" (toAttrs as) (maybe [] toContents a ++- concatMap toContents b ++ concatMap toContents c)) ()]- parseContents = do- { e@(Elem _ as _) <- element ["graph"]- ; interior e $ return (Graph (fromAttrs as))- `apply` optional parseContents `apply` many parseContents- `apply` many parseContents- } `adjustErr` ("in <graph>, "++)-instance XmlAttributes Graph_Attrs where- fromAttrs as =- Graph_Attrs- { graphId = definiteA fromAttrToStr "graph" "id" as- , graphRole = possibleA fromAttrToStr "role" as- , graphEdgeids = defaultA fromAttrToTyp Graph_edgeids_false "edgeids" as- , graphHypergraph = defaultA fromAttrToTyp Graph_hypergraph_false "hypergraph" as- , graphEdgemode = defaultA fromAttrToTyp Graph_edgemode_directed "edgemode" as- }- toAttrs v = catMaybes - [ toAttrFrStr "id" (graphId v)- , maybeToAttr toAttrFrStr "role" (graphRole v)- , defaultToAttr toAttrFrTyp "edgeids" (graphEdgeids v)- , defaultToAttr toAttrFrTyp "hypergraph" (graphHypergraph v)- , defaultToAttr toAttrFrTyp "edgemode" (graphEdgemode v)- ]--instance XmlAttrType Graph_edgeids where- fromAttrToTyp n (n',v)- | n==n' = translate (attr2str v)- | otherwise = Nothing- where translate "true" = Just Graph_edgeids_true- translate "false" = Just Graph_edgeids_false- translate _ = Nothing- toAttrFrTyp n Graph_edgeids_true = Just (n, str2attr "true")- toAttrFrTyp n Graph_edgeids_false = Just (n, str2attr "false")--instance XmlAttrType Graph_hypergraph where- fromAttrToTyp n (n',v)- | n==n' = translate (attr2str v)- | otherwise = Nothing- where translate "true" = Just Graph_hypergraph_true- translate "false" = Just Graph_hypergraph_false- translate _ = Nothing- toAttrFrTyp n Graph_hypergraph_true = Just (n, str2attr "true")- toAttrFrTyp n Graph_hypergraph_false = Just (n, str2attr "false")--instance XmlAttrType Graph_edgemode where- fromAttrToTyp n (n',v)- | n==n' = translate (attr2str v)- | otherwise = Nothing- where translate "directed" = Just Graph_edgemode_directed- translate "undirected" = Just Graph_edgemode_undirected- translate "defaultdirected" = Just Graph_edgemode_defaultdirected- translate "defaultundirected" = Just Graph_edgemode_defaultundirected- translate _ = Nothing- toAttrFrTyp n Graph_edgemode_directed = Just (n, str2attr "directed")- toAttrFrTyp n Graph_edgemode_undirected = Just (n, str2attr "undirected")- toAttrFrTyp n Graph_edgemode_defaultdirected = Just (n, str2attr "defaultdirected")- toAttrFrTyp n Graph_edgemode_defaultundirected = Just (n, str2attr "defaultundirected")--instance HTypeable Node where- toHType x = Defined "node" [] []-instance XmlContent Node where- toContents (Node as a b c) =- [CElem (Elem "node" (toAttrs as) (maybe [] toContents a ++- concatMap toContents b ++ concatMap toContents c)) ()]- parseContents = do- { e@(Elem _ as _) <- element ["node"]- ; interior e $ return (Node (fromAttrs as))- `apply` optional parseContents `apply` many parseContents- `apply` many parseContents- } `adjustErr` ("in <node>, "++)-instance XmlAttributes Node_Attrs where- fromAttrs as =- Node_Attrs- { nodeId = definiteA fromAttrToStr "node" "id" as- }- toAttrs v = catMaybes - [ toAttrFrStr "id" (nodeId v)- ]--instance HTypeable Edge where- toHType x = Defined "edge" [] []-instance XmlContent Edge where- toContents (Edge as a b c) =- [CElem (Elem "edge" (toAttrs as) (maybe [] toContents a ++- concatMap toContents b ++ concatMap toContents c)) ()]- parseContents = do- { e@(Elem _ as _) <- element ["edge"]- ; interior e $ return (Edge (fromAttrs as))- `apply` optional parseContents `apply` many parseContents- `apply` many parseContents- } `adjustErr` ("in <edge>, "++)-instance XmlAttributes Edge_Attrs where- fromAttrs as =- Edge_Attrs- { edgeId = possibleA fromAttrToStr "id" as- , edgeFrom = definiteA fromAttrToStr "edge" "from" as- , edgeTo = definiteA fromAttrToStr "edge" "to" as- , edgeFromorder = possibleA fromAttrToStr "fromorder" as- , edgeToorder = possibleA fromAttrToStr "toorder" as- , edgeIsdirected = possibleA fromAttrToTyp "isdirected" as- }- toAttrs v = catMaybes - [ maybeToAttr toAttrFrStr "id" (edgeId v)- , toAttrFrStr "from" (edgeFrom v)- , toAttrFrStr "to" (edgeTo v)- , maybeToAttr toAttrFrStr "fromorder" (edgeFromorder v)- , maybeToAttr toAttrFrStr "toorder" (edgeToorder v)- , maybeToAttr toAttrFrTyp "isdirected" (edgeIsdirected v)- ]--instance XmlAttrType Edge_isdirected where- fromAttrToTyp n (n',v)- | n==n' = translate (attr2str v)- | otherwise = Nothing- where translate "true" = Just Edge_isdirected_true- translate "false" = Just Edge_isdirected_false- translate _ = Nothing- toAttrFrTyp n Edge_isdirected_true = Just (n, str2attr "true")- toAttrFrTyp n Edge_isdirected_false = Just (n, str2attr "false")--instance HTypeable Rel where- toHType x = Defined "rel" [] []-instance XmlContent Rel where- toContents (Rel as a b c d) =- [CElem (Elem "rel" (toAttrs as) (maybe [] toContents a ++- concatMap toContents b ++ concatMap toContents c ++- concatMap toContents d)) ()]- parseContents = do- { e@(Elem _ as _) <- element ["rel"]- ; interior e $ return (Rel (fromAttrs as))- `apply` optional parseContents `apply` many parseContents- `apply` many parseContents `apply` many parseContents- } `adjustErr` ("in <rel>, "++)-instance XmlAttributes Rel_Attrs where- fromAttrs as =- Rel_Attrs- { relId = possibleA fromAttrToStr "id" as- , relIsdirected = possibleA fromAttrToTyp "isdirected" as- }- toAttrs v = catMaybes - [ maybeToAttr toAttrFrStr "id" (relId v)- , maybeToAttr toAttrFrTyp "isdirected" (relIsdirected v)- ]--instance XmlAttrType Rel_isdirected where- fromAttrToTyp n (n',v)- | n==n' = translate (attr2str v)- | otherwise = Nothing- where translate "true" = Just Rel_isdirected_true- translate "false" = Just Rel_isdirected_false- translate _ = Nothing- toAttrFrTyp n Rel_isdirected_true = Just (n, str2attr "true")- toAttrFrTyp n Rel_isdirected_false = Just (n, str2attr "false")--instance HTypeable Relend where- toHType x = Defined "relend" [] []-instance XmlContent Relend where- toContents (Relend as a) =- [CElem (Elem "relend" (toAttrs as) (concatMap toContents a)) ()]- parseContents = do- { e@(Elem _ as _) <- element ["relend"]- ; interior e $ return (Relend (fromAttrs as))- `apply` many parseContents- } `adjustErr` ("in <relend>, "++)-instance XmlAttributes Relend_Attrs where- fromAttrs as =- Relend_Attrs- { relendTarget = definiteA fromAttrToStr "relend" "target" as- , relendRole = possibleA fromAttrToStr "role" as- , relendDirection = possibleA fromAttrToTyp "direction" as- , relendStartorder = possibleA fromAttrToStr "startorder" as- , relendEndorder = possibleA fromAttrToStr "endorder" as- }- toAttrs v = catMaybes - [ toAttrFrStr "target" (relendTarget v)- , maybeToAttr toAttrFrStr "role" (relendRole v)- , maybeToAttr toAttrFrTyp "direction" (relendDirection v)- , maybeToAttr toAttrFrStr "startorder" (relendStartorder v)- , maybeToAttr toAttrFrStr "endorder" (relendEndorder v)- ]--instance XmlAttrType Relend_direction where- fromAttrToTyp n (n',v)- | n==n' = translate (attr2str v)- | otherwise = Nothing- where translate "in" = Just Relend_direction_in- translate "out" = Just Relend_direction_out- translate "none" = Just Relend_direction_none- translate _ = Nothing- toAttrFrTyp n Relend_direction_in = Just (n, str2attr "in")- toAttrFrTyp n Relend_direction_out = Just (n, str2attr "out")- toAttrFrTyp n Relend_direction_none = Just (n, str2attr "none")--instance HTypeable Attr where- toHType x = Defined "attr" [] []-instance XmlContent Attr where- toContents (Attr as a b) =- [CElem (Elem "attr" (toAttrs as) (concatMap toContents a ++- toContents b)) ()]- parseContents = do- { e@(Elem _ as _) <- element ["attr"]- ; interior e $ return (Attr (fromAttrs as))- `apply` many parseContents `apply` parseContents- } `adjustErr` ("in <attr>, "++)-instance XmlAttributes Attr_Attrs where- fromAttrs as =- Attr_Attrs- { attrId = possibleA fromAttrToStr "id" as- , attrName = definiteA fromAttrToStr "attr" "name" as- , attrKind = possibleA fromAttrToStr "kind" as- }- toAttrs v = catMaybes - [ maybeToAttr toAttrFrStr "id" (attrId v)- , toAttrFrStr "name" (attrName v)- , maybeToAttr toAttrFrStr "kind" (attrKind v)- ]--instance HTypeable Locator where- toHType x = Defined "locator" [] []-instance XmlContent Locator where- toContents as =- [CElem (Elem "locator" (toAttrs as) []) ()]- parseContents = do- { (Elem _ as []) <- element ["locator"]- ; return (fromAttrs as)- } `adjustErr` ("in <locator>, "++)-instance XmlAttributes Locator where- fromAttrs as =- Locator- { locatorXlink'type = defaultA fromAttrToTyp Locator_xlink'type_simple "xlink:type" as- , locatorXlink'href = definiteA fromAttrToStr "locator" "xlink:href" as- }- toAttrs v = catMaybes - [ defaultToAttr toAttrFrTyp "xlink:type" (locatorXlink'type v)- , toAttrFrStr "xlink:href" (locatorXlink'href v)- ]--instance XmlAttrType Locator_xlink'type where- fromAttrToTyp n (n',v)- | n==n' = translate (attr2str v)- | otherwise = Nothing- where translate "simple" = Just Locator_xlink'type_simple- translate _ = Nothing- toAttrFrTyp n Locator_xlink'type_simple = Just (n, str2attr "simple")--instance HTypeable Bool where- toHType x = Defined "bool" [] []-instance XmlContent Bool where- toContents (Bool a) =- [CElem (Elem "bool" [] (toText a)) ()]- parseContents = do- { e@(Elem _ [] _) <- element ["bool"]- ; interior e $ return (Bool) `apply` (text `onFail` return "")- } `adjustErr` ("in <bool>, "++)--instance HTypeable AInt where- toHType x = Defined "int" [] []-instance XmlContent AInt where- toContents (AInt a) =- [CElem (Elem "int" [] (toText a)) ()]- parseContents = do- { e@(Elem _ [] _) <- element ["int"]- ; interior e $ return (AInt) `apply` (text `onFail` return "")- } `adjustErr` ("in <int>, "++)--instance HTypeable AFloat where- toHType x = Defined "float" [] []-instance XmlContent AFloat where- toContents (AFloat a) =- [CElem (Elem "float" [] (toText a)) ()]- parseContents = do- { e@(Elem _ [] _) <- element ["float"]- ; interior e $ return (AFloat) `apply` (text `onFail` return "")- } `adjustErr` ("in <float>, "++)--instance HTypeable AString where- toHType x = Defined "string" [] []-instance XmlContent AString where- toContents (AString a) =- [CElem (Elem "string" [] (toText a)) ()]- parseContents = do- { e@(Elem _ [] _) <- element ["string"]- ; interior e $ return (AString) `apply` (text `onFail` return "")- } `adjustErr` ("in <string>, "++)--instance HTypeable Enum where- toHType x = Defined "enum" [] []-instance XmlContent Enum where- toContents (Enum a) =- [CElem (Elem "enum" [] (toText a)) ()]- parseContents = do- { e@(Elem _ [] _) <- element ["enum"]- ; interior e $ return (Enum) `apply` (text `onFail` return "")- } `adjustErr` ("in <enum>, "++)--instance HTypeable Seq where- toHType x = Defined "seq" [] []-instance XmlContent Seq where- toContents (Seq a) =- [CElem (Elem "seq" [] (concatMap toContents a)) ()]- parseContents = do- { e@(Elem _ [] _) <- element ["seq"]- ; interior e $ return (Seq) `apply` many parseContents- } `adjustErr` ("in <seq>, "++)--instance HTypeable Seq_ where- toHType x = Defined "seq" [] []-instance XmlContent Seq_ where- toContents (Seq_Locator a) = toContents a- toContents (Seq_Bool a) = toContents a- toContents (Seq_AInt a) = toContents a- toContents (Seq_AFloat a) = toContents a- toContents (Seq_AString a) = toContents a- toContents (Seq_Enum a) = toContents a- toContents (Seq_Seq a) = toContents a- toContents (Seq_Set a) = toContents a- toContents (Seq_Bag a) = toContents a- toContents (Seq_Tup a) = toContents a- parseContents = oneOf- [ return (Seq_Locator) `apply` parseContents- , return (Seq_Bool) `apply` parseContents- , return (Seq_AInt) `apply` parseContents- , return (Seq_AFloat) `apply` parseContents- , return (Seq_AString) `apply` parseContents- , return (Seq_Enum) `apply` parseContents- , return (Seq_Seq) `apply` parseContents- , return (Seq_Set) `apply` parseContents- , return (Seq_Bag) `apply` parseContents- , return (Seq_Tup) `apply` parseContents- ] `adjustErr` ("in <seq>, "++)--instance HTypeable Set where- toHType x = Defined "set" [] []-instance XmlContent Set where- toContents (Set a) =- [CElem (Elem "set" [] (concatMap toContents a)) ()]- parseContents = do- { e@(Elem _ [] _) <- element ["set"]- ; interior e $ return (Set) `apply` many parseContents- } `adjustErr` ("in <set>, "++)--instance HTypeable Set_ where- toHType x = Defined "set" [] []-instance XmlContent Set_ where- toContents (Set_Locator a) = toContents a- toContents (Set_Bool a) = toContents a- toContents (Set_AInt a) = toContents a- toContents (Set_AFloat a) = toContents a- toContents (Set_AString a) = toContents a- toContents (Set_Enum a) = toContents a- toContents (Set_Seq a) = toContents a- toContents (Set_Set a) = toContents a- toContents (Set_Bag a) = toContents a- toContents (Set_Tup a) = toContents a- parseContents = oneOf- [ return (Set_Locator) `apply` parseContents- , return (Set_Bool) `apply` parseContents- , return (Set_AInt) `apply` parseContents- , return (Set_AFloat) `apply` parseContents- , return (Set_AString) `apply` parseContents- , return (Set_Enum) `apply` parseContents- , return (Set_Seq) `apply` parseContents- , return (Set_Set) `apply` parseContents- , return (Set_Bag) `apply` parseContents- , return (Set_Tup) `apply` parseContents- ] `adjustErr` ("in <set>, "++)--instance HTypeable Bag where- toHType x = Defined "bag" [] []-instance XmlContent Bag where- toContents (Bag a) =- [CElem (Elem "bag" [] (concatMap toContents a)) ()]- parseContents = do- { e@(Elem _ [] _) <- element ["bag"]- ; interior e $ return (Bag) `apply` many parseContents- } `adjustErr` ("in <bag>, "++)--instance HTypeable Bag_ where- toHType x = Defined "bag" [] []-instance XmlContent Bag_ where- toContents (Bag_Locator a) = toContents a- toContents (Bag_Bool a) = toContents a- toContents (Bag_AInt a) = toContents a- toContents (Bag_AFloat a) = toContents a- toContents (Bag_AString a) = toContents a- toContents (Bag_Enum a) = toContents a- toContents (Bag_Seq a) = toContents a- toContents (Bag_Set a) = toContents a- toContents (Bag_Bag a) = toContents a- toContents (Bag_Tup a) = toContents a- parseContents = oneOf- [ return (Bag_Locator) `apply` parseContents- , return (Bag_Bool) `apply` parseContents- , return (Bag_AInt) `apply` parseContents- , return (Bag_AFloat) `apply` parseContents- , return (Bag_AString) `apply` parseContents- , return (Bag_Enum) `apply` parseContents- , return (Bag_Seq) `apply` parseContents- , return (Bag_Set) `apply` parseContents- , return (Bag_Bag) `apply` parseContents- , return (Bag_Tup) `apply` parseContents- ] `adjustErr` ("in <bag>, "++)--instance HTypeable Tup where- toHType x = Defined "tup" [] []-instance XmlContent Tup where- toContents (Tup a) =- [CElem (Elem "tup" [] (concatMap toContents a)) ()]- parseContents = do- { e@(Elem _ [] _) <- element ["tup"]- ; interior e $ return (Tup) `apply` many parseContents- } `adjustErr` ("in <tup>, "++)--instance HTypeable Tup_ where- toHType x = Defined "tup" [] []-instance XmlContent Tup_ where- toContents (Tup_Locator a) = toContents a- toContents (Tup_Bool a) = toContents a- toContents (Tup_AInt a) = toContents a- toContents (Tup_AFloat a) = toContents a- toContents (Tup_AString a) = toContents a- toContents (Tup_Enum a) = toContents a- toContents (Tup_Seq a) = toContents a- toContents (Tup_Set a) = toContents a- toContents (Tup_Bag a) = toContents a- toContents (Tup_Tup a) = toContents a- parseContents = oneOf- [ return (Tup_Locator) `apply` parseContents- , return (Tup_Bool) `apply` parseContents- , return (Tup_AInt) `apply` parseContents- , return (Tup_AFloat) `apply` parseContents- , return (Tup_AString) `apply` parseContents- , return (Tup_Enum) `apply` parseContents- , return (Tup_Seq) `apply` parseContents- , return (Tup_Set) `apply` parseContents- , return (Tup_Bag) `apply` parseContents- , return (Tup_Tup) `apply` parseContents- ] `adjustErr` ("in <tup>, "++)----{-Done-}
− examples/gxl-1.0.dtd
@@ -1,138 +0,0 @@-<!-- GXL (1.0)- Document Type Definition- (April 25, 2002)--copyright by-- Andy Schuerr- Real-Time Systems Lab- Darmstadt University of Technology- Merckstr. 25, D-64283 Darmstadt, Germany- andy.schuerr@es.tu-darmstadt.de-- Susan Elliott Sim- School of Information and Computer Science- 444 Computer Science Bldg.- University of California, Irvine- ses@ics.uci.edu-- Ric Holt- Department of Computer Science- University of Waterloo- Waterloo N2L 3G1, Canada- holt@plg.uwaterloo.ca-- Andreas Winter- Institute for Software Technology- University of Koblenz-Landau- Universitaetsstrasse 1, D-56070 Koblenz, Germany- winter@uni-koblenz.de--->-<!-- Extensions -->-<!ENTITY % gxl-extension "">-<!ENTITY % graph-extension "">-<!ENTITY % node-extension "">-<!ENTITY % edge-extension "">-<!ENTITY % rel-extension "">-<!ENTITY % value-extension "">-<!ENTITY % relend-extension "">-<!ENTITY % gxl-attr-extension "">-<!ENTITY % graph-attr-extension "">-<!ENTITY % node-attr-extension "">-<!ENTITY % edge-attr-extension "">-<!ENTITY % rel-attr-extension "">-<!ENTITY % relend-attr-extension "">-<!-- Attribute values -->-<!ENTITY % val "- locator |- bool |- int |- float |- string |- enum |- seq |- set |- bag |- tup- %value-extension;">-<!-- gxl -->-<!ELEMENT gxl (graph* %gxl-extension;) >-<!ATTLIST gxl- xmlns:xlink CDATA #FIXED "http://www.w3.org/1999/xlink"- %gxl-attr-extension;->-<!-- type -->-<!ELEMENT type EMPTY>-<!ATTLIST type- xlink:type (simple) #FIXED "simple"- xlink:href CDATA #REQUIRED->-<!-- graph -->-<!ELEMENT graph (type? , attr* , ( node | edge | rel )* %graph-extension;) >-<!ATTLIST graph- id ID #REQUIRED- role NMTOKEN #IMPLIED- edgeids (true | false) "false"- hypergraph (true | false) "false"- edgemode (directed | undirected | defaultdirected | defaultundirected) "directed"- %graph-attr-extension;->-<!-- node -->-<!ELEMENT node (type? , attr*, graph* %node-extension;) >-<!ATTLIST node- id ID #REQUIRED- %node-attr-extension;->-<!-- edge -->-<!ELEMENT edge (type?, attr*, graph* %edge-extension;) >-<!ATTLIST edge- id ID #IMPLIED- from IDREF #REQUIRED- to IDREF #REQUIRED- fromorder CDATA #IMPLIED- toorder CDATA #IMPLIED- isdirected (true | false) #IMPLIED- %edge-attr-extension;->-<!-- rel -->-<!ELEMENT rel (type? , attr*, graph*, relend* %rel-extension;) >-<!ATTLIST rel- id ID #IMPLIED- isdirected (true | false) #IMPLIED- %rel-attr-extension;->-<!-- relend -->-<!ELEMENT relend (attr* %relend-extension;) >-<!ATTLIST relend- target IDREF #REQUIRED- role NMTOKEN #IMPLIED- direction (in | out | none) #IMPLIED- startorder CDATA #IMPLIED- endorder CDATA #IMPLIED- %relend-attr-extension;->-<!-- attr -->-<!ELEMENT attr (attr*, (%val;))>-<!ATTLIST attr- id ID #IMPLIED- name NMTOKEN #REQUIRED- kind NMTOKEN #IMPLIED->-<!-- locator -->-<!ELEMENT locator EMPTY>-<!ATTLIST locator- xlink:type (simple) #FIXED "simple"- xlink:href CDATA #REQUIRED->-<!-- atomic values -->-<!ELEMENT bool (#PCDATA)>-<!ELEMENT int (#PCDATA)>-<!ELEMENT float (#PCDATA)>-<!ELEMENT string (#PCDATA)>-<!-- enumeration value -->-<!ELEMENT enum (#PCDATA)>-<!-- composite values -->-<!ELEMENT seq (%val;)*>-<!ELEMENT set (%val;)*>-<!ELEMENT bag (%val;)*>-<!ELEMENT tup (%val;)*>
src/Makefile view
@@ -1,5 +1,5 @@ SOFTWARE = HaXml-VERSION = 1.19+VERSION = 1.19.1 LIBSRCS = \ Text/XML/HaXml.hs Text/XML/HaXml/Combinators.hs Text/XML/HaXml/Lex.hs \
src/Text/XML/HaXml/SAX.hs view
@@ -12,7 +12,7 @@ import Text.XML.HaXml.Types import Text.XML.HaXml.Parse import Text.XML.HaXml.Lex-import Text.ParserCombinators.PolyState+import Text.ParserCombinators.Poly.NoLeak.State data SaxElement = SaxDocTypeDecl DocTypeDecl
src/Text/XML/HaXml/TypeMapping.hs view
@@ -58,11 +58,7 @@ -- variables occurring in the (second) list of real component types. -- If there are fieldnames, they are contained in the final list, and -- correspond one-to-one with the component types.--- The Synonym alternative is for where the type-mapping from Haskell to--- XML is user-defined rather than automatic. There, one might wish to--- rename an existing XML type, without the addition of a constructor\/tag. data Constr = Constr String [HType] [HType] -- (Maybe [String])- | Synonym HType deriving (Eq,Show) -- | Project the n'th constructor from an HType and convert it to a string@@ -156,14 +152,12 @@ | c `notElem` chist = [Element (ElementDecl (flatConstr c "") (ContentSpec (constrHtExpr c)))] | otherwise = [] - declConstr _ (Synonym ht) = [] declprim (Prim s t) = [ Element (ElementDecl t EMPTY) , AttList (AttListDecl t [AttDef "value" StringType REQUIRED])] declstring = Element (ElementDecl "string" (Mixed PCDATA)) grab (Constr _ _ hts) = hts- grab (Synonym ht) = [ht] (?) :: Bool -> (a->a) -> (a->a) b ? f | b = f@@ -188,7 +182,6 @@ flatConstr (Constr s fv _) = showString s . ((length fv > 0) ? (showChar '-')) . foldr (.) id (intersperse (showChar '-') (map showHType fv))-flatConstr (Synonym ht) = id outerHtExpr :: HType -> CP outerHtExpr (Maybe ht) = innerHtExpr ht Query@@ -208,6 +201,5 @@ constrHtExpr :: Constr -> CP constrHtExpr (Constr s fv []) = TagName "EMPTY" None -- ***HACK!!!*** constrHtExpr (Constr s fv hts) = innerHtExpr (Tuple hts) None-constrHtExpr (Synonym ht) = outerHtExpr ht ------------------------------------------------------------------------
src/Text/XML/HaXml/Types.hs view
@@ -109,7 +109,6 @@ ) where - {- A simple symbol table for storing macros whilst parsing. -} type SymTab a = [(String,a)]@@ -130,10 +129,14 @@ -- | The symbol table stored in a document holds all its general entity -- reference definitions. data Document i = Document Prolog (SymTab EntityDef) (Element i) [Misc]-data Prolog = Prolog (Maybe XMLDecl) [Misc] (Maybe DocTypeDecl) [Misc]-data XMLDecl = XMLDecl VersionInfo (Maybe EncodingDecl) (Maybe SDDecl) -data Misc = Comment Comment- | PI ProcessingInstruction+ deriving Eq+data Prolog = Prolog (Maybe XMLDecl) [Misc] (Maybe DocTypeDecl) [Misc]+ deriving Eq+data XMLDecl = XMLDecl VersionInfo (Maybe EncodingDecl) (Maybe SDDecl)+ deriving Eq+data Misc = Comment Comment+ | PI ProcessingInstruction + deriving Eq type ProcessingInstruction = (PITarget,String) @@ -142,26 +145,29 @@ type Comment = String type PITarget = String -data DocTypeDecl = DTD Name (Maybe ExternalID) [MarkupDecl] +data DocTypeDecl = DTD Name (Maybe ExternalID) [MarkupDecl] deriving Eq data MarkupDecl = Element ElementDecl | AttList AttListDecl | Entity EntityDecl | Notation NotationDecl | MarkupMisc Misc+ deriving Eq -data ExtSubset = ExtSubset (Maybe TextDecl) [ExtSubsetDecl] +data ExtSubset = ExtSubset (Maybe TextDecl) [ExtSubsetDecl] deriving Eq data ExtSubsetDecl = ExtMarkupDecl MarkupDecl | ExtConditionalSect ConditionalSect+ deriving Eq -data Element i = Elem Name [Attribute] [Content i]-data ElemTag = ElemTag Name [Attribute] -- ^ intermediate for parsing+data Element i = Elem Name [Attribute] [Content i] deriving Eq+ -- intermediate for parsing+data ElemTag = ElemTag Name [Attribute] type Attribute = (Name, AttValue) data Content i = CElem (Element i) i | CString Bool CharData i -- ^ bool is whether whitespace is significant | CRef Reference i | CMisc Misc i-+ deriving Eq info (CElem _ i) = i info (CString _ _ i) = i info (CRef _ i) = i@@ -177,26 +183,31 @@ fmap f (CRef r i) = CRef r (f i) fmap f (CMisc m i) = CMisc m (f i) -data ElementDecl = ElementDecl Name ContentSpec+data ElementDecl = ElementDecl Name ContentSpec deriving Eq data ContentSpec = EMPTY | ANY | Mixed Mixed | ContentSpec CP+ deriving Eq+-- FIXME: What is TagName here? Seems to be in disagreement with XML spec. data CP = TagName Name Modifier | Choice [CP] Modifier | Seq [CP] Modifier + deriving Eq data Modifier = None -- ^ Just One | Query -- ^ Zero Or One | Star -- ^ Zero Or More | Plus -- ^ One Or More + deriving Eq data Mixed = PCDATA | PCDATAplus [Name] --data AttListDecl = AttListDecl Name [AttDef]-data AttDef = AttDef Name AttType DefaultDecl + deriving Eq+data AttListDecl = AttListDecl Name [AttDef] deriving Eq+data AttDef = AttDef Name AttType DefaultDecl deriving Eq data AttType = StringType | TokenizedType TokenizedType | EnumeratedType EnumeratedType + deriving Eq data TokenizedType = ID | IDREF | IDREFS@@ -204,56 +215,61 @@ | ENTITIES | NMTOKEN | NMTOKENS + deriving Eq data EnumeratedType = NotationType NotationType | Enumeration Enumeration + deriving Eq type NotationType = [Name] -- nonempty list type Enumeration = [NmToken] -- nonempty list data DefaultDecl = REQUIRED | IMPLIED | DefaultTo AttValue (Maybe FIXED) -data FIXED = FIXED + deriving Eq+data FIXED = FIXED deriving Eq data ConditionalSect = IncludeSect IncludeSect | IgnoreSect IgnoreSect + deriving Eq type IncludeSect = [ExtSubsetDecl] type IgnoreSect = [IgnoreSectContents]-data Ignore = Ignore-data IgnoreSectContents = IgnoreSectContents Ignore [(IgnoreSectContents,Ignore)] +data Ignore = Ignore deriving Eq+data IgnoreSectContents = IgnoreSectContents Ignore [(IgnoreSectContents,Ignore)] deriving Eq data Reference = RefEntity EntityRef | RefChar CharRef - deriving (Eq, Show)+ deriving (Eq,Show) type EntityRef = Name type CharRef = Int type PEReference = Name data EntityDecl = EntityGEDecl GEDecl | EntityPEDecl PEDecl -data GEDecl = GEDecl Name EntityDef -data PEDecl = PEDecl Name PEDef -data EntityDef = DefEntityValue EntityValue+ deriving Eq+data GEDecl = GEDecl Name EntityDef deriving Eq+data PEDecl = PEDecl Name PEDef deriving Eq+data EntityDef = DefEntityValue EntityValue | DefExternalID ExternalID (Maybe NDataDecl) + deriving Eq data PEDef = PEDefEntityValue EntityValue- | PEDefExternalID ExternalID deriving (Show)+ | PEDefExternalID ExternalID deriving (Eq,Show) data ExternalID = SYSTEM SystemLiteral- | PUBLIC PubidLiteral SystemLiteral deriving (Show)-newtype NDataDecl = NDATA Name + | PUBLIC PubidLiteral SystemLiteral deriving (Eq,Show)+newtype NDataDecl = NDATA Name deriving Eq -data TextDecl = TextDecl (Maybe VersionInfo) EncodingDecl -data ExtParsedEnt i = ExtParsedEnt (Maybe TextDecl) (Content i)-data ExtPE = ExtPE (Maybe TextDecl) [ExtSubsetDecl]+data TextDecl = TextDecl (Maybe VersionInfo) EncodingDecl deriving Eq+data ExtParsedEnt i = ExtParsedEnt (Maybe TextDecl) (Content i) deriving Eq+data ExtPE = ExtPE (Maybe TextDecl) [ExtSubsetDecl] deriving Eq -data NotationDecl = NOTATION Name (Either ExternalID PublicID) -newtype PublicID = PUBLICID PubidLiteral -newtype EncodingDecl = EncodingDecl String +data NotationDecl = NOTATION Name (Either ExternalID PublicID) deriving Eq+newtype PublicID = PUBLICID PubidLiteral deriving Eq+newtype EncodingDecl = EncodingDecl String deriving Eq type Name = String -- non-empty string type Names = [Name] -- non-empty list type NmToken = String -- non-empty string type NmTokens = [NmToken] -- non-empty list -data AttValue = AttValue [Either String Reference]- deriving Eq+data AttValue = AttValue [Either String Reference] deriving Eq instance Show AttValue where show (AttValue v) = concatMap decode v where@@ -261,12 +277,12 @@ decode (Right (RefEntity ent)) = "&"++ent++";" decode (Right (RefChar cref)) = "&"++show cref++";" -data EntityValue = EntityValue [EV] deriving (Show)+data EntityValue = EntityValue [EV] deriving (Eq,Show) data EV = EVString String -- -- | EVPERef PEReference- | EVRef Reference deriving (Show)-newtype PubidLiteral = PubidLiteral String deriving (Show)-newtype SystemLiteral = SystemLiteral String deriving (Show)+ | EVRef Reference deriving (Eq,Show)+newtype PubidLiteral = PubidLiteral String deriving (Eq,Show)+newtype SystemLiteral = SystemLiteral String deriving (Eq,Show) type CharData = String type CDSect = CharData
src/Text/XML/HaXml/Xtract/Parse.hs view
@@ -11,6 +11,7 @@ import Text.XML.HaXml.Xtract.Lex import Text.XML.HaXml.Xtract.Combinators as D import Text.XML.HaXml.Combinators as C+import Text.XML.HaXml.Types (Content) import List(isPrefixOf) import Text.XML.HaXml.Escape (xmlUnEscapeContent,stdXmlEscaper)