packages feed

polyparse 1.4 → 1.4.1

raw patch · 58 files changed

+18334/−20 lines, 58 filesbinary-added

Files

+ Build.bat view
@@ -0,0 +1,98 @@+REM -- Build polyparse package using GHC
+REM
+REM    Usage: (case-sensitive)
+REM      Build         compile and install the polyparse library GHC package
+REM      Build Remove  remove the polyparse GHC library package
+
+rem -- Change the following variables (upto and including SRC)
+rem -- to suit the local system environment --
+
+rem    GHC version
+set GHCVER=6.6
+
+rem    GHC installation directory:
+set GHCDIR=C:\DEV\ghc\ghc-%GHCVER%
+
+rem    Programs needed to build polyparse:
+rem
+rem    NOTE: install MinGW linked from <http://www.mingw.org/>
+rem    for a copy of 'ar.exe'
+rem
+set GHC=C:\DEV\ghc\ghc-%GHCVER%\bin\ghc.exe
+set GHCPKG=C:\DEV\ghc\ghc-%GHCVER%\bin\ghc-pkg.exe
+set AR=C:\DEV\MinGW\bin\ar.exe
+set LD=C:\DEV\ghc\ghc-%GHCVER%\gcc-lib\ld.exe
+
+rem    Source directory for polyparse:
+set SRC=C:\DEV\Haskell\lib\polyparse-1.1\src
+
+rem    Two very long lines (500-600 chars) follow here.  
+rem    They should not need changing.
+set SRCS=Text/ParserCombinators/Poly.hs Text/ParserCombinators/PolyState.hs Text/ParserCombinators/TextParser.hs Text/ParserCombinators/PolyLazy.hs Text/ParserCombinators/PolyStateLazy.hs Text/ParserCombinators/Poly/Base.hs Text/ParserCombinators/Poly/Plain.hs Text/ParserCombinators/Poly/State.hs Text/ParserCombinators/Poly/Lazy.hs Text/ParserCombinators/Poly/StateLazy.hs Text/ParserCombinators/Poly/NoLeak/Plain.hs Text/ParserCombinators/Poly/NoLeak/State.hs Text/ParserCombinators/Poly/NoLeak/Lazy.hs Text/ParserCombinators/Poly/NoLeak/StateLazy.hs
+set OBJS=Text/ParserCombinators/Poly.o Text/ParserCombinators/PolyState.o Text/ParserCombinators/TextParser.o Text/ParserCombinators/PolyLazy.o Text/ParserCombinators/PolyStateLazy.o Text/ParserCombinators/Poly/Base.o Text/ParserCombinators/Poly/Plain.o Text/ParserCombinators/Poly/State.o Text/ParserCombinators/Poly/Lazy.o Text/ParserCombinators/Poly/StateLazy.o Text/ParserCombinators/Poly/NoLeak/Plain.o Text/ParserCombinators/Poly/NoLeak/State.o Text/ParserCombinators/Poly/NoLeak/Lazy.o Text/ParserCombinators/Poly/NoLeak/StateLazy.o
+
+
+rem -- Get on with the real work --
+
+if "%1"=="Remove" goto Remove
+
+rem -- Compile sources and create library archive
+if "%GHCVER%"=="6.4"   COPY polyparse.cabal %SRC%\pkg.conf
+if "%GHCVER%"=="6.4.1" COPY polyparse.cabal %SRC%\pkg.conf
+if "%GHCVER%"=="6.4.2" COPY polyparse.cabal %SRC%\pkg.conf
+if "%GHCVER%"=="6.6"   COPY polyparse.cabal %SRC%\pkg.conf
+if "%GHCVER%"=="6.6.1" COPY polyparse.cabal %SRC%\pkg.conf
+if "%GHCVER%"=="6.6.2" COPY polyparse.cabal %SRC%\pkg.conf
+cd %SRC%
+%GHC% --make -cpp -i. -package-name polyparse-1.1 %SRCS%
+%AR% r libHSpolyparse.a %OBJS%
+
+rem -- Create library file for GHCi
+%LD% -r --whole-archive -o HSpolyparse.o libHSpolyparse.a
+
+rem -- Install the library archive(s) where GHC can find them
+COPY libHSpolyparse.a %GHCDIR%
+COPY HSpolyparse.o    %GHCDIR%
+
+rem -- Install the interface files where GHC can find them
+rem    /L - list only, /Y - overrite without confirmation
+rem    /S - copy subdirectories, /T - create directories only
+rem    /F - display full filenames while copying
+XCOPY /S /F *.hi %GHCDIR%\imports
+
+rem -- Finally, register the package with GHC
+if "%GHCVER%"=="6.2"    goto OldRegister
+if "%GHCVER%"=="6.2.1"  goto OldRegister
+if "%GHCVER%"=="6.2.2"  goto OldRegister
+if "%GHCVER%"=="6.4"    goto NewRegister
+if "%GHCVER%"=="6.4.1"  goto NewRegister
+if "%GHCVER%"=="6.4.2"  goto NewRegister
+if "%GHCVER%"=="6.6"    goto NewRegister
+if "%GHCVER%"=="6.6.1"  goto NewRegister
+if "%GHCVER%"=="6.6.2"  goto NewRegister
+
+goto Exit
+
+rem -- old-style package registration
+:OldRegister
+%GHCPKG% --add-package -i pkg.conf
+goto Exit
+
+rem -- new-style package registration
+:NewRegister
+ECHO import-dirs:   %GHCDIR%\imports >>pkg.conf
+ECHO library-dirs:  %GHCDIR% >>pkg.conf
+ECHO depends:       base, haskell98 >>pkg.conf
+ECHO hs-libraries:  HSpolyparse >>pkg.conf
+%GHCPKG% register pkg.conf
+goto Exit
+
+rem -- Remove GHC package for polyparse --
+:Remove
+%GHCPKG% --remove-package polyparse-1.1
+
+goto Exit
+
+rem -- All done --
+
+:Exit
@@ -6,7 +6,7 @@     (c) copyright 1998-2000    Malcolm Wallace The modules Text.ParserCombinators.Poly* and Text.Parse and Text.Parse.* are-    (c) copyright 2006-2009    Malcolm Wallace+    (c) copyright 2006-2010    Malcolm Wallace  These modules are licensed under the terms of the GNU Lesser General Public Licence (LGPL), which can be found in the file called
+ LICENCE-LGPL view
@@ -0,0 +1,507 @@+                  GNU LESSER GENERAL PUBLIC LICENSE+                       Version 2.1, February 1999++ Copyright (C) 1991, 1999 Free Software Foundation, Inc.+     59 Temple Place, Suite 330, Boston, MA  02111-1307  USA+ Everyone is permitted to copy and distribute verbatim copies+ of this license document, but changing it is not allowed.++[This is the first released version of the Lesser GPL.  It also counts+ as the successor of the GNU Library Public License, version 2, hence+ the version number 2.1.]++                            Preamble++  The licenses for most software are designed to take away your+freedom to share and change it.  By contrast, the GNU General Public+Licenses are intended to guarantee your freedom to share and change+free software--to make sure the software is free for all its users.++  This license, the Lesser General Public License, applies to some+specially designated software packages--typically libraries--of the+Free Software Foundation and other authors who decide to use it.  You+can use it too, but we suggest you first think carefully about whether+this license or the ordinary General Public License is the better+strategy to use in any particular case, based on the explanations+below.++  When we speak of free software, we are referring to freedom of use,+not price.  Our General Public Licenses are designed to make sure that+you have the freedom to distribute copies of free software (and charge+for this service if you wish); that you receive source code or can get+it if you want it; that you can change the software and use pieces of+it in new free programs; and that you are informed that you can do+these things.++  To protect your rights, we need to make restrictions that forbid+distributors to deny you these rights or to ask you to surrender these+rights.  These restrictions translate to certain responsibilities for+you if you distribute copies of the library or if you modify it.++  For example, if you distribute copies of the library, whether gratis+or for a fee, you must give the recipients all the rights that we gave+you.  You must make sure that they, too, receive or can get the source+code.  If you link other code with the library, you must provide+complete object files to the recipients, so that they can relink them+with the library after making changes to the library and recompiling+it.  And you must show them these terms so they know their rights.++  We protect your rights with a two-step method: (1) we copyright the+library, and (2) we offer you this license, which gives you legal+permission to copy, distribute and/or modify the library.++  To protect each distributor, we want to make it very clear that+there is no warranty for the free library.  Also, if the library is+modified by someone else and passed on, the recipients should know+that what they have is not the original version, so that the original+author's reputation will not be affected by problems that might be+introduced by others.++  Finally, software patents pose a constant threat to the existence of+any free program.  We wish to make sure that a company cannot+effectively restrict the users of a free program by obtaining a+restrictive license from a patent holder.  Therefore, we insist that+any patent license obtained for a version of the library must be+consistent with the full freedom of use specified in this license.++  Most GNU software, including some libraries, is covered by the+ordinary GNU General Public License.  This license, the GNU Lesser+General Public License, applies to certain designated libraries, and+is quite different from the ordinary General Public License.  We use+this license for certain libraries in order to permit linking those+libraries into non-free programs.++  When a program is linked with a library, whether statically or using+a shared library, the combination of the two is legally speaking a+combined work, a derivative of the original library.  The ordinary+General Public License therefore permits such linking only if the+entire combination fits its criteria of freedom.  The Lesser General+Public License permits more lax criteria for linking other code with+the library.++  We call this license the "Lesser" General Public License because it+does Less to protect the user's freedom than the ordinary General+Public License.  It also provides other free software developers Less+of an advantage over competing non-free programs.  These disadvantages+are the reason we use the ordinary General Public License for many+libraries.  However, the Lesser license provides advantages in certain+special circumstances.++  For example, on rare occasions, there may be a special need to+encourage the widest possible use of a certain library, so that it+becomes a de-facto standard.  To achieve this, non-free programs must+be allowed to use the library.  A more frequent case is that a free+library does the same job as widely used non-free libraries.  In this+case, there is little to gain by limiting the free library to free+software only, so we use the Lesser General Public License.++  In other cases, permission to use a particular library in non-free+programs enables a greater number of people to use a large body of+free software.  For example, permission to use the GNU C Library in+non-free programs enables many more people to use the whole GNU+operating system, as well as its variant, the GNU/Linux operating+system.++  Although the Lesser General Public License is Less protective of the+users' freedom, it does ensure that the user of a program that is+linked with the Library has the freedom and the wherewithal to run+that program using a modified version of the Library.++  The precise terms and conditions for copying, distribution and+modification follow.  Pay close attention to the difference between a+"work based on the library" and a "work that uses the library".  The+former contains code derived from the library, whereas the latter must+be combined with the library in order to run.+++                  GNU LESSER GENERAL PUBLIC LICENSE+   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION++  0. This License Agreement applies to any software library or other+program which contains a notice placed by the copyright holder or+other authorized party saying it may be distributed under the terms of+this Lesser General Public License (also called "this License").+Each licensee is addressed as "you".++  A "library" means a collection of software functions and/or data+prepared so as to be conveniently linked with application programs+(which use some of those functions and data) to form executables.++  The "Library", below, refers to any such software library or work+which has been distributed under these terms.  A "work based on the+Library" means either the Library or any derivative work under+copyright law: that is to say, a work containing the Library or a+portion of it, either verbatim or with modifications and/or translated+straightforwardly into another language.  (Hereinafter, translation is+included without limitation in the term "modification".)++  "Source code" for a work means the preferred form of the work for+making modifications to it.  For a library, complete source code means+all the source code for all modules it contains, plus any associated+interface definition files, plus the scripts used to control+compilation and installation of the library.++  Activities other than copying, distribution and modification are not+covered by this License; they are outside its scope.  The act of+running a program using the Library is not restricted, and output from+such a program is covered only if its contents constitute a work based+on the Library (independent of the use of the Library in a tool for+writing it).  Whether that is true depends on what the Library does+and what the program that uses the Library does.++  1. You may copy and distribute verbatim copies of the Library's+complete source code as you receive it, in any medium, provided that+you conspicuously and appropriately publish on each copy an+appropriate copyright notice and disclaimer of warranty; keep intact+all the notices that refer to this License and to the absence of any+warranty; and distribute a copy of this License along with the+Library.++  You may charge a fee for the physical act of transferring a copy,+and you may at your option offer warranty protection in exchange for a+fee.++  2. You may modify your copy or copies of the Library or any portion+of it, thus forming a work based on the Library, and copy and+distribute such modifications or work under the terms of Section 1+above, provided that you also meet all of these conditions:++    a) The modified work must itself be a software library.++    b) You must cause the files modified to carry prominent notices+    stating that you changed the files and the date of any change.++    c) You must cause the whole of the work to be licensed at no+    charge to all third parties under the terms of this License.++    d) If a facility in the modified Library refers to a function or a+    table of data to be supplied by an application program that uses+    the facility, other than as an argument passed when the facility+    is invoked, then you must make a good faith effort to ensure that,+    in the event an application does not supply such function or+    table, the facility still operates, and performs whatever part of+    its purpose remains meaningful.++    (For example, a function in a library to compute square roots has+    a purpose that is entirely well-defined independent of the+    application.  Therefore, Subsection 2d requires that any+    application-supplied function or table used by this function must+    be optional: if the application does not supply it, the square+    root function must still compute square roots.)++These requirements apply to the modified work as a whole.  If+identifiable sections of that work are not derived from the Library,+and can be reasonably considered independent and separate works in+themselves, then this License, and its terms, do not apply to those+sections when you distribute them as separate works.  But when you+distribute the same sections as part of a whole which is a work based+on the Library, the distribution of the whole must be on the terms of+this License, whose permissions for other licensees extend to the+entire whole, and thus to each and every part regardless of who wrote+it.++Thus, it is not the intent of this section to claim rights or contest+your rights to work written entirely by you; rather, the intent is to+exercise the right to control the distribution of derivative or+collective works based on the Library.++In addition, mere aggregation of another work not based on the Library+with the Library (or with a work based on the Library) on a volume of+a storage or distribution medium does not bring the other work under+the scope of this License.++  3. You may opt to apply the terms of the ordinary GNU General Public+License instead of this License to a given copy of the Library.  To do+this, you must alter all the notices that refer to this License, so+that they refer to the ordinary GNU General Public License, version 2,+instead of to this License.  (If a newer version than version 2 of the+ordinary GNU General Public License has appeared, then you can specify+that version instead if you wish.)  Do not make any other change in+these notices.++  Once this change is made in a given copy, it is irreversible for+that copy, so the ordinary GNU General Public License applies to all+subsequent copies and derivative works made from that copy.++  This option is useful when you wish to copy part of the code of+the Library into a program that is not a library.++  4. You may copy and distribute the Library (or a portion or+derivative of it, under Section 2) in object code or executable form+under the terms of Sections 1 and 2 above provided that you accompany+it with the complete corresponding machine-readable source code, which+must be distributed under the terms of Sections 1 and 2 above on a+medium customarily used for software interchange.++  If distribution of object code is made by offering access to copy+from a designated place, then offering equivalent access to copy the+source code from the same place satisfies the requirement to+distribute the source code, even though third parties are not+compelled to copy the source along with the object code.++  5. A program that contains no derivative of any portion of the+Library, but is designed to work with the Library by being compiled or+linked with it, is called a "work that uses the Library".  Such a+work, in isolation, is not a derivative work of the Library, and+therefore falls outside the scope of this License.++  However, linking a "work that uses the Library" with the Library+creates an executable that is a derivative of the Library (because it+contains portions of the Library), rather than a "work that uses the+library".  The executable is therefore covered by this License.+Section 6 states terms for distribution of such executables.++  When a "work that uses the Library" uses material from a header file+that is part of the Library, the object code for the work may be a+derivative work of the Library even though the source code is not.+Whether this is true is especially significant if the work can be+linked without the Library, or if the work is itself a library.  The+threshold for this to be true is not precisely defined by law.++  If such an object file uses only numerical parameters, data+structure layouts and accessors, and small macros and small inline+functions (ten lines or less in length), then the use of the object+file is unrestricted, regardless of whether it is legally a derivative+work.  (Executables containing this object code plus portions of the+Library will still fall under Section 6.)++  Otherwise, if the work is a derivative of the Library, you may+distribute the object code for the work under the terms of Section 6.+Any executables containing that work also fall under Section 6,+whether or not they are linked directly with the Library itself.++  6. As an exception to the Sections above, you may also combine or+link a "work that uses the Library" with the Library to produce a+work containing portions of the Library, and distribute that work+under terms of your choice, provided that the terms permit+modification of the work for the customer's own use and reverse+engineering for debugging such modifications.++  You must give prominent notice with each copy of the work that the+Library is used in it and that the Library and its use are covered by+this License.  You must supply a copy of this License.  If the work+during execution displays copyright notices, you must include the+copyright notice for the Library among them, as well as a reference+directing the user to the copy of this License.  Also, you must do one+of these things:++    a) Accompany the work with the complete corresponding+    machine-readable source code for the Library including whatever+    changes were used in the work (which must be distributed under+    Sections 1 and 2 above); and, if the work is an executable linked+    with the Library, with the complete machine-readable "work that+    uses the Library", as object code and/or source code, so that the+    user can modify the Library and then relink to produce a modified+    executable containing the modified Library.  (It is understood+    that the user who changes the contents of definitions files in the+    Library will not necessarily be able to recompile the application+    to use the modified definitions.)++    b) Use a suitable shared library mechanism for linking with the+    Library.  A suitable mechanism is one that (1) uses at run time a+    copy of the library already present on the user's computer system,+    rather than copying library functions into the executable, and (2)+    will operate properly with a modified version of the library, if+    the user installs one, as long as the modified version is+    interface-compatible with the version that the work was made with.++    c) Accompany the work with a written offer, valid for at least+    three years, to give the same user the materials specified in+    Subsection 6a, above, for a charge no more than the cost of+    performing this distribution.++    d) If distribution of the work is made by offering access to copy+    from a designated place, offer equivalent access to copy the above+    specified materials from the same place.++    e) Verify that the user has already received a copy of these+    materials or that you have already sent this user a copy.++  For an executable, the required form of the "work that uses the+Library" must include any data and utility programs needed for+reproducing the executable from it.  However, as a special exception,+the materials to be distributed need not include anything that is+normally distributed (in either source or binary form) with the major+components (compiler, kernel, and so on) of the operating system on+which the executable runs, unless that component itself accompanies+the executable.++  It may happen that this requirement contradicts the license+restrictions of other proprietary libraries that do not normally+accompany the operating system.  Such a contradiction means you cannot+use both them and the Library together in an executable that you+distribute.++  7. You may place library facilities that are a work based on the+Library side-by-side in a single library together with other library+facilities not covered by this License, and distribute such a combined+library, provided that the separate distribution of the work based on+the Library and of the other library facilities is otherwise+permitted, and provided that you do these two things:++    a) Accompany the combined library with a copy of the same work+    based on the Library, uncombined with any other library+    facilities.  This must be distributed under the terms of the+    Sections above.++    b) Give prominent notice with the combined library of the fact+    that part of it is a work based on the Library, and explaining+    where to find the accompanying uncombined form of the same work.++  8. You may not copy, modify, sublicense, link with, or distribute+the Library except as expressly provided under this License.  Any+attempt otherwise to copy, modify, sublicense, link with, or+distribute the Library is void, and will automatically terminate your+rights under this License.  However, parties who have received copies,+or rights, from you under this License will not have their licenses+terminated so long as such parties remain in full compliance.++  9. You are not required to accept this License, since you have not+signed it.  However, nothing else grants you permission to modify or+distribute the Library or its derivative works.  These actions are+prohibited by law if you do not accept this License.  Therefore, by+modifying or distributing the Library (or any work based on the+Library), you indicate your acceptance of this License to do so, and+all its terms and conditions for copying, distributing or modifying+the Library or works based on it.++  10. Each time you redistribute the Library (or any work based on the+Library), the recipient automatically receives a license from the+original licensor to copy, distribute, link with or modify the Library+subject to these terms and conditions.  You may not impose any further+restrictions on the recipients' exercise of the rights granted herein.+You are not responsible for enforcing compliance by third parties with+this License.++  11. If, as a consequence of a court judgment or allegation of patent+infringement or for any other reason (not limited to patent issues),+conditions are imposed on you (whether by court order, agreement or+otherwise) that contradict the conditions of this License, they do not+excuse you from the conditions of this License.  If you cannot+distribute so as to satisfy simultaneously your obligations under this+License and any other pertinent obligations, then as a consequence you+may not distribute the Library at all.  For example, if a patent+license would not permit royalty-free redistribution of the Library by+all those who receive copies directly or indirectly through you, then+the only way you could satisfy both it and this License would be to+refrain entirely from distribution of the Library.++If any portion of this section is held invalid or unenforceable under+any particular circumstance, the balance of the section is intended to+apply, and the section as a whole is intended to apply in other+circumstances.++It is not the purpose of this section to induce you to infringe any+patents or other property right claims or to contest validity of any+such claims; this section has the sole purpose of protecting the+integrity of the free software distribution system which is+implemented by public license practices.  Many people have made+generous contributions to the wide range of software distributed+through that system in reliance on consistent application of that+system; it is up to the author/donor to decide if he or she is willing+to distribute software through any other system and a licensee cannot+impose that choice.++This section is intended to make thoroughly clear what is believed to+be a consequence of the rest of this License.++  12. If the distribution and/or use of the Library is restricted in+certain countries either by patents or by copyrighted interfaces, the+original copyright holder who places the Library under this License+may add an explicit geographical distribution limitation excluding those+countries, so that distribution is permitted only in or among+countries not thus excluded.  In such case, this License incorporates+the limitation as if written in the body of this License.++  13. The Free Software Foundation may publish revised and/or new+versions of the Lesser General Public License from time to time.+Such new versions will be similar in spirit to the present version,+but may differ in detail to address new problems or concerns.++Each version is given a distinguishing version number.  If the Library+specifies a version number of this License which applies to it and+"any later version", you have the option of following the terms and+conditions either of that version or of any later version published by+the Free Software Foundation.  If the Library does not specify a+license version number, you may choose any version ever published by+the Free Software Foundation.++  14. If you wish to incorporate parts of the Library into other free+programs whose distribution conditions are incompatible with these,+write to the author to ask for permission.  For software which is+copyrighted by the Free Software Foundation, write to the Free+Software Foundation; we sometimes make exceptions for this.  Our+decision will be guided by the two goals of preserving the free status+of all derivatives of our free software and of promoting the sharing+and reuse of software generally.++                            NO WARRANTY++  15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO+WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR+OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY+KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR+PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE+LIBRARY IS WITH YOU.  SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.++  16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY+AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU+FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR+CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE+LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A+FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH+DAMAGES.++                     END OF TERMS AND CONDITIONS+++           How to Apply These Terms to Your New Libraries++  If you develop a new library, and you want it to be of the greatest+possible use to the public, we recommend making it free software that+everyone can redistribute and change.  You can do so by permitting+redistribution under these terms (or, alternatively, under the terms of the+ordinary General Public License).++  To apply these terms, attach the following notices to the library.  It is+safest to attach them to the start of each source file to most effectively+convey the exclusion of warranty; and each file should have at least the+"copyright" line and a pointer to where the full notice is found.++    <one line to give the library's name and a brief idea of what it does.>+    Copyright (C) <year>  <name of author>++    This library is free software; you can redistribute it and/or+    modify it under the terms of the GNU Lesser General Public+    License as published by the Free Software Foundation; either+    version 2.1 of the License, or (at your option) any later version.++    This library is distributed in the hope that it will be useful,+    but WITHOUT ANY WARRANTY; without even the implied warranty of+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU+    Lesser General Public License for more details.++    You should have received a copy of the GNU Lesser General Public+    License along with this library; if not, write to the Free Software+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA++Also add information on how to contact you by electronic and paper mail.++You should also get your employer (if you work as a programmer) or your+school, if any, to sign a "copyright disclaimer" for the library, if+necessary.  Here is a sample; alter the names:++  Yoyodyne, Inc., hereby disclaims all copyright interest in the+  library `Frob' (a library for tweaking knobs) written by James Random Hacker.++  <signature of Ty Coon>, 1 April 1990+  Ty Coon, President of Vice++That's all there is to it!+
+ Makefile view
@@ -0,0 +1,107 @@+SOFTWARE = polyparse+VERSION  = 1.4.1++CPP      = cpp -traditional+#CPP     = cpphs --text 	# useful e.g. on MacOS X++DIRS = Text Text/Parse Text/ParserCombinators Text/ParserCombinators/Poly++SRCS = \+	src/Text/ParserCombinators/HuttonMeijer.hs \+	src/Text/ParserCombinators/HuttonMeijerWallace.hs \+	src/Text/ParserCombinators/Poly.hs \+	src/Text/ParserCombinators/Poly/Base.hs \+	src/Text/ParserCombinators/Poly/Plain.hs \+	src/Text/ParserCombinators/Poly/Lazy.hs \+	src/Text/ParserCombinators/Poly/State.hs \+	src/Text/ParserCombinators/Poly/StateLazy.hs \+	src/Text/ParserCombinators/Poly/ByteString.hs \+	src/Text/Parse.hs \+	src/Text/Parse/ByteString.hs++TOOLSRCS = \++AUX =	configure Makefile src/Makefile src/pkg.conf docs/* examples \+	README LICENCE* COPYRIGHT script/echo.c Build.bat \+	*.cabal Setup.hs+ALLFILES = $(SRCS) $(TOOLSRCS) $(AUX)++# These files in CVS are NOT included in the src distribution.+NOT =	Makefile.inc Makefile.nhc98 src/Makefile.inc src/Makefile.nhc98++.PHONY: all libs tools haddock install register++COMPILERS = $(shell cat obj/compilers)+LIBS  = $(patsubst %, libs-%, $(COMPILERS))+TOOLS = $(patsubst %, tools-%, $(COMPILERS))+INSTALL = $(patsubst %, install-%, $(COMPILERS))+FILESONLY = $(patsubst %, install-filesonly-%, $(COMPILERS))++all: $(LIBS) $(TOOLS)+libs: $(LIBS)+tools: $(TOOLS)+install: $(INSTALL)+install-filesonly: $(FILESONLY)+libs-ghc:+	cd obj/ghc; $(MAKE) HC=$(shell cat obj/ghccmd) libs+libs-nhc98:+	cd obj/nhc98; $(MAKE) HC=nhc98 libs+libs-hugs:+	@echo "No building required for Hugs version of $(SOFTWARE) libs."+tools-ghc:+	cd obj/ghc; $(MAKE) HC=$(shell cat obj/ghccmd) toolset+tools-nhc98:+	cd obj/nhc98; $(MAKE) HC=nhc98 toolset+tools-hugs:+	@echo "No building required for Hugs version of $(SOFTWARE) tools."+install-ghc:+	cd obj/ghc; $(MAKE) HC=$(shell cat obj/ghccmd) install-ghc+install-nhc98:+	cd obj/nhc98; $(MAKE) HC=nhc98 install-nhc98+install-hugs:+	hugs-package src+	cd obj/hugs; $(MAKE) install-tools-hugs+install-filesonly-ghc:+	cd obj/ghc; $(MAKE) HC=$(shell cat obj/ghccmd) install-filesonly-ghc+install-filesonly-nhc98:+	cd obj/nhc98; $(MAKE) HC=nhc98 install-filesonly-nhc98+install-filesonly-hugs: install-hugs+haddock:+	mkdir -p docs/haddock+	for dir in $(DIRS); \+		do mkdir -p docs/haddock/src/$$dir; \+		done+	for file in $(SRCS); \+		do $(CPP) -U__NHC__ $$file >$$file.uncpp.hs; \+		   HsColour -anchor -html $$file >docs/haddock/`dirname $$file`/`basename $$file .hs`.html; \+		done+	haddock --html --title=$(SOFTWARE) --odir=docs/haddock \+		--source-module="src/%{MODULE/.//}.html" \+		--source-entity="src/%{MODULE/.//}.html#%{NAME}" \+		$(patsubst %, %.uncpp.hs, $(SRCS))+	rm -f $(patsubst %, %.uncpp.hs, $(SRCS))++# packaging a distribution++srcDist: $(ALLFILES) haddock+	rm -f $(SOFTWARE)-$(VERSION).tar $(SOFTWARE)-$(VERSION).tar.gz+	mkdir $(SOFTWARE)-$(VERSION)+	tar cf - $(ALLFILES) | ( cd $(SOFTWARE)-$(VERSION); tar xf - )+	tar cf $(SOFTWARE)-$(VERSION).tar $(SOFTWARE)-$(VERSION)+	rm -rf $(SOFTWARE)-$(VERSION)+	gzip $(SOFTWARE)-$(VERSION).tar++zipDist: $(ALLFILES) haddock+	rm -f $(SOFTWARE)-$(VERSION).zip+	mkdir $(SOFTWARE)-$(VERSION)+	tar cf - $(ALLFILES) | ( cd $(SOFTWARE)-$(VERSION); tar xf - )+	zip -r $(SOFTWARE)-$(VERSION).zip $(SOFTWARE)-$(VERSION)+	rm -rf $(SOFTWARE)-$(VERSION)+++# clear up rubbish+clean:+	rm -rf obj/ghc obj/nhc98 obj/hugs+	cd examples;    rm -f *.hi *.o+realclean: clean+	rm -rf obj
+ README view
@@ -0,0 +1,51 @@+    polyparse - a collection of alternative parser combinator libraries+    -------------------------------------------------------------------++Installation instructions:+We currently support nhc98, ghc, and Hugs.  The automatic configuration+detects which compilers/interpreters you have, and prepares a build+tree for each.  Installation may require write-permission on the system+directories of the compiler/interpreter.  The libraries and interfaces+can then be used as "-package polyparse" (for ghc/nhc98 - no extra options+required for Hugs).++    sh configure+    make+    make install++Options to configure are:+    --buildwith=...  e.g. ghc-6.6,        to build for a specific compiler+    --prefix=...     e.g. /usr/local,     to change installation location++Complaints to:  :-)+    Malcolm.Wallace@cs.york.ac.uk++P.S.+    For those building on Windows /without/ Cygwin, you can avoid the need+    for configure/make steps by simply running the minimal build script in+        Build.bat+    You will need to edit it for the location of your compiler etc.++----+What this package contains:++  docs/			Some rudimentary HTML documentation about the libraries.+  docs/haddock/		Haddock-generated API documentation.+  examples/		Some small examples of how the libraries are used.++  src/Text+	Parse			A replacement for the Prelude Read class.+	Parse/ByteString	Like Text.Parse, except input is ByteString.+  src/Text/ParserCombinators+	HuttonMeijer		Early parser combinators from 1996.+	HuttonMeijerWallace	Extended for arbitrary token type + running+				state + error msgs.+  src/Text/ParserCombinators/Poly	Space-efficient parsers.+	Base		A class-based interface.  Most combinators defined here.+	Plain		The instance for simple polymorphic parsers.+	Lazy		The instance for lazy polymorphic parsers.+	State		The instance for strict polymorphic parsers with state.+	StateLazy	The instance for lazy polymorphic parsers with state.+	ByteString	An experimental instance for parsing from ByteString.++----
+ configure view
@@ -0,0 +1,320 @@+#!/bin/sh+#       configure -- prepare to compile/install the polyparse package+#       modified from the HaXml configure script: January 2007+#       author:   Malcolm.Wallace@cs.york.ac.uk, August 2002++SOFTWARE="polyparse"+VERSION="1.0"++if [ -f obj/prefix ]+then INSTALLDIR=`cat obj/prefix`+else INSTALLDIR=+fi++# We need a working `echo' command: at least Solaris2.6 may not have it.+CCC=${CC-gcc}+case `echo -n hello | wc -c | ( read n ; echo $n )` in+    5) ;;+    *) echo "The builtin 'echo' command doesn't do '-n' - emulating it."+       $CCC -o script/echo script/echo.c+       echo () { $PWD/script/echo "$@"; } ;;+esac++# We need a working `which' command: CYGWIN at least doesn't have it,+#  and some installed 'which's behave badly, e.g. Solaris, OSF/1.+which () {+  ( for path in `echo \"$PATH\" | sed -e 's/:/\" \"/g'`+    do+      thefile=`echo $path | tr -d "\""`/$1+      if [ -f "$thefile" -a -x "$thefile" ]+      then echo $thefile+           exit 0+      fi+    done; exit 1 )+}++DARWIN=false+CYGWIN=false+MINGW=false+SUNOS=false+case `uname -s` in+  CYGWIN*) CYGWIN=true;;+  MINGW*)  MINGW=true ;;+  Darwin*) DARWIN=true ;;+  SunOS*)  SUNOS=true ;;+esac++# Process command-line arguments+while [ "$1" != "" ]+do+  case $1 in+    --buildwith=*)  BUILDWITH=`echo "$1" | cut -c13-` ;;+    --buildopts=*)  BUILDOPTS=$BUILDOPTS" "`echo "$1" | cut -c13-` ;;+    --prefix=*)     INSTALLDIR=`echo "$1" | cut -c10-` ;;+    --help|-h)+  echo "`basename $0` options:     [default in brackets]"+  echo "  --buildwith=(ghc|hugs|nhc98) Build $SOFTWARE for the given compiler [detected]"+  echo "  --buildopts=flags    Give extra flags needed by your build compiler [none]"+  echo "  --prefix=dir         Installed files go under dir [compiler-specific]"+            exit 0 ;;+    --version|-v) echo "$SOFTWARE:     $VERSION"+                  exit 0 ;;+    *) echo "`basename $0`: unrecognised option $1"+       echo '    (use --help for option information)'+       exit 1 ;;+  esac+  shift+done++echo "Looking for Haskell compilers:"+# Assume that we start out with a blank config.+HMAKEKNOWN=+GHCKNOWN=+NHCKNOWN=+HUGSKNOWN=+HMAKENUM=0+GHCNUM=0+NHCNUM=0+HUGSNUM=0++echo -n "  Looking for hmake... "+if which hmake >/dev/null 2>&1+then+  HMAKEKNOWN=`which hmake`+  HMAKEVERSION=`${HMAKEKNOWN} --version | head -1 | cut -d' ' -f2`+  HMAKENUM=`echo $HMAKEVERSION | tr "v." "  " | ( read x y z; echo $x$y )`+fi+if [ "$HMAKEKNOWN" != "" ]+then echo "found ${HMAKEVERSION}"+else echo "(not found)"+fi++echo -n "  Looking for ghc...   "+if which ghc >/dev/null 2>&1+then+  GHCKNOWN=`which ghc`+  GHCVERSION=`${GHCKNOWN} --version 2>&1 | sed 's/^.*version[ ]*\([0-9.]*\).*/\1/'`+  GHCNUM=`echo $GHCVERSION | tr "v." "  " | ( read x y z; echo $x$y; )`+  if [ "$GHCNUM" -lt "100" ]+  then GHCNUM=${GHCNUM}0+  fi+fi+if [ "$GHCKNOWN" = "" ]+then echo "(not found)"+else echo "found ${GHCVERSION}"+     if [ "$GHCNUM" -lt "602" ]+     then  echo "    Warning: $SOFTWARE needs ghc-6.2 or later.  Ignoring ghc."+           GHCKNOWN=+     else  GHCLIBDIR=`${GHCKNOWN} -v 2>&1 | grep ' package config file: ' | head -1 | sed 's/.* package config file: //'`+           if $CYGWIN; then GHCLIBDIR=`cygpath -u $GHCLIBDIR`; fi+           if $MINGW; then GHCLIBDIR=`echo $GHCLIBDIR | tr '\\\\' '/'`; fi+           GHCLIBDIR=`dirname $GHCLIBDIR`+           GHCINCDIR=$GHCLIBDIR/imports+     fi+fi++# There may be another version of ghc to look for.+if [ -n "$BUILDWITH" ]+then+if [ "`basename $BUILDWITH | cut -c1-3`" = "ghc" ]+then+  VER=`basename $BUILDWITH | cut -c5-`+  if [ -n "$VER" -a "$VER" != "$GHCVERSION" ]+  then+    echo -n "  Looking for $BUILDWITH...   "+    if which $BUILDWITH >/dev/null 2>&1+    then+      GHC2KNOWN=`which $BUILDWITH`+      GHC2VERSION=`${GHC2KNOWN} --version 2>&1 | sed 's/^.*version[ ]*\([0-9.]*\).*/\1/'`+      GHC2NUM=`echo $GHC2VERSION | tr "." " " | ( read x y z; echo $x$y; )`+      if [ "$GHC2NUM" -lt "100" ]+      then GHC2NUM=${GHC2NUM}0+      fi+    fi+    if [ "$GHC2KNOWN" = "" ]+    then  echo "(not found)"+    else  echo "found ${GHC2VERSION}"+          if [ "$GHC2NUM" -lt "602" ]+          then echo "    Warning: $SOFTWARE needs ghc-6.2 or later.  Ignoring."+               GHC2KNOWN=+          else GHCKNOWN="$GHC2KNOWN"+               GHCVERSION="$GHC2VERSION"+               GHCNUM="$GHC2NUM"+               GHCLIBDIR=`${GHCKNOWN} -v 2>&1 | grep ' package config file: ' | head -1 | sed 's/.* package config file: //'`+               if $CYGWIN; then GHCLIBDIR=`cygpath -u $GHCLIBDIR`; fi+               if $MINGW; then GHCLIBDIR=`echo $GHCLIBDIR | tr '\\\\' '/'`; fi+               GHCLIBDIR=`dirname $GHCLIBDIR`+               GHCINCDIR=$GHCLIBDIR/imports+          fi+    fi+  fi+fi+fi++echo -n "  Looking for nhc98... "+if which nhc98 >/dev/null 2>&1+then+  NHCKNOWN=`which nhc98`+  NHCVERSION=`${NHCKNOWN} --version | head -1 | cut -d' ' -f2`+  NHCNUM=`echo $NHCVERSION | tr "v." "  " | ( read x y z; echo $x$y )`+fi+if [ "$NHCKNOWN" = "" ]+then  echo "(not found)"+else  echo "found ${NHCVERSION}"+     if [ "$HMAKENUM" -lt "306" ]+     then echo "    Warning: building with nhc98 needs hmake-3.06 or later."+          echo "    Available from:   http://www.haskell.org/hmake/"+     fi+     if [ "$NHCNUM" -lt "116" ]+     then  echo "    Warning: $SOFTWARE needs nhc98-1.16 or later.  Ignoring nhc98."+           NHCKNOWN=+     else  NHCLIBDIR=`grep '^NHC98LIBDIR' $NHCKNOWN | cut -c27- | cut -d'}' -f1 | head -1`+           NHCINCDIR=`grep '^NHC98INCDIR' $NHCKNOWN | cut -c27- | cut -d'}' -f1 | head -1`+     fi+fi++month() {+  read mon yr;+  case $mon in+    Jan*) echo 01;;+    Feb*) echo 02;;+    Mar*) echo 03;;+    Apr*) echo 04;;+    May)  echo 05;;+    Jun*) echo 06;;+    Jul*) echo 07;;+    Aug*) echo 08;;+    Sep*) echo 09;;+    Oct*) echo 10;;+    Nov*) echo 11;;+    Dec*) echo 12;;+    *)    echo 00;;+  esac;+}++echo -n "  Looking for hugs...  "+if which hugs >/dev/null 2>&1+then+  HUGSKNOWN=`which hugs`+  HUGSVERSION=`echo :q | $HUGSKNOWN 2>/dev/null | grep Version | cut -c18-32`+  HUGSNUM=`echo $HUGSVERSION | cut -d' ' -f2`+  HUGSNUM=$HUGSNUM`echo $HUGSVERSION | month`+fi+if [ "$HUGSKNOWN" = "" ]+then  echo "(not found)"+else  echo "found ${HUGSVERSION}"+  if [ "$HUGSNUM" -lt "200309" ]+  then  echo "    Warning: $SOFTWARE configuration only supports Hugs >= Sept 2003."+        HUGSKNOWN=+  fi+fi++if [ ! -z "$BUILDWITH" ]+then+  echo "  You want to build for only...  $BUILDWITH"+  if [ "`echo $BUILDWITH | cut -c1-3`" = "ghc" ]+  then+    if [ -z "$GHCKNOWN" ]+    then echo '   *** Did not find ghc - cannot continue.'+         exit 1+    else NHCKNOWN=+         HUGSKNOWN=+    fi+  else if [ "$BUILDWITH" = "nhc98" ]+  then+    if [ -z "$NHCKNOWN" ]+    then echo '   *** Did not find nhc98 - cannot continue.'+         exit 1+    else GHCKNOWN=+         HUGSKNOWN=+    fi+  else if [ "`echo $BUILDWITH | cut -c1-4`" = "hugs" ]+  then+    if [ -z "$HUGSKNOWN" ]+    then echo '   *** Did not find hugs - cannot continue.'+         exit 1+    else GHCKNOWN=+         NHCKNOWN=+    fi+  else echo '   *** I do not recognise this compiler:' $BUILDWITH+       exit 1+  fi;fi;fi;+fi++echo "  Files ultimately install in:"	# details generated below+echo "    (re-run ./configure --prefix=... if this wasn't your intention)"++if [ "$INSTALLDIR" != "" ]+then+  GHCLIBDIR=$INSTALLDIR/$SOFTWARE-$VERSION/ghc-$GHCVERSION/lib+  GHCINCDIR=$INSTALLDIR/$SOFTWARE-$VERSION/ghc-$GHCVERSION/imports+fi++# Prepare to build.+if [ ! -d obj ]+then mkdir obj+fi+if [ -f obj/compilers ]+then rm obj/compilers+fi+if [ "$HUGSKNOWN" != "" ]+then+  echo hugs >>obj/compilers+  if [ ! -d obj/hugs ]+  then mkdir obj/hugs+  fi+  cp -Rp src/Makefile obj/hugs+fi+if [ "$GHCKNOWN" != "" ]+then+  echo ghc >>obj/compilers+  if [ ! -d obj/ghc ]+  then mkdir obj/ghc+  fi+  echo $GHCLIBDIR >obj/ghc/ghclibdir+  echo $GHCINCDIR >obj/ghc/ghcincdir+  echo "      $GHCLIBDIR"	# report location to tty+  echo "      $GHCINCDIR"	# report location to tty+  if $CYGWIN || $MINGW+    then cygpath -w ${GHCLIBDIR} >obj/ghc/ghclibdirraw+         cygpath -w ${GHCINCDIR}/ >obj/ghc/ghcincdirraw+    else echo ${GHCLIBDIR} >obj/ghc/ghclibdirraw+         echo ${GHCINCDIR}/ >obj/ghc/ghcincdirraw+  fi+  if ghc-pkg-$GHCVERSION -l >/dev/null+    then echo ghc-pkg-$GHCVERSION >obj/ghc/ghcpkgcmd+    else echo ghc-pkg >obj/ghc/ghcpkgcmd+  fi+  echo ${BUILDWITH-ghc} >obj/ghccmd+  cp -Rp src/Text src/Makefile src/pkg.conf obj/ghc+  if [ "$GHCNUM" -ge "504" ]+  then echo "-package base" >obj/ghc/ghcpkgs+  else echo "" >obj/ghc/ghcpkgs+  fi+fi+if [ "$NHCKNOWN" != "" ]+then+  echo nhc98 >>obj/compilers+  if [ ! -d obj/nhc98 ]+  then mkdir obj/nhc98+  fi+  echo $NHCLIBDIR >obj/nhc98/nhc98libdir+  echo $NHCINCDIR >obj/nhc98/nhc98incdir+  echo "      $NHCLIBDIR"	# report location to tty+  echo "      $NHCINCDIR"	# report location to tty+  cp -Rp src/Text src/Makefile obj/nhc98+  if [ "$NHCNUM" -ge "116" ]+  then echo "-package base" >obj/nhc98/nhc98pkgs+  else echo "" >obj/nhc98/nhc98pkgs+  fi+fi++echo $INSTALLDIR >obj/prefix+if $CYGWIN || $MINGW ; then echo .exe >obj/exe; else touch obj/exe; fi+if $CYGWIN || $MINGW ; then echo main.exe >obj/out; else echo a.out >obj/out; fi+if $DARWIN ; then echo "-all_load -x"; else echo --whole-archive; fi >obj/ldopt+if $SUNOS ; then echo "-z allextract" >obj/ldopt; fi+++echo "Ready to build.  Type 'make' then (as root) 'make install'."+exit 0
+ docs/changelog.html view
@@ -0,0 +1,130 @@+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">+<html>+<head>+<title>+  polyparse change log+</title>+</head>++<body bgcolor='#ffffff'>++<center>+<h1>polyparse change log</h1>+</center>+<hr>++<h3>Changes in polyparse-1.4.1</h3>+<p>+<ul>+<li>Bugfix for 'discard', so that in the lazy variation it actually checks+    that the item to be discarded satisfies the given parser.+<li>Bugfixes in Text.Parse, such that 'optionalParens' is used more+    consistently.++<h3>Changes in polyparse-1.4</h3>+<p>+<ul>+<li>New API: the primitive parser 'eof' is now available in all variations of+    the Poly combinators.+<li>New implementation of Text.Parse.word - it no longer uses the+    Haskell'98 Prelude.lex, but provides its own proper lexer, with better+    error messages.+<li>New module: Text.ParserCombinators.Poly.ByteString is an instance of+    the PolyParse class specialised to ByteString input, rather than being+    polymorphic over the input token type.+<li>New module: Text.Parse.ByteString, is like Text.Parse but with+    ByteString input rather than String.+<li>New API calls: Text.Parse.readByParse and readsPrecByParsePrec,+    to make it easy to create instances of the old Read class (for+    backwards compatibility) from your TextParser.+<li>Bugfix: in Text.Parse, parseInt, parseDec, parseOct, and parseHex had an+    extra spurious argument that was unused, so it has been removed (API+    change).  In addition parseLitChar relied on the non-existent use of+    that argument, so it has been fixed too.+<li>Bugfix: Text.Parse.parseFloat now accepts a plain integer as a float,+    to match the H'98 behaviour of readFloat.+<li>Bugfix: the `discard` combinator now forces the discarded item;+    previously incorrect parses could hide inside, without triggering an error.+</ul>++<h3>Changes in polyparse-1.3</h3>+<p>+<ul>+<li>Bugfix: Text.Parse.parseFloat now accepts ordinary floating point+    notation, in addition to scientific (exponent) notation.+</ul>++<h3>Changes in polyparse-1.2</h3>+<p>+<ul>+<li>Improves the Text.Parse implementation significantly.  Where+    previously all the parsers for builtin basic datatype (Int,Float,Char)+    were just thin wrappers over the H'98 Read instances, now they are all+    proper parsers, therefore they should (a) be faster; (b) give better+    error messages.+<li>Reduced the number of implementation variations to choose from.+    In particular, NoLeak has become the default implementation, and+    the previous default has been dropped (because it space-leaks).+<!--+<li>[desired] The class interface providing common operations across all+    implementations, now need be no slower than the previous+    cut-n-pasted interface, due to compiler specialisation of all the+    instances.+<li>[desired] New combinators for parsing infix structures, with+    associativity and precedence information.+<li>[desired] Multiple layers of bracketing can be parsed in linear time,+    rather than the previous exponential solution.+-->+</ul>++<h3>Changes in polyparse-1.1</h3>+<p>+<ul>+<li>Much improved the laziness of the PolyLazy combinators.+<li>Addition of a class-based interface to the Poly libraries, to+    reduce code duplication amongst the variations, and to allow for+    more experimentation with different implementations.+<li>Several new experimental implementations of the interface.+</ul>++<h3>Changes in polyparse-1.0</h3>+<p>+<ul>+<li>Version number change from 1.00 to 1.0, for silly cabal/hackage.+<li>Minor fix to parsing strings in Text.Parse.+</ul>++<h3>Changes in polyparse-1.00</h3>+<p>+<ul>+<li>No changes, but released separately from HaXml+</ul>++<h3>Changes in HaXml-1.16</h3>+<p>+<ul>+<li> New: lazier parsers+     <ul>+     <li> <tt>Text.XML.HaXml.ParseLazy</tt>+     <li> <tt>Text.XML.HaXml.Html.ParseLazy</tt>+     <li> <tt>Text.ParserCombinators.PolyLazy</tt>+     <li> <tt>Text.ParserCombinators.PolyStateLazy</tt>+     </ul>+</ul>++<h3>Changes in HaXml-1.15</h3>+<p>+<ul>+<li> New: DrIFT has now been fully updated to+     produce instances of Text.ParserCombinators.TextParser.Parse.+<li> New: the parser combinator library Poly has been split into two+     variations, Poly and PolyState.  They have almost the same API,+     only the latter includes a running state where the former does not.+<li> The TextParser library (a replacement for the Haskell'98 Read class)+     has also been improved with more new combinators.  Really, these+     parser combinator experiments do not belong in HaXml, and will+     eventually be split out into a separate package.+</ul>++</body>+</html>
+ docs/haddock/Text-Parse-ByteString.html view
@@ -0,0 +1,1464 @@+<!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.Parse.ByteString</TITLE+><LINK HREF="haddock.css" REL="stylesheet" TYPE="text/css"+><SCRIPT SRC="haddock-util.js" TYPE="text/javascript"+></SCRIPT+><SCRIPT TYPE="text/javascript"+>window.onload = function () {setSynopsis("mini_Text-Parse-ByteString.html")};</SCRIPT+></HEAD+><BODY+><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"+><TR+><TD CLASS="topbar"+><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"+><TR+><TD+><IMG SRC="haskell_icon.gif" WIDTH="16" HEIGHT="16" ALT=" "+></TD+><TD CLASS="title"+>polyparse</TD+><TD CLASS="topbut"+><A HREF="src/Text/Parse/ByteString.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.Parse.ByteString</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 standard Read class. +</A+></DT+><DD+><DL+><DT+><A HREF="#2"+>Combinators specific to string input, lexed haskell-style+</A+></DT+><DT+><A HREF="#3"+>Parsers for literal numerics and characters+</A+></DT+><DT+><A HREF="#4"+>Re-export all the more general combinators from Poly too+</A+></DT+><DT+><A HREF="#5"+>ByteStrings and Strings as whole entities+</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-ByteString.html#t%3AParser"+>Parser</A+> 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-Parse-ByteString.html#t%3ATextParser"+>TextParser</A+> a</TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3AparsePrec"+>parsePrec</A+> :: Int -&gt; <A HREF="Text-Parse-ByteString.html#t%3ATextParser"+>TextParser</A+> a</TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3AparseList"+>parseList</A+> :: <A HREF="Text-Parse-ByteString.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 =&gt; String -&gt; <A HREF="Text-Parse-ByteString.html#t%3ATextParser"+>TextParser</A+> a</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3AreadByParse"+>readByParse</A+> ::  <A HREF="Text-Parse-ByteString.html#t%3ATextParser"+>TextParser</A+> a -&gt; ReadS a</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3AreadsPrecByParsePrec"+>readsPrecByParsePrec</A+> ::  (Int -&gt; <A HREF="Text-Parse-ByteString.html#t%3ATextParser"+>TextParser</A+> a) -&gt; Int -&gt; ReadS a</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3Aword"+>word</A+> :: <A HREF="Text-Parse-ByteString.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 -&gt; <A HREF="Text-Parse-ByteString.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-Parse-ByteString.html#t%3ATextParser"+>TextParser</A+> a -&gt; <A HREF="Text-Parse-ByteString.html#t%3ATextParser"+>TextParser</A+> a</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3Aparens"+>parens</A+> ::  Bool -&gt; <A HREF="Text-Parse-ByteString.html#t%3ATextParser"+>TextParser</A+> a -&gt; <A HREF="Text-Parse-ByteString.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-Parse-ByteString.html#t%3AParse"+>Parse</A+> a =&gt; String -&gt; <A HREF="Text-Parse-ByteString.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-Parse-ByteString.html#t%3ATextParser"+>TextParser</A+> a)] -&gt; <A HREF="Text-Parse-ByteString.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 =&gt; String -&gt; [a] -&gt; <A HREF="Text-Parse-ByteString.html#t%3ATextParser"+>TextParser</A+> a</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3AparseSigned"+>parseSigned</A+> :: Real a =&gt; <A HREF="Text-Parse-ByteString.html#t%3ATextParser"+>TextParser</A+> a -&gt; <A HREF="Text-Parse-ByteString.html#t%3ATextParser"+>TextParser</A+> a</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3AparseInt"+>parseInt</A+> :: Integral a =&gt; String -&gt; a -&gt; (Char -&gt; Bool) -&gt; (Char -&gt; Int) -&gt; <A HREF="Text-Parse-ByteString.html#t%3ATextParser"+>TextParser</A+> a</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3AparseDec"+>parseDec</A+> :: Integral a =&gt; <A HREF="Text-Parse-ByteString.html#t%3ATextParser"+>TextParser</A+> a</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3AparseOct"+>parseOct</A+> :: Integral a =&gt; <A HREF="Text-Parse-ByteString.html#t%3ATextParser"+>TextParser</A+> a</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3AparseHex"+>parseHex</A+> :: Integral a =&gt; <A HREF="Text-Parse-ByteString.html#t%3ATextParser"+>TextParser</A+> a</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3AparseUnsignedInteger"+>parseUnsignedInteger</A+> :: <A HREF="Text-Parse-ByteString.html#t%3ATextParser"+>TextParser</A+> Integer</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3AparseFloat"+>parseFloat</A+> :: RealFrac a =&gt; <A HREF="Text-Parse-ByteString.html#t%3ATextParser"+>TextParser</A+> a</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3AparseLitChar"+>parseLitChar</A+> :: <A HREF="Text-Parse-ByteString.html#t%3ATextParser"+>TextParser</A+> Char</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+>module <A HREF="Text-ParserCombinators-Poly-ByteString.html"+>Text.ParserCombinators.Poly.ByteString</A+></TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3AallAsByteString"+>allAsByteString</A+> :: <A HREF="Text-Parse-ByteString.html#t%3ATextParser"+>TextParser</A+> ByteString</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3AallAsString"+>allAsString</A+> :: <A HREF="Text-Parse-ByteString.html#t%3ATextParser"+>TextParser</A+> String</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 NAME="1"+>The Parse class is a replacement for the standard Read class. +</A+></A+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="doc"+>The Parse class is a replacement for the standard Read class.  It is a+ specialisation of the (poly) Parser monad for ByteString input.+ There are instances defined for all Prelude types.+ For user-defined types, you can write your own instance, or use+ DrIFT to generate them automatically, e.g. {-! derive : Parse !-}+</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:TextParser"+><A NAME="t%3ATextParser"+></A+></A+><B+>TextParser</B+> a = <A HREF="Text-ParserCombinators-Poly-ByteString.html#t%3AParser"+>Parser</A+> a</TD+><TD CLASS="declbut"+><A HREF="src/Text/Parse/ByteString.html#TextParser"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+>A synonym for a ByteString Parser, i.e. bytestring 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:Parse"+><A NAME="t%3AParse"+></A+></A+><B+>Parse</B+> a  <SPAN CLASS="keyword"+>where</SPAN+></TD+><TD CLASS="declbut"+><A HREF="src/Text/Parse/ByteString.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+>.  To apply a parser+   to some text, use <TT+>runParser</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:parse"+><A NAME="v%3Aparse"+></A+></A+><B+>parse</B+> :: <A HREF="Text-Parse-ByteString.html#t%3ATextParser"+>TextParser</A+> a</TD+><TD CLASS="declbut"+><A HREF="src/Text/Parse/ByteString.html#parse"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+>A straightforward parser for an item.  (A minimal definition of+   a class instance requires either |parse| or |parsePrec|.)+</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v:parsePrec"+><A NAME="v%3AparsePrec"+></A+></A+><B+>parsePrec</B+> :: Int -&gt; <A HREF="Text-Parse-ByteString.html#t%3ATextParser"+>TextParser</A+> a</TD+><TD CLASS="declbut"+><A HREF="src/Text/Parse/ByteString.html#parsePrec"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+>A straightforward parser for an item, given the precedence of+   any surrounding expression.  (Precedence determines whether+   parentheses are mandatory or optional.)+</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v:parseList"+><A NAME="v%3AparseList"+></A+></A+><B+>parseList</B+> :: <A HREF="Text-Parse-ByteString.html#t%3ATextParser"+>TextParser</A+> [a]</TD+><TD CLASS="declbut"+><A HREF="src/Text/Parse/ByteString.html#parseList"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+>Parsing a list of items by default accepts the [] and comma syntax,+   except when the list is really a character string using &quot;&quot;.+</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-Parse-ByteString.html#t%3AParse"+>Parse</A+> Bool</TD+></TR+><TR+><TD CLASS="decl"+><A HREF="Text-Parse-ByteString.html#t%3AParse"+>Parse</A+> Char</TD+></TR+><TR+><TD CLASS="decl"+><A HREF="Text-Parse-ByteString.html#t%3AParse"+>Parse</A+> Double</TD+></TR+><TR+><TD CLASS="decl"+><A HREF="Text-Parse-ByteString.html#t%3AParse"+>Parse</A+> Float</TD+></TR+><TR+><TD CLASS="decl"+><A HREF="Text-Parse-ByteString.html#t%3AParse"+>Parse</A+> Int</TD+></TR+><TR+><TD CLASS="decl"+><A HREF="Text-Parse-ByteString.html#t%3AParse"+>Parse</A+> Integer</TD+></TR+><TR+><TD CLASS="decl"+><A HREF="Text-Parse-ByteString.html#t%3AParse"+>Parse</A+> Ordering</TD+></TR+><TR+><TD CLASS="decl"+><A HREF="Text-Parse-ByteString.html#t%3AParse"+>Parse</A+> ()</TD+></TR+><TR+><TD CLASS="decl"+><A HREF="Text-Parse-ByteString.html#t%3AParse"+>Parse</A+> a =&gt; <A HREF="Text-Parse-ByteString.html#t%3AParse"+>Parse</A+> ([] a)</TD+></TR+><TR+><TD CLASS="decl"+><A HREF="Text-Parse-ByteString.html#t%3AParse"+>Parse</A+> a =&gt; <A HREF="Text-Parse-ByteString.html#t%3AParse"+>Parse</A+> (Maybe a)</TD+></TR+><TR+><TD CLASS="decl"+>(<A HREF="Text-Parse-ByteString.html#t%3AParse"+>Parse</A+> a, <A HREF="Text-Parse-ByteString.html#t%3AParse"+>Parse</A+> b) =&gt; <A HREF="Text-Parse-ByteString.html#t%3AParse"+>Parse</A+> (Either a b)</TD+></TR+><TR+><TD CLASS="decl"+>(<A HREF="Text-Parse-ByteString.html#t%3AParse"+>Parse</A+> a, <A HREF="Text-Parse-ByteString.html#t%3AParse"+>Parse</A+> b) =&gt; <A HREF="Text-Parse-ByteString.html#t%3AParse"+>Parse</A+> ((,) a b)</TD+></TR+><TR+><TD CLASS="decl"+>(<A HREF="Text-Parse-ByteString.html#t%3AParse"+>Parse</A+> a, <A HREF="Text-Parse-ByteString.html#t%3AParse"+>Parse</A+> b, <A HREF="Text-Parse-ByteString.html#t%3AParse"+>Parse</A+> c) =&gt; <A HREF="Text-Parse-ByteString.html#t%3AParse"+>Parse</A+> ((,,) a b c)</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:parseByRead"+><A NAME="v%3AparseByRead"+></A+></A+><B+>parseByRead</B+> :: Read a =&gt; String -&gt; <A HREF="Text-Parse-ByteString.html#t%3ATextParser"+>TextParser</A+> a</TD+><TD CLASS="declbut"+><A HREF="src/Text/Parse/ByteString.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.  The string argument+   is the expected type or value (for error-reporting only).  Use of this+   wrapper function is NOT recommended with ByteString, because there+   is a lot of inefficiency in repeated conversions to/from String.+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v:readByParse"+><A NAME="v%3AreadByParse"+></A+></A+><B+>readByParse</B+> ::  <A HREF="Text-Parse-ByteString.html#t%3ATextParser"+>TextParser</A+> a -&gt; ReadS a</TD+><TD CLASS="declbut"+><A HREF="src/Text/Parse/ByteString.html#readByParse"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+>If you have a TextParser for a type, you can easily make it into+   a Read instance, by throwing away any error messages.  Use of this+   wrapper function is NOT recommended with ByteString, because there+   is a lot of inefficiency in conversions to/from String.+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v:readsPrecByParsePrec"+><A NAME="v%3AreadsPrecByParsePrec"+></A+></A+><B+>readsPrecByParsePrec</B+> ::  (Int -&gt; <A HREF="Text-Parse-ByteString.html#t%3ATextParser"+>TextParser</A+> a) -&gt; Int -&gt; ReadS a</TD+><TD CLASS="declbut"+><A HREF="src/Text/Parse/ByteString.html#readsPrecByParsePrec"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+>If you have a TextParser for a type, you can easily make it into+   a Read instance, by throwing away any error messages.  Use of this+   wrapper function is NOT recommended with ByteString, because there+   is a lot of inefficiency in conversions to/from String.+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="section2"+><A NAME="2"+><A NAME="2"+>Combinators specific to string input, lexed haskell-style+</A+></A+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v:word"+><A NAME="v%3Aword"+></A+></A+><B+>word</B+> :: <A HREF="Text-Parse-ByteString.html#t%3ATextParser"+>TextParser</A+> String</TD+><TD CLASS="declbut"+><A HREF="src/Text/Parse/ByteString.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:isWord"+><A NAME="v%3AisWord"+></A+></A+><B+>isWord</B+> :: String -&gt; <A HREF="Text-Parse-ByteString.html#t%3ATextParser"+>TextParser</A+> String</TD+><TD CLASS="declbut"+><A HREF="src/Text/Parse/ByteString.html#isWord"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+>Ensure that the next input word is the 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:optionalParens"+><A NAME="v%3AoptionalParens"+></A+></A+><B+>optionalParens</B+> ::  <A HREF="Text-Parse-ByteString.html#t%3ATextParser"+>TextParser</A+> a -&gt; <A HREF="Text-Parse-ByteString.html#t%3ATextParser"+>TextParser</A+> a</TD+><TD CLASS="declbut"+><A HREF="src/Text/Parse/ByteString.html#optionalParens"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+>Allow optional nested 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:parens"+><A NAME="v%3Aparens"+></A+></A+><B+>parens</B+> ::  Bool -&gt; <A HREF="Text-Parse-ByteString.html#t%3ATextParser"+>TextParser</A+> a -&gt; <A HREF="Text-Parse-ByteString.html#t%3ATextParser"+>TextParser</A+> a</TD+><TD CLASS="declbut"+><A HREF="src/Text/Parse/ByteString.html#parens"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+>Allow nested parens around an item (one set required when Bool is True).+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v:field"+><A NAME="v%3Afield"+></A+></A+><B+>field</B+> :: <A HREF="Text-Parse-ByteString.html#t%3AParse"+>Parse</A+> a =&gt; String -&gt; <A HREF="Text-Parse-ByteString.html#t%3ATextParser"+>TextParser</A+> a</TD+><TD CLASS="declbut"+><A HREF="src/Text/Parse/ByteString.html#field"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+>Deal with named field syntax.  The string argument is the field name,+   and the parser returns the value of the field.+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v:constructors"+><A NAME="v%3Aconstructors"+></A+></A+><B+>constructors</B+> ::  [(String, <A HREF="Text-Parse-ByteString.html#t%3ATextParser"+>TextParser</A+> a)] -&gt; <A HREF="Text-Parse-ByteString.html#t%3ATextParser"+>TextParser</A+> a</TD+><TD CLASS="declbut"+><A HREF="src/Text/Parse/ByteString.html#constructors"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+>Parse one of a bunch of alternative constructors.  In the list argument,+   the first element of the pair is the constructor name, and+   the second is the parser for the rest of the value.  The first matching+   parse is returned.+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v:enumeration"+><A NAME="v%3Aenumeration"+></A+></A+><B+>enumeration</B+> :: Show a =&gt; String -&gt; [a] -&gt; <A HREF="Text-Parse-ByteString.html#t%3ATextParser"+>TextParser</A+> a</TD+><TD CLASS="declbut"+><A HREF="src/Text/Parse/ByteString.html#enumeration"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+>Parse one of the given nullary constructors (an enumeration).+   The string argument is the name of the type, and the list argument+   should contain all of the possible enumeration values.+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="section2"+><A NAME="3"+><A NAME="3"+>Parsers for literal numerics and characters+</A+></A+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v:parseSigned"+><A NAME="v%3AparseSigned"+></A+></A+><B+>parseSigned</B+> :: Real a =&gt; <A HREF="Text-Parse-ByteString.html#t%3ATextParser"+>TextParser</A+> a -&gt; <A HREF="Text-Parse-ByteString.html#t%3ATextParser"+>TextParser</A+> a</TD+><TD CLASS="declbut"+><A HREF="src/Text/Parse/ByteString.html#parseSigned"+>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:parseInt"+><A NAME="v%3AparseInt"+></A+></A+><B+>parseInt</B+> :: Integral a =&gt; String -&gt; a -&gt; (Char -&gt; Bool) -&gt; (Char -&gt; Int) -&gt; <A HREF="Text-Parse-ByteString.html#t%3ATextParser"+>TextParser</A+> a</TD+><TD CLASS="declbut"+><A HREF="src/Text/Parse/ByteString.html#parseInt"+>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:parseDec"+><A NAME="v%3AparseDec"+></A+></A+><B+>parseDec</B+> :: Integral a =&gt; <A HREF="Text-Parse-ByteString.html#t%3ATextParser"+>TextParser</A+> a</TD+><TD CLASS="declbut"+><A HREF="src/Text/Parse/ByteString.html#parseDec"+>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:parseOct"+><A NAME="v%3AparseOct"+></A+></A+><B+>parseOct</B+> :: Integral a =&gt; <A HREF="Text-Parse-ByteString.html#t%3ATextParser"+>TextParser</A+> a</TD+><TD CLASS="declbut"+><A HREF="src/Text/Parse/ByteString.html#parseOct"+>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:parseHex"+><A NAME="v%3AparseHex"+></A+></A+><B+>parseHex</B+> :: Integral a =&gt; <A HREF="Text-Parse-ByteString.html#t%3ATextParser"+>TextParser</A+> a</TD+><TD CLASS="declbut"+><A HREF="src/Text/Parse/ByteString.html#parseHex"+>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:parseUnsignedInteger"+><A NAME="v%3AparseUnsignedInteger"+></A+></A+><B+>parseUnsignedInteger</B+> :: <A HREF="Text-Parse-ByteString.html#t%3ATextParser"+>TextParser</A+> Integer</TD+><TD CLASS="declbut"+><A HREF="src/Text/Parse/ByteString.html#parseUnsignedInteger"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+>parseUnsignedInteger uses the underlying ByteString readInteger, so+   will be a lot faster than the generic character-by-character parseInt.+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v:parseFloat"+><A NAME="v%3AparseFloat"+></A+></A+><B+>parseFloat</B+> :: RealFrac a =&gt; <A HREF="Text-Parse-ByteString.html#t%3ATextParser"+>TextParser</A+> a</TD+><TD CLASS="declbut"+><A HREF="src/Text/Parse/ByteString.html#parseFloat"+>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:parseLitChar"+><A NAME="v%3AparseLitChar"+></A+></A+><B+>parseLitChar</B+> :: <A HREF="Text-Parse-ByteString.html#t%3ATextParser"+>TextParser</A+> Char</TD+><TD CLASS="declbut"+><A HREF="src/Text/Parse/ByteString.html#parseLitChar"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="section2"+><A NAME="4"+><A NAME="4"+>Re-export all the more general combinators from Poly too+</A+></A+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="decl"+>module <A HREF="Text-ParserCombinators-Poly-ByteString.html"+>Text.ParserCombinators.Poly.ByteString</A+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="section2"+><A NAME="5"+><A NAME="5"+>ByteStrings and Strings as whole entities+</A+></A+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v:allAsByteString"+><A NAME="v%3AallAsByteString"+></A+></A+><B+>allAsByteString</B+> :: <A HREF="Text-Parse-ByteString.html#t%3ATextParser"+>TextParser</A+> ByteString</TD+><TD CLASS="declbut"+><A HREF="src/Text/Parse/ByteString.html#allAsByteString"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+>Simply return the remaining input ByteString.+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v:allAsString"+><A NAME="v%3AallAsString"+></A+></A+><B+>allAsString</B+> :: <A HREF="Text-Parse-ByteString.html#t%3ATextParser"+>TextParser</A+> String</TD+><TD CLASS="declbut"+><A HREF="src/Text/Parse/ByteString.html#allAsString"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+>Simply return the remaining input as a String.+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="botbar"+>Produced by <A HREF="http://www.haskell.org/haddock/"+>Haddock</A+> version 2.4.2</TD+></TR+></TABLE+></BODY+></HTML+>
+ docs/haddock/Text-Parse.html view
@@ -0,0 +1,1311 @@+<!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.Parse</TITLE+><LINK HREF="haddock.css" REL="stylesheet" TYPE="text/css"+><SCRIPT SRC="haddock-util.js" TYPE="text/javascript"+></SCRIPT+><SCRIPT TYPE="text/javascript"+>window.onload = function () {setSynopsis("mini_Text-Parse.html")};</SCRIPT+></HEAD+><BODY+><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"+><TR+><TD CLASS="topbar"+><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"+><TR+><TD+><IMG SRC="haskell_icon.gif" WIDTH="16" HEIGHT="16" ALT=" "+></TD+><TD CLASS="title"+>polyparse</TD+><TD CLASS="topbut"+><A HREF="src/Text/Parse.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.Parse</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 standard Read class. +</A+></DT+><DD+><DL+><DT+><A HREF="#2"+>Combinators specific to string input, lexed haskell-style+</A+></DT+><DT+><A HREF="#3"+>Parsers for literal numerics and characters+</A+></DT+><DT+><A HREF="#4"+>Re-export all the more general combinators from Poly 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-Plain.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-Parse.html#t%3ATextParser"+>TextParser</A+> a</TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3AparsePrec"+>parsePrec</A+> :: Int -&gt; <A HREF="Text-Parse.html#t%3ATextParser"+>TextParser</A+> a</TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3AparseList"+>parseList</A+> :: <A HREF="Text-Parse.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 =&gt; String -&gt; <A HREF="Text-Parse.html#t%3ATextParser"+>TextParser</A+> a</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3AreadByParse"+>readByParse</A+> ::  <A HREF="Text-Parse.html#t%3ATextParser"+>TextParser</A+> a -&gt; ReadS a</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3AreadsPrecByParsePrec"+>readsPrecByParsePrec</A+> ::  (Int -&gt; <A HREF="Text-Parse.html#t%3ATextParser"+>TextParser</A+> a) -&gt; Int -&gt; ReadS a</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3Aword"+>word</A+> :: <A HREF="Text-Parse.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 -&gt; <A HREF="Text-Parse.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-Parse.html#t%3ATextParser"+>TextParser</A+> a -&gt; <A HREF="Text-Parse.html#t%3ATextParser"+>TextParser</A+> a</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3Aparens"+>parens</A+> ::  Bool -&gt; <A HREF="Text-Parse.html#t%3ATextParser"+>TextParser</A+> a -&gt; <A HREF="Text-Parse.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-Parse.html#t%3AParse"+>Parse</A+> a =&gt; String -&gt; <A HREF="Text-Parse.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-Parse.html#t%3ATextParser"+>TextParser</A+> a)] -&gt; <A HREF="Text-Parse.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 =&gt; String -&gt; [a] -&gt; <A HREF="Text-Parse.html#t%3ATextParser"+>TextParser</A+> a</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3AparseSigned"+>parseSigned</A+> :: Real a =&gt; <A HREF="Text-Parse.html#t%3ATextParser"+>TextParser</A+> a -&gt; <A HREF="Text-Parse.html#t%3ATextParser"+>TextParser</A+> a</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3AparseInt"+>parseInt</A+> :: Integral a =&gt; String -&gt; a -&gt; (Char -&gt; Bool) -&gt; (Char -&gt; Int) -&gt; <A HREF="Text-Parse.html#t%3ATextParser"+>TextParser</A+> a</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3AparseDec"+>parseDec</A+> :: Integral a =&gt; <A HREF="Text-Parse.html#t%3ATextParser"+>TextParser</A+> a</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3AparseOct"+>parseOct</A+> :: Integral a =&gt; <A HREF="Text-Parse.html#t%3ATextParser"+>TextParser</A+> a</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3AparseHex"+>parseHex</A+> :: Integral a =&gt; <A HREF="Text-Parse.html#t%3ATextParser"+>TextParser</A+> a</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3AparseFloat"+>parseFloat</A+> :: RealFrac a =&gt; <A HREF="Text-Parse.html#t%3ATextParser"+>TextParser</A+> a</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3AparseLitChar"+>parseLitChar</A+> :: <A HREF="Text-Parse.html#t%3ATextParser"+>TextParser</A+> Char</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"+><A NAME="1"+>The Parse class is a replacement for the standard Read class. +</A+></A+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="doc"+>The Parse class is a replacement for the standard Read class.  It is a+ specialisation of the (poly) Parser monad for String input.+ There are instances defined for all Prelude types.+ For user-defined types, you can write your own instance, or use+ DrIFT to generate them automatically, e.g. {-! derive : Parse !-}+</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:TextParser"+><A NAME="t%3ATextParser"+></A+></A+><B+>TextParser</B+> a = <A HREF="Text-ParserCombinators-Poly-Plain.html#t%3AParser"+>Parser</A+> Char a</TD+><TD CLASS="declbut"+><A HREF="src/Text/Parse.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:Parse"+><A NAME="t%3AParse"+></A+></A+><B+>Parse</B+> a  <SPAN CLASS="keyword"+>where</SPAN+></TD+><TD CLASS="declbut"+><A HREF="src/Text/Parse.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+>.  To apply a parser+   to some text, use <TT+>runParser</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:parse"+><A NAME="v%3Aparse"+></A+></A+><B+>parse</B+> :: <A HREF="Text-Parse.html#t%3ATextParser"+>TextParser</A+> a</TD+><TD CLASS="declbut"+><A HREF="src/Text/Parse.html#parse"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+>A straightforward parser for an item.  (A minimal definition of+   a class instance requires either |parse| or |parsePrec|.)+</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v:parsePrec"+><A NAME="v%3AparsePrec"+></A+></A+><B+>parsePrec</B+> :: Int -&gt; <A HREF="Text-Parse.html#t%3ATextParser"+>TextParser</A+> a</TD+><TD CLASS="declbut"+><A HREF="src/Text/Parse.html#parsePrec"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+>A straightforward parser for an item, given the precedence of+   any surrounding expression.  (Precedence determines whether+   parentheses are mandatory or optional.)+</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v:parseList"+><A NAME="v%3AparseList"+></A+></A+><B+>parseList</B+> :: <A HREF="Text-Parse.html#t%3ATextParser"+>TextParser</A+> [a]</TD+><TD CLASS="declbut"+><A HREF="src/Text/Parse.html#parseList"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+>Parsing a list of items by default accepts the [] and comma syntax,+   except when the list is really a character string using &quot;&quot;.+</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-Parse.html#t%3AParse"+>Parse</A+> Bool</TD+></TR+><TR+><TD CLASS="decl"+><A HREF="Text-Parse.html#t%3AParse"+>Parse</A+> Char</TD+></TR+><TR+><TD CLASS="decl"+><A HREF="Text-Parse.html#t%3AParse"+>Parse</A+> Double</TD+></TR+><TR+><TD CLASS="decl"+><A HREF="Text-Parse.html#t%3AParse"+>Parse</A+> Float</TD+></TR+><TR+><TD CLASS="decl"+><A HREF="Text-Parse.html#t%3AParse"+>Parse</A+> Int</TD+></TR+><TR+><TD CLASS="decl"+><A HREF="Text-Parse.html#t%3AParse"+>Parse</A+> Integer</TD+></TR+><TR+><TD CLASS="decl"+><A HREF="Text-Parse.html#t%3AParse"+>Parse</A+> Ordering</TD+></TR+><TR+><TD CLASS="decl"+><A HREF="Text-Parse.html#t%3AParse"+>Parse</A+> ()</TD+></TR+><TR+><TD CLASS="decl"+><A HREF="Text-Parse.html#t%3AParse"+>Parse</A+> a =&gt; <A HREF="Text-Parse.html#t%3AParse"+>Parse</A+> ([] a)</TD+></TR+><TR+><TD CLASS="decl"+><A HREF="Text-Parse.html#t%3AParse"+>Parse</A+> a =&gt; <A HREF="Text-Parse.html#t%3AParse"+>Parse</A+> (Maybe a)</TD+></TR+><TR+><TD CLASS="decl"+>(<A HREF="Text-Parse.html#t%3AParse"+>Parse</A+> a, <A HREF="Text-Parse.html#t%3AParse"+>Parse</A+> b) =&gt; <A HREF="Text-Parse.html#t%3AParse"+>Parse</A+> (Either a b)</TD+></TR+><TR+><TD CLASS="decl"+>(<A HREF="Text-Parse.html#t%3AParse"+>Parse</A+> a, <A HREF="Text-Parse.html#t%3AParse"+>Parse</A+> b) =&gt; <A HREF="Text-Parse.html#t%3AParse"+>Parse</A+> ((,) a b)</TD+></TR+><TR+><TD CLASS="decl"+>(<A HREF="Text-Parse.html#t%3AParse"+>Parse</A+> a, <A HREF="Text-Parse.html#t%3AParse"+>Parse</A+> b, <A HREF="Text-Parse.html#t%3AParse"+>Parse</A+> c) =&gt; <A HREF="Text-Parse.html#t%3AParse"+>Parse</A+> ((,,) a b c)</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:parseByRead"+><A NAME="v%3AparseByRead"+></A+></A+><B+>parseByRead</B+> :: Read a =&gt; String -&gt; <A HREF="Text-Parse.html#t%3ATextParser"+>TextParser</A+> a</TD+><TD CLASS="declbut"+><A HREF="src/Text/Parse.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.  The string argument+   is the expected type or value (for error-reporting only).+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v:readByParse"+><A NAME="v%3AreadByParse"+></A+></A+><B+>readByParse</B+> ::  <A HREF="Text-Parse.html#t%3ATextParser"+>TextParser</A+> a -&gt; ReadS a</TD+><TD CLASS="declbut"+><A HREF="src/Text/Parse.html#readByParse"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+>If you have a TextParser for a type, you can easily make it into+   a Read instance, by throwing away any error messages.+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v:readsPrecByParsePrec"+><A NAME="v%3AreadsPrecByParsePrec"+></A+></A+><B+>readsPrecByParsePrec</B+> ::  (Int -&gt; <A HREF="Text-Parse.html#t%3ATextParser"+>TextParser</A+> a) -&gt; Int -&gt; ReadS a</TD+><TD CLASS="declbut"+><A HREF="src/Text/Parse.html#readsPrecByParsePrec"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+>If you have a TextParser for a type, you can easily make it into+   a Read instance, by throwing away any error messages.+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="section2"+><A NAME="2"+><A NAME="2"+>Combinators specific to string input, lexed haskell-style+</A+></A+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v:word"+><A NAME="v%3Aword"+></A+></A+><B+>word</B+> :: <A HREF="Text-Parse.html#t%3ATextParser"+>TextParser</A+> String</TD+><TD CLASS="declbut"+><A HREF="src/Text/Parse.html#word"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+>One lexical chunk.  This is Haskell'98-style lexing - the result+   should match Prelude.lex apart from better error-reporting.+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v:isWord"+><A NAME="v%3AisWord"+></A+></A+><B+>isWord</B+> :: String -&gt; <A HREF="Text-Parse.html#t%3ATextParser"+>TextParser</A+> String</TD+><TD CLASS="declbut"+><A HREF="src/Text/Parse.html#isWord"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+>Ensure that the next input word is the 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:optionalParens"+><A NAME="v%3AoptionalParens"+></A+></A+><B+>optionalParens</B+> ::  <A HREF="Text-Parse.html#t%3ATextParser"+>TextParser</A+> a -&gt; <A HREF="Text-Parse.html#t%3ATextParser"+>TextParser</A+> a</TD+><TD CLASS="declbut"+><A HREF="src/Text/Parse.html#optionalParens"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+>Allow nested 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:parens"+><A NAME="v%3Aparens"+></A+></A+><B+>parens</B+> ::  Bool -&gt; <A HREF="Text-Parse.html#t%3ATextParser"+>TextParser</A+> a -&gt; <A HREF="Text-Parse.html#t%3ATextParser"+>TextParser</A+> a</TD+><TD CLASS="declbut"+><A HREF="src/Text/Parse.html#parens"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+>Allow nested parens around an item (one set required when Bool is True).+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v:field"+><A NAME="v%3Afield"+></A+></A+><B+>field</B+> :: <A HREF="Text-Parse.html#t%3AParse"+>Parse</A+> a =&gt; String -&gt; <A HREF="Text-Parse.html#t%3ATextParser"+>TextParser</A+> a</TD+><TD CLASS="declbut"+><A HREF="src/Text/Parse.html#field"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+>Deal with named field syntax.  The string argument is the field name,+   and the parser returns the value of the field.+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v:constructors"+><A NAME="v%3Aconstructors"+></A+></A+><B+>constructors</B+> ::  [(String, <A HREF="Text-Parse.html#t%3ATextParser"+>TextParser</A+> a)] -&gt; <A HREF="Text-Parse.html#t%3ATextParser"+>TextParser</A+> a</TD+><TD CLASS="declbut"+><A HREF="src/Text/Parse.html#constructors"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+>Parse one of a bunch of alternative constructors.  In the list argument,+   the first element of the pair is the constructor name, and+   the second is the parser for the rest of the value.  The first matching+   parse is returned.+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v:enumeration"+><A NAME="v%3Aenumeration"+></A+></A+><B+>enumeration</B+> :: Show a =&gt; String -&gt; [a] -&gt; <A HREF="Text-Parse.html#t%3ATextParser"+>TextParser</A+> a</TD+><TD CLASS="declbut"+><A HREF="src/Text/Parse.html#enumeration"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+>Parse one of the given nullary constructors (an enumeration).+   The string argument is the name of the type, and the list argument+   should contain all of the possible enumeration values.+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="section2"+><A NAME="3"+><A NAME="3"+>Parsers for literal numerics and characters+</A+></A+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v:parseSigned"+><A NAME="v%3AparseSigned"+></A+></A+><B+>parseSigned</B+> :: Real a =&gt; <A HREF="Text-Parse.html#t%3ATextParser"+>TextParser</A+> a -&gt; <A HREF="Text-Parse.html#t%3ATextParser"+>TextParser</A+> a</TD+><TD CLASS="declbut"+><A HREF="src/Text/Parse.html#parseSigned"+>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:parseInt"+><A NAME="v%3AparseInt"+></A+></A+><B+>parseInt</B+> :: Integral a =&gt; String -&gt; a -&gt; (Char -&gt; Bool) -&gt; (Char -&gt; Int) -&gt; <A HREF="Text-Parse.html#t%3ATextParser"+>TextParser</A+> a</TD+><TD CLASS="declbut"+><A HREF="src/Text/Parse.html#parseInt"+>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:parseDec"+><A NAME="v%3AparseDec"+></A+></A+><B+>parseDec</B+> :: Integral a =&gt; <A HREF="Text-Parse.html#t%3ATextParser"+>TextParser</A+> a</TD+><TD CLASS="declbut"+><A HREF="src/Text/Parse.html#parseDec"+>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:parseOct"+><A NAME="v%3AparseOct"+></A+></A+><B+>parseOct</B+> :: Integral a =&gt; <A HREF="Text-Parse.html#t%3ATextParser"+>TextParser</A+> a</TD+><TD CLASS="declbut"+><A HREF="src/Text/Parse.html#parseOct"+>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:parseHex"+><A NAME="v%3AparseHex"+></A+></A+><B+>parseHex</B+> :: Integral a =&gt; <A HREF="Text-Parse.html#t%3ATextParser"+>TextParser</A+> a</TD+><TD CLASS="declbut"+><A HREF="src/Text/Parse.html#parseHex"+>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:parseFloat"+><A NAME="v%3AparseFloat"+></A+></A+><B+>parseFloat</B+> :: RealFrac a =&gt; <A HREF="Text-Parse.html#t%3ATextParser"+>TextParser</A+> a</TD+><TD CLASS="declbut"+><A HREF="src/Text/Parse.html#parseFloat"+>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:parseLitChar"+><A NAME="v%3AparseLitChar"+></A+></A+><B+>parseLitChar</B+> :: <A HREF="Text-Parse.html#t%3ATextParser"+>TextParser</A+> Char</TD+><TD CLASS="declbut"+><A HREF="src/Text/Parse.html#parseLitChar"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="section2"+><A NAME="4"+><A NAME="4"+>Re-export all the more general combinators from Poly too+</A+></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 2.4.2</TD+></TR+></TABLE+></BODY+></HTML+>
+ docs/haddock/Text-ParserCombinators-HuttonMeijer.html view
@@ -0,0 +1,1636 @@+<!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-util.js" TYPE="text/javascript"+></SCRIPT+><SCRIPT TYPE="text/javascript"+>window.onload = function () {setSynopsis("mini_Text-ParserCombinators-HuttonMeijer.html")};</SCRIPT+></HEAD+><BODY+><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"+><TR+><TD CLASS="topbar"+><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"+><TR+><TD+><IMG SRC="haskell_icon.gif" WIDTH="16" HEIGHT="16" ALT=" "+></TD+><TD CLASS="title"+>polyparse</TD+><TD CLASS="topbut"+><A HREF="src/Text/ParserCombinators/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 &lt;Malcolm.Wallace@cs.york.ac.uk&gt;</TD+></TR+></TABLE+></TD+></TR+></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] -&gt; [(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 -&gt; <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 -&gt; [Token] -&gt; [(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 -&gt; <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> a -&gt; <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 -&gt; Bool) -&gt; <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 -&gt; <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 -&gt; <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 -&gt; <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> b -&gt; <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 -&gt; <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> b -&gt; <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 -&gt; <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> (a -&gt; a -&gt; a) -&gt; a -&gt; <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 -&gt; <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> (a -&gt; a -&gt; a) -&gt; <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 -&gt; <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> (a -&gt; a -&gt; a) -&gt; a -&gt; <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 -&gt; <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> (a -&gt; a -&gt; a) -&gt; <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)] -&gt; <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 -&gt; <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> b -&gt; <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> c -&gt; <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 -&gt; <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 -&gt; <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 -&gt; <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 -&gt; <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 -&gt; <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] -&gt; <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:Parser"+><A NAME="t%3AParser"+></A+></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:P"+><A NAME="v%3AP"+></A+></A+><B+>P</B+> ([Token] -&gt; [(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"+>Monad <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+></TD+></TR+><TR+><TD CLASS="decl"+>Functor <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:item"+><A NAME="v%3Aitem"+></A+></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:first"+><A NAME="v%3Afirst"+></A+></A+><B+>first</B+> ::  <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> a -&gt; <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:papply"+><A NAME="v%3Apapply"+></A+></A+><B+>papply</B+> ::  <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> a -&gt; [Token] -&gt; [(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:+++"+><A NAME="v%3A%2B%2B%2B"+></A+></A+><B+>(+++)</B+> ::  <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> a -&gt; <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> a -&gt; <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:sat"+><A NAME="v%3Asat"+></A+></A+><B+>sat</B+> :: (Token -&gt; Bool) -&gt; <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:many"+><A NAME="v%3Amany"+></A+></A+><B+>many</B+> ::  <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> a -&gt; <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:many1"+><A NAME="v%3Amany1"+></A+></A+><B+>many1</B+> ::  <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> a -&gt; <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:sepby"+><A NAME="v%3Asepby"+></A+></A+><B+>sepby</B+> ::  <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> a -&gt; <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> b -&gt; <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:sepby1"+><A NAME="v%3Asepby1"+></A+></A+><B+>sepby1</B+> ::  <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> a -&gt; <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> b -&gt; <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:chainl"+><A NAME="v%3Achainl"+></A+></A+><B+>chainl</B+> ::  <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> a -&gt; <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> (a -&gt; a -&gt; a) -&gt; a -&gt; <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:chainl1"+><A NAME="v%3Achainl1"+></A+></A+><B+>chainl1</B+> ::  <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> a -&gt; <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> (a -&gt; a -&gt; a) -&gt; <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:chainr"+><A NAME="v%3Achainr"+></A+></A+><B+>chainr</B+> ::  <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> a -&gt; <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> (a -&gt; a -&gt; a) -&gt; a -&gt; <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:chainr1"+><A NAME="v%3Achainr1"+></A+></A+><B+>chainr1</B+> ::  <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> a -&gt; <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> (a -&gt; a -&gt; a) -&gt; <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:ops"+><A NAME="v%3Aops"+></A+></A+><B+>ops</B+> ::  [(<A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> a, b)] -&gt; <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:bracket"+><A NAME="v%3Abracket"+></A+></A+><B+>bracket</B+> ::  <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> a -&gt; <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> b -&gt; <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> c -&gt; <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:char"+><A NAME="v%3Achar"+></A+></A+><B+>char</B+> :: Char -&gt; <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:digit"+><A NAME="v%3Adigit"+></A+></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:lower"+><A NAME="v%3Alower"+></A+></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:upper"+><A NAME="v%3Aupper"+></A+></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:letter"+><A NAME="v%3Aletter"+></A+></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:alphanum"+><A NAME="v%3Aalphanum"+></A+></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:string"+><A NAME="v%3Astring"+></A+></A+><B+>string</B+> :: String -&gt; <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:ident"+><A NAME="v%3Aident"+></A+></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:nat"+><A NAME="v%3Anat"+></A+></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:int"+><A NAME="v%3Aint"+></A+></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:spaces"+><A NAME="v%3Aspaces"+></A+></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:comment"+><A NAME="v%3Acomment"+></A+></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:junk"+><A NAME="v%3Ajunk"+></A+></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:skip"+><A NAME="v%3Askip"+></A+></A+><B+>skip</B+> ::  <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> a -&gt; <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:token"+><A NAME="v%3Atoken"+></A+></A+><B+>token</B+> ::  <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> a -&gt; <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:natural"+><A NAME="v%3Anatural"+></A+></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:integer"+><A NAME="v%3Ainteger"+></A+></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:symbol"+><A NAME="v%3Asymbol"+></A+></A+><B+>symbol</B+> :: String -&gt; <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:identifier"+><A NAME="v%3Aidentifier"+></A+></A+><B+>identifier</B+> :: [String] -&gt; <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 2.4.2</TD+></TR+></TABLE+></BODY+></HTML+>
+ docs/haddock/Text-ParserCombinators-HuttonMeijerWallace.html view
@@ -0,0 +1,1418 @@+<!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-util.js" TYPE="text/javascript"+></SCRIPT+><SCRIPT TYPE="text/javascript"+>window.onload = function () {setSynopsis("mini_Text-ParserCombinators-HuttonMeijerWallace.html")};</SCRIPT+></HEAD+><BODY+><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"+><TR+><TD CLASS="topbar"+><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"+><TR+><TD+><IMG SRC="haskell_icon.gif" WIDTH="16" HEIGHT="16" ALT=" "+></TD+><TD CLASS="title"+>polyparse</TD+><TD CLASS="topbut"+><A HREF="src/Text/ParserCombinators/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 state in the 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 -&gt; [Either e t] -&gt; 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 =&gt; <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 -&gt; s -&gt; [Either String t] -&gt; [(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 -&gt; s -&gt; [Either e t] -&gt; 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 -&gt; <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s t e a -&gt; <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 =&gt; t -&gt; <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 =&gt; [t] -&gt; <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 -&gt; <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 -&gt; <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 -&gt; <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s t e b -&gt; <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 -&gt; <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s t e b -&gt; <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 -&gt; <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s t e (a -&gt; a -&gt; a) -&gt; a -&gt; <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 -&gt; <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s t e (a -&gt; a -&gt; a) -&gt; <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 -&gt; <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s t e (a -&gt; a -&gt; a) -&gt; a -&gt; <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 -&gt; <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s t e (a -&gt; a -&gt; a) -&gt; <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)] -&gt; <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) =&gt; <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s (p, t) e a -&gt; <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s (p, t) e b -&gt; <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s (p, t) e c -&gt; <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 =&gt; <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s (p, t) String a -&gt; <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) =&gt; <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s (p, t) String a -&gt; String -&gt; <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 -&gt; s) -&gt; <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 -&gt; a) -&gt; <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] -&gt; <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"+><A NAME="1"+>The parser monad+</A+></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:Parser"+><A NAME="t%3AParser"+></A+></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:P"+><A NAME="v%3AP"+></A+></A+><B+>P</B+> (s -&gt; [Either e t] -&gt; 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"+>Monad (<A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s t e)</TD+></TR+><TR+><TD CLASS="decl"+>Functor (<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"+><A NAME="2"+>Primitive parser combinators+</A+></A+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v:item"+><A NAME="v%3Aitem"+></A+></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:eof"+><A NAME="v%3Aeof"+></A+></A+><B+>eof</B+> :: Show p =&gt; <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:papply"+><A NAME="v%3Apapply"+></A+></A+><B+>papply</B+> ::  <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s t String a -&gt; s -&gt; [Either String t] -&gt; [(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 <TT+>error</TT+> 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:papply'"+><A NAME="v%3Apapply%27"+></A+></A+><B+>papply'</B+> ::  <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s t e a -&gt; s -&gt; [Either e t] -&gt; 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"+><A NAME="3"+>Derived combinators+</A+></A+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v:+++"+><A NAME="v%3A%2B%2B%2B"+></A+></A+><B+>(+++)</B+> ::  <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s t e a -&gt; <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s t e a -&gt; <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:tok"+><A NAME="v%3Atok"+></A+></A+><B+>tok</B+> :: Eq t =&gt; t -&gt; <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:nottok"+><A NAME="v%3Anottok"+></A+></A+><B+>nottok</B+> :: Eq t =&gt; [t] -&gt; <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:many"+><A NAME="v%3Amany"+></A+></A+><B+>many</B+> ::  <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s t e a -&gt; <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:many1"+><A NAME="v%3Amany1"+></A+></A+><B+>many1</B+> ::  <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s t e a -&gt; <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:sepby"+><A NAME="v%3Asepby"+></A+></A+><B+>sepby</B+> ::  <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s t e a -&gt; <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s t e b -&gt; <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:sepby1"+><A NAME="v%3Asepby1"+></A+></A+><B+>sepby1</B+> ::  <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s t e a -&gt; <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s t e b -&gt; <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:chainl"+><A NAME="v%3Achainl"+></A+></A+><B+>chainl</B+> ::  <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s t e a -&gt; <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s t e (a -&gt; a -&gt; a) -&gt; a -&gt; <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:chainl1"+><A NAME="v%3Achainl1"+></A+></A+><B+>chainl1</B+> ::  <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s t e a -&gt; <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s t e (a -&gt; a -&gt; a) -&gt; <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:chainr"+><A NAME="v%3Achainr"+></A+></A+><B+>chainr</B+> ::  <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s t e a -&gt; <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s t e (a -&gt; a -&gt; a) -&gt; a -&gt; <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:chainr1"+><A NAME="v%3Achainr1"+></A+></A+><B+>chainr1</B+> ::  <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s t e a -&gt; <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s t e (a -&gt; a -&gt; a) -&gt; <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:ops"+><A NAME="v%3Aops"+></A+></A+><B+>ops</B+> ::  [(<A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s t e a, b)] -&gt; <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:bracket"+><A NAME="v%3Abracket"+></A+></A+><B+>bracket</B+> :: (Show p, Show t) =&gt; <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s (p, t) e a -&gt; <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s (p, t) e b -&gt; <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s (p, t) e c -&gt; <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:toEOF"+><A NAME="v%3AtoEOF"+></A+></A+><B+>toEOF</B+> :: Show p =&gt; <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s (p, t) String a -&gt; <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"+><A NAME="4"+>Error handling+</A+></A+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v:elserror"+><A NAME="v%3Aelserror"+></A+></A+><B+>elserror</B+> :: (Show p, Show t) =&gt; <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s (p, t) String a -&gt; String -&gt; <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"+><A NAME="5"+>State handling+</A+></A+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v:stupd"+><A NAME="v%3Astupd"+></A+></A+><B+>stupd</B+> ::  (s -&gt; s) -&gt; <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:stquery"+><A NAME="v%3Astquery"+></A+></A+><B+>stquery</B+> ::  (s -&gt; a) -&gt; <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:stget"+><A NAME="v%3Astget"+></A+></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"+><A NAME="6"+>Re-parsing+</A+></A+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v:reparse"+><A NAME="v%3Areparse"+></A+></A+><B+>reparse</B+> ::  [Either e t] -&gt; <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 2.4.2</TD+></TR+></TABLE+></BODY+></HTML+>
+ docs/haddock/Text-ParserCombinators-Poly-Base.html view
@@ -0,0 +1,1196 @@+<!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.Base</TITLE+><LINK HREF="haddock.css" REL="stylesheet" TYPE="text/css"+><SCRIPT SRC="haddock-util.js" TYPE="text/javascript"+></SCRIPT+><SCRIPT TYPE="text/javascript"+>window.onload = function () {setSynopsis("mini_Text-ParserCombinators-Poly-Base.html")};</SCRIPT+></HEAD+><BODY+><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"+><TR+><TD CLASS="topbar"+><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"+><TR+><TD+><IMG SRC="haskell_icon.gif" WIDTH="16" HEIGHT="16" ALT=" "+></TD+><TD CLASS="title"+>polyparse</TD+><TD CLASS="topbut"+><A HREF="src/Text/ParserCombinators/Poly/Base.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.Base</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 PolyParse class+</A+></DT+><DT+><A HREF="#2"+>Combinators general to all parser types.+</A+></DT+><DD+><DL+><DT+><A HREF="#3"+>Simple combinators+</A+></DT+><DT+><A HREF="#4"+>Error-handling+</A+></DT+><DT+><A HREF="#5"+>Choices+</A+></DT+><DT+><A HREF="#6"+>Sequences+</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"+>class</SPAN+> (Functor p, Monad p) =&gt; <A HREF="#t%3APolyParse"+>PolyParse</A+> p  <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%3Acommit"+>commit</A+> ::  p a -&gt; p a</TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3AadjustErr"+>adjustErr</A+> ::  p a -&gt; (String -&gt; String) -&gt; p a</TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3AonFail"+>onFail</A+> ::  p a -&gt; p a -&gt; p a</TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3AoneOf%27"+>oneOf'</A+> ::  [(String, p a)] -&gt; p a</TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3Aapply"+>apply</A+> ::  p (a -&gt; b) -&gt; p a -&gt; p b</TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3Adiscard"+>discard</A+> :: <A HREF="Text-ParserCombinators-Poly-Base.html#t%3APolyParse"+>PolyParse</A+> p =&gt; p a -&gt; p b -&gt; p a</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3AfailBad"+>failBad</A+> :: <A HREF="Text-ParserCombinators-Poly-Base.html#t%3APolyParse"+>PolyParse</A+> p =&gt; String -&gt; p a</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3AadjustErrBad"+>adjustErrBad</A+> :: <A HREF="Text-ParserCombinators-Poly-Base.html#t%3APolyParse"+>PolyParse</A+> p =&gt; p a -&gt; (String -&gt; String) -&gt; p a</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3Aindent"+>indent</A+> :: Int -&gt; String -&gt; String</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3AoneOf"+>oneOf</A+> :: <A HREF="Text-ParserCombinators-Poly-Base.html#t%3APolyParse"+>PolyParse</A+> p =&gt; [p a] -&gt; p a</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3Aoptional"+>optional</A+> :: <A HREF="Text-ParserCombinators-Poly-Base.html#t%3APolyParse"+>PolyParse</A+> p =&gt; p a -&gt; p (Maybe a)</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3Aexactly"+>exactly</A+> :: <A HREF="Text-ParserCombinators-Poly-Base.html#t%3APolyParse"+>PolyParse</A+> p =&gt; Int -&gt; p a -&gt; p [a]</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3Amany"+>many</A+> :: <A HREF="Text-ParserCombinators-Poly-Base.html#t%3APolyParse"+>PolyParse</A+> p =&gt; p a -&gt; p [a]</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3Amany1"+>many1</A+> :: <A HREF="Text-ParserCombinators-Poly-Base.html#t%3APolyParse"+>PolyParse</A+> p =&gt; p a -&gt; p [a]</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3AsepBy"+>sepBy</A+> :: <A HREF="Text-ParserCombinators-Poly-Base.html#t%3APolyParse"+>PolyParse</A+> p =&gt; p a -&gt; p sep -&gt; p [a]</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3AsepBy1"+>sepBy1</A+> :: <A HREF="Text-ParserCombinators-Poly-Base.html#t%3APolyParse"+>PolyParse</A+> p =&gt; p a -&gt; p sep -&gt; p [a]</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3AbracketSep"+>bracketSep</A+> :: <A HREF="Text-ParserCombinators-Poly-Base.html#t%3APolyParse"+>PolyParse</A+> p =&gt; p bra -&gt; p sep -&gt; p ket -&gt; p a -&gt; p [a]</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3Abracket"+>bracket</A+> :: <A HREF="Text-ParserCombinators-Poly-Base.html#t%3APolyParse"+>PolyParse</A+> p =&gt; p bra -&gt; p ket -&gt; p a -&gt; p a</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3AmanyFinally"+>manyFinally</A+> :: <A HREF="Text-ParserCombinators-Poly-Base.html#t%3APolyParse"+>PolyParse</A+> p =&gt; p a -&gt; p z -&gt; p [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"+><A NAME="1"+>The PolyParse class+</A+></A+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><SPAN CLASS="keyword"+>class</SPAN+> (Functor p, Monad p) =&gt; <A NAME="t:PolyParse"+><A NAME="t%3APolyParse"+></A+></A+><B+>PolyParse</B+> p  <SPAN CLASS="keyword"+>where</SPAN+></TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/Poly/Base.html#PolyParse"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="body"+><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"+><TR+><TD CLASS="ndoc"+><P+>The <TT+>PolyParse</TT+> class is an abstraction over all the current+   concrete representations of monadic parser combinators in this+   package.  The common feature is two-level error-handling.+   Some primitives must be implemented specific to each parser type+   (e.g. depending on whether the parser has a running state, or+   whether it is lazy).  But given those primitives, large numbers of+   combinators do not depend any further on the internal structure of+   the particular parser.+</P+><P+>There are two additional basic combinators that we expect to be implemented+   afresh for every concrete type, but which (for technical reasons)+   cannot be class methods.  They are <TT+>next</TT+> and <TT+>satisfy</TT+>.+</P+></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:commit"+><A NAME="v%3Acommit"+></A+></A+><B+>commit</B+> ::  p a -&gt; p a</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/Poly/Base.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="s8"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v:adjustErr"+><A NAME="v%3AadjustErr"+></A+></A+><B+>adjustErr</B+> ::  p a -&gt; (String -&gt; String) -&gt; p a</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/Poly/Base.html#adjustErr"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+><TT+>p <TT+><A HREF="Text-ParserCombinators-Poly-Base.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="s8"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v:onFail"+><A NAME="v%3AonFail"+></A+></A+><B+>onFail</B+> ::  p a -&gt; p a -&gt; p a</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/Poly/Base.html#onFail"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+><TT+>p <TT+><A HREF="Text-ParserCombinators-Poly-Base.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="s8"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v:oneOf'"+><A NAME="v%3AoneOf%27"+></A+></A+><B+>oneOf'</B+> ::  [(String, p a)] -&gt; p a</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/Poly/Base.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="s8"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v:apply"+><A NAME="v%3Aapply"+></A+></A+><B+>apply</B+> ::  p (a -&gt; b) -&gt; p a -&gt; p b</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/Poly/Base.html#apply"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+>Apply a parsed function to a parsed value.+   Rather like ordinary function application lifted into parsers.+</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:PolyParse')" ALT="show/hide"+> Instances</TD+></TR+><TR+><TD CLASS="body"+><DIV ID="i:PolyParse" STYLE="display:block;"+><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0"+><TR+><TD CLASS="decl"+><A HREF="Text-ParserCombinators-Poly-Base.html#t%3APolyParse"+>PolyParse</A+> <A HREF="Text-ParserCombinators-Poly-ByteString.html#t%3AParser"+>Parser</A+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="Text-ParserCombinators-Poly-Base.html#t%3APolyParse"+>PolyParse</A+> (<A HREF="Text-ParserCombinators-Poly-Plain.html#t%3AParser"+>Parser</A+> t)</TD+></TR+><TR+><TD CLASS="decl"+><A HREF="Text-ParserCombinators-Poly-Base.html#t%3APolyParse"+>PolyParse</A+> (<A HREF="Text-ParserCombinators-Poly-Lazy.html#t%3AParser"+>Parser</A+> t)</TD+></TR+><TR+><TD CLASS="decl"+><A HREF="Text-ParserCombinators-Poly-Base.html#t%3APolyParse"+>PolyParse</A+> (<A HREF="Text-ParserCombinators-Poly-State.html#t%3AParser"+>Parser</A+> s t)</TD+></TR+><TR+><TD CLASS="decl"+><A HREF="Text-ParserCombinators-Poly-Base.html#t%3APolyParse"+>PolyParse</A+> (<A HREF="Text-ParserCombinators-Poly-StateLazy.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="section1"+><A NAME="2"+><A NAME="2"+>Combinators general to all parser types.+</A+></A+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="section2"+><A NAME="3"+><A NAME="3"+>Simple combinators+</A+></A+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v:discard"+><A NAME="v%3Adiscard"+></A+></A+><B+>discard</B+> :: <A HREF="Text-ParserCombinators-Poly-Base.html#t%3APolyParse"+>PolyParse</A+> p =&gt; p a -&gt; p b -&gt; p a</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/Poly/Base.html#discard"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+><TT+>x <TT+><A HREF="Text-ParserCombinators-Poly-Base.html#v%3Adiscard"+>discard</A+></TT+> y</TT+> parses both x and y, but discards the result of y.+   Rather like <TT+>const</TT+> lifted into parsers.+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="section2"+><A NAME="4"+><A NAME="4"+>Error-handling+</A+></A+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v:failBad"+><A NAME="v%3AfailBad"+></A+></A+><B+>failBad</B+> :: <A HREF="Text-ParserCombinators-Poly-Base.html#t%3APolyParse"+>PolyParse</A+> p =&gt; String -&gt; p a</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/Poly/Base.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 cannot be overridden by choice+   operators.+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v:adjustErrBad"+><A NAME="v%3AadjustErrBad"+></A+></A+><B+>adjustErrBad</B+> :: <A HREF="Text-ParserCombinators-Poly-Base.html#t%3APolyParse"+>PolyParse</A+> p =&gt; p a -&gt; (String -&gt; String) -&gt; p a</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/Poly/Base.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:indent"+><A NAME="v%3Aindent"+></A+></A+><B+>indent</B+> :: Int -&gt; String -&gt; String</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/Poly/Base.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"+><A NAME="5"+>Choices+</A+></A+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v:oneOf"+><A NAME="v%3AoneOf"+></A+></A+><B+>oneOf</B+> :: <A HREF="Text-ParserCombinators-Poly-Base.html#t%3APolyParse"+>PolyParse</A+> p =&gt; [p a] -&gt; p a</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/Poly/Base.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:optional"+><A NAME="v%3Aoptional"+></A+></A+><B+>optional</B+> :: <A HREF="Text-ParserCombinators-Poly-Base.html#t%3APolyParse"+>PolyParse</A+> p =&gt; p a -&gt; p (Maybe a)</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/Poly/Base.html#optional"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+><TT+><A HREF="Text-ParserCombinators-Poly-Base.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"+><A NAME="6"+>Sequences+</A+></A+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v:exactly"+><A NAME="v%3Aexactly"+></A+></A+><B+>exactly</B+> :: <A HREF="Text-ParserCombinators-Poly-Base.html#t%3APolyParse"+>PolyParse</A+> p =&gt; Int -&gt; p a -&gt; p [a]</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/Poly/Base.html#exactly"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+>'exactly n p' parses precisely n items, using the parser p, in sequence.+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v:many"+><A NAME="v%3Amany"+></A+></A+><B+>many</B+> :: <A HREF="Text-ParserCombinators-Poly-Base.html#t%3APolyParse"+>PolyParse</A+> p =&gt; p a -&gt; p [a]</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/Poly/Base.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:many1"+><A NAME="v%3Amany1"+></A+></A+><B+>many1</B+> :: <A HREF="Text-ParserCombinators-Poly-Base.html#t%3APolyParse"+>PolyParse</A+> p =&gt; p a -&gt; p [a]</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/Poly/Base.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:sepBy"+><A NAME="v%3AsepBy"+></A+></A+><B+>sepBy</B+> :: <A HREF="Text-ParserCombinators-Poly-Base.html#t%3APolyParse"+>PolyParse</A+> p =&gt; p a -&gt; p sep -&gt; p [a]</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/Poly/Base.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:sepBy1"+><A NAME="v%3AsepBy1"+></A+></A+><B+>sepBy1</B+> :: <A HREF="Text-ParserCombinators-Poly-Base.html#t%3APolyParse"+>PolyParse</A+> p =&gt; p a -&gt; p sep -&gt; p [a]</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/Poly/Base.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:bracketSep"+><A NAME="v%3AbracketSep"+></A+></A+><B+>bracketSep</B+> :: <A HREF="Text-ParserCombinators-Poly-Base.html#t%3APolyParse"+>PolyParse</A+> p =&gt; p bra -&gt; p sep -&gt; p ket -&gt; p a -&gt; p [a]</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/Poly/Base.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:bracket"+><A NAME="v%3Abracket"+></A+></A+><B+>bracket</B+> :: <A HREF="Text-ParserCombinators-Poly-Base.html#t%3APolyParse"+>PolyParse</A+> p =&gt; p bra -&gt; p ket -&gt; p a -&gt; p a</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/Poly/Base.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:manyFinally"+><A NAME="v%3AmanyFinally"+></A+></A+><B+>manyFinally</B+> :: <A HREF="Text-ParserCombinators-Poly-Base.html#t%3APolyParse"+>PolyParse</A+> p =&gt; p a -&gt; p z -&gt; p [a]</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/Poly/Base.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.  The final t is discarded.  Any parse failures+   could be due either to a badly-formed terminator or a badly-formed+   element, so it raises both possible errors.+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="botbar"+>Produced by <A HREF="http://www.haskell.org/haddock/"+>Haddock</A+> version 2.4.2</TD+></TR+></TABLE+></BODY+></HTML+>
+ docs/haddock/Text-ParserCombinators-Poly-ByteString.html view
@@ -0,0 +1,675 @@+<!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.ByteString</TITLE+><LINK HREF="haddock.css" REL="stylesheet" TYPE="text/css"+><SCRIPT SRC="haddock-util.js" TYPE="text/javascript"+></SCRIPT+><SCRIPT TYPE="text/javascript"+>window.onload = function () {setSynopsis("mini_Text-ParserCombinators-Poly-ByteString.html")};</SCRIPT+></HEAD+><BODY+><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"+><TR+><TD CLASS="topbar"+><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"+><TR+><TD+><IMG SRC="haskell_icon.gif" WIDTH="16" HEIGHT="16" ALT=" "+></TD+><TD CLASS="title"+>polyparse</TD+><TD CLASS="topbut"+><A HREF="src/Text/ParserCombinators/Poly/ByteString.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.ByteString</FONT+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD+><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"+><TR+><TD CLASS="section4"+><B+>Contents</B+></TD+></TR+><TR+><TD+><DL+><DT+><A HREF="#1"+>The Parser datatype+</A+></DT+><DD+><DL+><DT+><A HREF="#2"+>basic parsers+</A+></DT+><DT+><A HREF="#3"+>re-parsing+</A+></DT+></DL+></DD+><DT+><A HREF="#4"+>Re-export all more general combinators+</A+></DT+></DL+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="section1"+>Synopsis</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="body"+><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"+><TR+><TD CLASS="decl"+><SPAN CLASS="keyword"+>newtype</SPAN+>  <A HREF="#t%3AParser"+>Parser</A+> a = <A HREF="#v%3AP"+>P</A+> (ByteString -&gt; <A HREF="Text-ParserCombinators-Poly-ByteString.html#t%3AResult"+>Result</A+> ByteString a)</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"+><TR+><TD CLASS="decl"+><SPAN CLASS="keyword"+>data</SPAN+>  <A HREF="#t%3AResult"+>Result</A+> z a </TD+></TR+><TR+><TD CLASS="body"+><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"+><TR+><TD CLASS="decl"+>= <A HREF="#v%3ASuccess"+>Success</A+> z a</TD+></TR+><TR+><TD CLASS="decl"+>| <A HREF="#v%3AFailure"+>Failure</A+> z String</TD+></TR+><TR+><TD CLASS="decl"+>| <A HREF="#v%3ACommitted"+>Committed</A+> (<A HREF="Text-ParserCombinators-Poly-ByteString.html#t%3AResult"+>Result</A+> z a)</TD+></TR+></TABLE+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3ArunParser"+>runParser</A+> ::  <A HREF="Text-ParserCombinators-Poly-ByteString.html#t%3AParser"+>Parser</A+> a -&gt; ByteString -&gt; (Either String a, ByteString)</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3Anext"+>next</A+> :: <A HREF="Text-ParserCombinators-Poly-ByteString.html#t%3AParser"+>Parser</A+> Char</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3Aeof"+>eof</A+> :: <A HREF="Text-ParserCombinators-Poly-ByteString.html#t%3AParser"+>Parser</A+> ()</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3Asatisfy"+>satisfy</A+> :: (Char -&gt; Bool) -&gt; <A HREF="Text-ParserCombinators-Poly-ByteString.html#t%3AParser"+>Parser</A+> Char</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3Areparse"+>reparse</A+> :: ByteString -&gt; <A HREF="Text-ParserCombinators-Poly-ByteString.html#t%3AParser"+>Parser</A+> ()</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+>module <A HREF="Text-ParserCombinators-Poly-Base.html"+>Text.ParserCombinators.Poly.Base</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="section1"+><A NAME="1"+><A NAME="1"+>The Parser datatype+</A+></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:Parser"+><A NAME="t%3AParser"+></A+></A+><B+>Parser</B+> a </TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/Poly/ByteString.html#Parser"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="body"+><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"+><TR+><TD CLASS="ndoc"+>This <TT+>Parser</TT+> datatype is a specialised parsing monad with error+   reporting.  Whereas the standard version can be used for arbitrary+   token types, this version is specialised to ByteString input only.+</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:P"+><A NAME="v%3AP"+></A+></A+><B+>P</B+> (ByteString -&gt; <A HREF="Text-ParserCombinators-Poly-ByteString.html#t%3AResult"+>Result</A+> ByteString a)</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"+>Monad <A HREF="Text-ParserCombinators-Poly-ByteString.html#t%3AParser"+>Parser</A+></TD+></TR+><TR+><TD CLASS="decl"+>Functor <A HREF="Text-ParserCombinators-Poly-ByteString.html#t%3AParser"+>Parser</A+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="Text-ParserCombinators-Poly-Base.html#t%3APolyParse"+>PolyParse</A+> <A HREF="Text-ParserCombinators-Poly-ByteString.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"+><SPAN CLASS="keyword"+>data</SPAN+>  <A NAME="t:Result"+><A NAME="t%3AResult"+></A+></A+><B+>Result</B+> z a </TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/Poly/ByteString.html#Result"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="body"+><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"+><TR+><TD CLASS="ndoc"+>A return type like Either, that distinguishes not only between+   right and wrong answers, but also has commitment, so that a failure+   cannot be undone.  This should only be used for writing very primitive+   parsers - really it is an internal detail of the library.+</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:Success"+><A NAME="v%3ASuccess"+></A+></A+><B+>Success</B+> z a</TD+><TD CLASS="rdoc"+></TD+></TR+><TR+><TD CLASS="arg"+><A NAME="v:Failure"+><A NAME="v%3AFailure"+></A+></A+><B+>Failure</B+> z String</TD+><TD CLASS="rdoc"+></TD+></TR+><TR+><TD CLASS="arg"+><A NAME="v:Committed"+><A NAME="v%3ACommitted"+></A+></A+><B+>Committed</B+> (<A HREF="Text-ParserCombinators-Poly-ByteString.html#t%3AResult"+>Result</A+> z a)</TD+><TD CLASS="rdoc"+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="section4"+><IMG SRC="minus.gif" CLASS="coll" ONCLICK="toggle(this,'i:Result')" ALT="show/hide"+> Instances</TD+></TR+><TR+><TD CLASS="body"+><DIV ID="i:Result" STYLE="display:block;"+><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0"+><TR+><TD CLASS="decl"+>Functor (<A HREF="Text-ParserCombinators-Poly-ByteString.html#t%3AResult"+>Result</A+> z)</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:runParser"+><A NAME="v%3ArunParser"+></A+></A+><B+>runParser</B+> ::  <A HREF="Text-ParserCombinators-Poly-ByteString.html#t%3AParser"+>Parser</A+> a -&gt; ByteString -&gt; (Either String a, ByteString)</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/Poly/ByteString.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="section2"+><A NAME="2"+><A NAME="2"+>basic parsers+</A+></A+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v:next"+><A NAME="v%3Anext"+></A+></A+><B+>next</B+> :: <A HREF="Text-ParserCombinators-Poly-ByteString.html#t%3AParser"+>Parser</A+> Char</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/Poly/ByteString.html#next"+>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:eof"+><A NAME="v%3Aeof"+></A+></A+><B+>eof</B+> :: <A HREF="Text-ParserCombinators-Poly-ByteString.html#t%3AParser"+>Parser</A+> ()</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/Poly/ByteString.html#eof"+>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:satisfy"+><A NAME="v%3Asatisfy"+></A+></A+><B+>satisfy</B+> :: (Char -&gt; Bool) -&gt; <A HREF="Text-ParserCombinators-Poly-ByteString.html#t%3AParser"+>Parser</A+> Char</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/Poly/ByteString.html#satisfy"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="section2"+><A NAME="3"+><A NAME="3"+>re-parsing+</A+></A+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v:reparse"+><A NAME="v%3Areparse"+></A+></A+><B+>reparse</B+> :: ByteString -&gt; <A HREF="Text-ParserCombinators-Poly-ByteString.html#t%3AParser"+>Parser</A+> ()</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/Poly/ByteString.html#reparse"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+>Push some tokens back onto the front of the input stream and reparse.+   This is useful e.g. for recursively expanding macros.  When the+   user-parser recognises a macro use, it can lookup the macro+   expansion from the parse state, lex it, and then stuff the+   lexed expansion back down into the parser.+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="section1"+><A NAME="4"+><A NAME="4"+>Re-export all more general combinators+</A+></A+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="decl"+>module <A HREF="Text-ParserCombinators-Poly-Base.html"+>Text.ParserCombinators.Poly.Base</A+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="botbar"+>Produced by <A HREF="http://www.haskell.org/haddock/"+>Haddock</A+> version 2.4.2</TD+></TR+></TABLE+></BODY+></HTML+>
+ docs/haddock/Text-ParserCombinators-Poly-Lazy.html view
@@ -0,0 +1,676 @@+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">+<!--Rendered using the Haskell Html Library v0.2-->+<HTML+><HEAD+><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8"+><TITLE+>Text.ParserCombinators.Poly.Lazy</TITLE+><LINK HREF="haddock.css" REL="stylesheet" TYPE="text/css"+><SCRIPT SRC="haddock-util.js" TYPE="text/javascript"+></SCRIPT+><SCRIPT TYPE="text/javascript"+>window.onload = function () {setSynopsis("mini_Text-ParserCombinators-Poly-Lazy.html")};</SCRIPT+></HEAD+><BODY+><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"+><TR+><TD CLASS="topbar"+><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"+><TR+><TD+><IMG SRC="haskell_icon.gif" WIDTH="16" HEIGHT="16" ALT=" "+></TD+><TD CLASS="title"+>polyparse</TD+><TD CLASS="topbut"+><A HREF="src/Text/ParserCombinators/Poly/Lazy.html"+>Source code</A+></TD+><TD CLASS="topbut"+><A HREF="index.html"+>Contents</A+></TD+><TD CLASS="topbut"+><A HREF="doc-index.html"+>Index</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="modulebar"+><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"+><TR+><TD+><FONT SIZE="6"+>Text.ParserCombinators.Poly.Lazy</FONT+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD+><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"+><TR+><TD CLASS="section4"+><B+>Contents</B+></TD+></TR+><TR+><TD+><DL+><DT+><A HREF="#1"+>The Parser datatype+</A+></DT+><DD+><DL+><DT+><A HREF="#2"+>basic parsers+</A+></DT+><DT+><A HREF="#3"+>re-parsing+</A+></DT+></DL+></DD+><DT+><A HREF="#4"+>Re-export all more general combinators+</A+></DT+></DL+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="section1"+>Synopsis</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="body"+><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"+><TR+><TD CLASS="decl"+><SPAN CLASS="keyword"+>newtype</SPAN+>  <A HREF="#t%3AParser"+>Parser</A+> t a = <A HREF="#v%3AP"+>P</A+> ([t] -&gt; <A HREF="Text-ParserCombinators-Poly-Lazy.html#t%3AResult"+>Result</A+> [t] a)</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"+><TR+><TD CLASS="decl"+><SPAN CLASS="keyword"+>data</SPAN+>  <A HREF="#t%3AResult"+>Result</A+> z a </TD+></TR+><TR+><TD CLASS="body"+><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"+><TR+><TD CLASS="decl"+>= <A HREF="#v%3ASuccess"+>Success</A+> z a</TD+></TR+><TR+><TD CLASS="decl"+>| <A HREF="#v%3AFailure"+>Failure</A+> z String</TD+></TR+><TR+><TD CLASS="decl"+>| <A HREF="#v%3ACommitted"+>Committed</A+> (<A HREF="Text-ParserCombinators-Poly-Lazy.html#t%3AResult"+>Result</A+> z a)</TD+></TR+></TABLE+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3ArunParser"+>runParser</A+> ::  <A HREF="Text-ParserCombinators-Poly-Lazy.html#t%3AParser"+>Parser</A+> t a -&gt; [t] -&gt; (a, [t])</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3Anext"+>next</A+> ::  <A HREF="Text-ParserCombinators-Poly-Lazy.html#t%3AParser"+>Parser</A+> t t</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3Aeof"+>eof</A+> ::  <A HREF="Text-ParserCombinators-Poly-Lazy.html#t%3AParser"+>Parser</A+> t ()</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3Asatisfy"+>satisfy</A+> ::  (t -&gt; Bool) -&gt; <A HREF="Text-ParserCombinators-Poly-Lazy.html#t%3AParser"+>Parser</A+> t t</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3Areparse"+>reparse</A+> ::  [t] -&gt; <A HREF="Text-ParserCombinators-Poly-Lazy.html#t%3AParser"+>Parser</A+> t ()</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+>module <A HREF="Text-ParserCombinators-Poly-Base.html"+>Text.ParserCombinators.Poly.Base</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="section1"+><A NAME="1"+><A NAME="1"+>The Parser datatype+</A+></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:Parser"+><A NAME="t%3AParser"+></A+></A+><B+>Parser</B+> t a </TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/Poly/Lazy.html#Parser"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="body"+><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"+><TR+><TD CLASS="ndoc"+>This <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:P"+><A NAME="v%3AP"+></A+></A+><B+>P</B+> ([t] -&gt; <A HREF="Text-ParserCombinators-Poly-Lazy.html#t%3AResult"+>Result</A+> [t] a)</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"+>Monad (<A HREF="Text-ParserCombinators-Poly-Lazy.html#t%3AParser"+>Parser</A+> t)</TD+></TR+><TR+><TD CLASS="decl"+>Functor (<A HREF="Text-ParserCombinators-Poly-Lazy.html#t%3AParser"+>Parser</A+> t)</TD+></TR+><TR+><TD CLASS="decl"+><A HREF="Text-ParserCombinators-Poly-Base.html#t%3APolyParse"+>PolyParse</A+> (<A HREF="Text-ParserCombinators-Poly-Lazy.html#t%3AParser"+>Parser</A+> t)</TD+></TR+></TABLE+></DIV+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><SPAN CLASS="keyword"+>data</SPAN+>  <A NAME="t:Result"+><A NAME="t%3AResult"+></A+></A+><B+>Result</B+> z a </TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/Poly/Lazy.html#Result"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="body"+><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"+><TR+><TD CLASS="ndoc"+>A return type like Either, that distinguishes not only between+   right and wrong answers, but also has gradations of wrongness.+   This should only be used for writing very primitive+   parsers - really it is an internal detail of the library.+</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:Success"+><A NAME="v%3ASuccess"+></A+></A+><B+>Success</B+> z a</TD+><TD CLASS="rdoc"+></TD+></TR+><TR+><TD CLASS="arg"+><A NAME="v:Failure"+><A NAME="v%3AFailure"+></A+></A+><B+>Failure</B+> z String</TD+><TD CLASS="rdoc"+></TD+></TR+><TR+><TD CLASS="arg"+><A NAME="v:Committed"+><A NAME="v%3ACommitted"+></A+></A+><B+>Committed</B+> (<A HREF="Text-ParserCombinators-Poly-Lazy.html#t%3AResult"+>Result</A+> z a)</TD+><TD CLASS="rdoc"+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="section4"+><IMG SRC="minus.gif" CLASS="coll" ONCLICK="toggle(this,'i:Result')" ALT="show/hide"+> Instances</TD+></TR+><TR+><TD CLASS="body"+><DIV ID="i:Result" STYLE="display:block;"+><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0"+><TR+><TD CLASS="decl"+>Functor (<A HREF="Text-ParserCombinators-Poly-Lazy.html#t%3AResult"+>Result</A+> z)</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:runParser"+><A NAME="v%3ArunParser"+></A+></A+><B+>runParser</B+> ::  <A HREF="Text-ParserCombinators-Poly-Lazy.html#t%3AParser"+>Parser</A+> t a -&gt; [t] -&gt; (a, [t])</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/Poly/Lazy.html#runParser"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+>Apply a parser to an input token sequence.+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="section2"+><A NAME="2"+><A NAME="2"+>basic parsers+</A+></A+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v:next"+><A NAME="v%3Anext"+></A+></A+><B+>next</B+> ::  <A HREF="Text-ParserCombinators-Poly-Lazy.html#t%3AParser"+>Parser</A+> t t</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/Poly/Lazy.html#next"+>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:eof"+><A NAME="v%3Aeof"+></A+></A+><B+>eof</B+> ::  <A HREF="Text-ParserCombinators-Poly-Lazy.html#t%3AParser"+>Parser</A+> t ()</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/Poly/Lazy.html#eof"+>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:satisfy"+><A NAME="v%3Asatisfy"+></A+></A+><B+>satisfy</B+> ::  (t -&gt; Bool) -&gt; <A HREF="Text-ParserCombinators-Poly-Lazy.html#t%3AParser"+>Parser</A+> t t</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/Poly/Lazy.html#satisfy"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="section2"+><A NAME="3"+><A NAME="3"+>re-parsing+</A+></A+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v:reparse"+><A NAME="v%3Areparse"+></A+></A+><B+>reparse</B+> ::  [t] -&gt; <A HREF="Text-ParserCombinators-Poly-Lazy.html#t%3AParser"+>Parser</A+> t ()</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/Poly/Lazy.html#reparse"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+>Push some tokens back onto the front of the input stream and reparse.+   This is useful e.g. for recursively expanding macros.  When the+   user-parser recognises a macro use, it can lookup the macro+   expansion from the parse state, lex it, and then stuff the+   lexed expansion back down into the parser.+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="section1"+><A NAME="4"+><A NAME="4"+>Re-export all more general combinators+</A+></A+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="decl"+>module <A HREF="Text-ParserCombinators-Poly-Base.html"+>Text.ParserCombinators.Poly.Base</A+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="botbar"+>Produced by <A HREF="http://www.haskell.org/haddock/"+>Haddock</A+> version 2.4.2</TD+></TR+></TABLE+></BODY+></HTML+>
+ docs/haddock/Text-ParserCombinators-Poly-Plain.html view
@@ -0,0 +1,676 @@+<!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.Plain</TITLE+><LINK HREF="haddock.css" REL="stylesheet" TYPE="text/css"+><SCRIPT SRC="haddock-util.js" TYPE="text/javascript"+></SCRIPT+><SCRIPT TYPE="text/javascript"+>window.onload = function () {setSynopsis("mini_Text-ParserCombinators-Poly-Plain.html")};</SCRIPT+></HEAD+><BODY+><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"+><TR+><TD CLASS="topbar"+><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"+><TR+><TD+><IMG SRC="haskell_icon.gif" WIDTH="16" HEIGHT="16" ALT=" "+></TD+><TD CLASS="title"+>polyparse</TD+><TD CLASS="topbut"+><A HREF="src/Text/ParserCombinators/Poly/Plain.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.Plain</FONT+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD+><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"+><TR+><TD CLASS="section4"+><B+>Contents</B+></TD+></TR+><TR+><TD+><DL+><DT+><A HREF="#1"+>The Parser datatype+</A+></DT+><DD+><DL+><DT+><A HREF="#2"+>basic parsers+</A+></DT+><DT+><A HREF="#3"+>re-parsing+</A+></DT+></DL+></DD+><DT+><A HREF="#4"+>Re-export all more general combinators+</A+></DT+></DL+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="section1"+>Synopsis</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="body"+><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"+><TR+><TD CLASS="decl"+><SPAN CLASS="keyword"+>newtype</SPAN+>  <A HREF="#t%3AParser"+>Parser</A+> t a = <A HREF="#v%3AP"+>P</A+> ([t] -&gt; <A HREF="Text-ParserCombinators-Poly-Plain.html#t%3AResult"+>Result</A+> [t] a)</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"+><TR+><TD CLASS="decl"+><SPAN CLASS="keyword"+>data</SPAN+>  <A HREF="#t%3AResult"+>Result</A+> z a </TD+></TR+><TR+><TD CLASS="body"+><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"+><TR+><TD CLASS="decl"+>= <A HREF="#v%3ASuccess"+>Success</A+> z a</TD+></TR+><TR+><TD CLASS="decl"+>| <A HREF="#v%3AFailure"+>Failure</A+> z String</TD+></TR+><TR+><TD CLASS="decl"+>| <A HREF="#v%3ACommitted"+>Committed</A+> (<A HREF="Text-ParserCombinators-Poly-Plain.html#t%3AResult"+>Result</A+> z a)</TD+></TR+></TABLE+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3ArunParser"+>runParser</A+> ::  <A HREF="Text-ParserCombinators-Poly-Plain.html#t%3AParser"+>Parser</A+> t a -&gt; [t] -&gt; (Either String a, [t])</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3Anext"+>next</A+> ::  <A HREF="Text-ParserCombinators-Poly-Plain.html#t%3AParser"+>Parser</A+> t t</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3Aeof"+>eof</A+> ::  <A HREF="Text-ParserCombinators-Poly-Plain.html#t%3AParser"+>Parser</A+> t ()</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3Asatisfy"+>satisfy</A+> ::  (t -&gt; Bool) -&gt; <A HREF="Text-ParserCombinators-Poly-Plain.html#t%3AParser"+>Parser</A+> t t</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3Areparse"+>reparse</A+> ::  [t] -&gt; <A HREF="Text-ParserCombinators-Poly-Plain.html#t%3AParser"+>Parser</A+> t ()</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+>module <A HREF="Text-ParserCombinators-Poly-Base.html"+>Text.ParserCombinators.Poly.Base</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="section1"+><A NAME="1"+><A NAME="1"+>The Parser datatype+</A+></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:Parser"+><A NAME="t%3AParser"+></A+></A+><B+>Parser</B+> t a </TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/Poly/Plain.html#Parser"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="body"+><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"+><TR+><TD CLASS="ndoc"+>This <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:P"+><A NAME="v%3AP"+></A+></A+><B+>P</B+> ([t] -&gt; <A HREF="Text-ParserCombinators-Poly-Plain.html#t%3AResult"+>Result</A+> [t] a)</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"+>Monad (<A HREF="Text-ParserCombinators-Poly-Plain.html#t%3AParser"+>Parser</A+> t)</TD+></TR+><TR+><TD CLASS="decl"+>Functor (<A HREF="Text-ParserCombinators-Poly-Plain.html#t%3AParser"+>Parser</A+> t)</TD+></TR+><TR+><TD CLASS="decl"+><A HREF="Text-ParserCombinators-Poly-Base.html#t%3APolyParse"+>PolyParse</A+> (<A HREF="Text-ParserCombinators-Poly-Plain.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"+><SPAN CLASS="keyword"+>data</SPAN+>  <A NAME="t:Result"+><A NAME="t%3AResult"+></A+></A+><B+>Result</B+> z a </TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/Poly/Plain.html#Result"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="body"+><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"+><TR+><TD CLASS="ndoc"+>A return type like Either, that distinguishes not only between+   right and wrong answers, but also has commitment, so that a failure+   cannot be undone.  This should only be used for writing very primitive+   parsers - really it is an internal detail of the library.+</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:Success"+><A NAME="v%3ASuccess"+></A+></A+><B+>Success</B+> z a</TD+><TD CLASS="rdoc"+></TD+></TR+><TR+><TD CLASS="arg"+><A NAME="v:Failure"+><A NAME="v%3AFailure"+></A+></A+><B+>Failure</B+> z String</TD+><TD CLASS="rdoc"+></TD+></TR+><TR+><TD CLASS="arg"+><A NAME="v:Committed"+><A NAME="v%3ACommitted"+></A+></A+><B+>Committed</B+> (<A HREF="Text-ParserCombinators-Poly-Plain.html#t%3AResult"+>Result</A+> z a)</TD+><TD CLASS="rdoc"+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="section4"+><IMG SRC="minus.gif" CLASS="coll" ONCLICK="toggle(this,'i:Result')" ALT="show/hide"+> Instances</TD+></TR+><TR+><TD CLASS="body"+><DIV ID="i:Result" STYLE="display:block;"+><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0"+><TR+><TD CLASS="decl"+>Functor (<A HREF="Text-ParserCombinators-Poly-Plain.html#t%3AResult"+>Result</A+> z)</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:runParser"+><A NAME="v%3ArunParser"+></A+></A+><B+>runParser</B+> ::  <A HREF="Text-ParserCombinators-Poly-Plain.html#t%3AParser"+>Parser</A+> t a -&gt; [t] -&gt; (Either String a, [t])</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/Poly/Plain.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="section2"+><A NAME="2"+><A NAME="2"+>basic parsers+</A+></A+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v:next"+><A NAME="v%3Anext"+></A+></A+><B+>next</B+> ::  <A HREF="Text-ParserCombinators-Poly-Plain.html#t%3AParser"+>Parser</A+> t t</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/Poly/Plain.html#next"+>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:eof"+><A NAME="v%3Aeof"+></A+></A+><B+>eof</B+> ::  <A HREF="Text-ParserCombinators-Poly-Plain.html#t%3AParser"+>Parser</A+> t ()</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/Poly/Plain.html#eof"+>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:satisfy"+><A NAME="v%3Asatisfy"+></A+></A+><B+>satisfy</B+> ::  (t -&gt; Bool) -&gt; <A HREF="Text-ParserCombinators-Poly-Plain.html#t%3AParser"+>Parser</A+> t t</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/Poly/Plain.html#satisfy"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="section2"+><A NAME="3"+><A NAME="3"+>re-parsing+</A+></A+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v:reparse"+><A NAME="v%3Areparse"+></A+></A+><B+>reparse</B+> ::  [t] -&gt; <A HREF="Text-ParserCombinators-Poly-Plain.html#t%3AParser"+>Parser</A+> t ()</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/Poly/Plain.html#reparse"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+>Push some tokens back onto the front of the input stream and reparse.+   This is useful e.g. for recursively expanding macros.  When the+   user-parser recognises a macro use, it can lookup the macro+   expansion from the parse state, lex it, and then stuff the+   lexed expansion back down into the parser.+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="section1"+><A NAME="4"+><A NAME="4"+>Re-export all more general combinators+</A+></A+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="decl"+>module <A HREF="Text-ParserCombinators-Poly-Base.html"+>Text.ParserCombinators.Poly.Base</A+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="botbar"+>Produced by <A HREF="http://www.haskell.org/haddock/"+>Haddock</A+> version 2.4.2</TD+></TR+></TABLE+></BODY+></HTML+>
+ docs/haddock/Text-ParserCombinators-Poly-State.html view
@@ -0,0 +1,823 @@+<!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.State</TITLE+><LINK HREF="haddock.css" REL="stylesheet" TYPE="text/css"+><SCRIPT SRC="haddock-util.js" TYPE="text/javascript"+></SCRIPT+><SCRIPT TYPE="text/javascript"+>window.onload = function () {setSynopsis("mini_Text-ParserCombinators-Poly-State.html")};</SCRIPT+></HEAD+><BODY+><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"+><TR+><TD CLASS="topbar"+><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"+><TR+><TD+><IMG SRC="haskell_icon.gif" WIDTH="16" HEIGHT="16" ALT=" "+></TD+><TD CLASS="title"+>polyparse</TD+><TD CLASS="topbut"+><A HREF="src/Text/ParserCombinators/Poly/State.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.State</FONT+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD+><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"+><TR+><TD CLASS="section4"+><B+>Contents</B+></TD+></TR+><TR+><TD+><DL+><DT+><A HREF="#1"+>The Parser datatype+</A+></DT+><DD+><DL+><DT+><A HREF="#2"+>basic parsers+</A+></DT+><DT+><A HREF="#3"+>State-handling+</A+></DT+><DT+><A HREF="#4"+>re-parsing+</A+></DT+></DL+></DD+><DT+><A HREF="#5"+>Re-export all more general combinators+</A+></DT+></DL+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="section1"+>Synopsis</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="body"+><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"+><TR+><TD CLASS="decl"+><SPAN CLASS="keyword"+>newtype</SPAN+>  <A HREF="#t%3AParser"+>Parser</A+> s t a = <A HREF="#v%3AP"+>P</A+> (s -&gt; [t] -&gt; <A HREF="Text-ParserCombinators-Poly-State.html#t%3AResult"+>Result</A+> [t] s a)</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"+><TR+><TD CLASS="decl"+><SPAN CLASS="keyword"+>data</SPAN+>  <A HREF="#t%3AResult"+>Result</A+> z s a </TD+></TR+><TR+><TD CLASS="body"+><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"+><TR+><TD CLASS="decl"+>= <A HREF="#v%3ASuccess"+>Success</A+> z s a</TD+></TR+><TR+><TD CLASS="decl"+>| <A HREF="#v%3AFailure"+>Failure</A+> z s String</TD+></TR+><TR+><TD CLASS="decl"+>| <A HREF="#v%3ACommitted"+>Committed</A+> (<A HREF="Text-ParserCombinators-Poly-State.html#t%3AResult"+>Result</A+> z s a)</TD+></TR+></TABLE+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3ArunParser"+>runParser</A+> ::  <A HREF="Text-ParserCombinators-Poly-State.html#t%3AParser"+>Parser</A+> s t a -&gt; s -&gt; [t] -&gt; (Either String a, s, [t])</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3Anext"+>next</A+> ::  <A HREF="Text-ParserCombinators-Poly-State.html#t%3AParser"+>Parser</A+> s t t</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3Aeof"+>eof</A+> ::  <A HREF="Text-ParserCombinators-Poly-State.html#t%3AParser"+>Parser</A+> s t ()</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3Asatisfy"+>satisfy</A+> ::  (t -&gt; Bool) -&gt; <A HREF="Text-ParserCombinators-Poly-State.html#t%3AParser"+>Parser</A+> s t t</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3AstUpdate"+>stUpdate</A+> ::  (s -&gt; s) -&gt; <A HREF="Text-ParserCombinators-Poly-State.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 -&gt; a) -&gt; <A HREF="Text-ParserCombinators-Poly-State.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-Poly-State.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] -&gt; <A HREF="Text-ParserCombinators-Poly-State.html#t%3AParser"+>Parser</A+> s t ()</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+>module <A HREF="Text-ParserCombinators-Poly-Base.html"+>Text.ParserCombinators.Poly.Base</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="section1"+><A NAME="1"+><A NAME="1"+>The Parser datatype+</A+></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:Parser"+><A NAME="t%3AParser"+></A+></A+><B+>Parser</B+> s t a </TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/Poly/State.html#Parser"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="body"+><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"+><TR+><TD CLASS="ndoc"+>This <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:P"+><A NAME="v%3AP"+></A+></A+><B+>P</B+> (s -&gt; [t] -&gt; <A HREF="Text-ParserCombinators-Poly-State.html#t%3AResult"+>Result</A+> [t] s a)</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"+>Monad (<A HREF="Text-ParserCombinators-Poly-State.html#t%3AParser"+>Parser</A+> s t)</TD+></TR+><TR+><TD CLASS="decl"+>Functor (<A HREF="Text-ParserCombinators-Poly-State.html#t%3AParser"+>Parser</A+> s t)</TD+></TR+><TR+><TD CLASS="decl"+><A HREF="Text-ParserCombinators-Poly-Base.html#t%3APolyParse"+>PolyParse</A+> (<A HREF="Text-ParserCombinators-Poly-State.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"+><SPAN CLASS="keyword"+>data</SPAN+>  <A NAME="t:Result"+><A NAME="t%3AResult"+></A+></A+><B+>Result</B+> z s a </TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/Poly/State.html#Result"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="body"+><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"+><TR+><TD CLASS="ndoc"+>A return type like Either, that distinguishes not only between+   right and wrong answers, but also has gradations of wrongness.+   This should only be used for writing very primitive+   parsers - really it is an internal detail of the library.+</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:Success"+><A NAME="v%3ASuccess"+></A+></A+><B+>Success</B+> z s a</TD+><TD CLASS="rdoc"+></TD+></TR+><TR+><TD CLASS="arg"+><A NAME="v:Failure"+><A NAME="v%3AFailure"+></A+></A+><B+>Failure</B+> z s String</TD+><TD CLASS="rdoc"+></TD+></TR+><TR+><TD CLASS="arg"+><A NAME="v:Committed"+><A NAME="v%3ACommitted"+></A+></A+><B+>Committed</B+> (<A HREF="Text-ParserCombinators-Poly-State.html#t%3AResult"+>Result</A+> z s a)</TD+><TD CLASS="rdoc"+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="section4"+><IMG SRC="minus.gif" CLASS="coll" ONCLICK="toggle(this,'i:Result')" ALT="show/hide"+> Instances</TD+></TR+><TR+><TD CLASS="body"+><DIV ID="i:Result" STYLE="display:block;"+><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0"+><TR+><TD CLASS="decl"+>Functor (<A HREF="Text-ParserCombinators-Poly-State.html#t%3AResult"+>Result</A+> z s)</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:runParser"+><A NAME="v%3ArunParser"+></A+></A+><B+>runParser</B+> ::  <A HREF="Text-ParserCombinators-Poly-State.html#t%3AParser"+>Parser</A+> s t a -&gt; s -&gt; [t] -&gt; (Either String a, s, [t])</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/Poly/State.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="section2"+><A NAME="2"+><A NAME="2"+>basic parsers+</A+></A+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v:next"+><A NAME="v%3Anext"+></A+></A+><B+>next</B+> ::  <A HREF="Text-ParserCombinators-Poly-State.html#t%3AParser"+>Parser</A+> s t t</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/Poly/State.html#next"+>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:eof"+><A NAME="v%3Aeof"+></A+></A+><B+>eof</B+> ::  <A HREF="Text-ParserCombinators-Poly-State.html#t%3AParser"+>Parser</A+> s t ()</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/Poly/State.html#eof"+>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:satisfy"+><A NAME="v%3Asatisfy"+></A+></A+><B+>satisfy</B+> ::  (t -&gt; Bool) -&gt; <A HREF="Text-ParserCombinators-Poly-State.html#t%3AParser"+>Parser</A+> s t t</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/Poly/State.html#satisfy"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="section2"+><A NAME="3"+><A NAME="3"+>State-handling+</A+></A+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v:stUpdate"+><A NAME="v%3AstUpdate"+></A+></A+><B+>stUpdate</B+> ::  (s -&gt; s) -&gt; <A HREF="Text-ParserCombinators-Poly-State.html#t%3AParser"+>Parser</A+> s t ()</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/Poly/State.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:stQuery"+><A NAME="v%3AstQuery"+></A+></A+><B+>stQuery</B+> ::  (s -&gt; a) -&gt; <A HREF="Text-ParserCombinators-Poly-State.html#t%3AParser"+>Parser</A+> s t a</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/Poly/State.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:stGet"+><A NAME="v%3AstGet"+></A+></A+><B+>stGet</B+> ::  <A HREF="Text-ParserCombinators-Poly-State.html#t%3AParser"+>Parser</A+> s t s</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/Poly/State.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="4"+><A NAME="4"+>re-parsing+</A+></A+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v:reparse"+><A NAME="v%3Areparse"+></A+></A+><B+>reparse</B+> ::  [t] -&gt; <A HREF="Text-ParserCombinators-Poly-State.html#t%3AParser"+>Parser</A+> s t ()</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/Poly/State.html#reparse"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+>Push some tokens back onto the front of the input stream and reparse.+   This is useful e.g. for recursively expanding macros.  When the+   user-parser recognises a macro use, it can lookup the macro+   expansion from the parse state, lex it, and then stuff the+   lexed expansion back down into the parser.+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="section1"+><A NAME="5"+><A NAME="5"+>Re-export all more general combinators+</A+></A+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="decl"+>module <A HREF="Text-ParserCombinators-Poly-Base.html"+>Text.ParserCombinators.Poly.Base</A+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="botbar"+>Produced by <A HREF="http://www.haskell.org/haddock/"+>Haddock</A+> version 2.4.2</TD+></TR+></TABLE+></BODY+></HTML+>
+ docs/haddock/Text-ParserCombinators-Poly-StateLazy.html view
@@ -0,0 +1,869 @@+<!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.StateLazy</TITLE+><LINK HREF="haddock.css" REL="stylesheet" TYPE="text/css"+><SCRIPT SRC="haddock-util.js" TYPE="text/javascript"+></SCRIPT+><SCRIPT TYPE="text/javascript"+>window.onload = function () {setSynopsis("mini_Text-ParserCombinators-Poly-StateLazy.html")};</SCRIPT+></HEAD+><BODY+><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"+><TR+><TD CLASS="topbar"+><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"+><TR+><TD+><IMG SRC="haskell_icon.gif" WIDTH="16" HEIGHT="16" ALT=" "+></TD+><TD CLASS="title"+>polyparse</TD+><TD CLASS="topbut"+><A HREF="src/Text/ParserCombinators/Poly/StateLazy.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.StateLazy</FONT+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD+><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"+><TR+><TD CLASS="section4"+><B+>Contents</B+></TD+></TR+><TR+><TD+><DL+><DT+><A HREF="#1"+>The Parser datatype+</A+></DT+><DD+><DL+><DT+><A HREF="#2"+>basic parsers+</A+></DT+><DT+><A HREF="#3"+>State-handling+</A+></DT+><DT+><A HREF="#4"+>re-parsing+</A+></DT+></DL+></DD+><DT+><A HREF="#5"+>Re-export all more general combinators+</A+></DT+></DL+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="section1"+>Synopsis</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="body"+><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"+><TR+><TD CLASS="decl"+><SPAN CLASS="keyword"+>newtype</SPAN+>  <A HREF="#t%3AParser"+>Parser</A+> s t a = <A HREF="#v%3AP"+>P</A+> (s -&gt; [t] -&gt; <A HREF="Text-ParserCombinators-Poly-StateLazy.html#t%3AResult"+>Result</A+> [t] s a)</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"+><TR+><TD CLASS="decl"+><SPAN CLASS="keyword"+>data</SPAN+>  <A HREF="#t%3AResult"+>Result</A+> z s a </TD+></TR+><TR+><TD CLASS="body"+><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"+><TR+><TD CLASS="decl"+>= <A HREF="#v%3ASuccess"+>Success</A+> z s a</TD+></TR+><TR+><TD CLASS="decl"+>| <A HREF="#v%3AFailure"+>Failure</A+> z s String</TD+></TR+><TR+><TD CLASS="decl"+>| <A HREF="#v%3ACommitted"+>Committed</A+> (<A HREF="Text-ParserCombinators-Poly-StateLazy.html#t%3AResult"+>Result</A+> z s a)</TD+></TR+></TABLE+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3ArunParser"+>runParser</A+> ::  <A HREF="Text-ParserCombinators-Poly-StateLazy.html#t%3AParser"+>Parser</A+> s t a -&gt; s -&gt; [t] -&gt; (a, s, [t])</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3Anext"+>next</A+> ::  <A HREF="Text-ParserCombinators-Poly-StateLazy.html#t%3AParser"+>Parser</A+> s t t</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3Aeof"+>eof</A+> ::  <A HREF="Text-ParserCombinators-Poly-StateLazy.html#t%3AParser"+>Parser</A+> s t ()</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3Asatisfy"+>satisfy</A+> ::  (t -&gt; Bool) -&gt; <A HREF="Text-ParserCombinators-Poly-StateLazy.html#t%3AParser"+>Parser</A+> s t t</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3AmanyFinally"+>manyFinally</A+> ::  <A HREF="Text-ParserCombinators-Poly-StateLazy.html#t%3AParser"+>Parser</A+> s t a -&gt; <A HREF="Text-ParserCombinators-Poly-StateLazy.html#t%3AParser"+>Parser</A+> s t z -&gt; <A HREF="Text-ParserCombinators-Poly-StateLazy.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 -&gt; s) -&gt; <A HREF="Text-ParserCombinators-Poly-StateLazy.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 -&gt; a) -&gt; <A HREF="Text-ParserCombinators-Poly-StateLazy.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-Poly-StateLazy.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] -&gt; <A HREF="Text-ParserCombinators-Poly-StateLazy.html#t%3AParser"+>Parser</A+> s t ()</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+>module <A HREF="Text-ParserCombinators-Poly-Base.html"+>Text.ParserCombinators.Poly.Base</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="section1"+><A NAME="1"+><A NAME="1"+>The Parser datatype+</A+></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:Parser"+><A NAME="t%3AParser"+></A+></A+><B+>Parser</B+> s t a </TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/Poly/StateLazy.html#Parser"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="body"+><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"+><TR+><TD CLASS="ndoc"+>This <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:P"+><A NAME="v%3AP"+></A+></A+><B+>P</B+> (s -&gt; [t] -&gt; <A HREF="Text-ParserCombinators-Poly-StateLazy.html#t%3AResult"+>Result</A+> [t] s a)</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"+>Monad (<A HREF="Text-ParserCombinators-Poly-StateLazy.html#t%3AParser"+>Parser</A+> s t)</TD+></TR+><TR+><TD CLASS="decl"+>Functor (<A HREF="Text-ParserCombinators-Poly-StateLazy.html#t%3AParser"+>Parser</A+> s t)</TD+></TR+><TR+><TD CLASS="decl"+><A HREF="Text-ParserCombinators-Poly-Base.html#t%3APolyParse"+>PolyParse</A+> (<A HREF="Text-ParserCombinators-Poly-StateLazy.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"+><SPAN CLASS="keyword"+>data</SPAN+>  <A NAME="t:Result"+><A NAME="t%3AResult"+></A+></A+><B+>Result</B+> z s a </TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/Poly/StateLazy.html#Result"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="body"+><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"+><TR+><TD CLASS="ndoc"+>A return type like Either, that distinguishes not only between+   right and wrong answers, but also has gradations of wrongness.+   This should only be used for writing very primitive+   parsers - really it is an internal detail of the library.+</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:Success"+><A NAME="v%3ASuccess"+></A+></A+><B+>Success</B+> z s a</TD+><TD CLASS="rdoc"+></TD+></TR+><TR+><TD CLASS="arg"+><A NAME="v:Failure"+><A NAME="v%3AFailure"+></A+></A+><B+>Failure</B+> z s String</TD+><TD CLASS="rdoc"+></TD+></TR+><TR+><TD CLASS="arg"+><A NAME="v:Committed"+><A NAME="v%3ACommitted"+></A+></A+><B+>Committed</B+> (<A HREF="Text-ParserCombinators-Poly-StateLazy.html#t%3AResult"+>Result</A+> z s a)</TD+><TD CLASS="rdoc"+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="section4"+><IMG SRC="minus.gif" CLASS="coll" ONCLICK="toggle(this,'i:Result')" ALT="show/hide"+> Instances</TD+></TR+><TR+><TD CLASS="body"+><DIV ID="i:Result" STYLE="display:block;"+><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0"+><TR+><TD CLASS="decl"+>Functor (<A HREF="Text-ParserCombinators-Poly-StateLazy.html#t%3AResult"+>Result</A+> z s)</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:runParser"+><A NAME="v%3ArunParser"+></A+></A+><B+>runParser</B+> ::  <A HREF="Text-ParserCombinators-Poly-StateLazy.html#t%3AParser"+>Parser</A+> s t a -&gt; s -&gt; [t] -&gt; (a, s, [t])</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/Poly/StateLazy.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="section2"+><A NAME="2"+><A NAME="2"+>basic parsers+</A+></A+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v:next"+><A NAME="v%3Anext"+></A+></A+><B+>next</B+> ::  <A HREF="Text-ParserCombinators-Poly-StateLazy.html#t%3AParser"+>Parser</A+> s t t</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/Poly/StateLazy.html#next"+>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:eof"+><A NAME="v%3Aeof"+></A+></A+><B+>eof</B+> ::  <A HREF="Text-ParserCombinators-Poly-StateLazy.html#t%3AParser"+>Parser</A+> s t ()</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/Poly/StateLazy.html#eof"+>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:satisfy"+><A NAME="v%3Asatisfy"+></A+></A+><B+>satisfy</B+> ::  (t -&gt; Bool) -&gt; <A HREF="Text-ParserCombinators-Poly-StateLazy.html#t%3AParser"+>Parser</A+> s t t</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/Poly/StateLazy.html#satisfy"+>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:manyFinally"+><A NAME="v%3AmanyFinally"+></A+></A+><B+>manyFinally</B+> ::  <A HREF="Text-ParserCombinators-Poly-StateLazy.html#t%3AParser"+>Parser</A+> s t a -&gt; <A HREF="Text-ParserCombinators-Poly-StateLazy.html#t%3AParser"+>Parser</A+> s t z -&gt; <A HREF="Text-ParserCombinators-Poly-StateLazy.html#t%3AParser"+>Parser</A+> s t [a]</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/Poly/StateLazy.html#manyFinally"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="section2"+><A NAME="3"+><A NAME="3"+>State-handling+</A+></A+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v:stUpdate"+><A NAME="v%3AstUpdate"+></A+></A+><B+>stUpdate</B+> ::  (s -&gt; s) -&gt; <A HREF="Text-ParserCombinators-Poly-StateLazy.html#t%3AParser"+>Parser</A+> s t ()</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/Poly/StateLazy.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:stQuery"+><A NAME="v%3AstQuery"+></A+></A+><B+>stQuery</B+> ::  (s -&gt; a) -&gt; <A HREF="Text-ParserCombinators-Poly-StateLazy.html#t%3AParser"+>Parser</A+> s t a</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/Poly/StateLazy.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:stGet"+><A NAME="v%3AstGet"+></A+></A+><B+>stGet</B+> ::  <A HREF="Text-ParserCombinators-Poly-StateLazy.html#t%3AParser"+>Parser</A+> s t s</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/Poly/StateLazy.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="4"+><A NAME="4"+>re-parsing+</A+></A+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v:reparse"+><A NAME="v%3Areparse"+></A+></A+><B+>reparse</B+> ::  [t] -&gt; <A HREF="Text-ParserCombinators-Poly-StateLazy.html#t%3AParser"+>Parser</A+> s t ()</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/Poly/StateLazy.html#reparse"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+>Push some tokens back onto the front of the input stream and reparse.+   This is useful e.g. for recursively expanding macros.  When the+   user-parser recognises a macro use, it can lookup the macro+   expansion from the parse state, lex it, and then stuff the+   lexed expansion back down into the parser.+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="section1"+><A NAME="5"+><A NAME="5"+>Re-export all more general combinators+</A+></A+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="decl"+>module <A HREF="Text-ParserCombinators-Poly-Base.html"+>Text.ParserCombinators.Poly.Base</A+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="botbar"+>Produced by <A HREF="http://www.haskell.org/haddock/"+>Haddock</A+> version 2.4.2</TD+></TR+></TABLE+></BODY+></HTML+>
+ docs/haddock/Text-ParserCombinators-Poly.html view
@@ -0,0 +1,92 @@+<!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-util.js" TYPE="text/javascript"+></SCRIPT+><SCRIPT TYPE="text/javascript"+>window.onload = function () {setSynopsis("mini_Text-ParserCombinators-Poly.html")};</SCRIPT+></HEAD+><BODY+><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"+><TR+><TD CLASS="topbar"+><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"+><TR+><TD+><IMG SRC="haskell_icon.gif" WIDTH="16" HEIGHT="16" ALT=" "+></TD+><TD CLASS="title"+>polyparse</TD+><TD CLASS="topbut"+><A HREF="src/Text/ParserCombinators/Poly.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 CLASS="s15"+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="section1"+>Documentation</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="decl"+>module <A HREF="Text-ParserCombinators-Poly-Plain.html"+>Text.ParserCombinators.Poly.Plain</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 2.4.2</TD+></TR+></TABLE+></BODY+></HTML+>
+ docs/haddock/doc-index.html view
@@ -0,0 +1,1774 @@+<!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+>polyparse (Index)</TITLE+><LINK HREF="haddock.css" REL="stylesheet" TYPE="text/css"+><SCRIPT SRC="haddock-util.js" TYPE="text/javascript"+></SCRIPT+></HEAD+><BODY+><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"+><TR+><TD CLASS="topbar"+><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"+><TR+><TD+><IMG SRC="haskell_icon.gif" WIDTH="16" HEIGHT="16" ALT=" "+></TD+><TD CLASS="title"+>polyparse</TD+><TD CLASS="topbut"+><A HREF="index.html"+>Contents</A+></TD+><TD CLASS="topbut"+><A HREF="doc-index.html"+>Index</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD COLSPAN="2" STYLE="padding-top:5px;"+><FORM onsubmit="full_search(); return false;" ACTION=""+>Search: <INPUT ID="searchbox" onkeyup="quick_search()"+> <INPUT VALUE="Search" TYPE="submit"+> <SPAN ID="searchmsg"+> </SPAN+></FORM+></TD+></TR+><TR+><TD+><TABLE ID="indexlist" CELLPADDING="0" CELLSPACING="5"+><TR CLASS="indexrow"+><TD CLASS="indexentry" COLSPAN="2"+>+++</TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>1 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#v%3A%2B%2B%2B"+>Text.ParserCombinators.HuttonMeijerWallace</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>2 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-HuttonMeijer.html#v%3A%2B%2B%2B"+>Text.ParserCombinators.HuttonMeijer</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexentry"+>adjustErr</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-Poly-Base.html#v%3AadjustErr"+>Text.ParserCombinators.Poly.Base</A+>, Text.ParserCombinators.Poly.Plain, Text.ParserCombinators.Poly.Lazy, Text.ParserCombinators.Poly.State, Text.ParserCombinators.Poly.StateLazy, Text.ParserCombinators.Poly.ByteString, Text.Parse.ByteString, Text.ParserCombinators.Poly, Text.Parse</TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexentry"+>adjustErrBad</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-Poly-Base.html#v%3AadjustErrBad"+>Text.ParserCombinators.Poly.Base</A+>, Text.ParserCombinators.Poly.Plain, Text.ParserCombinators.Poly.Lazy, Text.ParserCombinators.Poly.State, Text.ParserCombinators.Poly.StateLazy, Text.ParserCombinators.Poly.ByteString, Text.Parse.ByteString, Text.ParserCombinators.Poly, Text.Parse</TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexentry"+>allAsByteString</TD+><TD CLASS="indexlinks"+><A HREF="Text-Parse-ByteString.html#v%3AallAsByteString"+>Text.Parse.ByteString</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexentry"+>allAsString</TD+><TD CLASS="indexlinks"+><A HREF="Text-Parse-ByteString.html#v%3AallAsString"+>Text.Parse.ByteString</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexentry"+>alphanum</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-HuttonMeijer.html#v%3Aalphanum"+>Text.ParserCombinators.HuttonMeijer</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexentry"+>apply</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-Poly-Base.html#v%3Aapply"+>Text.ParserCombinators.Poly.Base</A+>, Text.ParserCombinators.Poly.Plain, Text.ParserCombinators.Poly.Lazy, Text.ParserCombinators.Poly.State, Text.ParserCombinators.Poly.StateLazy, Text.ParserCombinators.Poly.ByteString, Text.Parse.ByteString, Text.ParserCombinators.Poly, Text.Parse</TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexentry" COLSPAN="2"+>bracket</TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>1 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-Poly-Base.html#v%3Abracket"+>Text.ParserCombinators.Poly.Base</A+>, Text.ParserCombinators.Poly.Plain, Text.ParserCombinators.Poly.Lazy, Text.ParserCombinators.Poly.State, Text.ParserCombinators.Poly.StateLazy, Text.ParserCombinators.Poly.ByteString, Text.Parse.ByteString, Text.ParserCombinators.Poly, Text.Parse</TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>2 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#v%3Abracket"+>Text.ParserCombinators.HuttonMeijerWallace</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>3 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-HuttonMeijer.html#v%3Abracket"+>Text.ParserCombinators.HuttonMeijer</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexentry"+>bracketSep</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-Poly-Base.html#v%3AbracketSep"+>Text.ParserCombinators.Poly.Base</A+>, Text.ParserCombinators.Poly.Plain, Text.ParserCombinators.Poly.Lazy, Text.ParserCombinators.Poly.State, Text.ParserCombinators.Poly.StateLazy, Text.ParserCombinators.Poly.ByteString, Text.Parse.ByteString, Text.ParserCombinators.Poly, Text.Parse</TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexentry" COLSPAN="2"+>chainl</TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>1 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#v%3Achainl"+>Text.ParserCombinators.HuttonMeijerWallace</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>2 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-HuttonMeijer.html#v%3Achainl"+>Text.ParserCombinators.HuttonMeijer</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexentry" COLSPAN="2"+>chainl1</TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>1 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#v%3Achainl1"+>Text.ParserCombinators.HuttonMeijerWallace</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>2 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-HuttonMeijer.html#v%3Achainl1"+>Text.ParserCombinators.HuttonMeijer</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexentry" COLSPAN="2"+>chainr</TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>1 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#v%3Achainr"+>Text.ParserCombinators.HuttonMeijerWallace</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>2 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-HuttonMeijer.html#v%3Achainr"+>Text.ParserCombinators.HuttonMeijer</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexentry" COLSPAN="2"+>chainr1</TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>1 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#v%3Achainr1"+>Text.ParserCombinators.HuttonMeijerWallace</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>2 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-HuttonMeijer.html#v%3Achainr1"+>Text.ParserCombinators.HuttonMeijer</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexentry"+>char</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-HuttonMeijer.html#v%3Achar"+>Text.ParserCombinators.HuttonMeijer</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexentry"+>comment</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-HuttonMeijer.html#v%3Acomment"+>Text.ParserCombinators.HuttonMeijer</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexentry"+>commit</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-Poly-Base.html#v%3Acommit"+>Text.ParserCombinators.Poly.Base</A+>, Text.ParserCombinators.Poly.Plain, Text.ParserCombinators.Poly.Lazy, Text.ParserCombinators.Poly.State, Text.ParserCombinators.Poly.StateLazy, Text.ParserCombinators.Poly.ByteString, Text.Parse.ByteString, Text.ParserCombinators.Poly, Text.Parse</TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexentry" COLSPAN="2"+>Committed</TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>1 (Data Constructor)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-Poly-Plain.html#v%3ACommitted"+>Text.ParserCombinators.Poly.Plain</A+>, Text.ParserCombinators.Poly, Text.Parse</TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>2 (Data Constructor)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-Poly-Lazy.html#v%3ACommitted"+>Text.ParserCombinators.Poly.Lazy</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>3 (Data Constructor)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-Poly-State.html#v%3ACommitted"+>Text.ParserCombinators.Poly.State</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>4 (Data Constructor)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-Poly-StateLazy.html#v%3ACommitted"+>Text.ParserCombinators.Poly.StateLazy</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>5 (Data Constructor)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-Poly-ByteString.html#v%3ACommitted"+>Text.ParserCombinators.Poly.ByteString</A+>, Text.Parse.ByteString</TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexentry" COLSPAN="2"+>constructors</TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>1 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-Parse-ByteString.html#v%3Aconstructors"+>Text.Parse.ByteString</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>2 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-Parse.html#v%3Aconstructors"+>Text.Parse</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexentry"+>digit</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-HuttonMeijer.html#v%3Adigit"+>Text.ParserCombinators.HuttonMeijer</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexentry"+>discard</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-Poly-Base.html#v%3Adiscard"+>Text.ParserCombinators.Poly.Base</A+>, Text.ParserCombinators.Poly.Plain, Text.ParserCombinators.Poly.Lazy, Text.ParserCombinators.Poly.State, Text.ParserCombinators.Poly.StateLazy, Text.ParserCombinators.Poly.ByteString, Text.Parse.ByteString, Text.ParserCombinators.Poly, Text.Parse</TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexentry"+>elserror</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#v%3Aelserror"+>Text.ParserCombinators.HuttonMeijerWallace</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexentry" COLSPAN="2"+>enumeration</TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>1 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-Parse-ByteString.html#v%3Aenumeration"+>Text.Parse.ByteString</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>2 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-Parse.html#v%3Aenumeration"+>Text.Parse</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexentry" COLSPAN="2"+>eof</TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>1 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-Poly-Plain.html#v%3Aeof"+>Text.ParserCombinators.Poly.Plain</A+>, Text.ParserCombinators.Poly, Text.Parse</TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>2 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-Poly-Lazy.html#v%3Aeof"+>Text.ParserCombinators.Poly.Lazy</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>3 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-Poly-State.html#v%3Aeof"+>Text.ParserCombinators.Poly.State</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>4 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-Poly-StateLazy.html#v%3Aeof"+>Text.ParserCombinators.Poly.StateLazy</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>5 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-Poly-ByteString.html#v%3Aeof"+>Text.ParserCombinators.Poly.ByteString</A+>, Text.Parse.ByteString</TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>6 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#v%3Aeof"+>Text.ParserCombinators.HuttonMeijerWallace</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexentry"+>exactly</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-Poly-Base.html#v%3Aexactly"+>Text.ParserCombinators.Poly.Base</A+>, Text.ParserCombinators.Poly.Plain, Text.ParserCombinators.Poly.Lazy, Text.ParserCombinators.Poly.State, Text.ParserCombinators.Poly.StateLazy, Text.ParserCombinators.Poly.ByteString, Text.Parse.ByteString, Text.ParserCombinators.Poly, Text.Parse</TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexentry"+>failBad</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-Poly-Base.html#v%3AfailBad"+>Text.ParserCombinators.Poly.Base</A+>, Text.ParserCombinators.Poly.Plain, Text.ParserCombinators.Poly.Lazy, Text.ParserCombinators.Poly.State, Text.ParserCombinators.Poly.StateLazy, Text.ParserCombinators.Poly.ByteString, Text.Parse.ByteString, Text.ParserCombinators.Poly, Text.Parse</TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexentry" COLSPAN="2"+>Failure</TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>1 (Data Constructor)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-Poly-Plain.html#v%3AFailure"+>Text.ParserCombinators.Poly.Plain</A+>, Text.ParserCombinators.Poly, Text.Parse</TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>2 (Data Constructor)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-Poly-Lazy.html#v%3AFailure"+>Text.ParserCombinators.Poly.Lazy</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>3 (Data Constructor)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-Poly-State.html#v%3AFailure"+>Text.ParserCombinators.Poly.State</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>4 (Data Constructor)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-Poly-StateLazy.html#v%3AFailure"+>Text.ParserCombinators.Poly.StateLazy</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>5 (Data Constructor)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-Poly-ByteString.html#v%3AFailure"+>Text.ParserCombinators.Poly.ByteString</A+>, Text.Parse.ByteString</TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexentry" COLSPAN="2"+>field</TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>1 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-Parse-ByteString.html#v%3Afield"+>Text.Parse.ByteString</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>2 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-Parse.html#v%3Afield"+>Text.Parse</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexentry"+>first</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-HuttonMeijer.html#v%3Afirst"+>Text.ParserCombinators.HuttonMeijer</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexentry"+>ident</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-HuttonMeijer.html#v%3Aident"+>Text.ParserCombinators.HuttonMeijer</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexentry"+>identifier</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-HuttonMeijer.html#v%3Aidentifier"+>Text.ParserCombinators.HuttonMeijer</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexentry"+>indent</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-Poly-Base.html#v%3Aindent"+>Text.ParserCombinators.Poly.Base</A+>, Text.ParserCombinators.Poly.Plain, Text.ParserCombinators.Poly.Lazy, Text.ParserCombinators.Poly.State, Text.ParserCombinators.Poly.StateLazy, Text.ParserCombinators.Poly.ByteString, Text.Parse.ByteString, Text.ParserCombinators.Poly, Text.Parse</TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexentry"+>int</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-HuttonMeijer.html#v%3Aint"+>Text.ParserCombinators.HuttonMeijer</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexentry"+>integer</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-HuttonMeijer.html#v%3Ainteger"+>Text.ParserCombinators.HuttonMeijer</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexentry" COLSPAN="2"+>isWord</TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>1 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-Parse-ByteString.html#v%3AisWord"+>Text.Parse.ByteString</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>2 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-Parse.html#v%3AisWord"+>Text.Parse</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexentry" COLSPAN="2"+>item</TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>1 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#v%3Aitem"+>Text.ParserCombinators.HuttonMeijerWallace</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>2 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-HuttonMeijer.html#v%3Aitem"+>Text.ParserCombinators.HuttonMeijer</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexentry"+>junk</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-HuttonMeijer.html#v%3Ajunk"+>Text.ParserCombinators.HuttonMeijer</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexentry"+>letter</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-HuttonMeijer.html#v%3Aletter"+>Text.ParserCombinators.HuttonMeijer</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexentry"+>lower</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-HuttonMeijer.html#v%3Alower"+>Text.ParserCombinators.HuttonMeijer</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexentry" COLSPAN="2"+>many</TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>1 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-Poly-Base.html#v%3Amany"+>Text.ParserCombinators.Poly.Base</A+>, Text.ParserCombinators.Poly.Plain, Text.ParserCombinators.Poly.Lazy, Text.ParserCombinators.Poly.State, Text.ParserCombinators.Poly.StateLazy, Text.ParserCombinators.Poly.ByteString, Text.Parse.ByteString, Text.ParserCombinators.Poly, Text.Parse</TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>2 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#v%3Amany"+>Text.ParserCombinators.HuttonMeijerWallace</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>3 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-HuttonMeijer.html#v%3Amany"+>Text.ParserCombinators.HuttonMeijer</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexentry" COLSPAN="2"+>many1</TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>1 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-Poly-Base.html#v%3Amany1"+>Text.ParserCombinators.Poly.Base</A+>, Text.ParserCombinators.Poly.Plain, Text.ParserCombinators.Poly.Lazy, Text.ParserCombinators.Poly.State, Text.ParserCombinators.Poly.StateLazy, Text.ParserCombinators.Poly.ByteString, Text.Parse.ByteString, Text.ParserCombinators.Poly, Text.Parse</TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>2 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#v%3Amany1"+>Text.ParserCombinators.HuttonMeijerWallace</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>3 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-HuttonMeijer.html#v%3Amany1"+>Text.ParserCombinators.HuttonMeijer</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexentry" COLSPAN="2"+>manyFinally</TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>1 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-Poly-Base.html#v%3AmanyFinally"+>Text.ParserCombinators.Poly.Base</A+>, Text.ParserCombinators.Poly.Plain, Text.ParserCombinators.Poly.Lazy, Text.ParserCombinators.Poly.State, Text.ParserCombinators.Poly.ByteString, Text.Parse.ByteString, Text.ParserCombinators.Poly, Text.Parse</TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>2 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-Poly-StateLazy.html#v%3AmanyFinally"+>Text.ParserCombinators.Poly.StateLazy</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexentry"+>nat</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-HuttonMeijer.html#v%3Anat"+>Text.ParserCombinators.HuttonMeijer</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexentry"+>natural</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-HuttonMeijer.html#v%3Anatural"+>Text.ParserCombinators.HuttonMeijer</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexentry" COLSPAN="2"+>next</TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>1 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-Poly-Plain.html#v%3Anext"+>Text.ParserCombinators.Poly.Plain</A+>, Text.ParserCombinators.Poly, Text.Parse</TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>2 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-Poly-Lazy.html#v%3Anext"+>Text.ParserCombinators.Poly.Lazy</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>3 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-Poly-State.html#v%3Anext"+>Text.ParserCombinators.Poly.State</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>4 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-Poly-StateLazy.html#v%3Anext"+>Text.ParserCombinators.Poly.StateLazy</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>5 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-Poly-ByteString.html#v%3Anext"+>Text.ParserCombinators.Poly.ByteString</A+>, Text.Parse.ByteString</TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexentry"+>nottok</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#v%3Anottok"+>Text.ParserCombinators.HuttonMeijerWallace</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexentry"+>oneOf</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-Poly-Base.html#v%3AoneOf"+>Text.ParserCombinators.Poly.Base</A+>, Text.ParserCombinators.Poly.Plain, Text.ParserCombinators.Poly.Lazy, Text.ParserCombinators.Poly.State, Text.ParserCombinators.Poly.StateLazy, Text.ParserCombinators.Poly.ByteString, Text.Parse.ByteString, Text.ParserCombinators.Poly, Text.Parse</TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexentry"+>oneOf'</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-Poly-Base.html#v%3AoneOf%27"+>Text.ParserCombinators.Poly.Base</A+>, Text.ParserCombinators.Poly.Plain, Text.ParserCombinators.Poly.Lazy, Text.ParserCombinators.Poly.State, Text.ParserCombinators.Poly.StateLazy, Text.ParserCombinators.Poly.ByteString, Text.Parse.ByteString, Text.ParserCombinators.Poly, Text.Parse</TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexentry"+>onFail</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-Poly-Base.html#v%3AonFail"+>Text.ParserCombinators.Poly.Base</A+>, Text.ParserCombinators.Poly.Plain, Text.ParserCombinators.Poly.Lazy, Text.ParserCombinators.Poly.State, Text.ParserCombinators.Poly.StateLazy, Text.ParserCombinators.Poly.ByteString, Text.Parse.ByteString, Text.ParserCombinators.Poly, Text.Parse</TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexentry" COLSPAN="2"+>ops</TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>1 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#v%3Aops"+>Text.ParserCombinators.HuttonMeijerWallace</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>2 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-HuttonMeijer.html#v%3Aops"+>Text.ParserCombinators.HuttonMeijer</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexentry"+>optional</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-Poly-Base.html#v%3Aoptional"+>Text.ParserCombinators.Poly.Base</A+>, Text.ParserCombinators.Poly.Plain, Text.ParserCombinators.Poly.Lazy, Text.ParserCombinators.Poly.State, Text.ParserCombinators.Poly.StateLazy, Text.ParserCombinators.Poly.ByteString, Text.Parse.ByteString, Text.ParserCombinators.Poly, Text.Parse</TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexentry" COLSPAN="2"+>optionalParens</TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>1 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-Parse-ByteString.html#v%3AoptionalParens"+>Text.Parse.ByteString</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>2 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-Parse.html#v%3AoptionalParens"+>Text.Parse</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexentry" COLSPAN="2"+>P</TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>1 (Data Constructor)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-Poly-Plain.html#v%3AP"+>Text.ParserCombinators.Poly.Plain</A+>, Text.ParserCombinators.Poly, Text.Parse</TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>2 (Data Constructor)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-Poly-Lazy.html#v%3AP"+>Text.ParserCombinators.Poly.Lazy</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>3 (Data Constructor)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-Poly-State.html#v%3AP"+>Text.ParserCombinators.Poly.State</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>4 (Data Constructor)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-Poly-StateLazy.html#v%3AP"+>Text.ParserCombinators.Poly.StateLazy</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>5 (Data Constructor)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-Poly-ByteString.html#v%3AP"+>Text.ParserCombinators.Poly.ByteString</A+>, Text.Parse.ByteString</TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>6 (Data Constructor)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#v%3AP"+>Text.ParserCombinators.HuttonMeijerWallace</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>7 (Data Constructor)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-HuttonMeijer.html#v%3AP"+>Text.ParserCombinators.HuttonMeijer</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexentry" COLSPAN="2"+>papply</TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>1 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#v%3Apapply"+>Text.ParserCombinators.HuttonMeijerWallace</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>2 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-HuttonMeijer.html#v%3Apapply"+>Text.ParserCombinators.HuttonMeijer</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexentry"+>papply'</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#v%3Apapply%27"+>Text.ParserCombinators.HuttonMeijerWallace</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexentry" COLSPAN="2"+>parens</TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>1 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-Parse-ByteString.html#v%3Aparens"+>Text.Parse.ByteString</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>2 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-Parse.html#v%3Aparens"+>Text.Parse</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexentry" COLSPAN="2"+>Parse</TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>1 (Type/Class)</TD+><TD CLASS="indexlinks"+><A HREF="Text-Parse-ByteString.html#t%3AParse"+>Text.Parse.ByteString</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>2 (Type/Class)</TD+><TD CLASS="indexlinks"+><A HREF="Text-Parse.html#t%3AParse"+>Text.Parse</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexentry" COLSPAN="2"+>parse</TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>1 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-Parse-ByteString.html#v%3Aparse"+>Text.Parse.ByteString</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>2 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-Parse.html#v%3Aparse"+>Text.Parse</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexentry" COLSPAN="2"+>parseByRead</TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>1 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-Parse-ByteString.html#v%3AparseByRead"+>Text.Parse.ByteString</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>2 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-Parse.html#v%3AparseByRead"+>Text.Parse</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexentry" COLSPAN="2"+>parseDec</TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>1 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-Parse-ByteString.html#v%3AparseDec"+>Text.Parse.ByteString</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>2 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-Parse.html#v%3AparseDec"+>Text.Parse</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexentry" COLSPAN="2"+>parseFloat</TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>1 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-Parse-ByteString.html#v%3AparseFloat"+>Text.Parse.ByteString</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>2 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-Parse.html#v%3AparseFloat"+>Text.Parse</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexentry" COLSPAN="2"+>parseHex</TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>1 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-Parse-ByteString.html#v%3AparseHex"+>Text.Parse.ByteString</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>2 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-Parse.html#v%3AparseHex"+>Text.Parse</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexentry" COLSPAN="2"+>parseInt</TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>1 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-Parse-ByteString.html#v%3AparseInt"+>Text.Parse.ByteString</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>2 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-Parse.html#v%3AparseInt"+>Text.Parse</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexentry" COLSPAN="2"+>parseList</TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>1 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-Parse-ByteString.html#v%3AparseList"+>Text.Parse.ByteString</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>2 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-Parse.html#v%3AparseList"+>Text.Parse</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexentry" COLSPAN="2"+>parseLitChar</TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>1 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-Parse-ByteString.html#v%3AparseLitChar"+>Text.Parse.ByteString</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>2 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-Parse.html#v%3AparseLitChar"+>Text.Parse</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexentry" COLSPAN="2"+>parseOct</TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>1 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-Parse-ByteString.html#v%3AparseOct"+>Text.Parse.ByteString</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>2 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-Parse.html#v%3AparseOct"+>Text.Parse</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexentry" COLSPAN="2"+>parsePrec</TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>1 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-Parse-ByteString.html#v%3AparsePrec"+>Text.Parse.ByteString</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>2 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-Parse.html#v%3AparsePrec"+>Text.Parse</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexentry" COLSPAN="2"+>Parser</TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>1 (Type/Class)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-Poly-Plain.html#t%3AParser"+>Text.ParserCombinators.Poly.Plain</A+>, Text.ParserCombinators.Poly, Text.Parse</TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>2 (Type/Class)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-Poly-Lazy.html#t%3AParser"+>Text.ParserCombinators.Poly.Lazy</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>3 (Type/Class)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-Poly-State.html#t%3AParser"+>Text.ParserCombinators.Poly.State</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>4 (Type/Class)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-Poly-StateLazy.html#t%3AParser"+>Text.ParserCombinators.Poly.StateLazy</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>5 (Type/Class)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-Poly-ByteString.html#t%3AParser"+>Text.ParserCombinators.Poly.ByteString</A+>, Text.Parse.ByteString</TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>6 (Type/Class)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Text.ParserCombinators.HuttonMeijerWallace</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>7 (Type/Class)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Text.ParserCombinators.HuttonMeijer</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexentry" COLSPAN="2"+>parseSigned</TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>1 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-Parse-ByteString.html#v%3AparseSigned"+>Text.Parse.ByteString</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>2 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-Parse.html#v%3AparseSigned"+>Text.Parse</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexentry"+>parseUnsignedInteger</TD+><TD CLASS="indexlinks"+><A HREF="Text-Parse-ByteString.html#v%3AparseUnsignedInteger"+>Text.Parse.ByteString</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexentry"+>PolyParse</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-Poly-Base.html#t%3APolyParse"+>Text.ParserCombinators.Poly.Base</A+>, Text.ParserCombinators.Poly.Plain, Text.ParserCombinators.Poly.Lazy, Text.ParserCombinators.Poly.State, Text.ParserCombinators.Poly.StateLazy, Text.ParserCombinators.Poly.ByteString, Text.Parse.ByteString, Text.ParserCombinators.Poly, Text.Parse</TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexentry" COLSPAN="2"+>readByParse</TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>1 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-Parse-ByteString.html#v%3AreadByParse"+>Text.Parse.ByteString</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>2 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-Parse.html#v%3AreadByParse"+>Text.Parse</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexentry" COLSPAN="2"+>readsPrecByParsePrec</TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>1 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-Parse-ByteString.html#v%3AreadsPrecByParsePrec"+>Text.Parse.ByteString</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>2 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-Parse.html#v%3AreadsPrecByParsePrec"+>Text.Parse</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexentry" COLSPAN="2"+>reparse</TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>1 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-Poly-Plain.html#v%3Areparse"+>Text.ParserCombinators.Poly.Plain</A+>, Text.ParserCombinators.Poly, Text.Parse</TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>2 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-Poly-Lazy.html#v%3Areparse"+>Text.ParserCombinators.Poly.Lazy</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>3 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-Poly-State.html#v%3Areparse"+>Text.ParserCombinators.Poly.State</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>4 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-Poly-StateLazy.html#v%3Areparse"+>Text.ParserCombinators.Poly.StateLazy</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>5 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-Poly-ByteString.html#v%3Areparse"+>Text.ParserCombinators.Poly.ByteString</A+>, Text.Parse.ByteString</TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>6 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#v%3Areparse"+>Text.ParserCombinators.HuttonMeijerWallace</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexentry" COLSPAN="2"+>Result</TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>1 (Type/Class)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-Poly-Plain.html#t%3AResult"+>Text.ParserCombinators.Poly.Plain</A+>, Text.ParserCombinators.Poly, Text.Parse</TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>2 (Type/Class)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-Poly-Lazy.html#t%3AResult"+>Text.ParserCombinators.Poly.Lazy</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>3 (Type/Class)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-Poly-State.html#t%3AResult"+>Text.ParserCombinators.Poly.State</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>4 (Type/Class)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-Poly-StateLazy.html#t%3AResult"+>Text.ParserCombinators.Poly.StateLazy</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>5 (Type/Class)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-Poly-ByteString.html#t%3AResult"+>Text.ParserCombinators.Poly.ByteString</A+>, Text.Parse.ByteString</TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexentry" COLSPAN="2"+>runParser</TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>1 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-Poly-Plain.html#v%3ArunParser"+>Text.ParserCombinators.Poly.Plain</A+>, Text.ParserCombinators.Poly, Text.Parse</TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>2 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-Poly-Lazy.html#v%3ArunParser"+>Text.ParserCombinators.Poly.Lazy</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>3 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-Poly-State.html#v%3ArunParser"+>Text.ParserCombinators.Poly.State</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>4 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-Poly-StateLazy.html#v%3ArunParser"+>Text.ParserCombinators.Poly.StateLazy</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>5 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-Poly-ByteString.html#v%3ArunParser"+>Text.ParserCombinators.Poly.ByteString</A+>, Text.Parse.ByteString</TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexentry"+>sat</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-HuttonMeijer.html#v%3Asat"+>Text.ParserCombinators.HuttonMeijer</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexentry" COLSPAN="2"+>satisfy</TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>1 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-Poly-Plain.html#v%3Asatisfy"+>Text.ParserCombinators.Poly.Plain</A+>, Text.ParserCombinators.Poly, Text.Parse</TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>2 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-Poly-Lazy.html#v%3Asatisfy"+>Text.ParserCombinators.Poly.Lazy</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>3 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-Poly-State.html#v%3Asatisfy"+>Text.ParserCombinators.Poly.State</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>4 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-Poly-StateLazy.html#v%3Asatisfy"+>Text.ParserCombinators.Poly.StateLazy</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>5 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-Poly-ByteString.html#v%3Asatisfy"+>Text.ParserCombinators.Poly.ByteString</A+>, Text.Parse.ByteString</TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexentry"+>sepBy</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-Poly-Base.html#v%3AsepBy"+>Text.ParserCombinators.Poly.Base</A+>, Text.ParserCombinators.Poly.Plain, Text.ParserCombinators.Poly.Lazy, Text.ParserCombinators.Poly.State, Text.ParserCombinators.Poly.StateLazy, Text.ParserCombinators.Poly.ByteString, Text.Parse.ByteString, Text.ParserCombinators.Poly, Text.Parse</TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexentry" COLSPAN="2"+>sepby</TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>1 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#v%3Asepby"+>Text.ParserCombinators.HuttonMeijerWallace</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>2 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-HuttonMeijer.html#v%3Asepby"+>Text.ParserCombinators.HuttonMeijer</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexentry"+>sepBy1</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-Poly-Base.html#v%3AsepBy1"+>Text.ParserCombinators.Poly.Base</A+>, Text.ParserCombinators.Poly.Plain, Text.ParserCombinators.Poly.Lazy, Text.ParserCombinators.Poly.State, Text.ParserCombinators.Poly.StateLazy, Text.ParserCombinators.Poly.ByteString, Text.Parse.ByteString, Text.ParserCombinators.Poly, Text.Parse</TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexentry" COLSPAN="2"+>sepby1</TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>1 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#v%3Asepby1"+>Text.ParserCombinators.HuttonMeijerWallace</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>2 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-HuttonMeijer.html#v%3Asepby1"+>Text.ParserCombinators.HuttonMeijer</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexentry"+>skip</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-HuttonMeijer.html#v%3Askip"+>Text.ParserCombinators.HuttonMeijer</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexentry"+>spaces</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-HuttonMeijer.html#v%3Aspaces"+>Text.ParserCombinators.HuttonMeijer</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexentry" COLSPAN="2"+>stGet</TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>1 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-Poly-State.html#v%3AstGet"+>Text.ParserCombinators.Poly.State</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>2 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-Poly-StateLazy.html#v%3AstGet"+>Text.ParserCombinators.Poly.StateLazy</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexentry"+>stget</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#v%3Astget"+>Text.ParserCombinators.HuttonMeijerWallace</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexentry" COLSPAN="2"+>stQuery</TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>1 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-Poly-State.html#v%3AstQuery"+>Text.ParserCombinators.Poly.State</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>2 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-Poly-StateLazy.html#v%3AstQuery"+>Text.ParserCombinators.Poly.StateLazy</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexentry"+>stquery</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#v%3Astquery"+>Text.ParserCombinators.HuttonMeijerWallace</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexentry"+>string</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-HuttonMeijer.html#v%3Astring"+>Text.ParserCombinators.HuttonMeijer</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexentry"+>stupd</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#v%3Astupd"+>Text.ParserCombinators.HuttonMeijerWallace</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexentry" COLSPAN="2"+>stUpdate</TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>1 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-Poly-State.html#v%3AstUpdate"+>Text.ParserCombinators.Poly.State</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>2 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-Poly-StateLazy.html#v%3AstUpdate"+>Text.ParserCombinators.Poly.StateLazy</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexentry" COLSPAN="2"+>Success</TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>1 (Data Constructor)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-Poly-Plain.html#v%3ASuccess"+>Text.ParserCombinators.Poly.Plain</A+>, Text.ParserCombinators.Poly, Text.Parse</TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>2 (Data Constructor)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-Poly-Lazy.html#v%3ASuccess"+>Text.ParserCombinators.Poly.Lazy</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>3 (Data Constructor)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-Poly-State.html#v%3ASuccess"+>Text.ParserCombinators.Poly.State</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>4 (Data Constructor)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-Poly-StateLazy.html#v%3ASuccess"+>Text.ParserCombinators.Poly.StateLazy</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>5 (Data Constructor)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-Poly-ByteString.html#v%3ASuccess"+>Text.ParserCombinators.Poly.ByteString</A+>, Text.Parse.ByteString</TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexentry"+>symbol</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-HuttonMeijer.html#v%3Asymbol"+>Text.ParserCombinators.HuttonMeijer</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexentry" COLSPAN="2"+>TextParser</TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>1 (Type/Class)</TD+><TD CLASS="indexlinks"+><A HREF="Text-Parse-ByteString.html#t%3ATextParser"+>Text.Parse.ByteString</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>2 (Type/Class)</TD+><TD CLASS="indexlinks"+><A HREF="Text-Parse.html#t%3ATextParser"+>Text.Parse</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexentry"+>toEOF</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#v%3AtoEOF"+>Text.ParserCombinators.HuttonMeijerWallace</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexentry"+>tok</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#v%3Atok"+>Text.ParserCombinators.HuttonMeijerWallace</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexentry"+>token</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-HuttonMeijer.html#v%3Atoken"+>Text.ParserCombinators.HuttonMeijer</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexentry"+>upper</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-HuttonMeijer.html#v%3Aupper"+>Text.ParserCombinators.HuttonMeijer</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexentry" COLSPAN="2"+>word</TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>1 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-Parse-ByteString.html#v%3Aword"+>Text.Parse.ByteString</A+></TD+></TR+><TR CLASS="indexrow"+><TD CLASS="indexannot"+>2 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-Parse.html#v%3Aword"+>Text.Parse</A+></TD+></TR+></TABLE+></TD+></TR+></TABLE+></BODY+></HTML+>
+ docs/haddock/frames.html view
@@ -0,0 +1,27 @@+<html>
+<head>
+<script type="text/javascript"><!--
+/*
+
+  The synopsis frame needs to be updated using javascript, so we hide
+  it by default and only show it if javascript is enabled.
+
+  TODO: provide some means to disable it.
+*/
+function load() {
+  var d = document.getElementById("inner-fs");
+  d.rows = "50%,50%";
+}
+--></script>
+<frameset id="outer-fs" cols="25%,75%" onload="load()">
+  <frameset id="inner-fs" rows="100%,0%">
+
+    <frame src="index-frames.html" name="modules">
+    <frame src="" name="synopsis">
+
+  </frameset>
+  <frame src="index.html" name="main">
+
+</frameset>
+
+</html>
+ docs/haddock/haddock-util.js view
@@ -0,0 +1,139 @@+// Haddock JavaScript utilities+function toggle(button,id)+{+   var n = document.getElementById(id).style;+   if (n.display == "none")+   {+    button.src = "minus.gif";+    n.display = "block";+   }+   else+   {+    button.src = "plus.gif";+    n.display = "none";+   }+}+++var max_results = 75; // 50 is not enough to search for map in the base libraries+var shown_range = null;+var last_search = null;++function quick_search()+{+    perform_search(false);+}++function full_search()+{+    perform_search(true);+}+++function perform_search(full)+{+    var text = document.getElementById("searchbox").value.toLowerCase();+    if (text == last_search && !full) return;+    last_search = text;+    +    var table = document.getElementById("indexlist");+    var status = document.getElementById("searchmsg");+    var children = table.firstChild.childNodes;+    +    // first figure out the first node with the prefix+    var first = bisect(-1);+    var last = (first == -1 ? -1 : bisect(1));++    if (first == -1)+    {+        table.className = "";+        status.innerHTML = "No results found, displaying all";+    }+    else if (first == 0 && last == children.length - 1)+    {+        table.className = "";+        status.innerHTML = "";+    }+    else if (last - first >= max_results && !full)+    {+        table.className = "";+        status.innerHTML = "More than " + max_results + ", press Search to display";+    }+    else+    {+        // decide what you need to clear/show+        if (shown_range)+            setclass(shown_range[0], shown_range[1], "indexrow");+        setclass(first, last, "indexshow");+        shown_range = [first, last];+        table.className = "indexsearch";+        status.innerHTML = "";+    }++    +    function setclass(first, last, status)+    {+        for (var i = first; i <= last; i++)+        {+            children[i].className = status;+        }+    }+    +    +    // do a binary search, treating 0 as ...+    // return either -1 (no 0's found) or location of most far match+    function bisect(dir)+    {+        var first = 0, finish = children.length - 1;+        var mid, success = false;++        while (finish - first > 3)+        {+            mid = Math.floor((finish + first) / 2);++            var i = checkitem(mid);+            if (i == 0) i = dir;+            if (i == -1)+                finish = mid;+            else+                first = mid;+        }+        var a = (dir == 1 ? first : finish);+        var b = (dir == 1 ? finish : first);+        for (var i = b; i != a - dir; i -= dir)+        {+            if (checkitem(i) == 0) return i;+        }+        return -1;+    }    +    +    +    // from an index, decide what the result is+    // 0 = match, -1 is lower, 1 is higher+    function checkitem(i)+    {+        var s = getitem(i).toLowerCase().substr(0, text.length);+        if (s == text) return 0;+        else return (s > text ? -1 : 1);+    }+    +    +    // from an index, get its string+    // this abstracts over alternates+    function getitem(i)+    {+        for ( ; i >= 0; i--)+        {+            var s = children[i].firstChild.firstChild.data;+            if (s.indexOf(' ') == -1)+                return s;+        }+        return ""; // should never be reached+    }+}++function setSynopsis(filename) {+    if (parent.window.synopsis) {+      parent.window.synopsis.location = filename;+    }+}
+ docs/haddock/haddock.css view
@@ -0,0 +1,297 @@+/* -------- Global things --------- */++BODY { +  background-color: #ffffff;+  color: #000000;+  font-family: sans-serif;+  padding: 0 0;+  } ++A:link    { color: #0000e0; text-decoration: none }+A:visited { color: #0000a0; text-decoration: none }+A:hover   { background-color: #e0e0ff; text-decoration: none }++TABLE.vanilla {+  width: 100%;+  border-width: 0px;+  /* I can't seem to specify cellspacing or cellpadding properly using CSS... */+}++TABLE.vanilla2 {+  border-width: 0px;+}++/* <TT> font is a little too small in MSIE */+TT  { font-size: 100%; }+PRE { font-size: 100%; }++LI P { margin: 0pt } ++TD {+  border-width: 0px;+}++TABLE.narrow {+  border-width: 0px;+}++TD.s8  {  height: 8px;  }+TD.s15 {  height: 15px; }++SPAN.keyword { text-decoration: underline; }++/* Resize the buttom image to match the text size */+IMG.coll { width : 0.75em; height: 0.75em; margin-bottom: 0; margin-right: 0.5em }++/* --------- Contents page ---------- */++DIV.node {+  padding-left: 3em;+}++DIV.cnode {+  padding-left: 1.75em;+}++SPAN.pkg {+  position: absolute;+  left: 50em;+}++/* --------- Documentation elements ---------- */++TD.children {+  padding-left: 25px;+  }++TD.synopsis {+  padding: 2px;+  background-color: #f0f0f0;+  font-family: monospace+ }++TD.decl { +  padding: 2px;+  background-color: #f0f0f0; +  font-family: monospace;+  vertical-align: top;+  }++TD.topdecl {+  padding: 2px;+  background-color: #f0f0f0;+  font-family: monospace;+  vertical-align: top;+}++TABLE.declbar {+  border-spacing: 0px;+ }++TD.declname {+  width: 100%;+ }++TD.declbut {+  padding-left: 5px;+  padding-right: 5px;+  border-left-width: 1px;+  border-left-color: #000099;+  border-left-style: solid;+  white-space: nowrap;+  font-size: small;+ }++/* +  arg is just like decl, except that wrapping is not allowed.  It is+  used for function and constructor arguments which have a text box+  to the right, where if wrapping is allowed the text box squashes up+  the declaration by wrapping it.+*/+TD.arg { +  padding: 2px;+  background-color: #f0f0f0; +  font-family: monospace;+  vertical-align: top;+  white-space: nowrap;+  }++TD.recfield { padding-left: 20px }++TD.doc  { +  padding-top: 2px;+  padding-left: 10px;+  }++TD.ndoc  { +  padding: 2px;+  }++TD.rdoc  { +  padding: 2px;+  padding-left: 10px;+  width: 100%;+  }++TD.body  { +  padding-left: 10px+  }++TD.pkg {+  width: 100%;+  padding-left: 10px+}++TABLE.indexsearch TR.indexrow {+  display: none;+}+TABLE.indexsearch TR.indexshow {+  display: table-row;+}++TD.indexentry {+  vertical-align: top;+  padding-right: 10px+  }++TD.indexannot {+  vertical-align: top;+  padding-left: 20px;+  white-space: nowrap+  }++TD.indexlinks {+  width: 100%+  }++/* ------- Section Headings ------- */++TD.section1 {+  padding-top: 15px;+  font-weight: bold;+  font-size: 150%+  }++TD.section2 {+  padding-top: 10px;+  font-weight: bold;+  font-size: 130%+  }++TD.section3 {+  padding-top: 5px;+  font-weight: bold;+  font-size: 110%+  }++TD.section4 {+  font-weight: bold;+  font-size: 100%+  }++/* -------------- The title bar at the top of the page */++TD.infohead {+  color: #ffffff;+  font-weight: bold;+  padding-right: 10px;+  text-align: left;+}++TD.infoval {+  color: #ffffff;+  padding-right: 10px;+  text-align: left;+}++TD.topbar {+  background-color: #000099;+  padding: 5px;+}++TD.title {+  color: #ffffff;+  padding-left: 10px;+  width: 100%+  }++TD.topbut {+  padding-left: 5px;+  padding-right: 5px;+  border-left-width: 1px;+  border-left-color: #ffffff;+  border-left-style: solid;+  white-space: nowrap;+  }++TD.topbut A:link {+  color: #ffffff+  }++TD.topbut A:visited {+  color: #ffff00+  }++TD.topbut A:hover {+  background-color: #6060ff;+  }++TD.topbut:hover {+  background-color: #6060ff+  }++TD.modulebar { +  background-color: #0077dd;+  padding: 5px;+  border-top-width: 1px;+  border-top-color: #ffffff;+  border-top-style: solid;+  }++/* --------- The page footer --------- */++TD.botbar {+  background-color: #000099;+  color: #ffffff;+  padding: 5px+  }+TD.botbar A:link {+  color: #ffffff;+  text-decoration: underline+  }+TD.botbar A:visited {+  color: #ffff00+  }+TD.botbar A:hover {+  background-color: #6060ff+  }++/* --------- Mini Synopsis for Frame View --------- */++.outer {+  margin: 0 0;+  padding: 0 0;+}++.mini-synopsis {+  padding: 0.25em 0.25em;+}++.mini-synopsis H1 { font-size: 130%; }+.mini-synopsis H2 { font-size: 110%; }+.mini-synopsis H3 { font-size: 100%; }+.mini-synopsis H1, .mini-synopsis H2, .mini-synopsis H3 {+  margin-top: 0.5em;+  margin-bottom: 0.25em;+  padding: 0 0;+}++.mini-synopsis H1 { border-bottom: 1px solid #ccc; }++.mini-topbar {+  font-size: 130%;+  background: #0077dd;+  padding: 0.25em;+}++
+ docs/haddock/haskell_icon.gif view

binary file changed (absent → 911 bytes)

+ docs/haddock/index-frames.html view
@@ -0,0 +1,52 @@+<!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+>polyparse</TITLE+><LINK HREF="haddock.css" REL="stylesheet" TYPE="text/css"+><SCRIPT SRC="haddock-util.js" TYPE="text/javascript"+></SCRIPT+></HEAD+><BODY+><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"+><P+><A HREF="Text-Parse.html" TARGET="main"+>Text.Parse</A+><BR+><A HREF="Text-Parse-ByteString.html" TARGET="main"+>Text.Parse.ByteString</A+><BR+><A HREF="Text-ParserCombinators-HuttonMeijer.html" TARGET="main"+>Text.ParserCombinators.HuttonMeijer</A+><BR+><A HREF="Text-ParserCombinators-HuttonMeijerWallace.html" TARGET="main"+>Text.ParserCombinators.HuttonMeijerWallace</A+><BR+><A HREF="Text-ParserCombinators-Poly.html" TARGET="main"+>Text.ParserCombinators.Poly</A+><BR+><A HREF="Text-ParserCombinators-Poly-Base.html" TARGET="main"+>Text.ParserCombinators.Poly.Base</A+><BR+><A HREF="Text-ParserCombinators-Poly-ByteString.html" TARGET="main"+>Text.ParserCombinators.Poly.ByteString</A+><BR+><A HREF="Text-ParserCombinators-Poly-Lazy.html" TARGET="main"+>Text.ParserCombinators.Poly.Lazy</A+><BR+><A HREF="Text-ParserCombinators-Poly-Plain.html" TARGET="main"+>Text.ParserCombinators.Poly.Plain</A+><BR+><A HREF="Text-ParserCombinators-Poly-State.html" TARGET="main"+>Text.ParserCombinators.Poly.State</A+><BR+><A HREF="Text-ParserCombinators-Poly-StateLazy.html" TARGET="main"+>Text.ParserCombinators.Poly.StateLazy</A+><BR+></P+></TABLE+></BODY+></HTML+>
+ docs/haddock/index.html view
@@ -0,0 +1,212 @@+<!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+>polyparse</TITLE+><LINK HREF="haddock.css" REL="stylesheet" TYPE="text/css"+><SCRIPT SRC="haddock-util.js" TYPE="text/javascript"+></SCRIPT+></HEAD+><BODY+><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"+><TR+><TD CLASS="topbar"+><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"+><TR+><TD+><IMG SRC="haskell_icon.gif" WIDTH="16" HEIGHT="16" ALT=" "+></TD+><TD CLASS="title"+>polyparse</TD+><TD CLASS="topbut"+><A HREF="index.html"+>Contents</A+></TD+><TD CLASS="topbut"+><A HREF="doc-index.html"+>Index</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="section1"+>Modules</TD+></TR+><TR+><TD+><TABLE CLASS="vanilla2" CELLSPACING="0" CELLPADDING="0"+><TR+><TD STYLE="width: 50em"+><IMG SRC="minus.gif" CLASS="coll" ONCLICK="toggle(this,'n:0')" ALT="show/hide"+>Text</TD+><TD+></TD+><TD+></TD+></TR+><TR+><TD STYLE="padding: 0; padding-left: 2em" COLSPAN="3"+><TABLE CLASS="vanilla2" CELLSPACING="0" CELLPADDING="0" ID="n:0" STYLE="display:block;"+><TR+><TD STYLE="width: 48em"+><IMG SRC="minus.gif" CLASS="coll" ONCLICK="toggle(this,'n:1')" ALT="show/hide"+><A HREF="Text-Parse.html"+>Text.Parse</A+></TD+><TD+></TD+><TD+></TD+></TR+><TR+><TD STYLE="padding: 0; padding-left: 2em" COLSPAN="3"+><TABLE CLASS="vanilla2" CELLSPACING="0" CELLPADDING="0" ID="n:1" STYLE="display:block;"+><TR+><TD STYLE="padding-left: 1.25em;width: 46em"+><A HREF="Text-Parse-ByteString.html"+>Text.Parse.ByteString</A+></TD+><TD+></TD+><TD+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD STYLE="width: 48em"+><IMG SRC="minus.gif" CLASS="coll" ONCLICK="toggle(this,'n:2')" ALT="show/hide"+>ParserCombinators</TD+><TD+></TD+><TD+></TD+></TR+><TR+><TD STYLE="padding: 0; padding-left: 2em" COLSPAN="3"+><TABLE CLASS="vanilla2" CELLSPACING="0" CELLPADDING="0" ID="n:2" STYLE="display:block;"+><TR+><TD STYLE="padding-left: 1.25em;width: 46em"+><A HREF="Text-ParserCombinators-HuttonMeijer.html"+>Text.ParserCombinators.HuttonMeijer</A+></TD+><TD+></TD+><TD+></TD+></TR+><TR+><TD STYLE="padding-left: 1.25em;width: 46em"+><A HREF="Text-ParserCombinators-HuttonMeijerWallace.html"+>Text.ParserCombinators.HuttonMeijerWallace</A+></TD+><TD+></TD+><TD+></TD+></TR+><TR+><TD STYLE="width: 46em"+><IMG SRC="minus.gif" CLASS="coll" ONCLICK="toggle(this,'n:3')" ALT="show/hide"+><A HREF="Text-ParserCombinators-Poly.html"+>Text.ParserCombinators.Poly</A+></TD+><TD+></TD+><TD+></TD+></TR+><TR+><TD STYLE="padding: 0; padding-left: 2em" COLSPAN="3"+><TABLE CLASS="vanilla2" CELLSPACING="0" CELLPADDING="0" ID="n:3" STYLE="display:block;"+><TR+><TD STYLE="padding-left: 1.25em;width: 44em"+><A HREF="Text-ParserCombinators-Poly-Base.html"+>Text.ParserCombinators.Poly.Base</A+></TD+><TD+></TD+><TD+></TD+></TR+><TR+><TD STYLE="padding-left: 1.25em;width: 44em"+><A HREF="Text-ParserCombinators-Poly-ByteString.html"+>Text.ParserCombinators.Poly.ByteString</A+></TD+><TD+></TD+><TD+></TD+></TR+><TR+><TD STYLE="padding-left: 1.25em;width: 44em"+><A HREF="Text-ParserCombinators-Poly-Lazy.html"+>Text.ParserCombinators.Poly.Lazy</A+></TD+><TD+></TD+><TD+></TD+></TR+><TR+><TD STYLE="padding-left: 1.25em;width: 44em"+><A HREF="Text-ParserCombinators-Poly-Plain.html"+>Text.ParserCombinators.Poly.Plain</A+></TD+><TD+></TD+><TD+></TD+></TR+><TR+><TD STYLE="padding-left: 1.25em;width: 44em"+><A HREF="Text-ParserCombinators-Poly-State.html"+>Text.ParserCombinators.Poly.State</A+></TD+><TD+></TD+><TD+></TD+></TR+><TR+><TD STYLE="padding-left: 1.25em;width: 44em"+><A HREF="Text-ParserCombinators-Poly-StateLazy.html"+>Text.ParserCombinators.Poly.StateLazy</A+></TD+><TD+></TD+><TD+></TD+></TR+></TABLE+></TD+></TR+></TABLE+></TD+></TR+></TABLE+></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 2.4.2</TD+></TR+></TABLE+></BODY+></HTML+>
+ docs/haddock/mini_Text-Parse-ByteString.html view
@@ -0,0 +1,128 @@+<!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.Parse.ByteString</TITLE+><LINK HREF="haddock.css" REL="stylesheet" TYPE="text/css"+><SCRIPT SRC="haddock-util.js" TYPE="text/javascript"+></SCRIPT+></HEAD+><BODY+><DIV CLASS="outer"+><DIV CLASS="mini-topbar"+>Text.Parse.ByteString</DIV+><DIV CLASS="mini-synopsis"+><H1+>The Parse class is a replacement for the standard Read class. +</H1+>  <DIV CLASS="decl"+><SPAN CLASS="keyword"+>type</SPAN+>&nbsp;<A HREF="Text-Parse-ByteString.html#t%3ATextParser" TARGET="main"+>TextParser</A+> a</DIV+> <DIV CLASS="decl"+><SPAN CLASS="keyword"+>class</SPAN+>&nbsp;<A HREF="Text-Parse-ByteString.html#t%3AParse" TARGET="main"+>Parse</A+> a</DIV+> <DIV CLASS="decl"+><A HREF="Text-Parse-ByteString.html#v%3AparseByRead" TARGET="main"+>parseByRead</A+></DIV+> <DIV CLASS="decl"+><A HREF="Text-Parse-ByteString.html#v%3AreadByParse" TARGET="main"+>readByParse</A+></DIV+> <DIV CLASS="decl"+><A HREF="Text-Parse-ByteString.html#v%3AreadsPrecByParsePrec" TARGET="main"+>readsPrecByParsePrec</A+></DIV+> <H2+>Combinators specific to string input, lexed haskell-style+</H2+> <DIV CLASS="decl"+><A HREF="Text-Parse-ByteString.html#v%3Aword" TARGET="main"+>word</A+></DIV+> <DIV CLASS="decl"+><A HREF="Text-Parse-ByteString.html#v%3AisWord" TARGET="main"+>isWord</A+></DIV+> <DIV CLASS="decl"+><A HREF="Text-Parse-ByteString.html#v%3AoptionalParens" TARGET="main"+>optionalParens</A+></DIV+> <DIV CLASS="decl"+><A HREF="Text-Parse-ByteString.html#v%3Aparens" TARGET="main"+>parens</A+></DIV+> <DIV CLASS="decl"+><A HREF="Text-Parse-ByteString.html#v%3Afield" TARGET="main"+>field</A+></DIV+> <DIV CLASS="decl"+><A HREF="Text-Parse-ByteString.html#v%3Aconstructors" TARGET="main"+>constructors</A+></DIV+> <DIV CLASS="decl"+><A HREF="Text-Parse-ByteString.html#v%3Aenumeration" TARGET="main"+>enumeration</A+></DIV+> <H2+>Parsers for literal numerics and characters+</H2+> <DIV CLASS="decl"+><A HREF="Text-Parse-ByteString.html#v%3AparseSigned" TARGET="main"+>parseSigned</A+></DIV+> <DIV CLASS="decl"+><A HREF="Text-Parse-ByteString.html#v%3AparseInt" TARGET="main"+>parseInt</A+></DIV+> <DIV CLASS="decl"+><A HREF="Text-Parse-ByteString.html#v%3AparseDec" TARGET="main"+>parseDec</A+></DIV+> <DIV CLASS="decl"+><A HREF="Text-Parse-ByteString.html#v%3AparseOct" TARGET="main"+>parseOct</A+></DIV+> <DIV CLASS="decl"+><A HREF="Text-Parse-ByteString.html#v%3AparseHex" TARGET="main"+>parseHex</A+></DIV+> <DIV CLASS="decl"+><A HREF="Text-Parse-ByteString.html#v%3AparseUnsignedInteger" TARGET="main"+>parseUnsignedInteger</A+></DIV+> <DIV CLASS="decl"+><A HREF="Text-Parse-ByteString.html#v%3AparseFloat" TARGET="main"+>parseFloat</A+></DIV+> <DIV CLASS="decl"+><A HREF="Text-Parse-ByteString.html#v%3AparseLitChar" TARGET="main"+>parseLitChar</A+></DIV+> <H2+>Re-export all the more general combinators from Poly too+</H2+>  <H2+>ByteStrings and Strings as whole entities+</H2+> <DIV CLASS="decl"+><A HREF="Text-Parse-ByteString.html#v%3AallAsByteString" TARGET="main"+>allAsByteString</A+></DIV+> <DIV CLASS="decl"+><A HREF="Text-Parse-ByteString.html#v%3AallAsString" TARGET="main"+>allAsString</A+></DIV+></DIV+></DIV+></BODY+></HTML+>
+ docs/haddock/mini_Text-Parse.html view
@@ -0,0 +1,113 @@+<!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.Parse</TITLE+><LINK HREF="haddock.css" REL="stylesheet" TYPE="text/css"+><SCRIPT SRC="haddock-util.js" TYPE="text/javascript"+></SCRIPT+></HEAD+><BODY+><DIV CLASS="outer"+><DIV CLASS="mini-topbar"+>Text.Parse</DIV+><DIV CLASS="mini-synopsis"+><H1+>The Parse class is a replacement for the standard Read class. +</H1+>  <DIV CLASS="decl"+><SPAN CLASS="keyword"+>type</SPAN+>&nbsp;<A HREF="Text-Parse.html#t%3ATextParser" TARGET="main"+>TextParser</A+> a</DIV+> <DIV CLASS="decl"+><SPAN CLASS="keyword"+>class</SPAN+>&nbsp;<A HREF="Text-Parse.html#t%3AParse" TARGET="main"+>Parse</A+> a</DIV+> <DIV CLASS="decl"+><A HREF="Text-Parse.html#v%3AparseByRead" TARGET="main"+>parseByRead</A+></DIV+> <DIV CLASS="decl"+><A HREF="Text-Parse.html#v%3AreadByParse" TARGET="main"+>readByParse</A+></DIV+> <DIV CLASS="decl"+><A HREF="Text-Parse.html#v%3AreadsPrecByParsePrec" TARGET="main"+>readsPrecByParsePrec</A+></DIV+> <H2+>Combinators specific to string input, lexed haskell-style+</H2+> <DIV CLASS="decl"+><A HREF="Text-Parse.html#v%3Aword" TARGET="main"+>word</A+></DIV+> <DIV CLASS="decl"+><A HREF="Text-Parse.html#v%3AisWord" TARGET="main"+>isWord</A+></DIV+> <DIV CLASS="decl"+><A HREF="Text-Parse.html#v%3AoptionalParens" TARGET="main"+>optionalParens</A+></DIV+> <DIV CLASS="decl"+><A HREF="Text-Parse.html#v%3Aparens" TARGET="main"+>parens</A+></DIV+> <DIV CLASS="decl"+><A HREF="Text-Parse.html#v%3Afield" TARGET="main"+>field</A+></DIV+> <DIV CLASS="decl"+><A HREF="Text-Parse.html#v%3Aconstructors" TARGET="main"+>constructors</A+></DIV+> <DIV CLASS="decl"+><A HREF="Text-Parse.html#v%3Aenumeration" TARGET="main"+>enumeration</A+></DIV+> <H2+>Parsers for literal numerics and characters+</H2+> <DIV CLASS="decl"+><A HREF="Text-Parse.html#v%3AparseSigned" TARGET="main"+>parseSigned</A+></DIV+> <DIV CLASS="decl"+><A HREF="Text-Parse.html#v%3AparseInt" TARGET="main"+>parseInt</A+></DIV+> <DIV CLASS="decl"+><A HREF="Text-Parse.html#v%3AparseDec" TARGET="main"+>parseDec</A+></DIV+> <DIV CLASS="decl"+><A HREF="Text-Parse.html#v%3AparseOct" TARGET="main"+>parseOct</A+></DIV+> <DIV CLASS="decl"+><A HREF="Text-Parse.html#v%3AparseHex" TARGET="main"+>parseHex</A+></DIV+> <DIV CLASS="decl"+><A HREF="Text-Parse.html#v%3AparseFloat" TARGET="main"+>parseFloat</A+></DIV+> <DIV CLASS="decl"+><A HREF="Text-Parse.html#v%3AparseLitChar" TARGET="main"+>parseLitChar</A+></DIV+> <H2+>Re-export all the more general combinators from Poly too+</H2+> </DIV+></DIV+></BODY+></HTML+>
+ docs/haddock/mini_Text-ParserCombinators-HuttonMeijer.html view
@@ -0,0 +1,163 @@+<!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-util.js" TYPE="text/javascript"+></SCRIPT+></HEAD+><BODY+><DIV CLASS="outer"+><DIV CLASS="mini-topbar"+>Text.ParserCombinators.HuttonMeijer</DIV+><DIV CLASS="mini-synopsis"+><DIV CLASS="decl"+><SPAN CLASS="keyword"+>data</SPAN+>&nbsp;<A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser" TARGET="main"+>Parser</A+> a</DIV+> <DIV CLASS="decl"+><A HREF="Text-ParserCombinators-HuttonMeijer.html#v%3Aitem" TARGET="main"+>item</A+></DIV+> <DIV CLASS="decl"+><A HREF="Text-ParserCombinators-HuttonMeijer.html#v%3Afirst" TARGET="main"+>first</A+></DIV+> <DIV CLASS="decl"+><A HREF="Text-ParserCombinators-HuttonMeijer.html#v%3Apapply" TARGET="main"+>papply</A+></DIV+> <DIV CLASS="decl"+><A HREF="Text-ParserCombinators-HuttonMeijer.html#v%3A%2B%2B%2B" TARGET="main"+>(+++)</A+></DIV+> <DIV CLASS="decl"+><A HREF="Text-ParserCombinators-HuttonMeijer.html#v%3Asat" TARGET="main"+>sat</A+></DIV+> <DIV CLASS="decl"+><A HREF="Text-ParserCombinators-HuttonMeijer.html#v%3Amany" TARGET="main"+>many</A+></DIV+> <DIV CLASS="decl"+><A HREF="Text-ParserCombinators-HuttonMeijer.html#v%3Amany1" TARGET="main"+>many1</A+></DIV+> <DIV CLASS="decl"+><A HREF="Text-ParserCombinators-HuttonMeijer.html#v%3Asepby" TARGET="main"+>sepby</A+></DIV+> <DIV CLASS="decl"+><A HREF="Text-ParserCombinators-HuttonMeijer.html#v%3Asepby1" TARGET="main"+>sepby1</A+></DIV+> <DIV CLASS="decl"+><A HREF="Text-ParserCombinators-HuttonMeijer.html#v%3Achainl" TARGET="main"+>chainl</A+></DIV+> <DIV CLASS="decl"+><A HREF="Text-ParserCombinators-HuttonMeijer.html#v%3Achainl1" TARGET="main"+>chainl1</A+></DIV+> <DIV CLASS="decl"+><A HREF="Text-ParserCombinators-HuttonMeijer.html#v%3Achainr" TARGET="main"+>chainr</A+></DIV+> <DIV CLASS="decl"+><A HREF="Text-ParserCombinators-HuttonMeijer.html#v%3Achainr1" TARGET="main"+>chainr1</A+></DIV+> <DIV CLASS="decl"+><A HREF="Text-ParserCombinators-HuttonMeijer.html#v%3Aops" TARGET="main"+>ops</A+></DIV+> <DIV CLASS="decl"+><A HREF="Text-ParserCombinators-HuttonMeijer.html#v%3Abracket" TARGET="main"+>bracket</A+></DIV+> <DIV CLASS="decl"+><A HREF="Text-ParserCombinators-HuttonMeijer.html#v%3Achar" TARGET="main"+>char</A+></DIV+> <DIV CLASS="decl"+><A HREF="Text-ParserCombinators-HuttonMeijer.html#v%3Adigit" TARGET="main"+>digit</A+></DIV+> <DIV CLASS="decl"+><A HREF="Text-ParserCombinators-HuttonMeijer.html#v%3Alower" TARGET="main"+>lower</A+></DIV+> <DIV CLASS="decl"+><A HREF="Text-ParserCombinators-HuttonMeijer.html#v%3Aupper" TARGET="main"+>upper</A+></DIV+> <DIV CLASS="decl"+><A HREF="Text-ParserCombinators-HuttonMeijer.html#v%3Aletter" TARGET="main"+>letter</A+></DIV+> <DIV CLASS="decl"+><A HREF="Text-ParserCombinators-HuttonMeijer.html#v%3Aalphanum" TARGET="main"+>alphanum</A+></DIV+> <DIV CLASS="decl"+><A HREF="Text-ParserCombinators-HuttonMeijer.html#v%3Astring" TARGET="main"+>string</A+></DIV+> <DIV CLASS="decl"+><A HREF="Text-ParserCombinators-HuttonMeijer.html#v%3Aident" TARGET="main"+>ident</A+></DIV+> <DIV CLASS="decl"+><A HREF="Text-ParserCombinators-HuttonMeijer.html#v%3Anat" TARGET="main"+>nat</A+></DIV+> <DIV CLASS="decl"+><A HREF="Text-ParserCombinators-HuttonMeijer.html#v%3Aint" TARGET="main"+>int</A+></DIV+> <DIV CLASS="decl"+><A HREF="Text-ParserCombinators-HuttonMeijer.html#v%3Aspaces" TARGET="main"+>spaces</A+></DIV+> <DIV CLASS="decl"+><A HREF="Text-ParserCombinators-HuttonMeijer.html#v%3Acomment" TARGET="main"+>comment</A+></DIV+> <DIV CLASS="decl"+><A HREF="Text-ParserCombinators-HuttonMeijer.html#v%3Ajunk" TARGET="main"+>junk</A+></DIV+> <DIV CLASS="decl"+><A HREF="Text-ParserCombinators-HuttonMeijer.html#v%3Askip" TARGET="main"+>skip</A+></DIV+> <DIV CLASS="decl"+><A HREF="Text-ParserCombinators-HuttonMeijer.html#v%3Atoken" TARGET="main"+>token</A+></DIV+> <DIV CLASS="decl"+><A HREF="Text-ParserCombinators-HuttonMeijer.html#v%3Anatural" TARGET="main"+>natural</A+></DIV+> <DIV CLASS="decl"+><A HREF="Text-ParserCombinators-HuttonMeijer.html#v%3Ainteger" TARGET="main"+>integer</A+></DIV+> <DIV CLASS="decl"+><A HREF="Text-ParserCombinators-HuttonMeijer.html#v%3Asymbol" TARGET="main"+>symbol</A+></DIV+> <DIV CLASS="decl"+><A HREF="Text-ParserCombinators-HuttonMeijer.html#v%3Aidentifier" TARGET="main"+>identifier</A+></DIV+></DIV+></DIV+></BODY+></HTML+>
+ docs/haddock/mini_Text-ParserCombinators-HuttonMeijerWallace.html view
@@ -0,0 +1,137 @@+<!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-util.js" TYPE="text/javascript"+></SCRIPT+></HEAD+><BODY+><DIV CLASS="outer"+><DIV CLASS="mini-topbar"+>Text.ParserCombinators.HuttonMeijerWallace</DIV+><DIV CLASS="mini-synopsis"+><H1+>The parser monad+</H1+> <DIV CLASS="decl"+><SPAN CLASS="keyword"+>data</SPAN+>&nbsp;<A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser" TARGET="main"+>Parser</A+> s t e a</DIV+> <H1+>Primitive parser combinators+</H1+> <DIV CLASS="decl"+><A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#v%3Aitem" TARGET="main"+>item</A+></DIV+> <DIV CLASS="decl"+><A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#v%3Aeof" TARGET="main"+>eof</A+></DIV+> <DIV CLASS="decl"+><A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#v%3Apapply" TARGET="main"+>papply</A+></DIV+> <DIV CLASS="decl"+><A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#v%3Apapply%27" TARGET="main"+>papply'</A+></DIV+> <H1+>Derived combinators+</H1+> <DIV CLASS="decl"+><A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#v%3A%2B%2B%2B" TARGET="main"+>(+++)</A+></DIV+> <DIV CLASS="decl"+><A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#v%3Atok" TARGET="main"+>tok</A+></DIV+> <DIV CLASS="decl"+><A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#v%3Anottok" TARGET="main"+>nottok</A+></DIV+> <DIV CLASS="decl"+><A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#v%3Amany" TARGET="main"+>many</A+></DIV+> <DIV CLASS="decl"+><A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#v%3Amany1" TARGET="main"+>many1</A+></DIV+> <DIV CLASS="decl"+><A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#v%3Asepby" TARGET="main"+>sepby</A+></DIV+> <DIV CLASS="decl"+><A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#v%3Asepby1" TARGET="main"+>sepby1</A+></DIV+> <DIV CLASS="decl"+><A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#v%3Achainl" TARGET="main"+>chainl</A+></DIV+> <DIV CLASS="decl"+><A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#v%3Achainl1" TARGET="main"+>chainl1</A+></DIV+> <DIV CLASS="decl"+><A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#v%3Achainr" TARGET="main"+>chainr</A+></DIV+> <DIV CLASS="decl"+><A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#v%3Achainr1" TARGET="main"+>chainr1</A+></DIV+> <DIV CLASS="decl"+><A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#v%3Aops" TARGET="main"+>ops</A+></DIV+> <DIV CLASS="decl"+><A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#v%3Abracket" TARGET="main"+>bracket</A+></DIV+> <DIV CLASS="decl"+><A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#v%3AtoEOF" TARGET="main"+>toEOF</A+></DIV+> <H1+>Error handling+</H1+> <DIV CLASS="decl"+><A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#v%3Aelserror" TARGET="main"+>elserror</A+></DIV+> <H1+>State handling+</H1+> <DIV CLASS="decl"+><A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#v%3Astupd" TARGET="main"+>stupd</A+></DIV+> <DIV CLASS="decl"+><A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#v%3Astquery" TARGET="main"+>stquery</A+></DIV+> <DIV CLASS="decl"+><A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#v%3Astget" TARGET="main"+>stget</A+></DIV+> <H1+>Re-parsing+</H1+> <DIV CLASS="decl"+><A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#v%3Areparse" TARGET="main"+>reparse</A+></DIV+></DIV+></DIV+></BODY+></HTML+>
+ docs/haddock/mini_Text-ParserCombinators-Poly-Base.html view
@@ -0,0 +1,101 @@+<!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.Base</TITLE+><LINK HREF="haddock.css" REL="stylesheet" TYPE="text/css"+><SCRIPT SRC="haddock-util.js" TYPE="text/javascript"+></SCRIPT+></HEAD+><BODY+><DIV CLASS="outer"+><DIV CLASS="mini-topbar"+>Text.ParserCombinators.Poly.Base</DIV+><DIV CLASS="mini-synopsis"+><H1+>The PolyParse class+</H1+> <DIV CLASS="decl"+><SPAN CLASS="keyword"+>class</SPAN+>&nbsp;<A HREF="Text-ParserCombinators-Poly-Base.html#t%3APolyParse" TARGET="main"+>PolyParse</A+> p</DIV+> <H1+>Combinators general to all parser types.+</H1+> <H2+>Simple combinators+</H2+> <DIV CLASS="decl"+><A HREF="Text-ParserCombinators-Poly-Base.html#v%3Adiscard" TARGET="main"+>discard</A+></DIV+> <H2+>Error-handling+</H2+> <DIV CLASS="decl"+><A HREF="Text-ParserCombinators-Poly-Base.html#v%3AfailBad" TARGET="main"+>failBad</A+></DIV+> <DIV CLASS="decl"+><A HREF="Text-ParserCombinators-Poly-Base.html#v%3AadjustErrBad" TARGET="main"+>adjustErrBad</A+></DIV+> <DIV CLASS="decl"+><A HREF="Text-ParserCombinators-Poly-Base.html#v%3Aindent" TARGET="main"+>indent</A+></DIV+> <H2+>Choices+</H2+> <DIV CLASS="decl"+><A HREF="Text-ParserCombinators-Poly-Base.html#v%3AoneOf" TARGET="main"+>oneOf</A+></DIV+> <DIV CLASS="decl"+><A HREF="Text-ParserCombinators-Poly-Base.html#v%3Aoptional" TARGET="main"+>optional</A+></DIV+> <H2+>Sequences+</H2+> <DIV CLASS="decl"+><A HREF="Text-ParserCombinators-Poly-Base.html#v%3Aexactly" TARGET="main"+>exactly</A+></DIV+> <DIV CLASS="decl"+><A HREF="Text-ParserCombinators-Poly-Base.html#v%3Amany" TARGET="main"+>many</A+></DIV+> <DIV CLASS="decl"+><A HREF="Text-ParserCombinators-Poly-Base.html#v%3Amany1" TARGET="main"+>many1</A+></DIV+> <DIV CLASS="decl"+><A HREF="Text-ParserCombinators-Poly-Base.html#v%3AsepBy" TARGET="main"+>sepBy</A+></DIV+> <DIV CLASS="decl"+><A HREF="Text-ParserCombinators-Poly-Base.html#v%3AsepBy1" TARGET="main"+>sepBy1</A+></DIV+> <DIV CLASS="decl"+><A HREF="Text-ParserCombinators-Poly-Base.html#v%3AbracketSep" TARGET="main"+>bracketSep</A+></DIV+> <DIV CLASS="decl"+><A HREF="Text-ParserCombinators-Poly-Base.html#v%3Abracket" TARGET="main"+>bracket</A+></DIV+> <DIV CLASS="decl"+><A HREF="Text-ParserCombinators-Poly-Base.html#v%3AmanyFinally" TARGET="main"+>manyFinally</A+></DIV+></DIV+></DIV+></BODY+></HTML+>
+ docs/haddock/mini_Text-ParserCombinators-Poly-ByteString.html view
@@ -0,0 +1,65 @@+<!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.ByteString</TITLE+><LINK HREF="haddock.css" REL="stylesheet" TYPE="text/css"+><SCRIPT SRC="haddock-util.js" TYPE="text/javascript"+></SCRIPT+></HEAD+><BODY+><DIV CLASS="outer"+><DIV CLASS="mini-topbar"+>Text.ParserCombinators.Poly.ByteString</DIV+><DIV CLASS="mini-synopsis"+><H1+>The Parser datatype+</H1+> <DIV CLASS="decl"+><SPAN CLASS="keyword"+>data</SPAN+>&nbsp;<A HREF="Text-ParserCombinators-Poly-ByteString.html#t%3AParser" TARGET="main"+>Parser</A+> a</DIV+> <DIV CLASS="decl"+><SPAN CLASS="keyword"+>data</SPAN+>&nbsp;<A HREF="Text-ParserCombinators-Poly-ByteString.html#t%3AResult" TARGET="main"+>Result</A+> z a</DIV+> <DIV CLASS="decl"+><A HREF="Text-ParserCombinators-Poly-ByteString.html#v%3ArunParser" TARGET="main"+>runParser</A+></DIV+> <H2+>basic parsers+</H2+> <DIV CLASS="decl"+><A HREF="Text-ParserCombinators-Poly-ByteString.html#v%3Anext" TARGET="main"+>next</A+></DIV+> <DIV CLASS="decl"+><A HREF="Text-ParserCombinators-Poly-ByteString.html#v%3Aeof" TARGET="main"+>eof</A+></DIV+> <DIV CLASS="decl"+><A HREF="Text-ParserCombinators-Poly-ByteString.html#v%3Asatisfy" TARGET="main"+>satisfy</A+></DIV+> <H2+>re-parsing+</H2+> <DIV CLASS="decl"+><A HREF="Text-ParserCombinators-Poly-ByteString.html#v%3Areparse" TARGET="main"+>reparse</A+></DIV+> <H1+>Re-export all more general combinators+</H1+> </DIV+></DIV+></BODY+></HTML+>
+ docs/haddock/mini_Text-ParserCombinators-Poly-Lazy.html view
@@ -0,0 +1,65 @@+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">+<!--Rendered using the Haskell Html Library v0.2-->+<HTML+><HEAD+><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8"+><TITLE+>Text.ParserCombinators.Poly.Lazy</TITLE+><LINK HREF="haddock.css" REL="stylesheet" TYPE="text/css"+><SCRIPT SRC="haddock-util.js" TYPE="text/javascript"+></SCRIPT+></HEAD+><BODY+><DIV CLASS="outer"+><DIV CLASS="mini-topbar"+>Text.ParserCombinators.Poly.Lazy</DIV+><DIV CLASS="mini-synopsis"+><H1+>The Parser datatype+</H1+> <DIV CLASS="decl"+><SPAN CLASS="keyword"+>data</SPAN+>&nbsp;<A HREF="Text-ParserCombinators-Poly-Lazy.html#t%3AParser" TARGET="main"+>Parser</A+> t a</DIV+> <DIV CLASS="decl"+><SPAN CLASS="keyword"+>data</SPAN+>&nbsp;<A HREF="Text-ParserCombinators-Poly-Lazy.html#t%3AResult" TARGET="main"+>Result</A+> z a</DIV+> <DIV CLASS="decl"+><A HREF="Text-ParserCombinators-Poly-Lazy.html#v%3ArunParser" TARGET="main"+>runParser</A+></DIV+> <H2+>basic parsers+</H2+> <DIV CLASS="decl"+><A HREF="Text-ParserCombinators-Poly-Lazy.html#v%3Anext" TARGET="main"+>next</A+></DIV+> <DIV CLASS="decl"+><A HREF="Text-ParserCombinators-Poly-Lazy.html#v%3Aeof" TARGET="main"+>eof</A+></DIV+> <DIV CLASS="decl"+><A HREF="Text-ParserCombinators-Poly-Lazy.html#v%3Asatisfy" TARGET="main"+>satisfy</A+></DIV+> <H2+>re-parsing+</H2+> <DIV CLASS="decl"+><A HREF="Text-ParserCombinators-Poly-Lazy.html#v%3Areparse" TARGET="main"+>reparse</A+></DIV+> <H1+>Re-export all more general combinators+</H1+> </DIV+></DIV+></BODY+></HTML+>
+ docs/haddock/mini_Text-ParserCombinators-Poly-Plain.html view
@@ -0,0 +1,65 @@+<!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.Plain</TITLE+><LINK HREF="haddock.css" REL="stylesheet" TYPE="text/css"+><SCRIPT SRC="haddock-util.js" TYPE="text/javascript"+></SCRIPT+></HEAD+><BODY+><DIV CLASS="outer"+><DIV CLASS="mini-topbar"+>Text.ParserCombinators.Poly.Plain</DIV+><DIV CLASS="mini-synopsis"+><H1+>The Parser datatype+</H1+> <DIV CLASS="decl"+><SPAN CLASS="keyword"+>data</SPAN+>&nbsp;<A HREF="Text-ParserCombinators-Poly-Plain.html#t%3AParser" TARGET="main"+>Parser</A+> t a</DIV+> <DIV CLASS="decl"+><SPAN CLASS="keyword"+>data</SPAN+>&nbsp;<A HREF="Text-ParserCombinators-Poly-Plain.html#t%3AResult" TARGET="main"+>Result</A+> z a</DIV+> <DIV CLASS="decl"+><A HREF="Text-ParserCombinators-Poly-Plain.html#v%3ArunParser" TARGET="main"+>runParser</A+></DIV+> <H2+>basic parsers+</H2+> <DIV CLASS="decl"+><A HREF="Text-ParserCombinators-Poly-Plain.html#v%3Anext" TARGET="main"+>next</A+></DIV+> <DIV CLASS="decl"+><A HREF="Text-ParserCombinators-Poly-Plain.html#v%3Aeof" TARGET="main"+>eof</A+></DIV+> <DIV CLASS="decl"+><A HREF="Text-ParserCombinators-Poly-Plain.html#v%3Asatisfy" TARGET="main"+>satisfy</A+></DIV+> <H2+>re-parsing+</H2+> <DIV CLASS="decl"+><A HREF="Text-ParserCombinators-Poly-Plain.html#v%3Areparse" TARGET="main"+>reparse</A+></DIV+> <H1+>Re-export all more general combinators+</H1+> </DIV+></DIV+></BODY+></HTML+>
+ docs/haddock/mini_Text-ParserCombinators-Poly-State.html view
@@ -0,0 +1,80 @@+<!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.State</TITLE+><LINK HREF="haddock.css" REL="stylesheet" TYPE="text/css"+><SCRIPT SRC="haddock-util.js" TYPE="text/javascript"+></SCRIPT+></HEAD+><BODY+><DIV CLASS="outer"+><DIV CLASS="mini-topbar"+>Text.ParserCombinators.Poly.State</DIV+><DIV CLASS="mini-synopsis"+><H1+>The Parser datatype+</H1+> <DIV CLASS="decl"+><SPAN CLASS="keyword"+>data</SPAN+>&nbsp;<A HREF="Text-ParserCombinators-Poly-State.html#t%3AParser" TARGET="main"+>Parser</A+> s t a</DIV+> <DIV CLASS="decl"+><SPAN CLASS="keyword"+>data</SPAN+>&nbsp;<A HREF="Text-ParserCombinators-Poly-State.html#t%3AResult" TARGET="main"+>Result</A+> z s a</DIV+> <DIV CLASS="decl"+><A HREF="Text-ParserCombinators-Poly-State.html#v%3ArunParser" TARGET="main"+>runParser</A+></DIV+> <H2+>basic parsers+</H2+> <DIV CLASS="decl"+><A HREF="Text-ParserCombinators-Poly-State.html#v%3Anext" TARGET="main"+>next</A+></DIV+> <DIV CLASS="decl"+><A HREF="Text-ParserCombinators-Poly-State.html#v%3Aeof" TARGET="main"+>eof</A+></DIV+> <DIV CLASS="decl"+><A HREF="Text-ParserCombinators-Poly-State.html#v%3Asatisfy" TARGET="main"+>satisfy</A+></DIV+> <H2+>State-handling+</H2+> <DIV CLASS="decl"+><A HREF="Text-ParserCombinators-Poly-State.html#v%3AstUpdate" TARGET="main"+>stUpdate</A+></DIV+> <DIV CLASS="decl"+><A HREF="Text-ParserCombinators-Poly-State.html#v%3AstQuery" TARGET="main"+>stQuery</A+></DIV+> <DIV CLASS="decl"+><A HREF="Text-ParserCombinators-Poly-State.html#v%3AstGet" TARGET="main"+>stGet</A+></DIV+> <H2+>re-parsing+</H2+> <DIV CLASS="decl"+><A HREF="Text-ParserCombinators-Poly-State.html#v%3Areparse" TARGET="main"+>reparse</A+></DIV+> <H1+>Re-export all more general combinators+</H1+> </DIV+></DIV+></BODY+></HTML+>
+ docs/haddock/mini_Text-ParserCombinators-Poly-StateLazy.html view
@@ -0,0 +1,84 @@+<!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.StateLazy</TITLE+><LINK HREF="haddock.css" REL="stylesheet" TYPE="text/css"+><SCRIPT SRC="haddock-util.js" TYPE="text/javascript"+></SCRIPT+></HEAD+><BODY+><DIV CLASS="outer"+><DIV CLASS="mini-topbar"+>Text.ParserCombinators.Poly.StateLazy</DIV+><DIV CLASS="mini-synopsis"+><H1+>The Parser datatype+</H1+> <DIV CLASS="decl"+><SPAN CLASS="keyword"+>data</SPAN+>&nbsp;<A HREF="Text-ParserCombinators-Poly-StateLazy.html#t%3AParser" TARGET="main"+>Parser</A+> s t a</DIV+> <DIV CLASS="decl"+><SPAN CLASS="keyword"+>data</SPAN+>&nbsp;<A HREF="Text-ParserCombinators-Poly-StateLazy.html#t%3AResult" TARGET="main"+>Result</A+> z s a</DIV+> <DIV CLASS="decl"+><A HREF="Text-ParserCombinators-Poly-StateLazy.html#v%3ArunParser" TARGET="main"+>runParser</A+></DIV+> <H2+>basic parsers+</H2+> <DIV CLASS="decl"+><A HREF="Text-ParserCombinators-Poly-StateLazy.html#v%3Anext" TARGET="main"+>next</A+></DIV+> <DIV CLASS="decl"+><A HREF="Text-ParserCombinators-Poly-StateLazy.html#v%3Aeof" TARGET="main"+>eof</A+></DIV+> <DIV CLASS="decl"+><A HREF="Text-ParserCombinators-Poly-StateLazy.html#v%3Asatisfy" TARGET="main"+>satisfy</A+></DIV+> <DIV CLASS="decl"+><A HREF="Text-ParserCombinators-Poly-StateLazy.html#v%3AmanyFinally" TARGET="main"+>manyFinally</A+></DIV+> <H2+>State-handling+</H2+> <DIV CLASS="decl"+><A HREF="Text-ParserCombinators-Poly-StateLazy.html#v%3AstUpdate" TARGET="main"+>stUpdate</A+></DIV+> <DIV CLASS="decl"+><A HREF="Text-ParserCombinators-Poly-StateLazy.html#v%3AstQuery" TARGET="main"+>stQuery</A+></DIV+> <DIV CLASS="decl"+><A HREF="Text-ParserCombinators-Poly-StateLazy.html#v%3AstGet" TARGET="main"+>stGet</A+></DIV+> <H2+>re-parsing+</H2+> <DIV CLASS="decl"+><A HREF="Text-ParserCombinators-Poly-StateLazy.html#v%3Areparse" TARGET="main"+>reparse</A+></DIV+> <H1+>Re-export all more general combinators+</H1+> </DIV+></DIV+></BODY+></HTML+>
+ docs/haddock/mini_Text-ParserCombinators-Poly.html view
@@ -0,0 +1,21 @@+<!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-util.js" TYPE="text/javascript"+></SCRIPT+></HEAD+><BODY+><DIV CLASS="outer"+><DIV CLASS="mini-topbar"+>Text.ParserCombinators.Poly</DIV+><DIV CLASS="mini-synopsis"+></DIV+></DIV+></BODY+></HTML+>
+ docs/haddock/minus.gif view

binary file changed (absent → 56 bytes)

+ docs/haddock/plus.gif view

binary file changed (absent → 59 bytes)

+ docs/haddock/src/Text/Parse.html view
@@ -0,0 +1,435 @@+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">+<html>+<pre><a name="line-1"></a><font color=Green><u>module</u></font> Text<font color=Cyan>.</font>Parse+<a name="line-2"></a>  <font color=Cyan>(</font> <font color=Blue>-- * The Parse class is a replacement for the standard Read class. </font>+<a name="line-3"></a>    <font color=Blue>-- $parser</font>+<a name="line-4"></a>    TextParser	<font color=Blue>-- synonym for Parser Char, i.e. string input, no state</font>+<a name="line-5"></a>  <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>+<a name="line-6"></a>		<font color=Blue>--            Int, Integer, Float, Double, Char, Bool</font>+<a name="line-7"></a>  <font color=Cyan>,</font> parseByRead	<font color=Blue>-- :: Read a =&gt; String -&gt; TextParser a</font>+<a name="line-8"></a>  <font color=Cyan>,</font> readByParse <font color=Blue>-- :: TextParser a -&gt; ReadS a</font>+<a name="line-9"></a>  <font color=Cyan>,</font> readsPrecByParsePrec <font color=Blue>-- :: (Int-&gt;TextParser a) -&gt; Int -&gt; ReadS a</font>+<a name="line-10"></a>    <font color=Blue>-- ** Combinators specific to string input, lexed haskell-style</font>+<a name="line-11"></a>  <font color=Cyan>,</font> word	<font color=Blue>-- :: TextParser String</font>+<a name="line-12"></a>  <font color=Cyan>,</font> isWord	<font color=Blue>-- :: String -&gt; TextParser ()</font>+<a name="line-13"></a>  <font color=Cyan>,</font> optionalParens	<font color=Blue>-- :: TextParser a -&gt; TextParser a</font>+<a name="line-14"></a>  <font color=Cyan>,</font> parens	<font color=Blue>-- :: Bool -&gt; TextParser a -&gt; TextParser a</font>+<a name="line-15"></a>  <font color=Cyan>,</font> field	<font color=Blue>-- :: Parse a =&gt; String -&gt; TextParser a</font>+<a name="line-16"></a>  <font color=Cyan>,</font> constructors<font color=Blue>-- :: [(String,TextParser a)] -&gt; TextParser a</font>+<a name="line-17"></a>  <font color=Cyan>,</font> enumeration <font color=Blue>-- :: Show a =&gt; String -&gt; [a] -&gt; TextParser a</font>+<a name="line-18"></a>    <font color=Blue>-- ** Parsers for literal numerics and characters</font>+<a name="line-19"></a>  <font color=Cyan>,</font> parseSigned+<a name="line-20"></a>  <font color=Cyan>,</font> parseInt+<a name="line-21"></a>  <font color=Cyan>,</font> parseDec+<a name="line-22"></a>  <font color=Cyan>,</font> parseOct+<a name="line-23"></a>  <font color=Cyan>,</font> parseHex+<a name="line-24"></a>  <font color=Cyan>,</font> parseFloat+<a name="line-25"></a>  <font color=Cyan>,</font> parseLitChar+<a name="line-26"></a>    <font color=Blue>-- ** Re-export all the more general combinators from Poly too</font>+<a name="line-27"></a>  <font color=Cyan>,</font> <font color=Green><u>module</u></font> Text<font color=Cyan>.</font>ParserCombinators<font color=Cyan>.</font>Poly+<a name="line-28"></a>  <font color=Cyan>)</font> <font color=Green><u>where</u></font>+<a name="line-29"></a>+<a name="line-30"></a><font color=Green><u>import</u></font> Char <font color=Cyan>(</font>isSpace<font color=Cyan>,</font>toLower<font color=Cyan>,</font>isUpper<font color=Cyan>,</font>isDigit<font color=Cyan>,</font>isOctDigit<font color=Cyan>,</font>isHexDigit<font color=Cyan>,</font>digitToInt+<a name="line-31"></a>            <font color=Cyan>,</font>isAlpha<font color=Cyan>,</font>isAlphaNum<font color=Cyan>,</font>ord<font color=Cyan>,</font>chr<font color=Cyan>)</font>+<a name="line-32"></a><font color=Green><u>import</u></font> List <font color=Cyan>(</font>intersperse<font color=Cyan>)</font>+<a name="line-33"></a><font color=Green><u>import</u></font> Ratio+<a name="line-34"></a><font color=Green><u>import</u></font> Text<font color=Cyan>.</font>ParserCombinators<font color=Cyan>.</font>Poly+<a name="line-35"></a>+<a name="line-36"></a><font color=Blue>------------------------------------------------------------------------</font>+<a name="line-37"></a><font color=Blue>-- $parser</font>+<a name="line-38"></a><font color=Blue>-- The Parse class is a replacement for the standard Read class.  It is a</font>+<a name="line-39"></a><font color=Blue>-- specialisation of the (poly) Parser monad for String input.</font>+<a name="line-40"></a><font color=Blue>-- There are instances defined for all Prelude types.</font>+<a name="line-41"></a><font color=Blue>-- For user-defined types, you can write your own instance, or use</font>+<a name="line-42"></a><font color=Blue>-- DrIFT to generate them automatically, e.g. {-! derive : Parse !-}</font>+<a name="line-43"></a>+<a name="line-44"></a><a name="TextParser"></a><font color=Blue>-- | A synonym for Parser Char, i.e. string input (no state)</font>+<a name="line-45"></a><a name="TextParser"></a><font color=Green><u>type</u></font> TextParser a <font color=Red>=</font> Parser Char a+<a name="line-46"></a>+<a name="line-47"></a><a name="Parse"></a><font color=Blue>-- | The class @Parse@ is a replacement for @Read@, operating over String input.</font>+<a name="line-48"></a><a name="Parse"></a><font color=Blue>--   Essentially, it permits better error messages for why something failed to</font>+<a name="line-49"></a><a name="Parse"></a><font color=Blue>--   parse.  It is rather important that @parse@ can read back exactly what</font>+<a name="line-50"></a><a name="Parse"></a><font color=Blue>--   is generated by the corresponding instance of @show@.  To apply a parser</font>+<a name="line-51"></a><a name="Parse"></a><font color=Blue>--   to some text, use @runParser@.</font>+<a name="line-52"></a><a name="Parse"></a><font color=Green><u>class</u></font> Parse a <font color=Green><u>where</u></font>+<a name="line-53"></a>    <font color=Blue>-- | A straightforward parser for an item.  (A minimal definition of</font>+<a name="line-54"></a>    <font color=Blue>--   a class instance requires either |parse| or |parsePrec|.)</font>+<a name="line-55"></a>    parse     <font color=Red>::</font> TextParser a+<a name="line-56"></a>    parse       <font color=Red>=</font> parsePrec <font color=Magenta>0</font>+<a name="line-57"></a>    <font color=Blue>-- | A straightforward parser for an item, given the precedence of</font>+<a name="line-58"></a>    <font color=Blue>--   any surrounding expression.  (Precedence determines whether</font>+<a name="line-59"></a>    <font color=Blue>--   parentheses are mandatory or optional.)</font>+<a name="line-60"></a>    parsePrec <font color=Red>::</font> Int <font color=Red>-&gt;</font> TextParser a+<a name="line-61"></a>    parsePrec <font color=Green><u>_</u></font> <font color=Red>=</font> optionalParens parse+<a name="line-62"></a>    <font color=Blue>-- | Parsing a list of items by default accepts the [] and comma syntax,</font>+<a name="line-63"></a>    <font color=Blue>--   except when the list is really a character string using \"\".</font>+<a name="line-64"></a>    parseList <font color=Red>::</font> TextParser <font color=Red>[</font>a<font color=Red>]</font>	<font color=Blue>-- only to distinguish [] and ""</font>+<a name="line-65"></a>    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=Cyan>}</font>+<a name="line-66"></a>                   <font color=Cyan>`onFail`</font>+<a name="line-67"></a>                 <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=Cyan>}</font>+<a name="line-68"></a>                   <font color=Cyan>`onFail`</font>+<a name="line-69"></a>                 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>+<a name="line-70"></a>                            <font color=Cyan>(</font>optionalParens parse<font color=Cyan>)</font>+<a name="line-71"></a>                   <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>+<a name="line-72"></a>+<a name="line-73"></a><a name="parseByRead"></a><font color=Blue>-- | If there already exists a Read instance for a type, then we can make</font>+<a name="line-74"></a><font color=Blue>--   a Parser for it, but with only poor error-reporting.  The string argument</font>+<a name="line-75"></a><font color=Blue>--   is the expected type or value (for error-reporting only).</font>+<a name="line-76"></a><font color=Blue>parseByRead</font> <font color=Red>::</font> Read a <font color=Red>=&gt;</font> String <font color=Red>-&gt;</font> TextParser a+<a name="line-77"></a><font color=Blue>parseByRead</font> name <font color=Red>=</font>+<a name="line-78"></a>    P <font color=Cyan>(</font><font color=Red>\</font>s<font color=Red>-&gt;</font> <font color=Green><u>case</u></font> reads s <font color=Green><u>of</u></font>+<a name="line-79"></a>                []       <font color=Red>-&gt;</font> Failure s <font color=Cyan>(</font><font color=Magenta>"no parse, expected a "</font><font color=Cyan>++</font>name<font color=Cyan>)</font>+<a name="line-80"></a>                <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>-&gt;</font> Success s' a+<a name="line-81"></a>                <font color=Green><u>_</u></font>        <font color=Red>-&gt;</font> Failure s <font color=Cyan>(</font><font color=Magenta>"ambiguous parse, expected a "</font><font color=Cyan>++</font>name<font color=Cyan>)</font>+<a name="line-82"></a>      <font color=Cyan>)</font>+<a name="line-83"></a>+<a name="line-84"></a><a name="readByParse"></a><font color=Blue>-- | If you have a TextParser for a type, you can easily make it into</font>+<a name="line-85"></a><font color=Blue>--   a Read instance, by throwing away any error messages.</font>+<a name="line-86"></a><font color=Blue>readByParse</font> <font color=Red>::</font> TextParser a <font color=Red>-&gt;</font> ReadS a+<a name="line-87"></a><font color=Blue>readByParse</font> p <font color=Red>=</font> <font color=Red>\</font>inp<font color=Red>-&gt;</font>+<a name="line-88"></a>    <font color=Green><u>case</u></font> runParser p inp <font color=Green><u>of</u></font>+<a name="line-89"></a>        <font color=Cyan>(</font>Left err<font color=Cyan>,</font>  rest<font color=Cyan>)</font> <font color=Red>-&gt;</font> []+<a name="line-90"></a>        <font color=Cyan>(</font>Right val<font color=Cyan>,</font> rest<font color=Cyan>)</font> <font color=Red>-&gt;</font> <font color=Red>[</font><font color=Cyan>(</font>val<font color=Cyan>,</font>rest<font color=Cyan>)</font><font color=Red>]</font>+<a name="line-91"></a>+<a name="line-92"></a><a name="readsPrecByParsePrec"></a><font color=Blue>-- | If you have a TextParser for a type, you can easily make it into</font>+<a name="line-93"></a><font color=Blue>--   a Read instance, by throwing away any error messages.</font>+<a name="line-94"></a><font color=Blue>readsPrecByParsePrec</font> <font color=Red>::</font> <font color=Cyan>(</font>Int <font color=Red>-&gt;</font> TextParser a<font color=Cyan>)</font> <font color=Red>-&gt;</font> Int <font color=Red>-&gt;</font> ReadS a+<a name="line-95"></a><font color=Blue>readsPrecByParsePrec</font> p <font color=Red>=</font> <font color=Red>\</font>prec inp<font color=Red>-&gt;</font>+<a name="line-96"></a>    <font color=Green><u>case</u></font> runParser <font color=Cyan>(</font>p prec<font color=Cyan>)</font> inp <font color=Green><u>of</u></font>+<a name="line-97"></a>        <font color=Cyan>(</font>Left err<font color=Cyan>,</font>  rest<font color=Cyan>)</font> <font color=Red>-&gt;</font> []+<a name="line-98"></a>        <font color=Cyan>(</font>Right val<font color=Cyan>,</font> rest<font color=Cyan>)</font> <font color=Red>-&gt;</font> <font color=Red>[</font><font color=Cyan>(</font>val<font color=Cyan>,</font>rest<font color=Cyan>)</font><font color=Red>]</font>+<a name="line-99"></a>+<a name="line-100"></a><a name="word"></a><font color=Blue>-- | One lexical chunk.  This is Haskell'98-style lexing - the result</font>+<a name="line-101"></a><font color=Blue>--   should match Prelude.lex apart from better error-reporting.</font>+<a name="line-102"></a><font color=Blue>word</font> <font color=Red>::</font> TextParser String+<a name="line-103"></a><font color=Blue>word</font> <font color=Red>=</font> P p+<a name="line-104"></a>  <font color=Green><u>where</u></font>+<a name="line-105"></a>    p <font color=Magenta>""</font>       <font color=Red>=</font> Failure <font color=Magenta>""</font> <font color=Magenta>"end of input"</font>+<a name="line-106"></a>    p <font color=Cyan>(</font>c<font color=Red><b>:</b></font>s<font color=Cyan>)</font>    <font color=Red>|</font> isSpace c <font color=Red>=</font> p <font color=Cyan>(</font>dropWhile isSpace s<font color=Cyan>)</font>+<a name="line-107"></a>    p <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=Green><u>let</u></font> <font color=Cyan>(</font>P lit<font color=Cyan>)</font> <font color=Red>=</font> parseLitChar <font color=Green><u>in</u></font> fmap show <font color=Cyan>(</font>lit <font color=Cyan>(</font><font color=Magenta>'\''</font><font color=Red><b>:</b></font>s<font color=Cyan>)</font><font color=Cyan>)</font>+<a name="line-108"></a>    p <font color=Cyan>(</font><font color=Magenta>'"'</font><font color=Red><b>:</b></font>s<font color=Cyan>)</font>  <font color=Red>=</font> lexString <font color=Magenta>"\""</font> s+<a name="line-109"></a>             <font color=Green><u>where</u></font> lexString acc <font color=Cyan>(</font><font color=Magenta>'"'</font><font color=Red><b>:</b></font>s<font color=Cyan>)</font>      <font color=Red>=</font> Success s <font color=Cyan>(</font>reverse <font color=Cyan>(</font><font color=Magenta>'"'</font><font color=Red><b>:</b></font>acc<font color=Cyan>)</font><font color=Cyan>)</font>+<a name="line-110"></a>                   lexString acc <font color=Cyan>(</font><font color=Magenta>'\\'</font><font color=Red><b>:</b></font><font color=Magenta>'"'</font><font color=Red><b>:</b></font>s<font color=Cyan>)</font> <font color=Red>=</font> lexString <font color=Cyan>(</font><font color=Magenta>"\"\\"</font><font color=Cyan>++</font>acc<font color=Cyan>)</font> s+<a name="line-111"></a>                   lexString acc <font color=Cyan>(</font>c<font color=Red><b>:</b></font>s<font color=Cyan>)</font>        <font color=Red>=</font> lexString <font color=Cyan>(</font>c<font color=Red><b>:</b></font>acc<font color=Cyan>)</font> s+<a name="line-112"></a>                   lexString acc []           <font color=Red>=</font> Failure [] <font color=Cyan>(</font><font color=Magenta>"end of input in "</font>+<a name="line-113"></a>                                                           <font color=Cyan>++</font><font color=Magenta>"string literal "</font>+<a name="line-114"></a>                                                           <font color=Cyan>++</font>acc<font color=Cyan>)</font>+<a name="line-115"></a>    p <font color=Cyan>(</font><font color=Magenta>'0'</font><font color=Red><b>:</b></font><font color=Magenta>'x'</font><font color=Red><b>:</b></font>s<font color=Cyan>)</font> <font color=Red>=</font> Success t <font color=Cyan>(</font><font color=Magenta>'0'</font><font color=Red><b>:</b></font><font color=Magenta>'x'</font><font color=Red><b>:</b></font>ds<font color=Cyan>)</font> <font color=Green><u>where</u></font> <font color=Cyan>(</font>ds<font color=Cyan>,</font>t<font color=Cyan>)</font> <font color=Red>=</font> span isHexDigit s+<a name="line-116"></a>    p <font color=Cyan>(</font><font color=Magenta>'0'</font><font color=Red><b>:</b></font><font color=Magenta>'X'</font><font color=Red><b>:</b></font>s<font color=Cyan>)</font> <font color=Red>=</font> Success t <font color=Cyan>(</font><font color=Magenta>'0'</font><font color=Red><b>:</b></font><font color=Magenta>'X'</font><font color=Red><b>:</b></font>ds<font color=Cyan>)</font> <font color=Green><u>where</u></font> <font color=Cyan>(</font>ds<font color=Cyan>,</font>t<font color=Cyan>)</font> <font color=Red>=</font> span isHexDigit s+<a name="line-117"></a>    p <font color=Cyan>(</font><font color=Magenta>'0'</font><font color=Red><b>:</b></font><font color=Magenta>'o'</font><font color=Red><b>:</b></font>s<font color=Cyan>)</font> <font color=Red>=</font> Success t <font color=Cyan>(</font><font color=Magenta>'0'</font><font color=Red><b>:</b></font><font color=Magenta>'o'</font><font color=Red><b>:</b></font>ds<font color=Cyan>)</font> <font color=Green><u>where</u></font> <font color=Cyan>(</font>ds<font color=Cyan>,</font>t<font color=Cyan>)</font> <font color=Red>=</font> span isOctDigit s+<a name="line-118"></a>    p <font color=Cyan>(</font><font color=Magenta>'0'</font><font color=Red><b>:</b></font><font color=Magenta>'O'</font><font color=Red><b>:</b></font>s<font color=Cyan>)</font> <font color=Red>=</font> Success t <font color=Cyan>(</font><font color=Magenta>'0'</font><font color=Red><b>:</b></font><font color=Magenta>'O'</font><font color=Red><b>:</b></font>ds<font color=Cyan>)</font> <font color=Green><u>where</u></font> <font color=Cyan>(</font>ds<font color=Cyan>,</font>t<font color=Cyan>)</font> <font color=Red>=</font> span isOctDigit s+<a name="line-119"></a>    p <font color=Cyan>(</font>c<font color=Red><b>:</b></font>s<font color=Cyan>)</font> <font color=Red>|</font> isSingle c <font color=Red>=</font> Success s <font color=Red>[</font>c<font color=Red>]</font>+<a name="line-120"></a>            <font color=Red>|</font> isSym    c <font color=Red>=</font> <font color=Green><u>let</u></font> <font color=Cyan>(</font>sym<font color=Cyan>,</font>t<font color=Cyan>)</font> <font color=Red>=</font> span isSym s <font color=Green><u>in</u></font> Success t <font color=Cyan>(</font>c<font color=Red><b>:</b></font>sym<font color=Cyan>)</font>+<a name="line-121"></a>            <font color=Red>|</font> isIdInit c <font color=Red>=</font> <font color=Green><u>let</u></font> <font color=Cyan>(</font>nam<font color=Cyan>,</font>t<font color=Cyan>)</font> <font color=Red>=</font> span isIdChar s <font color=Green><u>in</u></font> Success t <font color=Cyan>(</font>c<font color=Red><b>:</b></font>nam<font color=Cyan>)</font>+<a name="line-122"></a>            <font color=Red>|</font> isDigit  c <font color=Red>=</font> <font color=Green><u>let</u></font> <font color=Cyan>(</font>ds<font color=Cyan>,</font>t<font color=Cyan>)</font>  <font color=Red>=</font> span isDigit s <font color=Green><u>in</u></font>+<a name="line-123"></a>                           lexFracExp <font color=Cyan>(</font>c<font color=Red><b>:</b></font>ds<font color=Cyan>)</font> t+<a name="line-124"></a>            <font color=Red>|</font> otherwise  <font color=Red>=</font> Failure <font color=Cyan>(</font>c<font color=Red><b>:</b></font>s<font color=Cyan>)</font> <font color=Cyan>(</font><font color=Magenta>"Bad character: "</font><font color=Cyan>++</font>show c<font color=Cyan>)</font>+<a name="line-125"></a>             <font color=Green><u>where</u></font> isSingle c  <font color=Red>=</font>  c <font color=Cyan>`elem`</font> <font color=Magenta>",;()[]{}`"</font>+<a name="line-126"></a>                   isSym    c  <font color=Red>=</font>  c <font color=Cyan>`elem`</font> <font color=Magenta>"!@#$%&amp;*+./&lt;=&gt;?\\^|:-~"</font>+<a name="line-127"></a>                   isIdInit c  <font color=Red>=</font>  isAlpha c <font color=Cyan>||</font> c <font color=Cyan>==</font> <font color=Magenta>'_'</font>+<a name="line-128"></a>                   isIdChar c  <font color=Red>=</font>  isAlphaNum c <font color=Cyan>||</font> c <font color=Cyan>`elem`</font> <font color=Magenta>"_'"</font>+<a name="line-129"></a>                   lexFracExp acc <font color=Cyan>(</font><font color=Magenta>'.'</font><font color=Red><b>:</b></font>d<font color=Red><b>:</b></font>s<font color=Cyan>)</font> <font color=Red>|</font> isDigit d   <font color=Red>=</font>+<a name="line-130"></a>                                      lexExp <font color=Cyan>(</font>acc<font color=Cyan>++</font><font color=Magenta>'.'</font><font color=Red><b>:</b></font>d<font color=Red><b>:</b></font>ds<font color=Cyan>)</font> t+<a name="line-131"></a>                                              <font color=Green><u>where</u></font> <font color=Cyan>(</font>ds<font color=Cyan>,</font>t<font color=Cyan>)</font> <font color=Red>=</font> span isDigit s+<a name="line-132"></a>                   lexFracExp acc s <font color=Red>=</font> lexExp acc s+<a name="line-133"></a>                   lexExp     acc <font color=Cyan>(</font>e<font color=Red><b>:</b></font>s<font color=Cyan>)</font> <font color=Red>|</font> e<font color=Cyan>`elem`</font><font color=Magenta>"eE"</font> <font color=Red>=</font>+<a name="line-134"></a>                                      <font color=Green><u>case</u></font> s <font color=Green><u>of</u></font>+<a name="line-135"></a>                                        <font color=Cyan>(</font><font color=Magenta>'+'</font><font color=Red><b>:</b></font>d<font color=Red><b>:</b></font>t<font color=Cyan>)</font> <font color=Red>|</font> isDigit d <font color=Red>-&gt;</font>+<a name="line-136"></a>                                                    <font color=Green><u>let</u></font> <font color=Cyan>(</font>ds<font color=Cyan>,</font>u<font color=Cyan>)</font><font color=Red>=</font>span isDigit t <font color=Green><u>in</u></font>+<a name="line-137"></a>                                                    Success u <font color=Cyan>(</font>acc<font color=Cyan>++</font><font color=Magenta>"e+"</font><font color=Cyan>++</font>d<font color=Red><b>:</b></font>ds<font color=Cyan>)</font>+<a name="line-138"></a>                                        <font color=Cyan>(</font><font color=Magenta>'-'</font><font color=Red><b>:</b></font>d<font color=Red><b>:</b></font>t<font color=Cyan>)</font> <font color=Red>|</font> isDigit d <font color=Red>-&gt;</font>+<a name="line-139"></a>                                                    <font color=Green><u>let</u></font> <font color=Cyan>(</font>ds<font color=Cyan>,</font>u<font color=Cyan>)</font><font color=Red>=</font>span isDigit t <font color=Green><u>in</u></font>+<a name="line-140"></a>                                                    Success u <font color=Cyan>(</font>acc<font color=Cyan>++</font><font color=Magenta>"e-"</font><font color=Cyan>++</font>d<font color=Red><b>:</b></font>ds<font color=Cyan>)</font>+<a name="line-141"></a>                                        <font color=Cyan>(</font>d<font color=Red><b>:</b></font>t<font color=Cyan>)</font> <font color=Red>|</font>isDigit d <font color=Red>-&gt;</font>+<a name="line-142"></a>                                                    <font color=Green><u>let</u></font> <font color=Cyan>(</font>ds<font color=Cyan>,</font>u<font color=Cyan>)</font><font color=Red>=</font>span isDigit t <font color=Green><u>in</u></font>+<a name="line-143"></a>                                                    Success u <font color=Cyan>(</font>acc<font color=Cyan>++</font><font color=Magenta>"e"</font><font color=Cyan>++</font>d<font color=Red><b>:</b></font>ds<font color=Cyan>)</font>+<a name="line-144"></a>                                        <font color=Green><u>_</u></font> <font color=Red>-&gt;</font> Failure s <font color=Cyan>(</font><font color=Magenta>"missing +/-/digit "</font>+<a name="line-145"></a>                                                       <font color=Cyan>++</font><font color=Magenta>"after e in float "</font>+<a name="line-146"></a>                                                       <font color=Cyan>++</font><font color=Magenta>"literal: "</font>+<a name="line-147"></a>                                                       <font color=Cyan>++</font>show <font color=Cyan>(</font>acc<font color=Cyan>++</font><font color=Magenta>"e"</font><font color=Cyan>++</font><font color=Magenta>"..."</font><font color=Cyan>)</font><font color=Cyan>)</font>+<a name="line-148"></a>                   lexExp     acc s     <font color=Red>=</font> Success s acc+<a name="line-149"></a>+<a name="line-150"></a>+<a name="line-151"></a>+<a name="line-152"></a><a name="oldword"></a><font color=Blue>-- | One lexical chunk (Haskell'98-style lexing - the result should match</font>+<a name="line-153"></a><font color=Blue>--   Prelude.lex apart from error-reporting).</font>+<a name="line-154"></a><font color=Blue>oldword</font> <font color=Red>::</font> TextParser String+<a name="line-155"></a><font color=Blue>oldword</font> <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>s<font color=Red>-&gt;</font> <font color=Green><u>case</u></font> lex s <font color=Green><u>of</u></font>+<a name="line-156"></a>                   []         <font color=Red>-&gt;</font> Failure s  <font color=Cyan>(</font><font color=Magenta>"no input? (impossible)"</font><font color=Cyan>)</font>+<a name="line-157"></a>                   <font color=Red>[</font><font color=Cyan>(</font><font color=Magenta>""</font><font color=Cyan>,</font><font color=Magenta>""</font><font color=Cyan>)</font><font color=Red>]</font>  <font color=Red>-&gt;</font> Failure <font color=Magenta>""</font> <font color=Cyan>(</font><font color=Magenta>"no input?"</font><font color=Cyan>)</font>+<a name="line-158"></a>                   <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>-&gt;</font> Failure s  <font color=Cyan>(</font><font color=Magenta>"lexing failed?"</font><font color=Cyan>)</font>+<a name="line-159"></a>                   <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>-&gt;</font> Success s' x+<a name="line-160"></a>         <font color=Cyan>)</font>+<a name="line-161"></a>+<a name="line-162"></a><a name="isWord"></a><font color=Blue>-- | Ensure that the next input word is the given string.  (Note the input</font>+<a name="line-163"></a><font color=Blue>--   is lexed as haskell, so wordbreaks at spaces, symbols, etc.)</font>+<a name="line-164"></a><font color=Blue>isWord</font> <font color=Red>::</font> String <font color=Red>-&gt;</font> TextParser String+<a name="line-165"></a><font color=Blue>isWord</font> w <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font> w' <font color=Red>&lt;-</font> word+<a name="line-166"></a>              <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>+<a name="line-167"></a>              <font color=Cyan>}</font>+<a name="line-168"></a>+<a name="line-169"></a><a name="optionalParens"></a><font color=Blue>-- | Allow nested parens around an item.</font>+<a name="line-170"></a><font color=Blue>optionalParens</font> <font color=Red>::</font> TextParser a <font color=Red>-&gt;</font> TextParser a+<a name="line-171"></a><font color=Blue>optionalParens</font> p <font color=Red>=</font> parens False p+<a name="line-172"></a>+<a name="line-173"></a><a name="parens"></a><font color=Blue>-- | Allow nested parens around an item (one set required when Bool is True).</font>+<a name="line-174"></a><font color=Blue>parens</font> <font color=Red>::</font> Bool <font color=Red>-&gt;</font> TextParser a <font color=Red>-&gt;</font> TextParser a+<a name="line-175"></a><font color=Blue>parens</font> True  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> <font color=Cyan>(</font>parens False p<font color=Cyan>)</font>+<a name="line-176"></a><font color=Blue>parens</font> False p <font color=Red>=</font> parens True p <font color=Cyan>`onFail`</font> p+<a name="line-177"></a>+<a name="line-178"></a><a name="field"></a><font color=Blue>-- | Deal with named field syntax.  The string argument is the field name,</font>+<a name="line-179"></a><font color=Blue>--   and the parser returns the value of the field.</font>+<a name="line-180"></a><font color=Blue>field</font> <font color=Red>::</font> Parse a <font color=Red>=&gt;</font> String <font color=Red>-&gt;</font> TextParser a+<a name="line-181"></a><font color=Blue>field</font> 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>+<a name="line-182"></a>+<a name="line-183"></a><a name="constructors"></a><font color=Blue>-- | Parse one of a bunch of alternative constructors.  In the list argument,</font>+<a name="line-184"></a><font color=Blue>--   the first element of the pair is the constructor name, and</font>+<a name="line-185"></a><font color=Blue>--   the second is the parser for the rest of the value.  The first matching</font>+<a name="line-186"></a><font color=Blue>--   parse is returned.</font>+<a name="line-187"></a><font color=Blue>constructors</font> <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>-&gt;</font> TextParser a+<a name="line-188"></a><font color=Blue>constructors</font> cs <font color=Red>=</font> oneOf' <font color=Cyan>(</font>map cons cs<font color=Cyan>)</font>+<a name="line-189"></a>    <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>+<a name="line-190"></a>               <font color=Cyan>(</font> name+<a name="line-191"></a>               <font color=Cyan>,</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font> isWord name+<a name="line-192"></a>                    <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>+<a name="line-193"></a>                                        <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>+<a name="line-194"></a>                    <font color=Cyan>}</font>+<a name="line-195"></a>               <font color=Cyan>)</font>+<a name="line-196"></a>+<a name="line-197"></a><a name="enumeration"></a><font color=Blue>-- | Parse one of the given nullary constructors (an enumeration).</font>+<a name="line-198"></a><font color=Blue>--   The string argument is the name of the type, and the list argument</font>+<a name="line-199"></a><font color=Blue>--   should contain all of the possible enumeration values.</font>+<a name="line-200"></a><font color=Blue>enumeration</font> <font color=Red>::</font> <font color=Cyan>(</font>Show a<font color=Cyan>)</font> <font color=Red>=&gt;</font> String <font color=Red>-&gt;</font> <font color=Red>[</font>a<font color=Red>]</font> <font color=Red>-&gt;</font> TextParser a+<a name="line-201"></a><font color=Blue>enumeration</font> typ cs <font color=Red>=</font> oneOf <font color=Cyan>(</font>map <font color=Cyan>(</font><font color=Red>\</font>c<font color=Red>-&gt;</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>+<a name="line-202"></a>                         <font color=Cyan>`adjustErr`</font>+<a name="line-203"></a>                     <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>+<a name="line-204"></a>    <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>+<a name="line-205"></a>              <font color=Cyan>++</font> <font color=Magenta>", or "</font> <font color=Cyan>++</font> show <font color=Cyan>(</font>last cs<font color=Cyan>)</font>+<a name="line-206"></a>+<a name="line-207"></a><font color=Blue>------------------------------------------------------------------------</font>+<a name="line-208"></a><font color=Blue>-- Instances for all the Standard Prelude types.</font>+<a name="line-209"></a>+<a name="line-210"></a><a name="parseSigned"></a><font color=Blue>-- Numeric types</font>+<a name="line-211"></a><font color=Blue>parseSigned</font> <font color=Red>::</font> Real a <font color=Red>=&gt;</font> TextParser a <font color=Red>-&gt;</font> TextParser a+<a name="line-212"></a><font color=Blue>parseSigned</font> p <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Magenta>'-'</font> <font color=Red>&lt;-</font> next<font color=Cyan>;</font> commit <font color=Cyan>(</font>fmap negate p<font color=Cyan>)</font>+<a name="line-213"></a>                <font color=Cyan>`onFail`</font>+<a name="line-214"></a>                <font color=Green><u>do</u></font> p+<a name="line-215"></a>+<a name="line-216"></a><a name="parseInt"></a><font color=Blue>parseInt</font> <font color=Red>::</font> <font color=Cyan>(</font>Integral a<font color=Cyan>)</font> <font color=Red>=&gt;</font> String <font color=Red>-&gt;</font>+<a name="line-217"></a>                            a <font color=Red>-&gt;</font> <font color=Cyan>(</font>Char <font color=Red>-&gt;</font> Bool<font color=Cyan>)</font> <font color=Red>-&gt;</font> <font color=Cyan>(</font>Char <font color=Red>-&gt;</font> Int<font color=Cyan>)</font> <font color=Red>-&gt;</font>+<a name="line-218"></a>                            TextParser a+<a name="line-219"></a><font color=Blue>parseInt</font> base radix isDigit digitToInt <font color=Red>=</font>+<a name="line-220"></a>                 <font color=Green><u>do</u></font> cs <font color=Red>&lt;-</font> many1 <font color=Cyan>(</font>satisfy isDigit<font color=Cyan>)</font>+<a name="line-221"></a>                    return <font color=Cyan>(</font>foldl1 <font color=Cyan>(</font><font color=Red>\</font>n d<font color=Red>-&gt;</font> n<font color=Cyan>*</font>radix<font color=Cyan>+</font>d<font color=Cyan>)</font>+<a name="line-222"></a>                                   <font color=Cyan>(</font>map <font color=Cyan>(</font>fromIntegral<font color=Cyan>.</font>digitToInt<font color=Cyan>)</font> cs<font color=Cyan>)</font><font color=Cyan>)</font>+<a name="line-223"></a>                 <font color=Cyan>`adjustErr`</font> <font color=Cyan>(</font><font color=Cyan>++</font><font color=Cyan>(</font><font color=Magenta>"\nexpected one or more "</font><font color=Cyan>++</font>base<font color=Cyan>++</font><font color=Magenta>" digits"</font><font color=Cyan>)</font><font color=Cyan>)</font>+<a name="line-224"></a><a name="parseDec"></a><font color=Blue>parseDec</font><font color=Cyan>,</font> parseOct<font color=Cyan>,</font> parseHex <font color=Red>::</font> <font color=Cyan>(</font>Integral a<font color=Cyan>)</font> <font color=Red>=&gt;</font> TextParser a+<a name="line-225"></a><font color=Blue>parseDec</font> <font color=Red>=</font> parseInt <font color=Magenta>"decimal"</font> <font color=Magenta>10</font> Char<font color=Cyan>.</font>isDigit    Char<font color=Cyan>.</font>digitToInt+<a name="line-226"></a><a name="parseOct"></a><font color=Blue>parseOct</font> <font color=Red>=</font> parseInt <font color=Magenta>"octal"</font>    <font color=Magenta>8</font> Char<font color=Cyan>.</font>isOctDigit Char<font color=Cyan>.</font>digitToInt+<a name="line-227"></a><a name="parseHex"></a><font color=Blue>parseHex</font> <font color=Red>=</font> parseInt <font color=Magenta>"hex"</font>     <font color=Magenta>16</font> Char<font color=Cyan>.</font>isHexDigit Char<font color=Cyan>.</font>digitToInt+<a name="line-228"></a>+<a name="line-229"></a><a name="parseFloat"></a><font color=Blue>parseFloat</font> <font color=Red>::</font> <font color=Cyan>(</font>RealFrac a<font color=Cyan>)</font> <font color=Red>=&gt;</font> TextParser a+<a name="line-230"></a><font color=Blue>parseFloat</font> <font color=Red>=</font> <font color=Green><u>do</u></font> ds   <font color=Red>&lt;-</font> many1 <font color=Cyan>(</font>satisfy isDigit<font color=Cyan>)</font>+<a name="line-231"></a>                frac <font color=Red>&lt;-</font> <font color=Cyan>(</font><font color=Green><u>do</u></font> <font color=Magenta>'.'</font> <font color=Red>&lt;-</font> next+<a name="line-232"></a>                            many <font color=Cyan>(</font>satisfy isDigit<font color=Cyan>)</font>+<a name="line-233"></a>                              <font color=Cyan>`adjustErrBad`</font> <font color=Cyan>(</font><font color=Cyan>++</font><font color=Magenta>"expected digit after ."</font><font color=Cyan>)</font>+<a name="line-234"></a>                         <font color=Cyan>`onFail`</font> return [] <font color=Cyan>)</font>+<a name="line-235"></a>                exp  <font color=Red>&lt;-</font> exponent <font color=Cyan>`onFail`</font> return <font color=Magenta>0</font>+<a name="line-236"></a>                <font color=Cyan>(</font> return <font color=Cyan>.</font> fromRational <font color=Cyan>.</font> <font color=Cyan>(</font><font color=Cyan>*</font> <font color=Cyan>(</font><font color=Magenta>10</font><font color=Cyan>^^</font><font color=Cyan>(</font>exp <font color=Blue>-</font> length frac<font color=Cyan>)</font><font color=Cyan>)</font><font color=Cyan>)</font>+<a name="line-237"></a>                  <font color=Cyan>.</font> <font color=Cyan>(</font><font color=Cyan>%</font><font color=Magenta>1</font><font color=Cyan>)</font> <font color=Cyan>.</font>  <font color=Cyan>(</font><font color=Red>\</font> <font color=Cyan>(</font>Right x<font color=Cyan>)</font><font color=Red>-&gt;</font>x<font color=Cyan>)</font> <font color=Cyan>.</font> fst+<a name="line-238"></a>                  <font color=Cyan>.</font> runParser parseDec <font color=Cyan>)</font> <font color=Cyan>(</font>ds<font color=Cyan>++</font>frac<font color=Cyan>)</font>+<a name="line-239"></a>             <font color=Cyan>`onFail`</font>+<a name="line-240"></a>             <font color=Green><u>do</u></font> w <font color=Red>&lt;-</font> many <font color=Cyan>(</font>satisfy <font color=Cyan>(</font>not<font color=Cyan>.</font>isSpace<font color=Cyan>)</font><font color=Cyan>)</font>+<a name="line-241"></a>                <font color=Green><u>case</u></font> map toLower w <font color=Green><u>of</u></font>+<a name="line-242"></a>                  <font color=Magenta>"nan"</font>      <font color=Red>-&gt;</font> return <font color=Cyan>(</font><font color=Magenta>0</font><font color=Cyan>/</font><font color=Magenta>0</font><font color=Cyan>)</font>+<a name="line-243"></a>                  <font color=Magenta>"infinity"</font> <font color=Red>-&gt;</font> return <font color=Cyan>(</font><font color=Magenta>1</font><font color=Cyan>/</font><font color=Magenta>0</font><font color=Cyan>)</font>+<a name="line-244"></a>                  <font color=Green><u>_</u></font>          <font color=Red>-&gt;</font> fail <font color=Magenta>"expected a floating point number"</font>+<a name="line-245"></a>  <font color=Green><u>where</u></font> exponent <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Magenta>'e'</font> <font color=Red>&lt;-</font> fmap toLower next+<a name="line-246"></a>                      commit <font color=Cyan>(</font><font color=Green><u>do</u></font> <font color=Magenta>'+'</font> <font color=Red>&lt;-</font> next<font color=Cyan>;</font> parseDec+<a name="line-247"></a>                              <font color=Cyan>`onFail`</font>+<a name="line-248"></a>                              parseSigned parseDec <font color=Cyan>)</font>+<a name="line-249"></a>+<a name="line-250"></a><a name="parseLitChar"></a><font color=Blue>parseLitChar</font> <font color=Red>::</font> TextParser Char+<a name="line-251"></a><font color=Blue>parseLitChar</font> <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Magenta>'\''</font> <font color=Red>&lt;-</font> next <font color=Cyan>`adjustErr`</font> <font color=Cyan>(</font><font color=Cyan>++</font><font color=Magenta>"expected a literal char"</font><font color=Cyan>)</font>+<a name="line-252"></a>                  c <font color=Red>&lt;-</font> next+<a name="line-253"></a>                  char <font color=Red>&lt;-</font> <font color=Green><u>case</u></font> c <font color=Green><u>of</u></font>+<a name="line-254"></a>                            <font color=Magenta>'\\'</font> <font color=Red>-&gt;</font> next <font color=Cyan>&gt;&gt;=</font> escape+<a name="line-255"></a>                            <font color=Magenta>'\''</font> <font color=Red>-&gt;</font> fail <font color=Magenta>"expected a literal char, got ''"</font>+<a name="line-256"></a>                            <font color=Green><u>_</u></font>    <font color=Red>-&gt;</font> return c+<a name="line-257"></a>                  <font color=Magenta>'\''</font> <font color=Red>&lt;-</font> next <font color=Cyan>`adjustErrBad`</font> <font color=Cyan>(</font><font color=Cyan>++</font><font color=Magenta>"literal char has no final '"</font><font color=Cyan>)</font>+<a name="line-258"></a>                  return char+<a name="line-259"></a>  <font color=Green><u>where</u></font>+<a name="line-260"></a>    escape <font color=Magenta>'a'</font>  <font color=Red>=</font> return <font color=Magenta>'\a'</font>+<a name="line-261"></a>    escape <font color=Magenta>'b'</font>  <font color=Red>=</font> return <font color=Magenta>'\b'</font>+<a name="line-262"></a>    escape <font color=Magenta>'f'</font>  <font color=Red>=</font> return <font color=Magenta>'\f'</font>+<a name="line-263"></a>    escape <font color=Magenta>'n'</font>  <font color=Red>=</font> return <font color=Magenta>'\n'</font>+<a name="line-264"></a>    escape <font color=Magenta>'r'</font>  <font color=Red>=</font> return <font color=Magenta>'\r'</font>+<a name="line-265"></a>    escape <font color=Magenta>'t'</font>  <font color=Red>=</font> return <font color=Magenta>'\t'</font>+<a name="line-266"></a>    escape <font color=Magenta>'v'</font>  <font color=Red>=</font> return <font color=Magenta>'\v'</font>+<a name="line-267"></a>    escape <font color=Magenta>'\\'</font> <font color=Red>=</font> return <font color=Magenta>'\\'</font>+<a name="line-268"></a>    escape <font color=Magenta>'"'</font>  <font color=Red>=</font> return <font color=Magenta>'"'</font>+<a name="line-269"></a>    escape <font color=Magenta>'\''</font> <font color=Red>=</font> return <font color=Magenta>'\''</font>+<a name="line-270"></a>    escape <font color=Magenta>'^'</font>  <font color=Red>=</font> <font color=Green><u>do</u></font> ctrl <font color=Red>&lt;-</font> next+<a name="line-271"></a>                     <font color=Green><u>if</u></font> ctrl <font color=Cyan>&gt;=</font> <font color=Magenta>'@'</font> <font color=Cyan>&amp;&amp;</font> ctrl <font color=Cyan>&lt;=</font> <font color=Magenta>'_'</font>+<a name="line-272"></a>                       <font color=Green><u>then</u></font> return <font color=Cyan>(</font>chr <font color=Cyan>(</font>ord ctrl <font color=Blue>-</font> ord <font color=Magenta>'@'</font><font color=Cyan>)</font><font color=Cyan>)</font>+<a name="line-273"></a>                       <font color=Green><u>else</u></font> fail <font color=Cyan>(</font><font color=Magenta>"literal char ctrl-escape malformed: \\^"</font>+<a name="line-274"></a>                                   <font color=Cyan>++</font><font color=Red>[</font>ctrl<font color=Red>]</font><font color=Cyan>)</font>+<a name="line-275"></a>    escape d <font color=Red>|</font> isDigit d+<a name="line-276"></a>                <font color=Red>=</font> fmap chr <font color=Cyan>$</font>  <font color=Cyan>(</font>reparse <font color=Red>[</font>d<font color=Red>]</font> <font color=Cyan>&gt;&gt;</font> parseDec<font color=Cyan>)</font>+<a name="line-277"></a>    escape <font color=Magenta>'o'</font>  <font color=Red>=</font> fmap chr <font color=Cyan>$</font>  parseOct+<a name="line-278"></a>    escape <font color=Magenta>'x'</font>  <font color=Red>=</font> fmap chr <font color=Cyan>$</font>  parseHex+<a name="line-279"></a>    escape c <font color=Red>|</font> isUpper c+<a name="line-280"></a>                <font color=Red>=</font> mnemonic c+<a name="line-281"></a>    escape c    <font color=Red>=</font> fail <font color=Cyan>(</font><font color=Magenta>"unrecognised escape sequence in literal char: \\"</font><font color=Cyan>++</font><font color=Red>[</font>c<font color=Red>]</font><font color=Cyan>)</font>+<a name="line-282"></a>+<a name="line-283"></a>    mnemonic <font color=Magenta>'A'</font> <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Magenta>'C'</font> <font color=Red>&lt;-</font> next<font color=Cyan>;</font> <font color=Magenta>'K'</font> <font color=Red>&lt;-</font> next<font color=Cyan>;</font> return <font color=Magenta>'\ACK'</font>+<a name="line-284"></a>                   <font color=Cyan>`wrap`</font> <font color=Magenta>"'\\ACK'"</font>+<a name="line-285"></a>    mnemonic <font color=Magenta>'B'</font> <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Magenta>'E'</font> <font color=Red>&lt;-</font> next<font color=Cyan>;</font> <font color=Magenta>'L'</font> <font color=Red>&lt;-</font> next<font color=Cyan>;</font> return <font color=Magenta>'\BEL'</font>+<a name="line-286"></a>                   <font color=Cyan>`onFail`</font>+<a name="line-287"></a>                   <font color=Green><u>do</u></font> <font color=Magenta>'S'</font> <font color=Red>&lt;-</font> next<font color=Cyan>;</font> return <font color=Magenta>'\BS'</font>+<a name="line-288"></a>                   <font color=Cyan>`wrap`</font> <font color=Magenta>"'\\BEL' or '\\BS'"</font>+<a name="line-289"></a>    mnemonic <font color=Magenta>'C'</font> <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Magenta>'R'</font> <font color=Red>&lt;-</font> next<font color=Cyan>;</font> return <font color=Magenta>'\CR'</font>+<a name="line-290"></a>                   <font color=Cyan>`onFail`</font>+<a name="line-291"></a>                   <font color=Green><u>do</u></font> <font color=Magenta>'A'</font> <font color=Red>&lt;-</font> next<font color=Cyan>;</font> <font color=Magenta>'N'</font> <font color=Red>&lt;-</font> next<font color=Cyan>;</font> return <font color=Magenta>'\CAN'</font>+<a name="line-292"></a>                   <font color=Cyan>`wrap`</font> <font color=Magenta>"'\\CR' or '\\CAN'"</font>+<a name="line-293"></a>    mnemonic <font color=Magenta>'D'</font> <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Magenta>'E'</font> <font color=Red>&lt;-</font> next<font color=Cyan>;</font> <font color=Magenta>'L'</font> <font color=Red>&lt;-</font> next<font color=Cyan>;</font> return <font color=Magenta>'\DEL'</font>+<a name="line-294"></a>                   <font color=Cyan>`onFail`</font>+<a name="line-295"></a>                   <font color=Green><u>do</u></font> <font color=Magenta>'L'</font> <font color=Red>&lt;-</font> next<font color=Cyan>;</font> <font color=Magenta>'E'</font> <font color=Red>&lt;-</font> next<font color=Cyan>;</font> return <font color=Magenta>'\DLE'</font>+<a name="line-296"></a>                   <font color=Cyan>`onFail`</font>+<a name="line-297"></a>                   <font color=Green><u>do</u></font> <font color=Magenta>'C'</font> <font color=Red>&lt;-</font> next<font color=Cyan>;</font> <font color=Cyan>(</font> <font color=Green><u>do</u></font> <font color=Magenta>'1'</font> <font color=Red>&lt;-</font> next<font color=Cyan>;</font> return <font color=Magenta>'\DC1'</font>+<a name="line-298"></a>                                     <font color=Cyan>`onFail`</font>+<a name="line-299"></a>                                     <font color=Green><u>do</u></font> <font color=Magenta>'2'</font> <font color=Red>&lt;-</font> next<font color=Cyan>;</font> return <font color=Magenta>'\DC2'</font>+<a name="line-300"></a>                                     <font color=Cyan>`onFail`</font>+<a name="line-301"></a>                                     <font color=Green><u>do</u></font> <font color=Magenta>'3'</font> <font color=Red>&lt;-</font> next<font color=Cyan>;</font> return <font color=Magenta>'\DC3'</font>+<a name="line-302"></a>                                     <font color=Cyan>`onFail`</font>+<a name="line-303"></a>                                     <font color=Green><u>do</u></font> <font color=Magenta>'4'</font> <font color=Red>&lt;-</font> next<font color=Cyan>;</font> return <font color=Magenta>'\DC4'</font> <font color=Cyan>)</font>+<a name="line-304"></a>                   <font color=Cyan>`wrap`</font> <font color=Magenta>"'\\DEL' or '\\DLE' or '\\DC[1..4]'"</font>+<a name="line-305"></a>    mnemonic <font color=Magenta>'E'</font> <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Magenta>'T'</font> <font color=Red>&lt;-</font> next<font color=Cyan>;</font> <font color=Magenta>'X'</font> <font color=Red>&lt;-</font> next<font color=Cyan>;</font> return <font color=Magenta>'\ETX'</font>+<a name="line-306"></a>                   <font color=Cyan>`onFail`</font>+<a name="line-307"></a>                   <font color=Green><u>do</u></font> <font color=Magenta>'O'</font> <font color=Red>&lt;-</font> next<font color=Cyan>;</font> <font color=Magenta>'T'</font> <font color=Red>&lt;-</font> next<font color=Cyan>;</font> return <font color=Magenta>'\EOT'</font>+<a name="line-308"></a>                   <font color=Cyan>`onFail`</font>+<a name="line-309"></a>                   <font color=Green><u>do</u></font> <font color=Magenta>'N'</font> <font color=Red>&lt;-</font> next<font color=Cyan>;</font> <font color=Magenta>'Q'</font> <font color=Red>&lt;-</font> next<font color=Cyan>;</font> return <font color=Magenta>'\ENQ'</font>+<a name="line-310"></a>                   <font color=Cyan>`onFail`</font>+<a name="line-311"></a>                   <font color=Green><u>do</u></font> <font color=Magenta>'T'</font> <font color=Red>&lt;-</font> next<font color=Cyan>;</font> <font color=Magenta>'B'</font> <font color=Red>&lt;-</font> next<font color=Cyan>;</font> return <font color=Magenta>'\ETB'</font>+<a name="line-312"></a>                   <font color=Cyan>`onFail`</font>+<a name="line-313"></a>                   <font color=Green><u>do</u></font> <font color=Magenta>'M'</font> <font color=Red>&lt;-</font> next<font color=Cyan>;</font> return <font color=Magenta>'\EM'</font>+<a name="line-314"></a>                   <font color=Cyan>`onFail`</font>+<a name="line-315"></a>                   <font color=Green><u>do</u></font> <font color=Magenta>'S'</font> <font color=Red>&lt;-</font> next<font color=Cyan>;</font> <font color=Magenta>'C'</font> <font color=Red>&lt;-</font> next<font color=Cyan>;</font> return <font color=Magenta>'\ESC'</font>+<a name="line-316"></a>                   <font color=Cyan>`wrap`</font> <font color=Magenta>"one of '\\ETX' '\\EOT' '\\ENQ' '\\ETB' '\\EM' or '\\ESC'"</font>+<a name="line-317"></a>    mnemonic <font color=Magenta>'F'</font> <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Magenta>'F'</font> <font color=Red>&lt;-</font> next<font color=Cyan>;</font> return <font color=Magenta>'\FF'</font>+<a name="line-318"></a>                   <font color=Cyan>`onFail`</font>+<a name="line-319"></a>                   <font color=Green><u>do</u></font> <font color=Magenta>'S'</font> <font color=Red>&lt;-</font> next<font color=Cyan>;</font> return <font color=Magenta>'\FS'</font>+<a name="line-320"></a>                   <font color=Cyan>`wrap`</font> <font color=Magenta>"'\\FF' or '\\FS'"</font>+<a name="line-321"></a>    mnemonic <font color=Magenta>'G'</font> <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Magenta>'S'</font> <font color=Red>&lt;-</font> next<font color=Cyan>;</font> return <font color=Magenta>'\GS'</font>+<a name="line-322"></a>                   <font color=Cyan>`wrap`</font> <font color=Magenta>"'\\GS'"</font>+<a name="line-323"></a>    mnemonic <font color=Magenta>'H'</font> <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Magenta>'T'</font> <font color=Red>&lt;-</font> next<font color=Cyan>;</font> return <font color=Magenta>'\HT'</font>+<a name="line-324"></a>                   <font color=Cyan>`wrap`</font> <font color=Magenta>"'\\HT'"</font>+<a name="line-325"></a>    mnemonic <font color=Magenta>'L'</font> <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Magenta>'F'</font> <font color=Red>&lt;-</font> next<font color=Cyan>;</font> return <font color=Magenta>'\LF'</font>+<a name="line-326"></a>                   <font color=Cyan>`wrap`</font> <font color=Magenta>"'\\LF'"</font>+<a name="line-327"></a>    mnemonic <font color=Magenta>'N'</font> <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Magenta>'U'</font> <font color=Red>&lt;-</font> next<font color=Cyan>;</font> <font color=Magenta>'L'</font> <font color=Red>&lt;-</font> next<font color=Cyan>;</font> return <font color=Magenta>'\NUL'</font>+<a name="line-328"></a>                   <font color=Cyan>`onFail`</font>+<a name="line-329"></a>                   <font color=Green><u>do</u></font> <font color=Magenta>'A'</font> <font color=Red>&lt;-</font> next<font color=Cyan>;</font> <font color=Magenta>'K'</font> <font color=Red>&lt;-</font> next<font color=Cyan>;</font> return <font color=Magenta>'\NAK'</font>+<a name="line-330"></a>                   <font color=Cyan>`wrap`</font> <font color=Magenta>"'\\NUL' or '\\NAK'"</font>+<a name="line-331"></a>    mnemonic <font color=Magenta>'R'</font> <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Magenta>'S'</font> <font color=Red>&lt;-</font> next<font color=Cyan>;</font> return <font color=Magenta>'\RS'</font>+<a name="line-332"></a>                   <font color=Cyan>`wrap`</font> <font color=Magenta>"'\\RS'"</font>+<a name="line-333"></a>    mnemonic <font color=Magenta>'S'</font> <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Magenta>'O'</font> <font color=Red>&lt;-</font> next<font color=Cyan>;</font> <font color=Magenta>'H'</font> <font color=Red>&lt;-</font> next<font color=Cyan>;</font> return <font color=Magenta>'\SOH'</font>+<a name="line-334"></a>                   <font color=Cyan>`onFail`</font>+<a name="line-335"></a>                   <font color=Green><u>do</u></font> <font color=Magenta>'O'</font> <font color=Red>&lt;-</font> next<font color=Cyan>;</font> return <font color=Magenta>'\SO'</font>+<a name="line-336"></a>                   <font color=Cyan>`onFail`</font>+<a name="line-337"></a>                   <font color=Green><u>do</u></font> <font color=Magenta>'T'</font> <font color=Red>&lt;-</font> next<font color=Cyan>;</font> <font color=Magenta>'X'</font> <font color=Red>&lt;-</font> next<font color=Cyan>;</font> return <font color=Magenta>'\STX'</font>+<a name="line-338"></a>                   <font color=Cyan>`onFail`</font>+<a name="line-339"></a>                   <font color=Green><u>do</u></font> <font color=Magenta>'I'</font> <font color=Red>&lt;-</font> next<font color=Cyan>;</font> return <font color=Magenta>'\SI'</font>+<a name="line-340"></a>                   <font color=Cyan>`onFail`</font>+<a name="line-341"></a>                   <font color=Green><u>do</u></font> <font color=Magenta>'Y'</font> <font color=Red>&lt;-</font> next<font color=Cyan>;</font> <font color=Magenta>'N'</font> <font color=Red>&lt;-</font> next<font color=Cyan>;</font> return <font color=Magenta>'\SYN'</font>+<a name="line-342"></a>                   <font color=Cyan>`onFail`</font>+<a name="line-343"></a>                   <font color=Green><u>do</u></font> <font color=Magenta>'U'</font> <font color=Red>&lt;-</font> next<font color=Cyan>;</font> <font color=Magenta>'B'</font> <font color=Red>&lt;-</font> next<font color=Cyan>;</font> return <font color=Magenta>'\SUB'</font>+<a name="line-344"></a>                   <font color=Cyan>`onFail`</font>+<a name="line-345"></a>                   <font color=Green><u>do</u></font> <font color=Magenta>'P'</font> <font color=Red>&lt;-</font> next<font color=Cyan>;</font> return <font color=Magenta>'\SP'</font>+<a name="line-346"></a>                   <font color=Cyan>`wrap`</font> <font color=Magenta>"'\\SOH' '\\SO' '\\STX' '\\SI' '\\SYN' '\\SUB' or '\\SP'"</font>+<a name="line-347"></a>    mnemonic <font color=Magenta>'U'</font> <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Magenta>'S'</font> <font color=Red>&lt;-</font> next<font color=Cyan>;</font> return <font color=Magenta>'\US'</font>+<a name="line-348"></a>                   <font color=Cyan>`wrap`</font> <font color=Magenta>"'\\US'"</font>+<a name="line-349"></a>    mnemonic <font color=Magenta>'V'</font> <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Magenta>'T'</font> <font color=Red>&lt;-</font> next<font color=Cyan>;</font> return <font color=Magenta>'\VT'</font>+<a name="line-350"></a>                   <font color=Cyan>`wrap`</font> <font color=Magenta>"'\\VT'"</font>+<a name="line-351"></a>    wrap p s <font color=Red>=</font> p <font color=Cyan>`onFail`</font> fail <font color=Cyan>(</font><font color=Magenta>"expected literal char "</font><font color=Cyan>++</font>s<font color=Cyan>)</font>+<a name="line-352"></a>+<a name="line-353"></a><font color=Blue>-- Basic types</font>+<a name="line-354"></a><font color=Green><u>instance</u></font> Parse Int <font color=Green><u>where</u></font>+<a name="line-355"></a> <font color=Blue>-- parse = parseByRead "Int"	-- convert from Integer, deals with minInt</font>+<a name="line-356"></a>    parse <font color=Red>=</font> fmap fromInteger <font color=Cyan>$</font>+<a name="line-357"></a>              <font color=Green><u>do</u></font> many <font color=Cyan>(</font>satisfy isSpace<font color=Cyan>)</font><font color=Cyan>;</font> parseSigned parseDec+<a name="line-358"></a><font color=Green><u>instance</u></font> Parse Integer <font color=Green><u>where</u></font>+<a name="line-359"></a> <font color=Blue>-- parse = parseByRead "Integer"</font>+<a name="line-360"></a>    parse <font color=Red>=</font> <font color=Green><u>do</u></font> many <font color=Cyan>(</font>satisfy isSpace<font color=Cyan>)</font><font color=Cyan>;</font> parseSigned parseDec+<a name="line-361"></a><font color=Green><u>instance</u></font> Parse Float <font color=Green><u>where</u></font>+<a name="line-362"></a> <font color=Blue>-- parse = parseByRead "Float"</font>+<a name="line-363"></a>    parse <font color=Red>=</font> <font color=Green><u>do</u></font> many <font color=Cyan>(</font>satisfy isSpace<font color=Cyan>)</font><font color=Cyan>;</font> parseSigned parseFloat+<a name="line-364"></a><font color=Green><u>instance</u></font> Parse Double <font color=Green><u>where</u></font>+<a name="line-365"></a> <font color=Blue>-- parse = parseByRead "Double"</font>+<a name="line-366"></a>    parse <font color=Red>=</font> <font color=Green><u>do</u></font> many <font color=Cyan>(</font>satisfy isSpace<font color=Cyan>)</font><font color=Cyan>;</font> parseSigned parseFloat+<a name="line-367"></a><font color=Green><u>instance</u></font> Parse Char <font color=Green><u>where</u></font>+<a name="line-368"></a><font color=Blue>--  parse = parseByRead "Char"</font>+<a name="line-369"></a>    parse <font color=Red>=</font> <font color=Green><u>do</u></font> many <font color=Cyan>(</font>satisfy isSpace<font color=Cyan>)</font><font color=Cyan>;</font> parseLitChar+<a name="line-370"></a> <font color=Blue>-- parse = do { w &lt;- word; if head w == '\'' then readLitChar (tail w)</font>+<a name="line-371"></a> <font color=Blue>--                                           else fail "expected a char" }</font>+<a name="line-372"></a> <font color=Blue>-- parseList = bracket (isWord "\"") (satisfy (=='"'))</font>+<a name="line-373"></a> <font color=Blue>--                     (many (satisfy (/='"')))</font>+<a name="line-374"></a>	<font color=Blue>-- not totally correct for strings...</font>+<a name="line-375"></a>    parseList <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font> w <font color=Red>&lt;-</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 <font color=Cyan>(</font>init <font color=Cyan>(</font>tail w<font color=Cyan>)</font><font color=Cyan>)</font>+<a name="line-376"></a>                                <font color=Green><u>else</u></font> fail <font color=Magenta>"not a string"</font> <font color=Cyan>}</font>+<a name="line-377"></a>+<a name="line-378"></a><font color=Green><u>instance</u></font> Parse Bool <font color=Green><u>where</u></font>+<a name="line-379"></a>    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>+<a name="line-380"></a>+<a name="line-381"></a><font color=Green><u>instance</u></font> Parse Ordering <font color=Green><u>where</u></font>+<a name="line-382"></a>    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>+<a name="line-383"></a>+<a name="line-384"></a><font color=Blue>-- Structural types</font>+<a name="line-385"></a><font color=Green><u>instance</u></font> Parse () <font color=Green><u>where</u></font>+<a name="line-386"></a>    parse <font color=Red>=</font> P p+<a name="line-387"></a>      <font color=Green><u>where</u></font> p []       <font color=Red>=</font> Failure [] <font color=Magenta>"no input: expected a ()"</font>+<a name="line-388"></a>            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>+<a name="line-389"></a>                             <font color=Cyan>(</font><font color=Magenta>')'</font><font color=Red><b>:</b></font>s<font color=Cyan>)</font> <font color=Red>-&gt;</font> Success s ()+<a name="line-390"></a>                             <font color=Green><u>_</u></font>       <font color=Red>-&gt;</font> Failure cs <font color=Magenta>"Expected ) after ("</font>+<a name="line-391"></a>            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+<a name="line-392"></a>                     <font color=Red>|</font> otherwise <font color=Red>=</font> Failure <font color=Cyan>(</font>c<font color=Red><b>:</b></font>cs<font color=Cyan>)</font> <font color=Cyan>(</font><font color=Magenta>"Expected a (), got "</font><font color=Cyan>++</font>show c<font color=Cyan>)</font>+<a name="line-393"></a>+<a name="line-394"></a><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>=&gt;</font> Parse <font color=Cyan>(</font>a<font color=Cyan>,</font>b<font color=Cyan>)</font> <font color=Green><u>where</u></font>+<a name="line-395"></a>    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>+<a name="line-396"></a>              <font color=Cyan>;</font> x <font color=Red>&lt;-</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>+<a name="line-397"></a>              <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>+<a name="line-398"></a>              <font color=Cyan>;</font> y <font color=Red>&lt;-</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>+<a name="line-399"></a>              <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>+<a name="line-400"></a>              <font color=Cyan>;</font> return <font color=Cyan>(</font>x<font color=Cyan>,</font>y<font color=Cyan>)</font> <font color=Cyan>}</font>+<a name="line-401"></a>+<a name="line-402"></a><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>=&gt;</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>+<a name="line-403"></a>    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>+<a name="line-404"></a>              <font color=Cyan>;</font> x <font color=Red>&lt;-</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>+<a name="line-405"></a>              <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>+<a name="line-406"></a>              <font color=Cyan>;</font> y <font color=Red>&lt;-</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>+<a name="line-407"></a>              <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>+<a name="line-408"></a>              <font color=Cyan>;</font> z <font color=Red>&lt;-</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>+<a name="line-409"></a>              <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>+<a name="line-410"></a>              <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>+<a name="line-411"></a>+<a name="line-412"></a><font color=Green><u>instance</u></font> Parse a <font color=Red>=&gt;</font> Parse <font color=Cyan>(</font>Maybe a<font color=Cyan>)</font> <font color=Green><u>where</u></font>+<a name="line-413"></a>    parsePrec p <font color=Red>=</font>+<a name="line-414"></a>            optionalParens <font color=Cyan>(</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>)</font>+<a name="line-415"></a>            <font color=Cyan>`onFail`</font>+<a name="line-416"></a>            parens <font color=Cyan>(</font>p<font color=Cyan>&gt;</font><font color=Magenta>9</font><font color=Cyan>)</font>   <font color=Cyan>(</font><font color=Green><u>do</u></font> <font color=Cyan>{</font> isWord <font color=Magenta>"Just"</font>+<a name="line-417"></a>                               <font color=Cyan>;</font> fmap Just <font color=Cyan>$</font> parsePrec <font color=Magenta>10</font>+<a name="line-418"></a>                                     <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>)</font>+<a name="line-419"></a>            <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>+<a name="line-420"></a>+<a name="line-421"></a><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>=&gt;</font> Parse <font color=Cyan>(</font>Either a b<font color=Cyan>)</font> <font color=Green><u>where</u></font>+<a name="line-422"></a>    parsePrec p <font color=Red>=</font>+<a name="line-423"></a>            parens <font color=Cyan>(</font>p<font color=Cyan>&gt;</font><font color=Magenta>9</font><font color=Cyan>)</font> <font color=Cyan>$</font>+<a name="line-424"></a>            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> parsePrec <font color=Magenta>10</font> <font color=Cyan>}</font> <font color=Cyan>)</font>+<a name="line-425"></a>                         <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> parsePrec <font color=Magenta>10</font> <font color=Cyan>}</font> <font color=Cyan>)</font>+<a name="line-426"></a>                         <font color=Red>]</font>+<a name="line-427"></a>+<a name="line-428"></a><font color=Green><u>instance</u></font> Parse a <font color=Red>=&gt;</font> Parse <font color=Red>[</font>a<font color=Red>]</font> <font color=Green><u>where</u></font>+<a name="line-429"></a>    parse <font color=Red>=</font> parseList+<a name="line-430"></a>+<a name="line-431"></a><font color=Blue>------------------------------------------------------------------------</font>+</pre>+</html>
+ docs/haddock/src/Text/Parse/ByteString.html view
@@ -0,0 +1,412 @@+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">+<html>+<pre><a name="line-1"></a><font color=Green><u>module</u></font> Text<font color=Cyan>.</font>Parse<font color=Cyan>.</font>ByteString+<a name="line-2"></a>  <font color=Cyan>(</font> <font color=Blue>-- * The Parse class is a replacement for the standard Read class. </font>+<a name="line-3"></a>    <font color=Blue>--   This particular instance reads from ByteString rather than String.</font>+<a name="line-4"></a>    <font color=Blue>-- $parser</font>+<a name="line-5"></a>    TextParser	<font color=Blue>-- synonym for Text.ParserCombinators.Poly.ByteString</font>+<a name="line-6"></a>  <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>+<a name="line-7"></a>		<font color=Blue>--            Int, Integer, Float, Double, Char, Bool</font>+<a name="line-8"></a>  <font color=Cyan>,</font> parseByRead	<font color=Blue>-- :: Read a =&gt; String -&gt; TextParser a</font>+<a name="line-9"></a>  <font color=Cyan>,</font> readByParse <font color=Blue>-- :: TextParser a -&gt; ReadS a</font>+<a name="line-10"></a>  <font color=Cyan>,</font> readsPrecByParsePrec <font color=Blue>-- :: (Int-&gt;TextParser a) -&gt; Int -&gt; ReadS a</font>+<a name="line-11"></a>    <font color=Blue>-- ** Combinators specific to string input, lexed haskell-style</font>+<a name="line-12"></a>  <font color=Cyan>,</font> word	<font color=Blue>-- :: TextParser String</font>+<a name="line-13"></a>  <font color=Cyan>,</font> isWord	<font color=Blue>-- :: String -&gt; TextParser ()</font>+<a name="line-14"></a>  <font color=Cyan>,</font> optionalParens	<font color=Blue>-- :: TextParser a -&gt; TextParser a</font>+<a name="line-15"></a>  <font color=Cyan>,</font> parens	<font color=Blue>-- :: Bool -&gt; TextParser a -&gt; TextParser a</font>+<a name="line-16"></a>  <font color=Cyan>,</font> field	<font color=Blue>-- :: Parse a =&gt; String -&gt; TextParser a</font>+<a name="line-17"></a>  <font color=Cyan>,</font> constructors<font color=Blue>-- :: [(String,TextParser a)] -&gt; TextParser a</font>+<a name="line-18"></a>  <font color=Cyan>,</font> enumeration <font color=Blue>-- :: Show a =&gt; String -&gt; [a] -&gt; TextParser a</font>+<a name="line-19"></a>    <font color=Blue>-- ** Parsers for literal numerics and characters</font>+<a name="line-20"></a>  <font color=Cyan>,</font> parseSigned+<a name="line-21"></a>  <font color=Cyan>,</font> parseInt+<a name="line-22"></a>  <font color=Cyan>,</font> parseDec+<a name="line-23"></a>  <font color=Cyan>,</font> parseOct+<a name="line-24"></a>  <font color=Cyan>,</font> parseHex+<a name="line-25"></a>  <font color=Cyan>,</font> parseUnsignedInteger+<a name="line-26"></a>  <font color=Cyan>,</font> parseFloat+<a name="line-27"></a>  <font color=Cyan>,</font> parseLitChar+<a name="line-28"></a>    <font color=Blue>-- ** Re-export all the more general combinators from Poly too</font>+<a name="line-29"></a>  <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>ByteString+<a name="line-30"></a>    <font color=Blue>-- ** ByteStrings and Strings as whole entities</font>+<a name="line-31"></a>  <font color=Cyan>,</font> allAsByteString+<a name="line-32"></a>  <font color=Cyan>,</font> allAsString+<a name="line-33"></a>  <font color=Cyan>)</font> <font color=Green><u>where</u></font>+<a name="line-34"></a>+<a name="line-35"></a><font color=Green><u>import</u></font> Char <font color=Cyan>(</font>isSpace<font color=Cyan>,</font>toLower<font color=Cyan>,</font>isUpper<font color=Cyan>,</font>isDigit<font color=Cyan>,</font>isOctDigit<font color=Cyan>,</font>isHexDigit<font color=Cyan>,</font>digitToInt+<a name="line-36"></a>            <font color=Cyan>,</font>ord<font color=Cyan>,</font>chr<font color=Cyan>)</font>+<a name="line-37"></a><font color=Green><u>import</u></font> List <font color=Cyan>(</font>intersperse<font color=Cyan>)</font>+<a name="line-38"></a><font color=Green><u>import</u></font> Ratio+<a name="line-39"></a><font color=Green><u>import</u></font> <font color=Green><u>qualified</u></font> Data<font color=Cyan>.</font>ByteString<font color=Cyan>.</font>Lazy<font color=Cyan>.</font>Char8 <font color=Green><u>as</u></font> BS+<a name="line-40"></a><font color=Green><u>import</u></font> Data<font color=Cyan>.</font>ByteString<font color=Cyan>.</font>Lazy<font color=Cyan>.</font>Char8 <font color=Cyan>(</font>ByteString<font color=Cyan>)</font>+<a name="line-41"></a><font color=Green><u>import</u></font> Text<font color=Cyan>.</font>ParserCombinators<font color=Cyan>.</font>Poly<font color=Cyan>.</font>ByteString+<a name="line-42"></a>+<a name="line-43"></a><font color=Blue>------------------------------------------------------------------------</font>+<a name="line-44"></a><font color=Blue>-- $parser</font>+<a name="line-45"></a><font color=Blue>-- The Parse class is a replacement for the standard Read class.  It is a</font>+<a name="line-46"></a><font color=Blue>-- specialisation of the (poly) Parser monad for ByteString input.</font>+<a name="line-47"></a><font color=Blue>-- There are instances defined for all Prelude types.</font>+<a name="line-48"></a><font color=Blue>-- For user-defined types, you can write your own instance, or use</font>+<a name="line-49"></a><font color=Blue>-- DrIFT to generate them automatically, e.g. {-! derive : Parse !-}</font>+<a name="line-50"></a>+<a name="line-51"></a><a name="TextParser"></a><font color=Blue>-- | A synonym for a ByteString Parser, i.e. bytestring input (no state)</font>+<a name="line-52"></a><a name="TextParser"></a><font color=Green><u>type</u></font> TextParser a <font color=Red>=</font> Parser a+<a name="line-53"></a>+<a name="line-54"></a><a name="Parse"></a><font color=Blue>-- | The class @Parse@ is a replacement for @Read@, operating over String input.</font>+<a name="line-55"></a><a name="Parse"></a><font color=Blue>--   Essentially, it permits better error messages for why something failed to</font>+<a name="line-56"></a><a name="Parse"></a><font color=Blue>--   parse.  It is rather important that @parse@ can read back exactly what</font>+<a name="line-57"></a><a name="Parse"></a><font color=Blue>--   is generated by the corresponding instance of @show@.  To apply a parser</font>+<a name="line-58"></a><a name="Parse"></a><font color=Blue>--   to some text, use @runParser@.</font>+<a name="line-59"></a><a name="Parse"></a><font color=Green><u>class</u></font> Parse a <font color=Green><u>where</u></font>+<a name="line-60"></a>    <font color=Blue>-- | A straightforward parser for an item.  (A minimal definition of</font>+<a name="line-61"></a>    <font color=Blue>--   a class instance requires either |parse| or |parsePrec|.)</font>+<a name="line-62"></a>    parse     <font color=Red>::</font> TextParser a+<a name="line-63"></a>    parse       <font color=Red>=</font> parsePrec <font color=Magenta>0</font>+<a name="line-64"></a>    <font color=Blue>-- | A straightforward parser for an item, given the precedence of</font>+<a name="line-65"></a>    <font color=Blue>--   any surrounding expression.  (Precedence determines whether</font>+<a name="line-66"></a>    <font color=Blue>--   parentheses are mandatory or optional.)</font>+<a name="line-67"></a>    parsePrec <font color=Red>::</font> Int <font color=Red>-&gt;</font> TextParser a+<a name="line-68"></a>    parsePrec <font color=Green><u>_</u></font> <font color=Red>=</font> optionalParens parse+<a name="line-69"></a>    <font color=Blue>-- | Parsing a list of items by default accepts the [] and comma syntax,</font>+<a name="line-70"></a>    <font color=Blue>--   except when the list is really a character string using \"\".</font>+<a name="line-71"></a>    parseList <font color=Red>::</font> TextParser <font color=Red>[</font>a<font color=Red>]</font>	<font color=Blue>-- only to distinguish [] and ""</font>+<a name="line-72"></a>    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=Cyan>}</font>+<a name="line-73"></a>                   <font color=Cyan>`onFail`</font>+<a name="line-74"></a>                 <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=Cyan>}</font>+<a name="line-75"></a>                   <font color=Cyan>`onFail`</font>+<a name="line-76"></a>                 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>+<a name="line-77"></a>                            <font color=Cyan>(</font>optionalParens parse<font color=Cyan>)</font>+<a name="line-78"></a>                   <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>+<a name="line-79"></a>+<a name="line-80"></a><a name="parseByRead"></a><font color=Blue>-- | If there already exists a Read instance for a type, then we can make</font>+<a name="line-81"></a><font color=Blue>--   a Parser for it, but with only poor error-reporting.  The string argument</font>+<a name="line-82"></a><font color=Blue>--   is the expected type or value (for error-reporting only).  Use of this</font>+<a name="line-83"></a><font color=Blue>--   wrapper function is NOT recommended with ByteString, because there</font>+<a name="line-84"></a><font color=Blue>--   is a lot of inefficiency in repeated conversions to/from String.</font>+<a name="line-85"></a><font color=Blue>parseByRead</font> <font color=Red>::</font> Read a <font color=Red>=&gt;</font> String <font color=Red>-&gt;</font> TextParser a+<a name="line-86"></a><font color=Blue>parseByRead</font> name <font color=Red>=</font>+<a name="line-87"></a>    P <font color=Cyan>(</font><font color=Red>\</font>s<font color=Red>-&gt;</font> <font color=Green><u>case</u></font> reads <font color=Cyan>(</font>BS<font color=Cyan>.</font>unpack s<font color=Cyan>)</font> <font color=Green><u>of</u></font>+<a name="line-88"></a>                []       <font color=Red>-&gt;</font> Failure s <font color=Cyan>(</font><font color=Magenta>"no parse, expected a "</font><font color=Cyan>++</font>name<font color=Cyan>)</font>+<a name="line-89"></a>                <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>-&gt;</font> Success <font color=Cyan>(</font>BS<font color=Cyan>.</font>pack s'<font color=Cyan>)</font> a+<a name="line-90"></a>                <font color=Green><u>_</u></font>        <font color=Red>-&gt;</font> Failure s <font color=Cyan>(</font><font color=Magenta>"ambiguous parse, expected a "</font><font color=Cyan>++</font>name<font color=Cyan>)</font>+<a name="line-91"></a>      <font color=Cyan>)</font>+<a name="line-92"></a>+<a name="line-93"></a><a name="readByParse"></a><font color=Blue>-- | If you have a TextParser for a type, you can easily make it into</font>+<a name="line-94"></a><font color=Blue>--   a Read instance, by throwing away any error messages.  Use of this</font>+<a name="line-95"></a><font color=Blue>--   wrapper function is NOT recommended with ByteString, because there</font>+<a name="line-96"></a><font color=Blue>--   is a lot of inefficiency in conversions to/from String.</font>+<a name="line-97"></a><font color=Blue>readByParse</font> <font color=Red>::</font> TextParser a <font color=Red>-&gt;</font> ReadS a+<a name="line-98"></a><font color=Blue>readByParse</font> p <font color=Red>=</font> <font color=Red>\</font>inp<font color=Red>-&gt;</font>+<a name="line-99"></a>    <font color=Green><u>case</u></font> runParser p <font color=Cyan>(</font>BS<font color=Cyan>.</font>pack inp<font color=Cyan>)</font> <font color=Green><u>of</u></font>+<a name="line-100"></a>        <font color=Cyan>(</font>Left err<font color=Cyan>,</font>  rest<font color=Cyan>)</font> <font color=Red>-&gt;</font> []+<a name="line-101"></a>        <font color=Cyan>(</font>Right val<font color=Cyan>,</font> rest<font color=Cyan>)</font> <font color=Red>-&gt;</font> <font color=Red>[</font><font color=Cyan>(</font>val<font color=Cyan>,</font> BS<font color=Cyan>.</font>unpack rest<font color=Cyan>)</font><font color=Red>]</font>+<a name="line-102"></a>+<a name="line-103"></a><a name="readsPrecByParsePrec"></a><font color=Blue>-- | If you have a TextParser for a type, you can easily make it into</font>+<a name="line-104"></a><font color=Blue>--   a Read instance, by throwing away any error messages.  Use of this</font>+<a name="line-105"></a><font color=Blue>--   wrapper function is NOT recommended with ByteString, because there</font>+<a name="line-106"></a><font color=Blue>--   is a lot of inefficiency in conversions to/from String.</font>+<a name="line-107"></a><font color=Blue>readsPrecByParsePrec</font> <font color=Red>::</font> <font color=Cyan>(</font>Int <font color=Red>-&gt;</font> TextParser a<font color=Cyan>)</font> <font color=Red>-&gt;</font> Int <font color=Red>-&gt;</font> ReadS a+<a name="line-108"></a><font color=Blue>readsPrecByParsePrec</font> p <font color=Red>=</font> <font color=Red>\</font>prec inp<font color=Red>-&gt;</font>+<a name="line-109"></a>    <font color=Green><u>case</u></font> runParser <font color=Cyan>(</font>p prec<font color=Cyan>)</font> <font color=Cyan>(</font>BS<font color=Cyan>.</font>pack inp<font color=Cyan>)</font> <font color=Green><u>of</u></font>+<a name="line-110"></a>        <font color=Cyan>(</font>Left err<font color=Cyan>,</font>  rest<font color=Cyan>)</font> <font color=Red>-&gt;</font> []+<a name="line-111"></a>        <font color=Cyan>(</font>Right val<font color=Cyan>,</font> rest<font color=Cyan>)</font> <font color=Red>-&gt;</font> <font color=Red>[</font><font color=Cyan>(</font>val<font color=Cyan>,</font> BS<font color=Cyan>.</font>unpack rest<font color=Cyan>)</font><font color=Red>]</font>+<a name="line-112"></a>+<a name="line-113"></a>+<a name="line-114"></a><a name="word"></a><font color=Blue>-- | One lexical chunk (Haskell-style lexing).</font>+<a name="line-115"></a><font color=Blue>word</font> <font color=Red>::</font> TextParser String+<a name="line-116"></a><font color=Blue>word</font> <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>s<font color=Red>-&gt;</font> <font color=Green><u>case</u></font> lex <font color=Cyan>(</font>BS<font color=Cyan>.</font>unpack s<font color=Cyan>)</font> <font color=Green><u>of</u></font>+<a name="line-117"></a>                   []         <font color=Red>-&gt;</font> Failure s  <font color=Cyan>(</font><font color=Magenta>"no input? (impossible)"</font><font color=Cyan>)</font>+<a name="line-118"></a>                   <font color=Red>[</font><font color=Cyan>(</font><font color=Magenta>""</font><font color=Cyan>,</font><font color=Magenta>""</font><font color=Cyan>)</font><font color=Red>]</font>  <font color=Red>-&gt;</font> Failure s <font color=Cyan>(</font><font color=Magenta>"no input?"</font><font color=Cyan>)</font>+<a name="line-119"></a>                   <font color=Red>[</font><font color=Cyan>(</font><font color=Magenta>""</font><font color=Cyan>,</font><font color=Green><u>_</u></font><font color=Cyan>)</font><font color=Red>]</font>   <font color=Red>-&gt;</font> Failure s  <font color=Cyan>(</font><font color=Magenta>"lexing failed?"</font><font color=Cyan>)</font>+<a name="line-120"></a>                   <font color=Cyan>(</font><font color=Cyan>(</font>x<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>-&gt;</font> Success <font color=Cyan>(</font>BS<font color=Cyan>.</font>drop <font color=Cyan>(</font>fromIntegral <font color=Cyan>(</font>length x<font color=Cyan>)</font><font color=Cyan>)</font> s<font color=Cyan>)</font> x+<a name="line-121"></a>         <font color=Cyan>)</font>+<a name="line-122"></a>+<a name="line-123"></a><a name="isWord"></a><font color=Blue>-- | Ensure that the next input word is the given string.  (Note the input</font>+<a name="line-124"></a><font color=Blue>--   is lexed as haskell, so wordbreaks at spaces, symbols, etc.)</font>+<a name="line-125"></a><font color=Blue>isWord</font> <font color=Red>::</font> String <font color=Red>-&gt;</font> TextParser String+<a name="line-126"></a><font color=Blue>isWord</font> w <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font> w' <font color=Red>&lt;-</font> word+<a name="line-127"></a>              <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>+<a name="line-128"></a>              <font color=Cyan>}</font>+<a name="line-129"></a>+<a name="line-130"></a><a name="optionalParens"></a><font color=Blue>-- | Allow optional nested string parens around an item.</font>+<a name="line-131"></a><font color=Blue>optionalParens</font> <font color=Red>::</font> TextParser a <font color=Red>-&gt;</font> TextParser a+<a name="line-132"></a><font color=Blue>optionalParens</font> p <font color=Red>=</font> parens False p+<a name="line-133"></a>+<a name="line-134"></a><a name="parens"></a><font color=Blue>-- | Allow nested parens around an item (one set required when Bool is True).</font>+<a name="line-135"></a><font color=Blue>parens</font> <font color=Red>::</font> Bool <font color=Red>-&gt;</font> TextParser a <font color=Red>-&gt;</font> TextParser a+<a name="line-136"></a><font color=Blue>parens</font> True  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> <font color=Cyan>(</font>parens False p<font color=Cyan>)</font>+<a name="line-137"></a><font color=Blue>parens</font> False p <font color=Red>=</font> parens True p <font color=Cyan>`onFail`</font> p+<a name="line-138"></a>+<a name="line-139"></a><a name="field"></a><font color=Blue>-- | Deal with named field syntax.  The string argument is the field name,</font>+<a name="line-140"></a><font color=Blue>--   and the parser returns the value of the field.</font>+<a name="line-141"></a><font color=Blue>field</font> <font color=Red>::</font> Parse a <font color=Red>=&gt;</font> String <font color=Red>-&gt;</font> TextParser a+<a name="line-142"></a><font color=Blue>field</font> 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>+<a name="line-143"></a>+<a name="line-144"></a><a name="constructors"></a><font color=Blue>-- | Parse one of a bunch of alternative constructors.  In the list argument,</font>+<a name="line-145"></a><font color=Blue>--   the first element of the pair is the constructor name, and</font>+<a name="line-146"></a><font color=Blue>--   the second is the parser for the rest of the value.  The first matching</font>+<a name="line-147"></a><font color=Blue>--   parse is returned.</font>+<a name="line-148"></a><font color=Blue>constructors</font> <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>-&gt;</font> TextParser a+<a name="line-149"></a><font color=Blue>constructors</font> cs <font color=Red>=</font> oneOf' <font color=Cyan>(</font>map cons cs<font color=Cyan>)</font>+<a name="line-150"></a>    <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>+<a name="line-151"></a>               <font color=Cyan>(</font> name+<a name="line-152"></a>               <font color=Cyan>,</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font> isWord name+<a name="line-153"></a>                    <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>+<a name="line-154"></a>                                        <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>+<a name="line-155"></a>                    <font color=Cyan>}</font>+<a name="line-156"></a>               <font color=Cyan>)</font>+<a name="line-157"></a>+<a name="line-158"></a><a name="enumeration"></a><font color=Blue>-- | Parse one of the given nullary constructors (an enumeration).</font>+<a name="line-159"></a><font color=Blue>--   The string argument is the name of the type, and the list argument</font>+<a name="line-160"></a><font color=Blue>--   should contain all of the possible enumeration values.</font>+<a name="line-161"></a><font color=Blue>enumeration</font> <font color=Red>::</font> <font color=Cyan>(</font>Show a<font color=Cyan>)</font> <font color=Red>=&gt;</font> String <font color=Red>-&gt;</font> <font color=Red>[</font>a<font color=Red>]</font> <font color=Red>-&gt;</font> TextParser a+<a name="line-162"></a><font color=Blue>enumeration</font> typ cs <font color=Red>=</font> oneOf <font color=Cyan>(</font>map <font color=Cyan>(</font><font color=Red>\</font>c<font color=Red>-&gt;</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>+<a name="line-163"></a>                         <font color=Cyan>`adjustErr`</font>+<a name="line-164"></a>                     <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>+<a name="line-165"></a>    <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>+<a name="line-166"></a>              <font color=Cyan>++</font> <font color=Magenta>", or "</font> <font color=Cyan>++</font> show <font color=Cyan>(</font>last cs<font color=Cyan>)</font>+<a name="line-167"></a>+<a name="line-168"></a><font color=Blue>------------------------------------------------------------------------</font>+<a name="line-169"></a><font color=Blue>-- Instances for all the Standard Prelude types.</font>+<a name="line-170"></a>+<a name="line-171"></a><a name="parseSigned"></a><font color=Blue>-- Numeric types</font>+<a name="line-172"></a><font color=Blue>parseSigned</font> <font color=Red>::</font> Real a <font color=Red>=&gt;</font> TextParser a <font color=Red>-&gt;</font> TextParser a+<a name="line-173"></a><font color=Blue>parseSigned</font> p <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Magenta>'-'</font> <font color=Red>&lt;-</font> next<font color=Cyan>;</font> commit <font color=Cyan>(</font>fmap negate p<font color=Cyan>)</font>+<a name="line-174"></a>                <font color=Cyan>`onFail`</font>+<a name="line-175"></a>                <font color=Green><u>do</u></font> p+<a name="line-176"></a>+<a name="line-177"></a><a name="parseInt"></a><font color=Blue>parseInt</font> <font color=Red>::</font> <font color=Cyan>(</font>Integral a<font color=Cyan>)</font> <font color=Red>=&gt;</font> String <font color=Red>-&gt;</font>+<a name="line-178"></a>                            a <font color=Red>-&gt;</font> <font color=Cyan>(</font>Char <font color=Red>-&gt;</font> Bool<font color=Cyan>)</font> <font color=Red>-&gt;</font> <font color=Cyan>(</font>Char <font color=Red>-&gt;</font> Int<font color=Cyan>)</font> <font color=Red>-&gt;</font>+<a name="line-179"></a>                            TextParser a+<a name="line-180"></a><font color=Blue>parseInt</font> base radix isDigit digitToInt <font color=Red>=</font>+<a name="line-181"></a>                 <font color=Green><u>do</u></font> cs <font color=Red>&lt;-</font> many1 <font color=Cyan>(</font>satisfy isDigit<font color=Cyan>)</font>+<a name="line-182"></a>                    return <font color=Cyan>(</font>foldl1 <font color=Cyan>(</font><font color=Red>\</font>n d<font color=Red>-&gt;</font> n<font color=Cyan>*</font>radix<font color=Cyan>+</font>d<font color=Cyan>)</font>+<a name="line-183"></a>                                   <font color=Cyan>(</font>map <font color=Cyan>(</font>fromIntegral<font color=Cyan>.</font>digitToInt<font color=Cyan>)</font> cs<font color=Cyan>)</font><font color=Cyan>)</font>+<a name="line-184"></a>                 <font color=Cyan>`adjustErr`</font> <font color=Cyan>(</font><font color=Cyan>++</font><font color=Cyan>(</font><font color=Magenta>"\nexpected one or more "</font><font color=Cyan>++</font>base<font color=Cyan>++</font><font color=Magenta>" digits"</font><font color=Cyan>)</font><font color=Cyan>)</font>+<a name="line-185"></a><a name="parseDec"></a><font color=Blue>parseDec</font><font color=Cyan>,</font> parseOct<font color=Cyan>,</font> parseHex <font color=Red>::</font> <font color=Cyan>(</font>Integral a<font color=Cyan>)</font> <font color=Red>=&gt;</font> TextParser a+<a name="line-186"></a><font color=Blue>parseDec</font> <font color=Red>=</font> parseInt <font color=Magenta>"decimal"</font> <font color=Magenta>10</font> Char<font color=Cyan>.</font>isDigit    Char<font color=Cyan>.</font>digitToInt+<a name="line-187"></a><a name="parseOct"></a><font color=Blue>parseOct</font> <font color=Red>=</font> parseInt <font color=Magenta>"octal"</font>    <font color=Magenta>8</font> Char<font color=Cyan>.</font>isOctDigit Char<font color=Cyan>.</font>digitToInt+<a name="line-188"></a><a name="parseHex"></a><font color=Blue>parseHex</font> <font color=Red>=</font> parseInt <font color=Magenta>"hex"</font>     <font color=Magenta>16</font> Char<font color=Cyan>.</font>isHexDigit Char<font color=Cyan>.</font>digitToInt+<a name="line-189"></a>+<a name="line-190"></a><a name="parseUnsignedInteger"></a><font color=Blue>-- | parseUnsignedInteger uses the underlying ByteString readInteger, so</font>+<a name="line-191"></a><font color=Blue>--   will be a lot faster than the generic character-by-character parseInt.</font>+<a name="line-192"></a><font color=Blue>parseUnsignedInteger</font> <font color=Red>::</font> TextParser Integer+<a name="line-193"></a><font color=Blue>parseUnsignedInteger</font> <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>bs <font color=Red>-&gt;</font> <font color=Green><u>case</u></font> BS<font color=Cyan>.</font>uncons bs <font color=Green><u>of</u></font>+<a name="line-194"></a>                                 Just <font color=Cyan>(</font>c<font color=Cyan>,</font> <font color=Green><u>_</u></font><font color=Cyan>)</font>+<a name="line-195"></a>                                  <font color=Red>|</font> Char<font color=Cyan>.</font>isDigit c <font color=Red>-&gt;</font>+<a name="line-196"></a>                                     <font color=Green><u>case</u></font> BS<font color=Cyan>.</font>readInteger bs <font color=Green><u>of</u></font>+<a name="line-197"></a>                                     Just <font color=Cyan>(</font>i<font color=Cyan>,</font> bs'<font color=Cyan>)</font> <font color=Red>-&gt;</font> Success bs' i+<a name="line-198"></a>                                     Nothing <font color=Red>-&gt;</font> error <font color=Magenta>"XXX Can't happen"</font>+<a name="line-199"></a>                                 <font color=Green><u>_</u></font> <font color=Red>-&gt;</font> Failure bs <font color=Magenta>"parsing Integer: not a digit"</font><font color=Cyan>)</font>+<a name="line-200"></a>               <font color=Cyan>`adjustErr`</font> <font color=Cyan>(</font><font color=Cyan>++</font><font color=Cyan>(</font><font color=Magenta>"\nexpected one or more decimal digits"</font><font color=Cyan>)</font><font color=Cyan>)</font>+<a name="line-201"></a>+<a name="line-202"></a>+<a name="line-203"></a><a name="parseFloat"></a><font color=Blue>parseFloat</font> <font color=Red>::</font> <font color=Cyan>(</font>RealFrac a<font color=Cyan>)</font> <font color=Red>=&gt;</font> TextParser a+<a name="line-204"></a><font color=Blue>parseFloat</font> <font color=Red>=</font> <font color=Green><u>do</u></font> ds   <font color=Red>&lt;-</font> many1 <font color=Cyan>(</font>satisfy isDigit<font color=Cyan>)</font>+<a name="line-205"></a>                frac <font color=Red>&lt;-</font> <font color=Cyan>(</font><font color=Green><u>do</u></font> <font color=Magenta>'.'</font> <font color=Red>&lt;-</font> next+<a name="line-206"></a>                            many <font color=Cyan>(</font>satisfy isDigit<font color=Cyan>)</font>+<a name="line-207"></a>                              <font color=Cyan>`adjustErrBad`</font> <font color=Cyan>(</font><font color=Cyan>++</font><font color=Magenta>"expected digit after ."</font><font color=Cyan>)</font>+<a name="line-208"></a>                         <font color=Cyan>`onFail`</font> return [] <font color=Cyan>)</font>+<a name="line-209"></a>                exp  <font color=Red>&lt;-</font> exponent <font color=Cyan>`onFail`</font> return <font color=Magenta>0</font>+<a name="line-210"></a>                <font color=Cyan>(</font> return <font color=Cyan>.</font> fromRational <font color=Cyan>.</font> <font color=Cyan>(</font><font color=Cyan>*</font> <font color=Cyan>(</font><font color=Magenta>10</font><font color=Cyan>^^</font><font color=Cyan>(</font>exp <font color=Blue>-</font> length frac<font color=Cyan>)</font><font color=Cyan>)</font><font color=Cyan>)</font>+<a name="line-211"></a>                  <font color=Cyan>.</font> <font color=Cyan>(</font><font color=Cyan>%</font><font color=Magenta>1</font><font color=Cyan>)</font> <font color=Cyan>.</font>  <font color=Cyan>(</font><font color=Red>\</font> <font color=Cyan>(</font>Right x<font color=Cyan>)</font><font color=Red>-&gt;</font>x<font color=Cyan>)</font> <font color=Cyan>.</font> fst+<a name="line-212"></a>                  <font color=Cyan>.</font> runParser parseDec <font color=Cyan>)</font> <font color=Cyan>(</font>BS<font color=Cyan>.</font>pack <font color=Cyan>(</font>ds<font color=Cyan>++</font>frac<font color=Cyan>)</font><font color=Cyan>)</font>+<a name="line-213"></a>             <font color=Cyan>`onFail`</font>+<a name="line-214"></a>             <font color=Green><u>do</u></font> w <font color=Red>&lt;-</font> many <font color=Cyan>(</font>satisfy <font color=Cyan>(</font>not<font color=Cyan>.</font>isSpace<font color=Cyan>)</font><font color=Cyan>)</font>+<a name="line-215"></a>                <font color=Green><u>case</u></font> map toLower w <font color=Green><u>of</u></font>+<a name="line-216"></a>                  <font color=Magenta>"nan"</font>      <font color=Red>-&gt;</font> return <font color=Cyan>(</font><font color=Magenta>0</font><font color=Cyan>/</font><font color=Magenta>0</font><font color=Cyan>)</font>+<a name="line-217"></a>                  <font color=Magenta>"infinity"</font> <font color=Red>-&gt;</font> return <font color=Cyan>(</font><font color=Magenta>1</font><font color=Cyan>/</font><font color=Magenta>0</font><font color=Cyan>)</font>+<a name="line-218"></a>                  <font color=Green><u>_</u></font>          <font color=Red>-&gt;</font> fail <font color=Magenta>"expected a floating point number"</font>+<a name="line-219"></a>  <font color=Green><u>where</u></font> exponent <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Magenta>'e'</font> <font color=Red>&lt;-</font> fmap toLower next+<a name="line-220"></a>                      commit <font color=Cyan>(</font><font color=Green><u>do</u></font> <font color=Magenta>'+'</font> <font color=Red>&lt;-</font> next<font color=Cyan>;</font> parseDec+<a name="line-221"></a>                              <font color=Cyan>`onFail`</font>+<a name="line-222"></a>                              parseSigned parseDec <font color=Cyan>)</font>+<a name="line-223"></a>+<a name="line-224"></a><a name="parseLitChar"></a><font color=Blue>parseLitChar</font> <font color=Red>::</font> TextParser Char+<a name="line-225"></a><font color=Blue>parseLitChar</font> <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Magenta>'\''</font> <font color=Red>&lt;-</font> next <font color=Cyan>`adjustErr`</font> <font color=Cyan>(</font><font color=Cyan>++</font><font color=Magenta>"expected a literal char"</font><font color=Cyan>)</font>+<a name="line-226"></a>                  c <font color=Red>&lt;-</font> next+<a name="line-227"></a>                  char <font color=Red>&lt;-</font> <font color=Green><u>case</u></font> c <font color=Green><u>of</u></font>+<a name="line-228"></a>                            <font color=Magenta>'\\'</font> <font color=Red>-&gt;</font> next <font color=Cyan>&gt;&gt;=</font> escape+<a name="line-229"></a>                            <font color=Magenta>'\''</font> <font color=Red>-&gt;</font> fail <font color=Magenta>"expected a literal char, got ''"</font>+<a name="line-230"></a>                            <font color=Green><u>_</u></font>    <font color=Red>-&gt;</font> return c+<a name="line-231"></a>                  <font color=Magenta>'\''</font> <font color=Red>&lt;-</font> next <font color=Cyan>`adjustErrBad`</font> <font color=Cyan>(</font><font color=Cyan>++</font><font color=Magenta>"literal char has no final '"</font><font color=Cyan>)</font>+<a name="line-232"></a>                  return char+<a name="line-233"></a>  <font color=Green><u>where</u></font>+<a name="line-234"></a>    escape <font color=Magenta>'a'</font>  <font color=Red>=</font> return <font color=Magenta>'\a'</font>+<a name="line-235"></a>    escape <font color=Magenta>'b'</font>  <font color=Red>=</font> return <font color=Magenta>'\b'</font>+<a name="line-236"></a>    escape <font color=Magenta>'f'</font>  <font color=Red>=</font> return <font color=Magenta>'\f'</font>+<a name="line-237"></a>    escape <font color=Magenta>'n'</font>  <font color=Red>=</font> return <font color=Magenta>'\n'</font>+<a name="line-238"></a>    escape <font color=Magenta>'r'</font>  <font color=Red>=</font> return <font color=Magenta>'\r'</font>+<a name="line-239"></a>    escape <font color=Magenta>'t'</font>  <font color=Red>=</font> return <font color=Magenta>'\t'</font>+<a name="line-240"></a>    escape <font color=Magenta>'v'</font>  <font color=Red>=</font> return <font color=Magenta>'\v'</font>+<a name="line-241"></a>    escape <font color=Magenta>'\\'</font> <font color=Red>=</font> return <font color=Magenta>'\\'</font>+<a name="line-242"></a>    escape <font color=Magenta>'"'</font>  <font color=Red>=</font> return <font color=Magenta>'"'</font>+<a name="line-243"></a>    escape <font color=Magenta>'\''</font> <font color=Red>=</font> return <font color=Magenta>'\''</font>+<a name="line-244"></a>    escape <font color=Magenta>'^'</font>  <font color=Red>=</font> <font color=Green><u>do</u></font> ctrl <font color=Red>&lt;-</font> next+<a name="line-245"></a>                     <font color=Green><u>if</u></font> ctrl <font color=Cyan>&gt;=</font> <font color=Magenta>'@'</font> <font color=Cyan>&amp;&amp;</font> ctrl <font color=Cyan>&lt;=</font> <font color=Magenta>'_'</font>+<a name="line-246"></a>                       <font color=Green><u>then</u></font> return <font color=Cyan>(</font>chr <font color=Cyan>(</font>ord ctrl <font color=Blue>-</font> ord <font color=Magenta>'@'</font><font color=Cyan>)</font><font color=Cyan>)</font>+<a name="line-247"></a>                       <font color=Green><u>else</u></font> fail <font color=Cyan>(</font><font color=Magenta>"literal char ctrl-escape malformed: \\^"</font>+<a name="line-248"></a>                                   <font color=Cyan>++</font><font color=Red>[</font>ctrl<font color=Red>]</font><font color=Cyan>)</font>+<a name="line-249"></a>    escape d <font color=Red>|</font> isDigit d+<a name="line-250"></a>                <font color=Red>=</font> fmap chr <font color=Cyan>$</font>  <font color=Cyan>(</font>reparse <font color=Cyan>(</font>BS<font color=Cyan>.</font>pack <font color=Red>[</font>d<font color=Red>]</font><font color=Cyan>)</font> <font color=Cyan>&gt;&gt;</font> parseDec<font color=Cyan>)</font>+<a name="line-251"></a>    escape <font color=Magenta>'o'</font>  <font color=Red>=</font> fmap chr <font color=Cyan>$</font>  parseOct+<a name="line-252"></a>    escape <font color=Magenta>'x'</font>  <font color=Red>=</font> fmap chr <font color=Cyan>$</font>  parseHex+<a name="line-253"></a>    escape c <font color=Red>|</font> isUpper c+<a name="line-254"></a>                <font color=Red>=</font> mnemonic c+<a name="line-255"></a>    escape c    <font color=Red>=</font> fail <font color=Cyan>(</font><font color=Magenta>"unrecognised escape sequence in literal char: \\"</font><font color=Cyan>++</font><font color=Red>[</font>c<font color=Red>]</font><font color=Cyan>)</font>+<a name="line-256"></a>+<a name="line-257"></a>    mnemonic <font color=Magenta>'A'</font> <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Magenta>'C'</font> <font color=Red>&lt;-</font> next<font color=Cyan>;</font> <font color=Magenta>'K'</font> <font color=Red>&lt;-</font> next<font color=Cyan>;</font> return <font color=Magenta>'\ACK'</font>+<a name="line-258"></a>                   <font color=Cyan>`wrap`</font> <font color=Magenta>"'\\ACK'"</font>+<a name="line-259"></a>    mnemonic <font color=Magenta>'B'</font> <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Magenta>'E'</font> <font color=Red>&lt;-</font> next<font color=Cyan>;</font> <font color=Magenta>'L'</font> <font color=Red>&lt;-</font> next<font color=Cyan>;</font> return <font color=Magenta>'\BEL'</font>+<a name="line-260"></a>                   <font color=Cyan>`onFail`</font>+<a name="line-261"></a>                   <font color=Green><u>do</u></font> <font color=Magenta>'S'</font> <font color=Red>&lt;-</font> next<font color=Cyan>;</font> return <font color=Magenta>'\BS'</font>+<a name="line-262"></a>                   <font color=Cyan>`wrap`</font> <font color=Magenta>"'\\BEL' or '\\BS'"</font>+<a name="line-263"></a>    mnemonic <font color=Magenta>'C'</font> <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Magenta>'R'</font> <font color=Red>&lt;-</font> next<font color=Cyan>;</font> return <font color=Magenta>'\CR'</font>+<a name="line-264"></a>                   <font color=Cyan>`onFail`</font>+<a name="line-265"></a>                   <font color=Green><u>do</u></font> <font color=Magenta>'A'</font> <font color=Red>&lt;-</font> next<font color=Cyan>;</font> <font color=Magenta>'N'</font> <font color=Red>&lt;-</font> next<font color=Cyan>;</font> return <font color=Magenta>'\CAN'</font>+<a name="line-266"></a>                   <font color=Cyan>`wrap`</font> <font color=Magenta>"'\\CR' or '\\CAN'"</font>+<a name="line-267"></a>    mnemonic <font color=Magenta>'D'</font> <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Magenta>'E'</font> <font color=Red>&lt;-</font> next<font color=Cyan>;</font> <font color=Magenta>'L'</font> <font color=Red>&lt;-</font> next<font color=Cyan>;</font> return <font color=Magenta>'\DEL'</font>+<a name="line-268"></a>                   <font color=Cyan>`onFail`</font>+<a name="line-269"></a>                   <font color=Green><u>do</u></font> <font color=Magenta>'L'</font> <font color=Red>&lt;-</font> next<font color=Cyan>;</font> <font color=Magenta>'E'</font> <font color=Red>&lt;-</font> next<font color=Cyan>;</font> return <font color=Magenta>'\DLE'</font>+<a name="line-270"></a>                   <font color=Cyan>`onFail`</font>+<a name="line-271"></a>                   <font color=Green><u>do</u></font> <font color=Magenta>'C'</font> <font color=Red>&lt;-</font> next<font color=Cyan>;</font> <font color=Cyan>(</font> <font color=Green><u>do</u></font> <font color=Magenta>'1'</font> <font color=Red>&lt;-</font> next<font color=Cyan>;</font> return <font color=Magenta>'\DC1'</font>+<a name="line-272"></a>                                     <font color=Cyan>`onFail`</font>+<a name="line-273"></a>                                     <font color=Green><u>do</u></font> <font color=Magenta>'2'</font> <font color=Red>&lt;-</font> next<font color=Cyan>;</font> return <font color=Magenta>'\DC2'</font>+<a name="line-274"></a>                                     <font color=Cyan>`onFail`</font>+<a name="line-275"></a>                                     <font color=Green><u>do</u></font> <font color=Magenta>'3'</font> <font color=Red>&lt;-</font> next<font color=Cyan>;</font> return <font color=Magenta>'\DC3'</font>+<a name="line-276"></a>                                     <font color=Cyan>`onFail`</font>+<a name="line-277"></a>                                     <font color=Green><u>do</u></font> <font color=Magenta>'4'</font> <font color=Red>&lt;-</font> next<font color=Cyan>;</font> return <font color=Magenta>'\DC4'</font> <font color=Cyan>)</font>+<a name="line-278"></a>                   <font color=Cyan>`wrap`</font> <font color=Magenta>"'\\DEL' or '\\DLE' or '\\DC[1..4]'"</font>+<a name="line-279"></a>    mnemonic <font color=Magenta>'E'</font> <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Magenta>'T'</font> <font color=Red>&lt;-</font> next<font color=Cyan>;</font> <font color=Magenta>'X'</font> <font color=Red>&lt;-</font> next<font color=Cyan>;</font> return <font color=Magenta>'\ETX'</font>+<a name="line-280"></a>                   <font color=Cyan>`onFail`</font>+<a name="line-281"></a>                   <font color=Green><u>do</u></font> <font color=Magenta>'O'</font> <font color=Red>&lt;-</font> next<font color=Cyan>;</font> <font color=Magenta>'T'</font> <font color=Red>&lt;-</font> next<font color=Cyan>;</font> return <font color=Magenta>'\EOT'</font>+<a name="line-282"></a>                   <font color=Cyan>`onFail`</font>+<a name="line-283"></a>                   <font color=Green><u>do</u></font> <font color=Magenta>'N'</font> <font color=Red>&lt;-</font> next<font color=Cyan>;</font> <font color=Magenta>'Q'</font> <font color=Red>&lt;-</font> next<font color=Cyan>;</font> return <font color=Magenta>'\ENQ'</font>+<a name="line-284"></a>                   <font color=Cyan>`onFail`</font>+<a name="line-285"></a>                   <font color=Green><u>do</u></font> <font color=Magenta>'T'</font> <font color=Red>&lt;-</font> next<font color=Cyan>;</font> <font color=Magenta>'B'</font> <font color=Red>&lt;-</font> next<font color=Cyan>;</font> return <font color=Magenta>'\ETB'</font>+<a name="line-286"></a>                   <font color=Cyan>`onFail`</font>+<a name="line-287"></a>                   <font color=Green><u>do</u></font> <font color=Magenta>'M'</font> <font color=Red>&lt;-</font> next<font color=Cyan>;</font> return <font color=Magenta>'\EM'</font>+<a name="line-288"></a>                   <font color=Cyan>`onFail`</font>+<a name="line-289"></a>                   <font color=Green><u>do</u></font> <font color=Magenta>'S'</font> <font color=Red>&lt;-</font> next<font color=Cyan>;</font> <font color=Magenta>'C'</font> <font color=Red>&lt;-</font> next<font color=Cyan>;</font> return <font color=Magenta>'\ESC'</font>+<a name="line-290"></a>                   <font color=Cyan>`wrap`</font> <font color=Magenta>"one of '\\ETX' '\\EOT' '\\ENQ' '\\ETB' '\\EM' or '\\ESC'"</font>+<a name="line-291"></a>    mnemonic <font color=Magenta>'F'</font> <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Magenta>'F'</font> <font color=Red>&lt;-</font> next<font color=Cyan>;</font> return <font color=Magenta>'\FF'</font>+<a name="line-292"></a>                   <font color=Cyan>`onFail`</font>+<a name="line-293"></a>                   <font color=Green><u>do</u></font> <font color=Magenta>'S'</font> <font color=Red>&lt;-</font> next<font color=Cyan>;</font> return <font color=Magenta>'\FS'</font>+<a name="line-294"></a>                   <font color=Cyan>`wrap`</font> <font color=Magenta>"'\\FF' or '\\FS'"</font>+<a name="line-295"></a>    mnemonic <font color=Magenta>'G'</font> <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Magenta>'S'</font> <font color=Red>&lt;-</font> next<font color=Cyan>;</font> return <font color=Magenta>'\GS'</font>+<a name="line-296"></a>                   <font color=Cyan>`wrap`</font> <font color=Magenta>"'\\GS'"</font>+<a name="line-297"></a>    mnemonic <font color=Magenta>'H'</font> <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Magenta>'T'</font> <font color=Red>&lt;-</font> next<font color=Cyan>;</font> return <font color=Magenta>'\HT'</font>+<a name="line-298"></a>                   <font color=Cyan>`wrap`</font> <font color=Magenta>"'\\HT'"</font>+<a name="line-299"></a>    mnemonic <font color=Magenta>'L'</font> <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Magenta>'F'</font> <font color=Red>&lt;-</font> next<font color=Cyan>;</font> return <font color=Magenta>'\LF'</font>+<a name="line-300"></a>                   <font color=Cyan>`wrap`</font> <font color=Magenta>"'\\LF'"</font>+<a name="line-301"></a>    mnemonic <font color=Magenta>'N'</font> <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Magenta>'U'</font> <font color=Red>&lt;-</font> next<font color=Cyan>;</font> <font color=Magenta>'L'</font> <font color=Red>&lt;-</font> next<font color=Cyan>;</font> return <font color=Magenta>'\NUL'</font>+<a name="line-302"></a>                   <font color=Cyan>`onFail`</font>+<a name="line-303"></a>                   <font color=Green><u>do</u></font> <font color=Magenta>'A'</font> <font color=Red>&lt;-</font> next<font color=Cyan>;</font> <font color=Magenta>'K'</font> <font color=Red>&lt;-</font> next<font color=Cyan>;</font> return <font color=Magenta>'\NAK'</font>+<a name="line-304"></a>                   <font color=Cyan>`wrap`</font> <font color=Magenta>"'\\NUL' or '\\NAK'"</font>+<a name="line-305"></a>    mnemonic <font color=Magenta>'R'</font> <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Magenta>'S'</font> <font color=Red>&lt;-</font> next<font color=Cyan>;</font> return <font color=Magenta>'\RS'</font>+<a name="line-306"></a>                   <font color=Cyan>`wrap`</font> <font color=Magenta>"'\\RS'"</font>+<a name="line-307"></a>    mnemonic <font color=Magenta>'S'</font> <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Magenta>'O'</font> <font color=Red>&lt;-</font> next<font color=Cyan>;</font> <font color=Magenta>'H'</font> <font color=Red>&lt;-</font> next<font color=Cyan>;</font> return <font color=Magenta>'\SOH'</font>+<a name="line-308"></a>                   <font color=Cyan>`onFail`</font>+<a name="line-309"></a>                   <font color=Green><u>do</u></font> <font color=Magenta>'O'</font> <font color=Red>&lt;-</font> next<font color=Cyan>;</font> return <font color=Magenta>'\SO'</font>+<a name="line-310"></a>                   <font color=Cyan>`onFail`</font>+<a name="line-311"></a>                   <font color=Green><u>do</u></font> <font color=Magenta>'T'</font> <font color=Red>&lt;-</font> next<font color=Cyan>;</font> <font color=Magenta>'X'</font> <font color=Red>&lt;-</font> next<font color=Cyan>;</font> return <font color=Magenta>'\STX'</font>+<a name="line-312"></a>                   <font color=Cyan>`onFail`</font>+<a name="line-313"></a>                   <font color=Green><u>do</u></font> <font color=Magenta>'I'</font> <font color=Red>&lt;-</font> next<font color=Cyan>;</font> return <font color=Magenta>'\SI'</font>+<a name="line-314"></a>                   <font color=Cyan>`onFail`</font>+<a name="line-315"></a>                   <font color=Green><u>do</u></font> <font color=Magenta>'Y'</font> <font color=Red>&lt;-</font> next<font color=Cyan>;</font> <font color=Magenta>'N'</font> <font color=Red>&lt;-</font> next<font color=Cyan>;</font> return <font color=Magenta>'\SYN'</font>+<a name="line-316"></a>                   <font color=Cyan>`onFail`</font>+<a name="line-317"></a>                   <font color=Green><u>do</u></font> <font color=Magenta>'U'</font> <font color=Red>&lt;-</font> next<font color=Cyan>;</font> <font color=Magenta>'B'</font> <font color=Red>&lt;-</font> next<font color=Cyan>;</font> return <font color=Magenta>'\SUB'</font>+<a name="line-318"></a>                   <font color=Cyan>`onFail`</font>+<a name="line-319"></a>                   <font color=Green><u>do</u></font> <font color=Magenta>'P'</font> <font color=Red>&lt;-</font> next<font color=Cyan>;</font> return <font color=Magenta>'\SP'</font>+<a name="line-320"></a>                   <font color=Cyan>`wrap`</font> <font color=Magenta>"'\\SOH' '\\SO' '\\STX' '\\SI' '\\SYN' '\\SUB' or '\\SP'"</font>+<a name="line-321"></a>    mnemonic <font color=Magenta>'U'</font> <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Magenta>'S'</font> <font color=Red>&lt;-</font> next<font color=Cyan>;</font> return <font color=Magenta>'\US'</font>+<a name="line-322"></a>                   <font color=Cyan>`wrap`</font> <font color=Magenta>"'\\US'"</font>+<a name="line-323"></a>    mnemonic <font color=Magenta>'V'</font> <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Magenta>'T'</font> <font color=Red>&lt;-</font> next<font color=Cyan>;</font> return <font color=Magenta>'\VT'</font>+<a name="line-324"></a>                   <font color=Cyan>`wrap`</font> <font color=Magenta>"'\\VT'"</font>+<a name="line-325"></a>    wrap p s <font color=Red>=</font> p <font color=Cyan>`onFail`</font> fail <font color=Cyan>(</font><font color=Magenta>"expected literal char "</font><font color=Cyan>++</font>s<font color=Cyan>)</font>+<a name="line-326"></a>+<a name="line-327"></a><font color=Blue>-- Basic types</font>+<a name="line-328"></a><font color=Green><u>instance</u></font> Parse Int <font color=Green><u>where</u></font>+<a name="line-329"></a>    parse <font color=Red>=</font> fmap fromInteger <font color=Cyan>$</font>	<font color=Blue>-- convert from Integer, deals with minInt</font>+<a name="line-330"></a>              <font color=Green><u>do</u></font> many <font color=Cyan>(</font>satisfy isSpace<font color=Cyan>)</font><font color=Cyan>;</font> parseSigned parseUnsignedInteger+<a name="line-331"></a><font color=Green><u>instance</u></font> Parse Integer <font color=Green><u>where</u></font>+<a name="line-332"></a>    parse <font color=Red>=</font> <font color=Green><u>do</u></font> many <font color=Cyan>(</font>satisfy isSpace<font color=Cyan>)</font><font color=Cyan>;</font> parseSigned parseUnsignedInteger+<a name="line-333"></a><font color=Green><u>instance</u></font> Parse Float <font color=Green><u>where</u></font>+<a name="line-334"></a>    parse <font color=Red>=</font> <font color=Green><u>do</u></font> many <font color=Cyan>(</font>satisfy isSpace<font color=Cyan>)</font><font color=Cyan>;</font> parseSigned parseFloat+<a name="line-335"></a><font color=Green><u>instance</u></font> Parse Double <font color=Green><u>where</u></font>+<a name="line-336"></a>    parse <font color=Red>=</font> <font color=Green><u>do</u></font> many <font color=Cyan>(</font>satisfy isSpace<font color=Cyan>)</font><font color=Cyan>;</font> parseSigned parseFloat+<a name="line-337"></a><font color=Green><u>instance</u></font> Parse Char <font color=Green><u>where</u></font>+<a name="line-338"></a>    parse <font color=Red>=</font> <font color=Green><u>do</u></font> many <font color=Cyan>(</font>satisfy isSpace<font color=Cyan>)</font><font color=Cyan>;</font> parseLitChar+<a name="line-339"></a>	<font color=Blue>-- not totally correct for strings...</font>+<a name="line-340"></a>    parseList <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font> w <font color=Red>&lt;-</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 <font color=Cyan>(</font>init <font color=Cyan>(</font>tail w<font color=Cyan>)</font><font color=Cyan>)</font>+<a name="line-341"></a>                                <font color=Green><u>else</u></font> fail <font color=Magenta>"not a string"</font> <font color=Cyan>}</font>+<a name="line-342"></a>+<a name="line-343"></a><font color=Green><u>instance</u></font> Parse Bool <font color=Green><u>where</u></font>+<a name="line-344"></a>    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>+<a name="line-345"></a>+<a name="line-346"></a><font color=Green><u>instance</u></font> Parse Ordering <font color=Green><u>where</u></font>+<a name="line-347"></a>    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>+<a name="line-348"></a>+<a name="line-349"></a><font color=Blue>-- Structural types</font>+<a name="line-350"></a><font color=Green><u>instance</u></font> Parse () <font color=Green><u>where</u></font>+<a name="line-351"></a>    parse <font color=Red>=</font> P <font color=Cyan>(</font>p <font color=Cyan>.</font> BS<font color=Cyan>.</font>uncons<font color=Cyan>)</font>+<a name="line-352"></a>      <font color=Green><u>where</u></font> p Nothing         <font color=Red>=</font> Failure BS<font color=Cyan>.</font>empty <font color=Magenta>"no input: expected a ()"</font>+<a name="line-353"></a>            p <font color=Cyan>(</font>Just <font color=Cyan>(</font><font color=Magenta>'('</font><font color=Cyan>,</font>cs<font color=Cyan>)</font><font color=Cyan>)</font> <font color=Red>=</font> <font color=Green><u>case</u></font> BS<font color=Cyan>.</font>uncons <font color=Cyan>(</font>BS<font color=Cyan>.</font>dropWhile isSpace cs<font color=Cyan>)</font> <font color=Green><u>of</u></font>+<a name="line-354"></a>                                Just <font color=Cyan>(</font><font color=Magenta>')'</font><font color=Cyan>,</font>s<font color=Cyan>)</font> <font color=Red>-&gt;</font> Success s ()+<a name="line-355"></a>                                <font color=Green><u>_</u></font>            <font color=Red>-&gt;</font> Failure cs <font color=Magenta>"Expected ) after ("</font>+<a name="line-356"></a>            p <font color=Cyan>(</font>Just <font color=Cyan>(</font>c<font color=Cyan>,</font>cs<font color=Cyan>)</font><font color=Cyan>)</font>   <font color=Red>|</font> isSpace c <font color=Red>=</font> p <font color=Cyan>(</font>BS<font color=Cyan>.</font>uncons cs<font color=Cyan>)</font>+<a name="line-357"></a>                              <font color=Red>|</font> otherwise <font color=Red>=</font> Failure <font color=Cyan>(</font>BS<font color=Cyan>.</font>cons c cs<font color=Cyan>)</font>+<a name="line-358"></a>                                                <font color=Cyan>(</font><font color=Magenta>"Expected a (), got "</font><font color=Cyan>++</font>show c<font color=Cyan>)</font>+<a name="line-359"></a>+<a name="line-360"></a><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>=&gt;</font> Parse <font color=Cyan>(</font>a<font color=Cyan>,</font>b<font color=Cyan>)</font> <font color=Green><u>where</u></font>+<a name="line-361"></a>    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>+<a name="line-362"></a>              <font color=Cyan>;</font> x <font color=Red>&lt;-</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>+<a name="line-363"></a>              <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>+<a name="line-364"></a>              <font color=Cyan>;</font> y <font color=Red>&lt;-</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>+<a name="line-365"></a>              <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>+<a name="line-366"></a>              <font color=Cyan>;</font> return <font color=Cyan>(</font>x<font color=Cyan>,</font>y<font color=Cyan>)</font> <font color=Cyan>}</font>+<a name="line-367"></a>+<a name="line-368"></a><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>=&gt;</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>+<a name="line-369"></a>    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>+<a name="line-370"></a>              <font color=Cyan>;</font> x <font color=Red>&lt;-</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>+<a name="line-371"></a>              <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>+<a name="line-372"></a>              <font color=Cyan>;</font> y <font color=Red>&lt;-</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>+<a name="line-373"></a>              <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>+<a name="line-374"></a>              <font color=Cyan>;</font> z <font color=Red>&lt;-</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>+<a name="line-375"></a>              <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>+<a name="line-376"></a>              <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>+<a name="line-377"></a>+<a name="line-378"></a><font color=Green><u>instance</u></font> Parse a <font color=Red>=&gt;</font> Parse <font color=Cyan>(</font>Maybe a<font color=Cyan>)</font> <font color=Green><u>where</u></font>+<a name="line-379"></a>    parsePrec p <font color=Red>=</font>+<a name="line-380"></a>            optionalParens <font color=Cyan>(</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>)</font>+<a name="line-381"></a>            <font color=Cyan>`onFail`</font>+<a name="line-382"></a>            parens <font color=Cyan>(</font>p<font color=Cyan>&gt;</font><font color=Magenta>9</font><font color=Cyan>)</font>   <font color=Cyan>(</font><font color=Green><u>do</u></font> <font color=Cyan>{</font> isWord <font color=Magenta>"Just"</font>+<a name="line-383"></a>                               <font color=Cyan>;</font> fmap Just <font color=Cyan>$</font> parsePrec <font color=Magenta>10</font>+<a name="line-384"></a>                                     <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>)</font>+<a name="line-385"></a>            <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>+<a name="line-386"></a>+<a name="line-387"></a><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>=&gt;</font> Parse <font color=Cyan>(</font>Either a b<font color=Cyan>)</font> <font color=Green><u>where</u></font>+<a name="line-388"></a>    parsePrec p <font color=Red>=</font>+<a name="line-389"></a>            parens <font color=Cyan>(</font>p<font color=Cyan>&gt;</font><font color=Magenta>9</font><font color=Cyan>)</font> <font color=Cyan>$</font>+<a name="line-390"></a>            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> parsePrec <font color=Magenta>10</font> <font color=Cyan>}</font> <font color=Cyan>)</font>+<a name="line-391"></a>                         <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> parsePrec <font color=Magenta>10</font> <font color=Cyan>}</font> <font color=Cyan>)</font>+<a name="line-392"></a>                         <font color=Red>]</font>+<a name="line-393"></a>+<a name="line-394"></a><font color=Green><u>instance</u></font> Parse a <font color=Red>=&gt;</font> Parse <font color=Red>[</font>a<font color=Red>]</font> <font color=Green><u>where</u></font>+<a name="line-395"></a>    parse <font color=Red>=</font> parseList+<a name="line-396"></a>+<a name="line-397"></a><font color=Blue>------------------------------------------------------------------------</font>+<a name="line-398"></a><font color=Blue>-- ByteStrings as a whole entity.</font>+<a name="line-399"></a>+<a name="line-400"></a><a name="allAsByteString"></a><font color=Blue>-- | Simply return the remaining input ByteString.</font>+<a name="line-401"></a><font color=Blue>allAsByteString</font> <font color=Red>::</font> TextParser ByteString+<a name="line-402"></a><font color=Blue>allAsByteString</font> <font color=Red>=</font>  P <font color=Cyan>(</font><font color=Red>\</font>bs<font color=Red>-&gt;</font> Success BS<font color=Cyan>.</font>empty bs<font color=Cyan>)</font>+<a name="line-403"></a>+<a name="line-404"></a><a name="allAsString"></a><font color=Blue>-- | Simply return the remaining input as a String.</font>+<a name="line-405"></a><font color=Blue>allAsString</font>     <font color=Red>::</font> TextParser String+<a name="line-406"></a><font color=Blue>allAsString</font>     <font color=Red>=</font>  fmap BS<font color=Cyan>.</font>unpack allAsByteString+<a name="line-407"></a>+<a name="line-408"></a><font color=Blue>------------------------------------------------------------------------</font>+</pre>+</html>
+ docs/haddock/src/Text/ParserCombinators/HuttonMeijer.html view
@@ -0,0 +1,222 @@+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">+<html>+<pre><a name="line-1"></a><font color=Blue>-----------------------------------------------------------------------------</font>+<a name="line-2"></a><font color=Blue>-- |</font>+<a name="line-3"></a><font color=Blue>-- Module      :  Text.ParserCombinators.HuttonMeijer</font>+<a name="line-4"></a><font color=Blue>-- Copyright   :  Graham Hutton (University of Nottingham), Erik Meijer (University of Utrecht)</font>+<a name="line-5"></a><font color=Blue>-- Licence     :  BSD</font>+<a name="line-6"></a><font color=Blue>-- </font>+<a name="line-7"></a><font color=Blue>-- Maintainer  :  Malcolm Wallace &lt;Malcolm.Wallace@cs.york.ac.uk&gt;</font>+<a name="line-8"></a><font color=Blue>-- Stability   :  Stable</font>+<a name="line-9"></a><font color=Blue>-- Portability :  All</font>+<a name="line-10"></a><font color=Blue>--</font>+<a name="line-11"></a><font color=Blue>--                  A LIBRARY OF MONADIC PARSER COMBINATORS</font>+<a name="line-12"></a><font color=Blue>-- </font>+<a name="line-13"></a><font color=Blue>--                               29th July 1996</font>+<a name="line-14"></a><font color=Blue>-- </font>+<a name="line-15"></a><font color=Blue>--                  Graham Hutton               Erik Meijer</font>+<a name="line-16"></a><font color=Blue>--             University of Nottingham    University of Utrecht</font>+<a name="line-17"></a><font color=Blue>-- </font>+<a name="line-18"></a><font color=Blue>-- This Haskell script defines a library of parser combinators, and is</font>+<a name="line-19"></a><font color=Blue>-- taken from sections 1-6 of our article "Monadic Parser Combinators".</font>+<a name="line-20"></a><font color=Blue>-- Some changes to the library have been made in the move from Gofer</font>+<a name="line-21"></a><font color=Blue>-- to Haskell:</font>+<a name="line-22"></a><font color=Blue>-- </font>+<a name="line-23"></a><font color=Blue>--    * Do notation is used in place of monad comprehension notation;</font>+<a name="line-24"></a><font color=Blue>-- </font>+<a name="line-25"></a><font color=Blue>--    * The parser datatype is defined using "newtype", to avoid the overhead</font>+<a name="line-26"></a><font color=Blue>--      of tagging and untagging parsers with the P constructor.</font>+<a name="line-27"></a><font color=Blue>-----------------------------------------------------------------------------</font>+<a name="line-28"></a>+<a name="line-29"></a>+<a name="line-30"></a><font color=Green><u>module</u></font> Text<font color=Cyan>.</font>ParserCombinators<font color=Cyan>.</font>HuttonMeijer+<a name="line-31"></a>   <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>+<a name="line-32"></a>    sepby<font color=Cyan>,</font> sepby1<font color=Cyan>,</font> chainl<font color=Cyan>,</font>+<a name="line-33"></a>    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>+<a name="line-34"></a>    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>+<a name="line-35"></a>    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>+<a name="line-36"></a>+<a name="line-37"></a><font color=Green><u>import</u></font> Char+<a name="line-38"></a><font color=Green><u>import</u></font> Monad+<a name="line-39"></a>+<a name="line-40"></a><font color=Green><u>infixr</u></font> <font color=Magenta>5</font> <font color=Cyan>+++</font>+<a name="line-41"></a>+<a name="line-42"></a><a name="Token"></a><font color=Green><u>type</u></font> Token <font color=Red>=</font> Char+<a name="line-43"></a>+<a name="line-44"></a><font color=Blue>---------------------------------------------------------</font>+<a name="line-45"></a><font color=Blue>-- | The parser monad</font>+<a name="line-46"></a>+<a name="line-47"></a><a name="Parser"></a><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>-&gt;</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>+<a name="line-48"></a>+<a name="line-49"></a><font color=Green><u>instance</u></font> Functor Parser <font color=Green><u>where</u></font>+<a name="line-50"></a>   <font color=Blue>-- map         :: (a -&gt; b) -&gt; (Parser a -&gt; Parser b)</font>+<a name="line-51"></a>   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>-&gt;</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>&lt;-</font> p inp<font color=Red>]</font><font color=Cyan>)</font>+<a name="line-52"></a>+<a name="line-53"></a><font color=Green><u>instance</u></font> Monad Parser <font color=Green><u>where</u></font>+<a name="line-54"></a>   <font color=Blue>-- return      :: a -&gt; Parser a</font>+<a name="line-55"></a>   return v        <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>inp <font color=Red>-&gt;</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>+<a name="line-56"></a>+<a name="line-57"></a>   <font color=Blue>-- &gt;&gt;=         :: Parser a -&gt; (a -&gt; Parser b) -&gt; Parser b</font>+<a name="line-58"></a>   <font color=Cyan>(</font>P p<font color=Cyan>)</font> <font color=Cyan>&gt;&gt;=</font> f     <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>inp <font color=Red>-&gt;</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>&lt;-</font> p inp<font color=Red>]</font><font color=Cyan>)</font>+<a name="line-59"></a>+<a name="line-60"></a>   <font color=Blue>-- fail        :: String -&gt; Parser a</font>+<a name="line-61"></a>   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>-&gt;</font> []<font color=Cyan>)</font>+<a name="line-62"></a>+<a name="line-63"></a><font color=Green><u>instance</u></font> MonadPlus Parser <font color=Green><u>where</u></font>+<a name="line-64"></a>   <font color=Blue>-- mzero       :: Parser a</font>+<a name="line-65"></a>   mzero           <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font><font color=Green><u>_</u></font> <font color=Red>-&gt;</font> []<font color=Cyan>)</font>+<a name="line-66"></a>+<a name="line-67"></a>   <font color=Blue>-- mplus       :: Parser a -&gt; Parser a -&gt; Parser a</font>+<a name="line-68"></a>   <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>-&gt;</font> <font color=Cyan>(</font>p inp <font color=Cyan>++</font> q inp<font color=Cyan>)</font><font color=Cyan>)</font>+<a name="line-69"></a>+<a name="line-70"></a><font color=Blue>-- ------------------------------------------------------------</font>+<a name="line-71"></a><font color=Blue>-- * Other primitive parser combinators</font>+<a name="line-72"></a><font color=Blue>-- ------------------------------------------------------------</font>+<a name="line-73"></a>+<a name="line-74"></a><a name="item"></a><font color=Blue>item</font>               <font color=Red>::</font> Parser Token+<a name="line-75"></a><font color=Blue>item</font>                <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>inp <font color=Red>-&gt;</font> <font color=Green><u>case</u></font> inp <font color=Green><u>of</u></font>+<a name="line-76"></a>                                   []     <font color=Red>-&gt;</font> []+<a name="line-77"></a>                                   <font color=Cyan>(</font>x<font color=Red><b>:</b></font>xs<font color=Cyan>)</font> <font color=Red>-&gt;</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>+<a name="line-78"></a>+<a name="line-79"></a><a name="first"></a><font color=Blue>first</font>             <font color=Red>::</font> Parser a <font color=Red>-&gt;</font> Parser a+<a name="line-80"></a><font color=Blue>first</font> <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>-&gt;</font> <font color=Green><u>case</u></font> p inp <font color=Green><u>of</u></font>+<a name="line-81"></a>                                   []    <font color=Red>-&gt;</font> []+<a name="line-82"></a>                                   <font color=Cyan>(</font>x<font color=Red><b>:</b></font><font color=Green><u>_</u></font><font color=Cyan>)</font> <font color=Red>-&gt;</font> <font color=Red>[</font>x<font color=Red>]</font><font color=Cyan>)</font>+<a name="line-83"></a>+<a name="line-84"></a><a name="papply"></a><font color=Blue>papply</font>            <font color=Red>::</font> Parser a <font color=Red>-&gt;</font> <font color=Red>[</font>Token<font color=Red>]</font> <font color=Red>-&gt;</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="line-85"></a><font color=Blue>papply</font> <font color=Cyan>(</font>P p<font color=Cyan>)</font> inp   <font color=Red>=</font> p inp+<a name="line-86"></a>+<a name="line-87"></a><font color=Blue>-- ------------------------------------------------------------</font>+<a name="line-88"></a><font color=Blue>-- * Derived combinators</font>+<a name="line-89"></a><font color=Blue>-- ------------------------------------------------------------</font>+<a name="line-90"></a>+<a name="line-91"></a><a name="+++"></a><font color=Cyan>(</font><font color=Cyan>+++</font><font color=Cyan>)</font>             <font color=Red>::</font> Parser a <font color=Red>-&gt;</font> Parser a <font color=Red>-&gt;</font> Parser a+<a name="line-92"></a><a name="p"></a><font color=Blue>p</font> <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>+<a name="line-93"></a>+<a name="line-94"></a><a name="sat"></a><font color=Blue>sat</font>               <font color=Red>::</font> <font color=Cyan>(</font>Token <font color=Red>-&gt;</font> Bool<font color=Cyan>)</font> <font color=Red>-&gt;</font> Parser Token+<a name="line-95"></a><font color=Blue>sat</font> p              <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font>x <font color=Red>&lt;-</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>+<a name="line-96"></a>+<a name="line-97"></a><font color=Blue>--tok               :: Token -&gt; Parser Token</font>+<a name="line-98"></a><font color=Blue>--tok t              = do {x &lt;- item; if t==snd x then return t else mzero}</font>+<a name="line-99"></a>+<a name="line-100"></a><a name="many"></a><font color=Blue>many</font>              <font color=Red>::</font> Parser a <font color=Red>-&gt;</font> Parser <font color=Red>[</font>a<font color=Red>]</font>+<a name="line-101"></a><font color=Blue>many</font> p             <font color=Red>=</font> many1 p <font color=Cyan>+++</font> return []+<a name="line-102"></a><font color=Blue>--many p           = force (many1 p +++ return [])</font>+<a name="line-103"></a>+<a name="line-104"></a><a name="many1"></a><font color=Blue>many1</font>             <font color=Red>::</font> Parser a <font color=Red>-&gt;</font> Parser <font color=Red>[</font>a<font color=Red>]</font>+<a name="line-105"></a><font color=Blue>many1</font> p            <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font>x <font color=Red>&lt;-</font> p<font color=Cyan>;</font> xs <font color=Red>&lt;-</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>+<a name="line-106"></a>+<a name="line-107"></a><a name="sepby"></a><font color=Blue>sepby</font>             <font color=Red>::</font> Parser a <font color=Red>-&gt;</font> Parser b <font color=Red>-&gt;</font> Parser <font color=Red>[</font>a<font color=Red>]</font>+<a name="line-108"></a><a name="sepby"></a><font color=Blue>p</font> <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 []+<a name="line-109"></a>+<a name="line-110"></a><a name="sepby1"></a><font color=Blue>sepby1</font>            <font color=Red>::</font> Parser a <font color=Red>-&gt;</font> Parser b <font color=Red>-&gt;</font> Parser <font color=Red>[</font>a<font color=Red>]</font>+<a name="line-111"></a><a name="sepby1"></a><font color=Blue>p</font> <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>&lt;-</font> p<font color=Cyan>;</font> xs <font color=Red>&lt;-</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>+<a name="line-112"></a>+<a name="line-113"></a><a name="chainl"></a><font color=Blue>chainl</font>            <font color=Red>::</font> Parser a <font color=Red>-&gt;</font> Parser <font color=Cyan>(</font>a <font color=Red>-&gt;</font> a <font color=Red>-&gt;</font> a<font color=Cyan>)</font> <font color=Red>-&gt;</font> a <font color=Red>-&gt;</font> Parser a+<a name="line-114"></a><font color=Blue>chainl</font> 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+<a name="line-115"></a>+<a name="line-116"></a><a name="chainl1"></a><font color=Blue>chainl1</font>           <font color=Red>::</font> Parser a <font color=Red>-&gt;</font> Parser <font color=Cyan>(</font>a <font color=Red>-&gt;</font> a <font color=Red>-&gt;</font> a<font color=Cyan>)</font> <font color=Red>-&gt;</font> Parser a+<a name="line-117"></a><a name="chainl1"></a><font color=Blue>p</font> <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>&lt;-</font> p<font color=Cyan>;</font> rest x<font color=Cyan>}</font>+<a name="line-118"></a>                     <font color=Green><u>where</u></font>+<a name="line-119"></a>                        rest x <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font>f <font color=Red>&lt;-</font> op<font color=Cyan>;</font> y <font color=Red>&lt;-</font> p<font color=Cyan>;</font> rest <font color=Cyan>(</font>f x y<font color=Cyan>)</font><font color=Cyan>}</font>+<a name="line-120"></a>                                 <font color=Cyan>+++</font> return x+<a name="line-121"></a>+<a name="line-122"></a><a name="chainr"></a><font color=Blue>chainr</font>            <font color=Red>::</font> Parser a <font color=Red>-&gt;</font> Parser <font color=Cyan>(</font>a <font color=Red>-&gt;</font> a <font color=Red>-&gt;</font> a<font color=Cyan>)</font> <font color=Red>-&gt;</font> a <font color=Red>-&gt;</font> Parser a+<a name="line-123"></a><font color=Blue>chainr</font> 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+<a name="line-124"></a>+<a name="line-125"></a><a name="chainr1"></a><font color=Blue>chainr1</font>           <font color=Red>::</font> Parser a <font color=Red>-&gt;</font> Parser <font color=Cyan>(</font>a <font color=Red>-&gt;</font> a <font color=Red>-&gt;</font> a<font color=Cyan>)</font> <font color=Red>-&gt;</font> Parser a+<a name="line-126"></a><a name="chainr1"></a><font color=Blue>p</font> <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>&lt;-</font> p<font color=Cyan>;</font> rest x<font color=Cyan>}</font>+<a name="line-127"></a>                     <font color=Green><u>where</u></font>+<a name="line-128"></a>                        rest x <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font>f <font color=Red>&lt;-</font> op<font color=Cyan>;</font> y <font color=Red>&lt;-</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>+<a name="line-129"></a>                                 <font color=Cyan>+++</font> return x+<a name="line-130"></a>+<a name="line-131"></a><a name="ops"></a><font color=Blue>ops</font>               <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>-&gt;</font> Parser b+<a name="line-132"></a><font color=Blue>ops</font> 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>&lt;-</font> xs<font color=Red>]</font>+<a name="line-133"></a>+<a name="line-134"></a><a name="bracket"></a><font color=Blue>bracket</font>           <font color=Red>::</font> Parser a <font color=Red>-&gt;</font> Parser b <font color=Red>-&gt;</font> Parser c <font color=Red>-&gt;</font> Parser b+<a name="line-135"></a><font color=Blue>bracket</font> 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>&lt;-</font> p<font color=Cyan>;</font> close<font color=Cyan>;</font> return x<font color=Cyan>}</font>+<a name="line-136"></a>+<a name="line-137"></a><font color=Blue>-- ------------------------------------------------------------</font>+<a name="line-138"></a><font color=Blue>-- * Useful parsers</font>+<a name="line-139"></a><font color=Blue>-- ------------------------------------------------------------</font>+<a name="line-140"></a>+<a name="line-141"></a><a name="char"></a><font color=Blue>char</font>              <font color=Red>::</font> Char <font color=Red>-&gt;</font> Parser Char+<a name="line-142"></a><font color=Blue>char</font> x             <font color=Red>=</font> sat <font color=Cyan>(</font><font color=Red>\</font>y <font color=Red>-&gt;</font> x <font color=Cyan>==</font> y<font color=Cyan>)</font>+<a name="line-143"></a>+<a name="line-144"></a><a name="digit"></a><font color=Blue>digit</font>             <font color=Red>::</font> Parser Char+<a name="line-145"></a><font color=Blue>digit</font>              <font color=Red>=</font> sat isDigit+<a name="line-146"></a>+<a name="line-147"></a><a name="lower"></a><font color=Blue>lower</font>             <font color=Red>::</font> Parser Char+<a name="line-148"></a><font color=Blue>lower</font>              <font color=Red>=</font> sat isLower+<a name="line-149"></a>+<a name="line-150"></a><a name="upper"></a><font color=Blue>upper</font>             <font color=Red>::</font> Parser Char+<a name="line-151"></a><font color=Blue>upper</font>              <font color=Red>=</font> sat isUpper+<a name="line-152"></a>+<a name="line-153"></a><a name="letter"></a><font color=Blue>letter</font>            <font color=Red>::</font> Parser Char+<a name="line-154"></a><font color=Blue>letter</font>             <font color=Red>=</font> sat isAlpha+<a name="line-155"></a>+<a name="line-156"></a><a name="alphanum"></a><font color=Blue>alphanum</font>          <font color=Red>::</font> Parser Char+<a name="line-157"></a><font color=Blue>alphanum</font>           <font color=Red>=</font> sat isAlphaNum <font color=Cyan>+++</font> char <font color=Magenta>'_'</font>+<a name="line-158"></a>+<a name="line-159"></a><a name="string"></a><font color=Blue>string</font>            <font color=Red>::</font> String <font color=Red>-&gt;</font> Parser String+<a name="line-160"></a><font color=Blue>string</font> <font color=Magenta>""</font>          <font color=Red>=</font> return <font color=Magenta>""</font>+<a name="line-161"></a><font color=Blue>string</font> <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>+<a name="line-162"></a>+<a name="line-163"></a><a name="ident"></a><font color=Blue>ident</font>             <font color=Red>::</font> Parser String+<a name="line-164"></a><font color=Blue>ident</font>              <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font>x <font color=Red>&lt;-</font> lower<font color=Cyan>;</font> xs <font color=Red>&lt;-</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>+<a name="line-165"></a>+<a name="line-166"></a><a name="nat"></a><font color=Blue>nat</font>               <font color=Red>::</font> Parser Int+<a name="line-167"></a><font color=Blue>nat</font>                <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font>x <font color=Red>&lt;-</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+<a name="line-168"></a>                     <font color=Green><u>where</u></font>+<a name="line-169"></a>                        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+<a name="line-170"></a>+<a name="line-171"></a><a name="int"></a><font color=Blue>int</font>               <font color=Red>::</font> Parser Int+<a name="line-172"></a><font color=Blue>int</font>                <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>&lt;-</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+<a name="line-173"></a>+<a name="line-174"></a><font color=Blue>-- ------------------------------------------------------------</font>+<a name="line-175"></a><font color=Blue>-- * Lexical combinators</font>+<a name="line-176"></a><font color=Blue>-- ------------------------------------------------------------</font>+<a name="line-177"></a>+<a name="line-178"></a><a name="spaces"></a><font color=Blue>spaces</font>            <font color=Red>::</font> Parser ()+<a name="line-179"></a><font color=Blue>spaces</font>             <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>+<a name="line-180"></a>+<a name="line-181"></a><a name="comment"></a><font color=Blue>comment</font>           <font color=Red>::</font> Parser ()+<a name="line-182"></a><font color=Blue>--comment            = do {string "--"; many (sat (\x -&gt; x /= '\n')); return ()}</font>+<a name="line-183"></a><font color=Blue>--comment            = do </font>+<a name="line-184"></a><font color=Blue>--                       _ &lt;- string "--"</font>+<a name="line-185"></a><font color=Blue>--                       _ &lt;- many (sat (\x -&gt; x /= '\n'))</font>+<a name="line-186"></a><font color=Blue>--                       return ()</font>+<a name="line-187"></a><font color=Blue>comment</font>            <font color=Red>=</font> <font color=Green><u>do</u></font>+<a name="line-188"></a>                       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>+<a name="line-189"></a>                       return ()+<a name="line-190"></a>+<a name="line-191"></a><a name="junk"></a><font color=Blue>junk</font>              <font color=Red>::</font> Parser ()+<a name="line-192"></a><font color=Blue>junk</font>               <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>+<a name="line-193"></a>+<a name="line-194"></a><a name="skip"></a><font color=Blue>skip</font>              <font color=Red>::</font> Parser a <font color=Red>-&gt;</font> Parser a+<a name="line-195"></a><font color=Blue>skip</font> 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>+<a name="line-196"></a>+<a name="line-197"></a><a name="token"></a><font color=Blue>token</font>             <font color=Red>::</font> Parser a <font color=Red>-&gt;</font> Parser a+<a name="line-198"></a><font color=Blue>token</font> p            <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font>v <font color=Red>&lt;-</font> p<font color=Cyan>;</font> junk<font color=Cyan>;</font> return v<font color=Cyan>}</font>+<a name="line-199"></a>+<a name="line-200"></a><font color=Blue>-- ------------------------------------------------------------</font>+<a name="line-201"></a><font color=Blue>-- * Token parsers</font>+<a name="line-202"></a><font color=Blue>-- ------------------------------------------------------------</font>+<a name="line-203"></a>+<a name="line-204"></a><a name="natural"></a><font color=Blue>natural</font>           <font color=Red>::</font> Parser Int+<a name="line-205"></a><font color=Blue>natural</font>            <font color=Red>=</font> token nat+<a name="line-206"></a>+<a name="line-207"></a><a name="integer"></a><font color=Blue>integer</font>           <font color=Red>::</font> Parser Int+<a name="line-208"></a><font color=Blue>integer</font>            <font color=Red>=</font> token int+<a name="line-209"></a>+<a name="line-210"></a><a name="symbol"></a><font color=Blue>symbol</font>            <font color=Red>::</font> String <font color=Red>-&gt;</font> Parser String+<a name="line-211"></a><font color=Blue>symbol</font> xs          <font color=Red>=</font> token <font color=Cyan>(</font>string xs<font color=Cyan>)</font>+<a name="line-212"></a>+<a name="line-213"></a><a name="identifier"></a><font color=Blue>identifier</font>        <font color=Red>::</font> <font color=Red>[</font>String<font color=Red>]</font> <font color=Red>-&gt;</font> Parser String+<a name="line-214"></a><font color=Blue>identifier</font> 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>&lt;-</font> ident<font color=Cyan>;</font>+<a name="line-215"></a>                                <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+<a name="line-216"></a>                                <font color=Green><u>else</u></font> return mzero<font color=Cyan>}</font><font color=Cyan>)</font>+<a name="line-217"></a>+<a name="line-218"></a><font color=Blue>------------------------------------------------------------------------------</font>+</pre>+</html>
+ docs/haddock/src/Text/ParserCombinators/HuttonMeijerWallace.html view
@@ -0,0 +1,301 @@+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">+<html>+<pre><a name="line-1"></a><font color=Blue>{-----------------------------------------------------------------------------+<a name="line-2"></a>+<a name="line-3"></a>                 A LIBRARY OF MONADIC PARSER COMBINATORS+<a name="line-4"></a>+<a name="line-5"></a>                              29th July 1996+<a name="line-6"></a>+<a name="line-7"></a>                 Graham Hutton               Erik Meijer+<a name="line-8"></a>            University of Nottingham    University of Utrecht+<a name="line-9"></a>+<a name="line-10"></a>This Haskell 1.3 script defines a library of parser combinators, and is taken+<a name="line-11"></a>from sections 1-6 of our article "Monadic Parser Combinators".  Some changes+<a name="line-12"></a>to the library have been made in the move from Gofer to Haskell:+<a name="line-13"></a>+<a name="line-14"></a>   * Do notation is used in place of monad comprehension notation;+<a name="line-15"></a>+<a name="line-16"></a>   * The parser datatype is defined using "newtype", to avoid the overhead+<a name="line-17"></a>     of tagging and untagging parsers with the P constructor.+<a name="line-18"></a>+<a name="line-19"></a>------------------------------------------------------------------------------+<a name="line-20"></a>** Extended to allow a symbol table/state to be threaded through the monad.+<a name="line-21"></a>** Extended to allow a parameterised token type, rather than just strings.+<a name="line-22"></a>** Extended to allow error-reporting.+<a name="line-23"></a>+<a name="line-24"></a>(Extensions: 1998-2000 Malcolm.Wallace@cs.york.ac.uk)+<a name="line-25"></a>(More extensions: 2004 gk-haskell@ninebynine.org)+<a name="line-26"></a>+<a name="line-27"></a>------------------------------------------------------------------------------}</font>+<a name="line-28"></a>+<a name="line-29"></a><font color=Blue>-- | This library of monadic parser combinators is based on the ones</font>+<a name="line-30"></a><font color=Blue>--   defined by Graham Hutton and Erik Meijer.  It has been extended by</font>+<a name="line-31"></a><font color=Blue>--   Malcolm Wallace to use an abstract token type (no longer just a</font>+<a name="line-32"></a><font color=Blue>--   string) as input, and to incorporate state in the monad, useful</font>+<a name="line-33"></a><font color=Blue>--   for symbol tables, macros, and so on.  Basic facilities for error</font>+<a name="line-34"></a><font color=Blue>--   reporting have also been added, and later extended by Graham Klyne</font>+<a name="line-35"></a><font color=Blue>--   to return the errors through an @Either@ type, rather than just</font>+<a name="line-36"></a><font color=Blue>--   calling @error@.</font>+<a name="line-37"></a>+<a name="line-38"></a><font color=Green><u>module</u></font> Text<font color=Cyan>.</font>ParserCombinators<font color=Cyan>.</font>HuttonMeijerWallace+<a name="line-39"></a>  <font color=Cyan>(</font>+<a name="line-40"></a>  <font color=Blue>-- * The parser monad</font>+<a name="line-41"></a>    Parser<font color=Cyan>(</font><font color=Red>..</font><font color=Cyan>)</font>+<a name="line-42"></a>  <font color=Blue>-- * Primitive parser combinators</font>+<a name="line-43"></a>  <font color=Cyan>,</font> item<font color=Cyan>,</font> eof<font color=Cyan>,</font> papply<font color=Cyan>,</font> papply'+<a name="line-44"></a>  <font color=Blue>-- * Derived combinators</font>+<a name="line-45"></a>  <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+<a name="line-46"></a>  <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+<a name="line-47"></a>  <font color=Cyan>,</font> toEOF+<a name="line-48"></a>  <font color=Blue>-- * Error handling</font>+<a name="line-49"></a>  <font color=Cyan>,</font> elserror+<a name="line-50"></a>  <font color=Blue>-- * State handling</font>+<a name="line-51"></a>  <font color=Cyan>,</font> stupd<font color=Cyan>,</font> stquery<font color=Cyan>,</font> stget+<a name="line-52"></a>  <font color=Blue>-- * Re-parsing</font>+<a name="line-53"></a>  <font color=Cyan>,</font> reparse+<a name="line-54"></a>  <font color=Cyan>)</font> <font color=Green><u>where</u></font>+<a name="line-55"></a>+<a name="line-56"></a><font color=Green><u>import</u></font> Char+<a name="line-57"></a><font color=Green><u>import</u></font> Monad+<a name="line-58"></a>+<a name="line-59"></a><font color=Green><u>infixr</u></font> <font color=Magenta>5</font> <font color=Cyan>+++</font>+<a name="line-60"></a>+<a name="line-61"></a><font color=Blue>--- The parser monad ---------------------------------------------------------</font>+<a name="line-62"></a>+<a name="line-63"></a><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>+<a name="line-64"></a>+<a name="line-65"></a><a name="Parser"></a><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>-&gt;</font> <font color=Red>[</font>Either e t<font color=Red>]</font> <font color=Red>-&gt;</font> ParseResult s t e a <font color=Cyan>)</font>+<a name="line-66"></a>    <font color=Blue>-- ^ The parser type is parametrised on the types of the state @s@,</font>+<a name="line-67"></a>    <font color=Blue>--   the input tokens @t@, error-type @e@, and the result value @a@.</font>+<a name="line-68"></a>    <font color=Blue>--   The state and remaining input are threaded through the monad.</font>+<a name="line-69"></a>+<a name="line-70"></a><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>+<a name="line-71"></a>   <font color=Blue>-- fmap        :: (a -&gt; b) -&gt; (Parser s t e a -&gt; Parser s t e b)</font>+<a name="line-72"></a>   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>-&gt;</font> <font color=Green><u>case</u></font> p st inp <font color=Green><u>of</u></font>+<a name="line-73"></a>                        Right res <font color=Red>-&gt;</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>&lt;-</font> res<font color=Red>]</font>+<a name="line-74"></a>                        Left err  <font color=Red>-&gt;</font> Left err+<a name="line-75"></a>                       <font color=Cyan>)</font>+<a name="line-76"></a>+<a name="line-77"></a><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>+<a name="line-78"></a>   <font color=Blue>-- return      :: a -&gt; Parser s t e a</font>+<a name="line-79"></a>   return v        <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>st inp <font color=Red>-&gt;</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>+<a name="line-80"></a>   <font color=Blue>-- &gt;&gt;=         :: Parser s t e a -&gt; (a -&gt; Parser s t e b) -&gt; Parser s t e b</font>+<a name="line-81"></a>   <font color=Cyan>(</font>P p<font color=Cyan>)</font> <font color=Cyan>&gt;&gt;=</font> f     <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>st inp <font color=Red>-&gt;</font> <font color=Green><u>case</u></font> p st inp <font color=Green><u>of</u></font>+<a name="line-82"></a>                        Right res <font color=Red>-&gt;</font> foldr joinresults <font color=Cyan>(</font>Right []<font color=Cyan>)</font>+<a name="line-83"></a>                            <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>&lt;-</font> res <font color=Red>]</font>+<a name="line-84"></a>                        Left err  <font color=Red>-&gt;</font> Left err+<a name="line-85"></a>                       <font color=Cyan>)</font>+<a name="line-86"></a>   <font color=Blue>-- fail        :: String -&gt; Parser s t e a</font>+<a name="line-87"></a>   fail err        <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>st inp <font color=Red>-&gt;</font> Right []<font color=Cyan>)</font>+<a name="line-88"></a>  <font color=Blue>-- I know it's counterintuitive, but we want no-parse, not an error.</font>+<a name="line-89"></a>+<a name="line-90"></a><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>+<a name="line-91"></a>   <font color=Blue>-- mzero       :: Parser s t e a</font>+<a name="line-92"></a>   mzero           <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>st inp <font color=Red>-&gt;</font> Right []<font color=Cyan>)</font>+<a name="line-93"></a>   <font color=Blue>-- mplus       :: Parser s t e a -&gt; Parser s t e a -&gt; Parser s t e a</font>+<a name="line-94"></a>   <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>-&gt;</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>+<a name="line-95"></a>+<a name="line-96"></a><a name="joinresults"></a><font color=Blue>-- joinresults ensures that explicitly raised errors are dominant,</font>+<a name="line-97"></a><font color=Blue>-- provided no parse has yet been found.  The commented out code is</font>+<a name="line-98"></a><font color=Blue>-- a slightly stricter specification of the real code.</font>+<a name="line-99"></a><font color=Blue>joinresults</font> <font color=Red>::</font> ParseResult s t e a <font color=Red>-&gt;</font> ParseResult s t e a <font color=Red>-&gt;</font> ParseResult s t e a+<a name="line-100"></a><font color=Blue>{-+<a name="line-101"></a>joinresults (Left  p)  (Left  q)  = Left  p+<a name="line-102"></a>joinresults (Left  p)  (Right _)  = Left  p+<a name="line-103"></a>joinresults (Right []) (Left  q)  = Left  q+<a name="line-104"></a>joinresults (Right p)  (Left  q)  = Right p+<a name="line-105"></a>joinresults (Right p)  (Right q)  = Right (p++q)+<a name="line-106"></a>-}</font>+<a name="line-107"></a><font color=Blue>joinresults</font> <font color=Cyan>(</font>Left  p<font color=Cyan>)</font>  q  <font color=Red>=</font> Left p+<a name="line-108"></a><font color=Blue>joinresults</font> <font color=Cyan>(</font>Right []<font color=Cyan>)</font> q  <font color=Red>=</font> q+<a name="line-109"></a><font color=Blue>joinresults</font> <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>-&gt;</font> []+<a name="line-110"></a>                                                 Right r <font color=Red>-&gt;</font> r<font color=Cyan>)</font>+<a name="line-111"></a>+<a name="line-112"></a>+<a name="line-113"></a><font color=Blue>--- Primitive parser combinators ---------------------------------------------</font>+<a name="line-114"></a>+<a name="line-115"></a><a name="item"></a><font color=Blue>-- | Deliver the first remaining token.</font>+<a name="line-116"></a><font color=Blue>item</font>              <font color=Red>::</font> Parser s t e t+<a name="line-117"></a><font color=Blue>item</font>               <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>st inp <font color=Red>-&gt;</font> <font color=Green><u>case</u></font> inp <font color=Green><u>of</u></font>+<a name="line-118"></a>                        []            <font color=Red>-&gt;</font> Right []+<a name="line-119"></a>                        <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>-&gt;</font> Left e+<a name="line-120"></a>                        <font color=Cyan>(</font>Right x<font color=Red><b>:</b></font> xs<font color=Cyan>)</font> <font color=Red>-&gt;</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>+<a name="line-121"></a>                       <font color=Cyan>)</font>+<a name="line-122"></a>+<a name="line-123"></a><a name="eof"></a><font color=Blue>-- | Fail if end of input is not reached</font>+<a name="line-124"></a><font color=Blue>eof</font>               <font color=Red>::</font> Show p <font color=Red>=&gt;</font> Parser s <font color=Cyan>(</font>p<font color=Cyan>,</font>t<font color=Cyan>)</font> String ()+<a name="line-125"></a><font color=Blue>eof</font>                <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>st inp <font color=Red>-&gt;</font> <font color=Green><u>case</u></font> inp <font color=Green><u>of</u></font>+<a name="line-126"></a>                        []         <font color=Red>-&gt;</font> Right <font color=Red>[</font><font color=Cyan>(</font>()<font color=Cyan>,</font>st<font color=Cyan>,</font>[]<font color=Cyan>)</font><font color=Red>]</font>+<a name="line-127"></a>                        <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>-&gt;</font> Left e+<a name="line-128"></a>                        <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>-&gt;</font> Left <font color=Cyan>(</font><font color=Magenta>"End of input expected at "</font>+<a name="line-129"></a>                                                 <font color=Cyan>++</font>show p<font color=Cyan>++</font><font color=Magenta>"\n  but found text"</font><font color=Cyan>)</font>+<a name="line-130"></a>                       <font color=Cyan>)</font>+<a name="line-131"></a>+<a name="line-132"></a><font color=Blue>{-+<a name="line-133"></a>-- | Ensure the value delivered by the parser is evaluated to WHNF.+<a name="line-134"></a>force             :: Parser s t e a -&gt; Parser s t e a+<a name="line-135"></a>force (P p)        = P (\st inp -&gt; let Right xs = p st inp+<a name="line-136"></a>                                       h = head xs in+<a name="line-137"></a>                                   h `seq` Right (h: tail xs)+<a name="line-138"></a>                       )+<a name="line-139"></a>--  [[[GK]]]  ^^^^^^+<a name="line-140"></a>--  WHNF = Weak Head Normal Form, meaning that it has no top-level redex.+<a name="line-141"></a>--  In this case, I think that means that the first element of the list+<a name="line-142"></a>--  is fully evaluated.+<a name="line-143"></a>--+<a name="line-144"></a>--  NOTE:  the original form of this function fails if there is no parse+<a name="line-145"></a>--  result for p st inp (head xs fails if xs is null), so the modified+<a name="line-146"></a>--  form can assume a Right value only.+<a name="line-147"></a>--+<a name="line-148"></a>--  Why is this needed?+<a name="line-149"></a>--  It's not exported, and the only use of this I see is commented out.+<a name="line-150"></a>---------------------------------------+<a name="line-151"></a>-}</font>+<a name="line-152"></a>+<a name="line-153"></a>+<a name="line-154"></a><a name="first"></a><font color=Blue>-- | Deliver the first parse result only, eliminating any backtracking.</font>+<a name="line-155"></a><font color=Blue>first</font>             <font color=Red>::</font> Parser s t e a <font color=Red>-&gt;</font> Parser s t e a+<a name="line-156"></a><font color=Blue>first</font> <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>-&gt;</font> <font color=Green><u>case</u></font> p st inp <font color=Green><u>of</u></font>+<a name="line-157"></a>                                   Right <font color=Cyan>(</font>x<font color=Red><b>:</b></font>xs<font color=Cyan>)</font> <font color=Red>-&gt;</font> Right <font color=Red>[</font>x<font color=Red>]</font>+<a name="line-158"></a>                                   otherwise    <font color=Red>-&gt;</font> otherwise+<a name="line-159"></a>                       <font color=Cyan>)</font>+<a name="line-160"></a>+<a name="line-161"></a><a name="papply"></a><font color=Blue>-- | Apply the parser to some real input, given an initial state value.</font>+<a name="line-162"></a><font color=Blue>--   If the parser fails, raise 'error' to halt the program.</font>+<a name="line-163"></a><font color=Blue>--   (This is the original exported behaviour - to allow the caller to</font>+<a name="line-164"></a><font color=Blue>--   deal with the error differently, see @papply'@.)</font>+<a name="line-165"></a><font color=Blue>papply</font>            <font color=Red>::</font> Parser s t String a <font color=Red>-&gt;</font> s <font color=Red>-&gt;</font> <font color=Red>[</font>Either String t<font color=Red>]</font>+<a name="line-166"></a>                                              <font color=Red>-&gt;</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="line-167"></a><font color=Blue>papply</font> <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>+<a name="line-168"></a>+<a name="line-169"></a><a name="papply'"></a><font color=Blue>-- | Apply the parser to some real input, given an initial state value.</font>+<a name="line-170"></a><font color=Blue>--   If the parser fails, return a diagnostic message to the caller.</font>+<a name="line-171"></a><font color=Blue>papply'</font>           <font color=Red>::</font> Parser s t e a <font color=Red>-&gt;</font> s <font color=Red>-&gt;</font> <font color=Red>[</font>Either e t<font color=Red>]</font>+<a name="line-172"></a>                                         <font color=Red>-&gt;</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="line-173"></a><font color=Blue>papply'</font> <font color=Cyan>(</font>P p<font color=Cyan>)</font> st inp <font color=Red>=</font> p st inp+<a name="line-174"></a>+<a name="line-175"></a><font color=Blue>--- Derived combinators ------------------------------------------------------</font>+<a name="line-176"></a>+<a name="line-177"></a><a name="+++"></a><font color=Blue>-- | A choice between parsers.  Keep only the first success.</font>+<a name="line-178"></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>-&gt;</font> Parser s t e a <font color=Red>-&gt;</font> Parser s t e a+<a name="line-179"></a><a name="p"></a><font color=Blue>p</font> <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>+<a name="line-180"></a>+<a name="line-181"></a><a name="sat"></a><font color=Blue>-- | Deliver the first token if it satisfies a predicate.</font>+<a name="line-182"></a><font color=Blue>sat</font>               <font color=Red>::</font> <font color=Cyan>(</font>t <font color=Red>-&gt;</font> Bool<font color=Cyan>)</font> <font color=Red>-&gt;</font> Parser s <font color=Cyan>(</font>p<font color=Cyan>,</font>t<font color=Cyan>)</font> e t+<a name="line-183"></a><font color=Blue>sat</font> 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>&lt;-</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>+<a name="line-184"></a>+<a name="line-185"></a><a name="tok"></a><font color=Blue>-- | Deliver the first token if it equals the argument.</font>+<a name="line-186"></a><font color=Blue>tok</font>               <font color=Red>::</font> Eq t <font color=Red>=&gt;</font> t <font color=Red>-&gt;</font> Parser s <font color=Cyan>(</font>p<font color=Cyan>,</font>t<font color=Cyan>)</font> e t+<a name="line-187"></a><font color=Blue>tok</font> 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>&lt;-</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>+<a name="line-188"></a>+<a name="line-189"></a><a name="nottok"></a><font color=Blue>-- | Deliver the first token if it does not equal the argument.</font>+<a name="line-190"></a><font color=Blue>nottok</font>            <font color=Red>::</font> Eq t <font color=Red>=&gt;</font> <font color=Red>[</font>t<font color=Red>]</font> <font color=Red>-&gt;</font> Parser s <font color=Cyan>(</font>p<font color=Cyan>,</font>t<font color=Cyan>)</font> e t+<a name="line-191"></a><font color=Blue>nottok</font> 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>&lt;-</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+<a name="line-192"></a>                                        <font color=Green><u>else</u></font> mzero<font color=Cyan>}</font>+<a name="line-193"></a>+<a name="line-194"></a><a name="many"></a><font color=Blue>-- | Deliver zero or more values of @a@.</font>+<a name="line-195"></a><font color=Blue>many</font>              <font color=Red>::</font> Parser s t e a <font color=Red>-&gt;</font> Parser s t e <font color=Red>[</font>a<font color=Red>]</font>+<a name="line-196"></a><font color=Blue>many</font> p             <font color=Red>=</font> many1 p <font color=Cyan>+++</font> return []+<a name="line-197"></a><font color=Blue>--many p           = force (many1 p +++ return [])</font>+<a name="line-198"></a>+<a name="line-199"></a><a name="many1"></a><font color=Blue>-- | Deliver one or more values of @a@.</font>+<a name="line-200"></a><font color=Blue>many1</font>             <font color=Red>::</font> Parser s t e a <font color=Red>-&gt;</font> Parser s t e <font color=Red>[</font>a<font color=Red>]</font>+<a name="line-201"></a><font color=Blue>many1</font> p            <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font>x <font color=Red>&lt;-</font> p<font color=Cyan>;</font> xs <font color=Red>&lt;-</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>+<a name="line-202"></a>+<a name="line-203"></a><a name="sepby"></a><font color=Blue>-- | Deliver zero or more values of @a@ separated by @b@'s.</font>+<a name="line-204"></a><font color=Blue>sepby</font>             <font color=Red>::</font> Parser s t e a <font color=Red>-&gt;</font> Parser s t e b <font color=Red>-&gt;</font> Parser s t e <font color=Red>[</font>a<font color=Red>]</font>+<a name="line-205"></a><a name="sepby"></a><font color=Blue>p</font> <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 []+<a name="line-206"></a>+<a name="line-207"></a><a name="sepby1"></a><font color=Blue>-- | Deliver one or more values of @a@ separated by @b@'s.</font>+<a name="line-208"></a><font color=Blue>sepby1</font>            <font color=Red>::</font> Parser s t e a <font color=Red>-&gt;</font> Parser s t e b <font color=Red>-&gt;</font> Parser s t e <font color=Red>[</font>a<font color=Red>]</font>+<a name="line-209"></a><a name="sepby1"></a><font color=Blue>p</font> <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>&lt;-</font> p<font color=Cyan>;</font> xs <font color=Red>&lt;-</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>+<a name="line-210"></a>+<a name="line-211"></a><a name="chainl"></a><font color=Blue>chainl</font>            <font color=Red>::</font> Parser s t e a <font color=Red>-&gt;</font> Parser s t e <font color=Cyan>(</font>a<font color=Red>-&gt;</font>a<font color=Red>-&gt;</font>a<font color=Cyan>)</font> <font color=Red>-&gt;</font> a+<a name="line-212"></a>                                                              <font color=Red>-&gt;</font> Parser s t e a+<a name="line-213"></a><font color=Blue>chainl</font> 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+<a name="line-214"></a>+<a name="line-215"></a><a name="chainl1"></a><font color=Blue>chainl1</font>           <font color=Red>::</font> Parser s t e a <font color=Red>-&gt;</font> Parser s t e <font color=Cyan>(</font>a<font color=Red>-&gt;</font>a<font color=Red>-&gt;</font>a<font color=Cyan>)</font> <font color=Red>-&gt;</font> Parser s t e a+<a name="line-216"></a><a name="chainl1"></a><font color=Blue>p</font> <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>&lt;-</font> p<font color=Cyan>;</font> rest x<font color=Cyan>}</font>+<a name="line-217"></a>                     <font color=Green><u>where</u></font>+<a name="line-218"></a>                        rest x <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font>f <font color=Red>&lt;-</font> op<font color=Cyan>;</font> y <font color=Red>&lt;-</font> p<font color=Cyan>;</font> rest <font color=Cyan>(</font>f x y<font color=Cyan>)</font><font color=Cyan>}</font>+<a name="line-219"></a>                                 <font color=Cyan>+++</font> return x+<a name="line-220"></a>+<a name="line-221"></a><a name="chainr"></a><font color=Blue>chainr</font>            <font color=Red>::</font> Parser s t e a <font color=Red>-&gt;</font> Parser s t e <font color=Cyan>(</font>a<font color=Red>-&gt;</font>a<font color=Red>-&gt;</font>a<font color=Cyan>)</font> <font color=Red>-&gt;</font> a+<a name="line-222"></a>                                                              <font color=Red>-&gt;</font> Parser s t e a+<a name="line-223"></a><font color=Blue>chainr</font> 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+<a name="line-224"></a>+<a name="line-225"></a><a name="chainr1"></a><font color=Blue>chainr1</font>           <font color=Red>::</font> Parser s t e a <font color=Red>-&gt;</font> Parser s t e <font color=Cyan>(</font>a<font color=Red>-&gt;</font>a<font color=Red>-&gt;</font>a<font color=Cyan>)</font> <font color=Red>-&gt;</font> Parser s t e a+<a name="line-226"></a><a name="chainr1"></a><font color=Blue>p</font> <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>&lt;-</font> p<font color=Cyan>;</font> rest x<font color=Cyan>}</font>+<a name="line-227"></a>                     <font color=Green><u>where</u></font>+<a name="line-228"></a>                        rest x <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font> f <font color=Red>&lt;-</font> op+<a name="line-229"></a>                                    <font color=Cyan>;</font> y <font color=Red>&lt;-</font> p <font color=Cyan>`chainr1`</font> op+<a name="line-230"></a>                                    <font color=Cyan>;</font> return <font color=Cyan>(</font>f x y<font color=Cyan>)</font>+<a name="line-231"></a>                                    <font color=Cyan>}</font>+<a name="line-232"></a>                                 <font color=Cyan>+++</font> return x+<a name="line-233"></a>+<a name="line-234"></a><a name="ops"></a><font color=Blue>ops</font>               <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>-&gt;</font> Parser s t e b+<a name="line-235"></a><font color=Blue>ops</font> 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>&lt;-</font> xs<font color=Red>]</font>+<a name="line-236"></a>+<a name="line-237"></a><a name="bracket"></a><font color=Blue>bracket</font>           <font color=Red>::</font> <font color=Cyan>(</font>Show p<font color=Cyan>,</font>Show t<font color=Cyan>)</font> <font color=Red>=&gt;</font>+<a name="line-238"></a>                     Parser s <font color=Cyan>(</font>p<font color=Cyan>,</font>t<font color=Cyan>)</font> e a <font color=Red>-&gt;</font> Parser s <font color=Cyan>(</font>p<font color=Cyan>,</font>t<font color=Cyan>)</font> e b <font color=Red>-&gt;</font>+<a name="line-239"></a>                               Parser s <font color=Cyan>(</font>p<font color=Cyan>,</font>t<font color=Cyan>)</font> e c <font color=Red>-&gt;</font> Parser s <font color=Cyan>(</font>p<font color=Cyan>,</font>t<font color=Cyan>)</font> e b+<a name="line-240"></a><font color=Blue>bracket</font> open p close <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font> open+<a name="line-241"></a>                          <font color=Cyan>;</font> x <font color=Red>&lt;-</font> p+<a name="line-242"></a>                          <font color=Cyan>;</font> close <font color=Blue>-- `elserror` "improperly matched construct";</font>+<a name="line-243"></a>                          <font color=Cyan>;</font> return x+<a name="line-244"></a>                          <font color=Cyan>}</font>+<a name="line-245"></a>+<a name="line-246"></a><a name="toEOF"></a><font color=Blue>-- | Accept a complete parse of the input only, no partial parses.</font>+<a name="line-247"></a><font color=Blue>toEOF</font>             <font color=Red>::</font> Show p <font color=Red>=&gt;</font>+<a name="line-248"></a>                     Parser s <font color=Cyan>(</font>p<font color=Cyan>,</font>t<font color=Cyan>)</font> String a <font color=Red>-&gt;</font> Parser s <font color=Cyan>(</font>p<font color=Cyan>,</font>t<font color=Cyan>)</font> String a+<a name="line-249"></a><font color=Blue>toEOF</font> p            <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font> x <font color=Red>&lt;-</font> p<font color=Cyan>;</font> eof<font color=Cyan>;</font> return x <font color=Cyan>}</font>+<a name="line-250"></a>+<a name="line-251"></a>+<a name="line-252"></a><font color=Blue>--- Error handling -----------------------------------------------------------</font>+<a name="line-253"></a>+<a name="line-254"></a><a name="parseerror"></a><font color=Blue>-- | Return an error using the supplied diagnostic string, and a token type</font>+<a name="line-255"></a><font color=Blue>--   which includes position information.</font>+<a name="line-256"></a><font color=Blue>parseerror</font> <font color=Red>::</font> <font color=Cyan>(</font>Show p<font color=Cyan>,</font>Show t<font color=Cyan>)</font> <font color=Red>=&gt;</font> String <font color=Red>-&gt;</font> Parser s <font color=Cyan>(</font>p<font color=Cyan>,</font>t<font color=Cyan>)</font> String a+<a name="line-257"></a><font color=Blue>parseerror</font> err <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>st inp <font color=Red>-&gt;</font>+<a name="line-258"></a>                         <font color=Green><u>case</u></font> inp <font color=Green><u>of</u></font>+<a name="line-259"></a>                           [] <font color=Red>-&gt;</font> Left <font color=Magenta>"Parse error: unexpected EOF\n"</font>+<a name="line-260"></a>                           <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>-&gt;</font> Left <font color=Cyan>(</font><font color=Magenta>"Lexical error:  "</font><font color=Cyan>++</font>e<font color=Cyan>)</font>+<a name="line-261"></a>                           <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>-&gt;</font>+<a name="line-262"></a>                                 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>+<a name="line-263"></a>                                       <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>+<a name="line-264"></a>                   <font color=Cyan>)</font>+<a name="line-265"></a>+<a name="line-266"></a>+<a name="line-267"></a><a name="elserror"></a><font color=Blue>-- | If the parser fails, generate an error message.</font>+<a name="line-268"></a><font color=Blue>elserror</font>          <font color=Red>::</font> <font color=Cyan>(</font>Show p<font color=Cyan>,</font>Show t<font color=Cyan>)</font> <font color=Red>=&gt;</font> Parser s <font color=Cyan>(</font>p<font color=Cyan>,</font>t<font color=Cyan>)</font> String a <font color=Red>-&gt;</font> String+<a name="line-269"></a>                                        <font color=Red>-&gt;</font> Parser s <font color=Cyan>(</font>p<font color=Cyan>,</font>t<font color=Cyan>)</font> String a+<a name="line-270"></a><a name="elserror"></a><font color=Blue>p</font> <font color=Cyan>`elserror`</font> s     <font color=Red>=</font> p <font color=Cyan>+++</font> parseerror s+<a name="line-271"></a>+<a name="line-272"></a><font color=Blue>--- State handling -----------------------------------------------------------</font>+<a name="line-273"></a>+<a name="line-274"></a><a name="stupd"></a><font color=Blue>-- | Update the internal state.</font>+<a name="line-275"></a><font color=Blue>stupd</font>      <font color=Red>::</font> <font color=Cyan>(</font>s<font color=Red>-&gt;</font>s<font color=Cyan>)</font> <font color=Red>-&gt;</font> Parser s t e ()+<a name="line-276"></a><font color=Blue>stupd</font> f     <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>st inp<font color=Red>-&gt;</font> <font color=Blue>{-let newst = f st in newst `seq`-}</font>+<a name="line-277"></a>                           Right <font color=Red>[</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>+<a name="line-278"></a>+<a name="line-279"></a><a name="stquery"></a><font color=Blue>-- | Query the internal state.</font>+<a name="line-280"></a><font color=Blue>stquery</font>    <font color=Red>::</font> <font color=Cyan>(</font>s<font color=Red>-&gt;</font>a<font color=Cyan>)</font> <font color=Red>-&gt;</font> Parser s t e a+<a name="line-281"></a><font color=Blue>stquery</font> f   <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>st inp<font color=Red>-&gt;</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>+<a name="line-282"></a>+<a name="line-283"></a><a name="stget"></a><font color=Blue>-- | Deliver the entire internal state.</font>+<a name="line-284"></a><font color=Blue>stget</font>      <font color=Red>::</font> Parser s t e s+<a name="line-285"></a><font color=Blue>stget</font>       <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>st inp<font color=Red>-&gt;</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>+<a name="line-286"></a>+<a name="line-287"></a>+<a name="line-288"></a><font color=Blue>--- Push some tokens back onto the input stream and reparse ------------------</font>+<a name="line-289"></a>+<a name="line-290"></a><a name="reparse"></a><font color=Blue>-- | This is useful for recursively expanding macros.  When the</font>+<a name="line-291"></a><font color=Blue>--   user-parser recognises a macro use, it can lookup the macro</font>+<a name="line-292"></a><font color=Blue>--   expansion from the parse state, lex it, and then stuff the</font>+<a name="line-293"></a><font color=Blue>--   lexed expansion back down into the parser.</font>+<a name="line-294"></a><font color=Blue>reparse</font>    <font color=Red>::</font> <font color=Red>[</font>Either e t<font color=Red>]</font> <font color=Red>-&gt;</font> Parser s t e ()+<a name="line-295"></a><font color=Blue>reparse</font> ts  <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>st inp<font color=Red>-&gt;</font> Right <font color=Red>[</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>+<a name="line-296"></a>+<a name="line-297"></a><font color=Blue>------------------------------------------------------------------------------</font>+</pre>+</html>
+ docs/haddock/src/Text/ParserCombinators/Poly.html view
@@ -0,0 +1,9 @@+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">+<html>+<pre><a name="line-1"></a><font color=Green><u>module</u></font> Text<font color=Cyan>.</font>ParserCombinators<font color=Cyan>.</font>Poly+<a name="line-2"></a>  <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>Plain+<a name="line-3"></a>  <font color=Cyan>)</font> <font color=Green><u>where</u></font>+<a name="line-4"></a>+<a name="line-5"></a><font color=Green><u>import</u></font> Text<font color=Cyan>.</font>ParserCombinators<font color=Cyan>.</font>Poly<font color=Cyan>.</font>Plain+</pre>+</html>
+ docs/haddock/src/Text/ParserCombinators/Poly/Base.html view
@@ -0,0 +1,199 @@+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">+<html>+<pre><a name="line-1"></a><font color=Green><u>module</u></font> Text<font color=Cyan>.</font>ParserCombinators<font color=Cyan>.</font>Poly<font color=Cyan>.</font>Base+<a name="line-2"></a>  <font color=Cyan>(</font> <font color=Blue>-- * The PolyParse class</font>+<a name="line-3"></a>    PolyParse<font color=Cyan>(</font><font color=Red>..</font><font color=Cyan>)</font>	<font color=Blue>-- class of all monadic two-level-error parsers</font>+<a name="line-4"></a>+<a name="line-5"></a>    <font color=Blue>-- * Combinators general to all parser types.</font>+<a name="line-6"></a>    <font color=Blue>-- ** Simple combinators</font>+<a name="line-7"></a>  <font color=Cyan>,</font> discard	<font color=Blue>-- :: PolyParse p =&gt; p a -&gt; p b -&gt; p a</font>+<a name="line-8"></a>    <font color=Blue>-- ** Error-handling</font>+<a name="line-9"></a>  <font color=Cyan>,</font> failBad	<font color=Blue>-- :: PolyParse p =&gt; String -&gt; p a</font>+<a name="line-10"></a>  <font color=Cyan>,</font> adjustErrBad<font color=Blue>-- :: PolyParse p =&gt; p a -&gt; (String-&gt;String) -&gt; p a</font>+<a name="line-11"></a>  <font color=Cyan>,</font> indent	<font color=Blue>-- :: Int -&gt; String -&gt; String</font>+<a name="line-12"></a>    <font color=Blue>-- ** Choices</font>+<a name="line-13"></a>  <font color=Cyan>,</font> oneOf	<font color=Blue>-- :: PolyParse p =&gt; [p a] -&gt; p a</font>+<a name="line-14"></a>  <font color=Cyan>,</font> optional	<font color=Blue>-- :: PolyParse p =&gt; p a -&gt; p (Maybe a)</font>+<a name="line-15"></a>    <font color=Blue>-- ** Sequences</font>+<a name="line-16"></a>  <font color=Cyan>,</font> exactly	<font color=Blue>-- :: PolyParse p =&gt; Int -&gt; p a -&gt; p [a]</font>+<a name="line-17"></a>  <font color=Cyan>,</font> many	<font color=Blue>-- :: PolyParse p =&gt; p a -&gt; p [a]</font>+<a name="line-18"></a>  <font color=Cyan>,</font> many1	<font color=Blue>-- :: PolyParse p =&gt; p a -&gt; p [a]</font>+<a name="line-19"></a>  <font color=Cyan>,</font> sepBy	<font color=Blue>-- :: PolyParse p =&gt; p a -&gt; p sep -&gt; p [a]</font>+<a name="line-20"></a>  <font color=Cyan>,</font> sepBy1	<font color=Blue>-- :: PolyParse p =&gt; p a -&gt; p sep -&gt; p [a]</font>+<a name="line-21"></a>  <font color=Cyan>,</font> bracketSep	<font color=Blue>-- :: PolyParse p =&gt; p bra -&gt; p sep -&gt; p ket -&gt; p a -&gt; p [a]</font>+<a name="line-22"></a>  <font color=Cyan>,</font> bracket	<font color=Blue>-- :: PolyParse p =&gt; p bra -&gt; p ket -&gt; p a -&gt; p a</font>+<a name="line-23"></a>  <font color=Cyan>,</font> manyFinally <font color=Blue>-- :: PolyParse p =&gt; p a -&gt; p z -&gt; p [a]</font>+<a name="line-24"></a>  <font color=Cyan>)</font> <font color=Green><u>where</u></font>+<a name="line-25"></a>+<a name="line-26"></a><font color=Magenta><em>#ifdef __NHC__</em></font>+<a name="line-27"></a><font color=Green><u>default</u></font> <font color=Cyan>(</font>Integer<font color=Cyan>,</font>Double<font color=Cyan>,</font>[]<font color=Cyan>)</font>	<font color=Blue>-- hack to avoid bizarre type defaulting error</font>+<a name="line-28"></a><font color=Green><u>instance</u></font> PolyParse []+<a name="line-29"></a><font color=Magenta><em>#endif</em></font>+<a name="line-30"></a>+<a name="line-31"></a><a name="PolyParse"></a><font color=Blue>-- | The @PolyParse@ class is an abstraction over all the current</font>+<a name="line-32"></a><a name="PolyParse"></a><font color=Blue>--   concrete representations of monadic parser combinators in this</font>+<a name="line-33"></a><a name="PolyParse"></a><font color=Blue>--   package.  The common feature is two-level error-handling.</font>+<a name="line-34"></a><a name="PolyParse"></a><font color=Blue>--   Some primitives must be implemented specific to each parser type</font>+<a name="line-35"></a><a name="PolyParse"></a><font color=Blue>--   (e.g. depending on whether the parser has a running state, or</font>+<a name="line-36"></a><a name="PolyParse"></a><font color=Blue>--   whether it is lazy).  But given those primitives, large numbers of</font>+<a name="line-37"></a><a name="PolyParse"></a><font color=Blue>--   combinators do not depend any further on the internal structure of</font>+<a name="line-38"></a><a name="PolyParse"></a><font color=Blue>--   the particular parser.</font>+<a name="line-39"></a><a name="PolyParse"></a><font color=Blue>--</font>+<a name="line-40"></a><a name="PolyParse"></a><font color=Blue>--   There are two additional basic combinators that we expect to be implemented</font>+<a name="line-41"></a><a name="PolyParse"></a><font color=Blue>--   afresh for every concrete type, but which (for technical reasons)</font>+<a name="line-42"></a><a name="PolyParse"></a><font color=Blue>--   cannot be class methods.  They are @next@ and @satisfy@.</font>+<a name="line-43"></a><a name="PolyParse"></a><font color=Green><u>class</u></font> <font color=Cyan>(</font>Functor p<font color=Cyan>,</font> Monad p<font color=Cyan>)</font> <font color=Red>=&gt;</font> PolyParse p <font color=Green><u>where</u></font>+<a name="line-44"></a>    <font color=Blue>-- | Commit is a way of raising the severity of any errors found within</font>+<a name="line-45"></a>    <font color=Blue>--   its argument.  Used in the middle of a parser definition, it means that</font>+<a name="line-46"></a>    <font color=Blue>--   any operations prior to commitment fail softly, but after commitment,</font>+<a name="line-47"></a>    <font color=Blue>--   they fail hard.</font>+<a name="line-48"></a>    commit    <font color=Red>::</font> p a <font color=Red>-&gt;</font> p a+<a name="line-49"></a>    <font color=Blue>-- | @p `adjustErr` f@ applies the transformation @f@ to any error message</font>+<a name="line-50"></a>    <font color=Blue>--   generated in @p@, having no effect if @p@ succeeds.</font>+<a name="line-51"></a>    adjustErr <font color=Red>::</font> p a <font color=Red>-&gt;</font> <font color=Cyan>(</font>String <font color=Red>-&gt;</font> String<font color=Cyan>)</font> <font color=Red>-&gt;</font> p a+<a name="line-52"></a>    <font color=Blue>-- | @p `onFail` q@ means parse p, unless p fails, in which case</font>+<a name="line-53"></a>    <font color=Blue>--   parse q instead.</font>+<a name="line-54"></a>    <font color=Blue>--   Can be chained together to give multiple attempts to parse something.</font>+<a name="line-55"></a>    <font color=Blue>--   (Note that q could itself be a failing parser, e.g. to change the error</font>+<a name="line-56"></a>    <font color=Blue>--   message from that defined in p to something different.)</font>+<a name="line-57"></a>    <font color=Blue>--   However, a severe failure in p cannot be ignored.</font>+<a name="line-58"></a>    onFail    <font color=Red>::</font> p a <font color=Red>-&gt;</font> p a <font color=Red>-&gt;</font> p a+<a name="line-59"></a>    <font color=Blue>-- | Parse the first alternative that succeeds, but if none succeed,</font>+<a name="line-60"></a>    <font color=Blue>--   report only the severe errors, and if none of those, then report</font>+<a name="line-61"></a>    <font color=Blue>--   all the soft errors.</font>+<a name="line-62"></a>    oneOf'    <font color=Red>::</font> <font color=Red>[</font><font color=Cyan>(</font>String<font color=Cyan>,</font> p a<font color=Cyan>)</font><font color=Red>]</font> <font color=Red>-&gt;</font> p a+<a name="line-63"></a>    <font color=Blue>-- | Apply a parsed function to a parsed value.</font>+<a name="line-64"></a>    <font color=Blue>--   Rather like ordinary function application lifted into parsers.</font>+<a name="line-65"></a>    apply     <font color=Red>::</font> p <font color=Cyan>(</font>a<font color=Red>-&gt;</font>b<font color=Cyan>)</font> <font color=Red>-&gt;</font> p a <font color=Red>-&gt;</font> p b+<a name="line-66"></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>&lt;-</font> pf<font color=Cyan>;</font> x <font color=Red>&lt;-</font> px<font color=Cyan>;</font> return <font color=Cyan>(</font>f x<font color=Cyan>)</font> <font color=Cyan>}</font>+<a name="line-67"></a>      <font color=Blue>-- note: the Poly.Lazy variants override this defn with a lazier one.</font>+<a name="line-68"></a>+<a name="line-69"></a><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>+<a name="line-70"></a><font color=Green><u>infixl</u></font> <font color=Magenta>3</font> <font color=Cyan>`apply`</font>+<a name="line-71"></a><font color=Green><u>infixl</u></font> <font color=Magenta>3</font> <font color=Cyan>`discard`</font>+<a name="line-72"></a>+<a name="line-73"></a><font color=Blue>{-+<a name="line-74"></a>-- Combinators we expect most concrete parser types to implement.+<a name="line-75"></a>--   For technical reasons, they cannot be class members.+<a name="line-76"></a>+<a name="line-77"></a>-- | Yield the next token+<a name="line-78"></a>next      :: PolyParse p =&gt; p t+<a name="line-79"></a>  --  where t is constrained to be the input token type+<a name="line-80"></a>+<a name="line-81"></a>-- | One token satisfying a predicate.+<a name="line-82"></a>satisfy :: PolyParse p =&gt; (t-&gt;Bool) -&gt; p t t+<a name="line-83"></a>satisfy p = do{ x &lt;- next+<a name="line-84"></a>              ; if p x then return x else fail "Parse.satisfy: failed"+<a name="line-85"></a>              }+<a name="line-86"></a>  -- note: must be re-defined for each implementation because+<a name="line-87"></a>  --       its type cannot be expressed otherwise.+<a name="line-88"></a>-}</font>+<a name="line-89"></a>+<a name="line-90"></a><a name="failBad"></a><font color=Blue>-- | When a simple fail is not strong enough, use failBad for emphasis.</font>+<a name="line-91"></a><font color=Blue>--   An emphasised (severe) error cannot be overridden by choice</font>+<a name="line-92"></a><font color=Blue>--   operators.</font>+<a name="line-93"></a><font color=Blue>failBad</font> <font color=Red>::</font> PolyParse p <font color=Red>=&gt;</font> String <font color=Red>-&gt;</font> p a+<a name="line-94"></a><font color=Blue>failBad</font> e <font color=Red>=</font> commit <font color=Cyan>(</font>fail e<font color=Cyan>)</font>+<a name="line-95"></a>+<a name="line-96"></a><a name="discard"></a><font color=Blue>-- | @x `discard` y@ parses both x and y, but discards the result of y.</font>+<a name="line-97"></a><font color=Blue>--   Rather like @const@ lifted into parsers.</font>+<a name="line-98"></a><font color=Blue>discard</font> <font color=Red>::</font> PolyParse p <font color=Red>=&gt;</font> p a <font color=Red>-&gt;</font> p b <font color=Red>-&gt;</font> p a+<a name="line-99"></a><a name="discard"></a><font color=Blue>px</font> <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>&lt;-</font> px<font color=Cyan>;</font> py<font color=Cyan>;</font> return x<font color=Cyan>;</font> <font color=Cyan>}</font>+<a name="line-100"></a>+<a name="line-101"></a><a name="adjustErrBad"></a><font color=Blue>-- | @adjustErrBad@ is just like @adjustErr@ except it also raises the</font>+<a name="line-102"></a><font color=Blue>--   severity of the error.</font>+<a name="line-103"></a><font color=Blue>adjustErrBad</font> <font color=Red>::</font> PolyParse p <font color=Red>=&gt;</font> p a <font color=Red>-&gt;</font> <font color=Cyan>(</font>String<font color=Red>-&gt;</font>String<font color=Cyan>)</font> <font color=Red>-&gt;</font> p a+<a name="line-104"></a><a name="adjustErrBad"></a><font color=Blue>p</font> <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>+<a name="line-105"></a>+<a name="line-106"></a><a name="oneOf"></a><font color=Blue>-- | Parse the first alternative in the list that succeeds.</font>+<a name="line-107"></a><font color=Blue>oneOf</font> <font color=Red>::</font> PolyParse p <font color=Red>=&gt;</font> <font color=Red>[</font>p a<font color=Red>]</font> <font color=Red>-&gt;</font> p a+<a name="line-108"></a><font color=Blue>oneOf</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>+<a name="line-109"></a><font color=Blue>oneOf</font> <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+<a name="line-110"></a><font color=Blue>--oneOf :: Show t =&gt; [Parser t a] -&gt; Parser t a</font>+<a name="line-111"></a><font color=Blue>--oneOf []     = do { n &lt;- next</font>+<a name="line-112"></a><font color=Blue>--                  ; fail ("failed to parse any of the possible choices"</font>+<a name="line-113"></a><font color=Blue>--                         ++"\n  next token is "++show n)</font>+<a name="line-114"></a><font color=Blue>--                  }</font>+<a name="line-115"></a><font color=Blue>--oneOf (p:ps) = p `onFail` oneOf ps</font>+<a name="line-116"></a>+<a name="line-117"></a><a name="indent"></a><font color=Blue>-- | Helper for formatting error messages: indents all lines by a fixed amount.</font>+<a name="line-118"></a><font color=Blue>indent</font> <font color=Red>::</font> Int <font color=Red>-&gt;</font> String <font color=Red>-&gt;</font> String+<a name="line-119"></a><font color=Blue>indent</font> 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+<a name="line-120"></a>+<a name="line-121"></a><a name="optional"></a><font color=Blue>-- | 'optional' indicates whether the parser succeeded through the Maybe type.</font>+<a name="line-122"></a><font color=Blue>optional</font> <font color=Red>::</font> PolyParse p <font color=Red>=&gt;</font> p a <font color=Red>-&gt;</font> p <font color=Cyan>(</font>Maybe a<font color=Cyan>)</font>+<a name="line-123"></a><font color=Blue>optional</font> p <font color=Red>=</font> fmap Just p <font color=Cyan>`onFail`</font> return Nothing+<a name="line-124"></a>+<a name="line-125"></a><a name="exactly"></a><font color=Blue>-- | 'exactly n p' parses precisely n items, using the parser p, in sequence.</font>+<a name="line-126"></a><font color=Blue>exactly</font> <font color=Red>::</font> PolyParse p <font color=Red>=&gt;</font> Int <font color=Red>-&gt;</font> p a <font color=Red>-&gt;</font> p <font color=Red>[</font>a<font color=Red>]</font>+<a name="line-127"></a><font color=Blue>exactly</font> <font color=Magenta>0</font> p <font color=Red>=</font> return []+<a name="line-128"></a><font color=Blue>exactly</font> n p <font color=Red>=</font> return <font color=Cyan>(</font><font color=Red><b>:</b></font><font color=Cyan>)</font> <font color=Cyan>`apply`</font>  <font color=Cyan>(</font>p <font color=Cyan>`adjustErr`</font> <font color=Cyan>(</font><font color=Cyan>(</font><font color=Magenta>"When expecting exactly "</font>+<a name="line-129"></a>                                                    <font color=Cyan>++</font>show n<font color=Cyan>++</font><font color=Magenta>" more items"</font><font color=Cyan>)</font><font color=Cyan>++</font><font color=Cyan>)</font><font color=Cyan>)</font>+<a name="line-130"></a>                         <font color=Cyan>`apply`</font>  exactly <font color=Cyan>(</font>n<font color=Blue>-</font><font color=Magenta>1</font><font color=Cyan>)</font> p+<a name="line-131"></a>+<a name="line-132"></a><a name="many"></a><font color=Blue>-- | 'many p' parses a list of elements with individual parser p.</font>+<a name="line-133"></a><font color=Blue>--   Cannot fail, since an empty list is a valid return value.</font>+<a name="line-134"></a><font color=Blue>many</font> <font color=Red>::</font> PolyParse p <font color=Red>=&gt;</font> p a <font color=Red>-&gt;</font> p <font color=Red>[</font>a<font color=Red>]</font>+<a name="line-135"></a><font color=Blue>many</font> p <font color=Red>=</font> many1 p <font color=Cyan>`onFail`</font> return []+<a name="line-136"></a>+<a name="line-137"></a><a name="many1"></a><font color=Blue>-- | Parse a non-empty list of items.</font>+<a name="line-138"></a><font color=Blue>many1</font> <font color=Red>::</font> PolyParse p <font color=Red>=&gt;</font> p a <font color=Red>-&gt;</font> p <font color=Red>[</font>a<font color=Red>]</font>+<a name="line-139"></a><font color=Blue>many1</font> p <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font> x <font color=Red>&lt;-</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>+<a name="line-140"></a>             <font color=Cyan>;</font> return <font color=Cyan>(</font>x<font color=Red><b>:</b></font><font color=Cyan>)</font> <font color=Cyan>`apply`</font> many p+<a name="line-141"></a>             <font color=Cyan>}</font>+<a name="line-142"></a><font color=Blue>--       `adjustErr` ("When looking for a non-empty sequence:\n\t"++)</font>+<a name="line-143"></a>+<a name="line-144"></a><a name="sepBy"></a><font color=Blue>-- | Parse a list of items separated by discarded junk.</font>+<a name="line-145"></a><font color=Blue>sepBy</font> <font color=Red>::</font> PolyParse p <font color=Red>=&gt;</font> p a <font color=Red>-&gt;</font> p sep <font color=Red>-&gt;</font> p <font color=Red>[</font>a<font color=Red>]</font>+<a name="line-146"></a><font color=Blue>sepBy</font> p sep <font color=Red>=</font> <font color=Green><u>do</u></font> sepBy1 p sep <font color=Cyan>`onFail`</font> return []+<a name="line-147"></a>+<a name="line-148"></a><a name="sepBy1"></a><font color=Blue>-- | Parse a non-empty list of items separated by discarded junk.</font>+<a name="line-149"></a><font color=Blue>sepBy1</font> <font color=Red>::</font> PolyParse p <font color=Red>=&gt;</font> p a <font color=Red>-&gt;</font> p sep <font color=Red>-&gt;</font> p <font color=Red>[</font>a<font color=Red>]</font>+<a name="line-150"></a><font color=Blue>sepBy1</font> p sep <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font> x <font color=Red>&lt;-</font> p+<a name="line-151"></a>                  <font color=Cyan>;</font> return <font color=Cyan>(</font>x<font color=Red><b>:</b></font><font color=Cyan>)</font> <font color=Cyan>`apply`</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>+<a name="line-152"></a>                  <font color=Cyan>}</font>+<a name="line-153"></a>         <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>+<a name="line-154"></a> +<a name="line-155"></a><a name="bracketSep"></a><font color=Blue>-- | Parse a list of items, discarding the start, end, and separator</font>+<a name="line-156"></a><font color=Blue>--   items.</font>+<a name="line-157"></a><font color=Blue>bracketSep</font> <font color=Red>::</font> PolyParse p <font color=Red>=&gt;</font> p bra <font color=Red>-&gt;</font> p sep <font color=Red>-&gt;</font> p ket <font color=Red>-&gt;</font> p a <font color=Red>-&gt;</font> p <font color=Red>[</font>a<font color=Red>]</font>+<a name="line-158"></a><font color=Blue>bracketSep</font> open sep close p <font color=Red>=</font>+<a name="line-159"></a>    <font color=Green><u>do</u></font> <font color=Cyan>{</font> open<font color=Cyan>;</font> close<font color=Cyan>;</font> return [] <font color=Cyan>}</font>+<a name="line-160"></a>       <font color=Cyan>`onFail`</font>+<a name="line-161"></a>    <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>+<a name="line-162"></a>       <font color=Cyan>;</font> x <font color=Red>&lt;-</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>+<a name="line-163"></a>       <font color=Cyan>;</font> return <font color=Cyan>(</font>x<font color=Red><b>:</b></font><font color=Cyan>)</font>+<a name="line-164"></a>           <font color=Cyan>`apply`</font> manyFinally <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>+<a name="line-165"></a>              <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>+<a name="line-166"></a>       <font color=Cyan>}</font>+<a name="line-167"></a>+<a name="line-168"></a><a name="bracket"></a><font color=Blue>-- | Parse a bracketed item, discarding the brackets.</font>+<a name="line-169"></a><font color=Blue>bracket</font> <font color=Red>::</font> PolyParse p <font color=Red>=&gt;</font> p bra <font color=Red>-&gt;</font> p ket <font color=Red>-&gt;</font> p a <font color=Red>-&gt;</font> p a+<a name="line-170"></a><font color=Blue>bracket</font> open close p <font color=Red>=</font> <font color=Green><u>do</u></font>+<a name="line-171"></a>    <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>+<a name="line-172"></a>       <font color=Cyan>;</font> p <font color=Cyan>`discard`</font> <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>+<a name="line-173"></a>       <font color=Cyan>}</font>+<a name="line-174"></a>+<a name="line-175"></a><a name="manyFinally"></a><font color=Blue>-- | 'manyFinally e t' parses a possibly-empty sequence of e's,</font>+<a name="line-176"></a><font color=Blue>--   terminated by a t.  The final t is discarded.  Any parse failures</font>+<a name="line-177"></a><font color=Blue>--   could be due either to a badly-formed terminator or a badly-formed</font>+<a name="line-178"></a><font color=Blue>--   element, so it raises both possible errors.</font>+<a name="line-179"></a><font color=Blue>manyFinally</font> <font color=Red>::</font> PolyParse p <font color=Red>=&gt;</font> p a <font color=Red>-&gt;</font> p z <font color=Red>-&gt;</font> p <font color=Red>[</font>a<font color=Red>]</font>+<a name="line-180"></a><font color=Blue>manyFinally</font> p t <font color=Red>=</font>+<a name="line-181"></a>    <font color=Cyan>(</font>many p <font color=Cyan>`discard`</font> t<font color=Cyan>)</font>+<a name="line-182"></a>      <font color=Cyan>`onFail`</font>+<a name="line-183"></a>    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>+<a name="line-184"></a>           <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>+<a name="line-185"></a>           <font color=Red>]</font>+<a name="line-186"></a><font color=Blue>{-+<a name="line-187"></a>manyFinally p t =+<a name="line-188"></a>    do { xs &lt;- many p+<a name="line-189"></a>       ; oneOf' [ ("sequence terminator", do { t; return () } )+<a name="line-190"></a>                , ("item in a sequence",  do { p; return () } )+<a name="line-191"></a>                ]+<a name="line-192"></a>       ; return xs+<a name="line-193"></a>       }+<a name="line-194"></a>-}</font>+<a name="line-195"></a><font color=Blue>------------------------------------------------------------------------</font>+</pre>+</html>
+ docs/haddock/src/Text/ParserCombinators/Poly/ByteString.html view
@@ -0,0 +1,117 @@+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">+<html>+<pre><a name="line-1"></a><font color=Green><u>module</u></font> Text<font color=Cyan>.</font>ParserCombinators<font color=Cyan>.</font>Poly<font color=Cyan>.</font>ByteString+<a name="line-2"></a>  <font color=Cyan>(</font> <font color=Blue>-- * The Parser datatype</font>+<a name="line-3"></a>    Parser<font color=Cyan>(</font>P<font color=Cyan>)</font>+<a name="line-4"></a>  <font color=Cyan>,</font> Result<font color=Cyan>(</font><font color=Red>..</font><font color=Cyan>)</font>+<a name="line-5"></a>  <font color=Cyan>,</font> runParser+<a name="line-6"></a>    <font color=Blue>-- ** basic parsers</font>+<a name="line-7"></a>  <font color=Cyan>,</font> next+<a name="line-8"></a>  <font color=Cyan>,</font> eof+<a name="line-9"></a>  <font color=Cyan>,</font> satisfy+<a name="line-10"></a>    <font color=Blue>-- ** re-parsing</font>+<a name="line-11"></a>  <font color=Cyan>,</font> reparse+<a name="line-12"></a>    <font color=Blue>-- * Re-export all more general combinators</font>+<a name="line-13"></a>  <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>Base+<a name="line-14"></a>  <font color=Cyan>)</font> <font color=Green><u>where</u></font>+<a name="line-15"></a>+<a name="line-16"></a>+<a name="line-17"></a><font color=Green><u>import</u></font> Text<font color=Cyan>.</font>ParserCombinators<font color=Cyan>.</font>Poly<font color=Cyan>.</font>Base+<a name="line-18"></a><font color=Green><u>import</u></font> <font color=Green><u>qualified</u></font> Data<font color=Cyan>.</font>ByteString<font color=Cyan>.</font>Lazy<font color=Cyan>.</font>Char8 <font color=Green><u>as</u></font> BS+<a name="line-19"></a><font color=Green><u>import</u></font> Data<font color=Cyan>.</font>ByteString<font color=Cyan>.</font>Lazy<font color=Cyan>.</font>Char8 <font color=Cyan>(</font>ByteString<font color=Cyan>)</font>+<a name="line-20"></a>+<a name="line-21"></a><a name="Parser"></a><font color=Blue>-- | This @Parser@ datatype is a specialised parsing monad with error</font>+<a name="line-22"></a><a name="Parser"></a><font color=Blue>--   reporting.  Whereas the standard version can be used for arbitrary</font>+<a name="line-23"></a><a name="Parser"></a><font color=Blue>--   token types, this version is specialised to ByteString input only.</font>+<a name="line-24"></a><a name="Parser"></a><font color=Green><u>newtype</u></font> Parser a <font color=Red>=</font> P <font color=Cyan>(</font>ByteString <font color=Red>-&gt;</font> Result ByteString a<font color=Cyan>)</font>+<a name="line-25"></a>+<a name="line-26"></a><a name="Result"></a><font color=Blue>-- | A return type like Either, that distinguishes not only between</font>+<a name="line-27"></a><a name="Result"></a><font color=Blue>--   right and wrong answers, but also has commitment, so that a failure</font>+<a name="line-28"></a><a name="Result"></a><font color=Blue>--   cannot be undone.  This should only be used for writing very primitive</font>+<a name="line-29"></a><a name="Result"></a><font color=Blue>--   parsers - really it is an internal detail of the library.</font>+<a name="line-30"></a><a name="Result"></a><font color=Green><u>data</u></font> Result z a <font color=Red>=</font> Success   z a+<a name="line-31"></a>                <font color=Red>|</font> Failure   z String+<a name="line-32"></a>                <font color=Red>|</font> Committed <font color=Cyan>(</font>Result z a<font color=Cyan>)</font>+<a name="line-33"></a>+<a name="line-34"></a><font color=Green><u>instance</u></font> Functor <font color=Cyan>(</font>Result z<font color=Cyan>)</font> <font color=Green><u>where</u></font>+<a name="line-35"></a>    fmap f <font color=Cyan>(</font>Success z a<font color=Cyan>)</font> <font color=Red>=</font> Success z <font color=Cyan>(</font>f a<font color=Cyan>)</font>+<a name="line-36"></a>    fmap <font color=Green><u>_</u></font> <font color=Cyan>(</font>Failure z e<font color=Cyan>)</font> <font color=Red>=</font> Failure z e+<a name="line-37"></a>    fmap f <font color=Cyan>(</font>Committed r<font color=Cyan>)</font> <font color=Red>=</font> Committed <font color=Cyan>(</font>fmap f r<font color=Cyan>)</font>+<a name="line-38"></a>+<a name="line-39"></a><a name="runParser"></a><font color=Blue>-- | Apply a parser to an input token sequence.</font>+<a name="line-40"></a><font color=Blue>runParser</font> <font color=Red>::</font> Parser a <font color=Red>-&gt;</font> ByteString <font color=Red>-&gt;</font> <font color=Cyan>(</font>Either String a<font color=Cyan>,</font> ByteString<font color=Cyan>)</font>+<a name="line-41"></a><font color=Blue>runParser</font> <font color=Cyan>(</font>P p<font color=Cyan>)</font> <font color=Red>=</font> resultToEither <font color=Cyan>.</font> p+<a name="line-42"></a>  <font color=Green><u>where</u></font>+<a name="line-43"></a>    resultToEither <font color=Red>::</font> Result z a <font color=Red>-&gt;</font> <font color=Cyan>(</font>Either String a<font color=Cyan>,</font> z<font color=Cyan>)</font>+<a name="line-44"></a>    resultToEither <font color=Cyan>(</font>Success z a<font color=Cyan>)</font>  <font color=Red>=</font>  <font color=Cyan>(</font>Right a<font color=Cyan>,</font> z<font color=Cyan>)</font>+<a name="line-45"></a>    resultToEither <font color=Cyan>(</font>Failure z e<font color=Cyan>)</font>  <font color=Red>=</font>  <font color=Cyan>(</font>Left e<font color=Cyan>,</font> z<font color=Cyan>)</font>+<a name="line-46"></a>    resultToEither <font color=Cyan>(</font>Committed r<font color=Cyan>)</font>  <font color=Red>=</font>  resultToEither r+<a name="line-47"></a>+<a name="line-48"></a><font color=Green><u>instance</u></font> Functor Parser <font color=Green><u>where</u></font>+<a name="line-49"></a>    fmap f <font color=Cyan>(</font>P p<font color=Cyan>)</font> <font color=Red>=</font> P <font color=Cyan>(</font>fmap f <font color=Cyan>.</font> p<font color=Cyan>)</font>+<a name="line-50"></a>+<a name="line-51"></a><font color=Green><u>instance</u></font> Monad Parser <font color=Green><u>where</u></font>+<a name="line-52"></a>    return x     <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>ts<font color=Red>-&gt;</font> Success ts x<font color=Cyan>)</font>+<a name="line-53"></a>    fail e       <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>ts<font color=Red>-&gt;</font> Failure ts e<font color=Cyan>)</font>+<a name="line-54"></a>    <font color=Cyan>(</font>P f<font color=Cyan>)</font> <font color=Cyan>&gt;&gt;=</font> g  <font color=Red>=</font> P <font color=Cyan>(</font>continue <font color=Cyan>.</font> f<font color=Cyan>)</font>+<a name="line-55"></a>      <font color=Green><u>where</u></font>+<a name="line-56"></a>        continue <font color=Cyan>(</font>Success ts x<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+<a name="line-57"></a>        continue <font color=Cyan>(</font>Committed <font color=Cyan>(</font>Committed r<font color=Cyan>)</font><font color=Cyan>)</font>  <font color=Red>=</font> continue <font color=Cyan>(</font>Committed r<font color=Cyan>)</font>+<a name="line-58"></a>        continue <font color=Cyan>(</font>Committed r<font color=Cyan>)</font>              <font color=Red>=</font> Committed <font color=Cyan>(</font>continue r<font color=Cyan>)</font>+<a name="line-59"></a>        continue <font color=Cyan>(</font>Failure ts e<font color=Cyan>)</font>             <font color=Red>=</font> Failure ts e+<a name="line-60"></a>+<a name="line-61"></a><font color=Green><u>instance</u></font> PolyParse Parser <font color=Green><u>where</u></font>+<a name="line-62"></a>    commit <font color=Cyan>(</font>P p<font color=Cyan>)</font>         <font color=Red>=</font> P <font color=Cyan>(</font>Committed <font color=Cyan>.</font> p<font color=Cyan>)</font>+<a name="line-63"></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>adjust <font color=Cyan>.</font> p<font color=Cyan>)</font>+<a name="line-64"></a>      <font color=Green><u>where</u></font>+<a name="line-65"></a>        adjust <font color=Cyan>(</font>Failure z e<font color=Cyan>)</font> <font color=Red>=</font> Failure z <font color=Cyan>(</font>f e<font color=Cyan>)</font>+<a name="line-66"></a>        adjust <font color=Cyan>(</font>Committed r<font color=Cyan>)</font> <font color=Red>=</font> Committed <font color=Cyan>(</font>adjust r<font color=Cyan>)</font>+<a name="line-67"></a>        adjust  good         <font color=Red>=</font> good+<a name="line-68"></a>+<a name="line-69"></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>-&gt;</font> continue ts <font color=Cyan>$</font> p ts<font color=Cyan>)</font>+<a name="line-70"></a>      <font color=Green><u>where</u></font>+<a name="line-71"></a>        continue ts <font color=Cyan>(</font>Failure <font color=Green><u>_</u></font> <font color=Green><u>_</u></font><font color=Cyan>)</font> <font color=Red>=</font> q ts+<a name="line-72"></a>    <font color=Blue>--  continue _  (Committed r) = r	-- no, remain Committed</font>+<a name="line-73"></a>        continue <font color=Green><u>_</u></font>  r             <font color=Red>=</font> r+<a name="line-74"></a>+<a name="line-75"></a>    oneOf' <font color=Red>=</font> accum []+<a name="line-76"></a>      <font color=Green><u>where</u></font> accum errs [] <font color=Red>=</font>+<a name="line-77"></a>                fail <font color=Cyan>(</font><font color=Magenta>"failed to parse any of the possible choices:\n"</font>+<a name="line-78"></a>                            <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>+<a name="line-79"></a>            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>+<a name="line-80"></a>                P <font color=Cyan>(</font><font color=Red>\</font>ts<font color=Red>-&gt;</font> <font color=Green><u>case</u></font> p ts <font color=Green><u>of</u></font>+<a name="line-81"></a>                           Failure <font color=Green><u>_</u></font> err <font color=Red>-&gt;</font>+<a name="line-82"></a>                                       <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+<a name="line-83"></a>                                       <font color=Green><u>in</u></font> p' ts+<a name="line-84"></a>                           r<font color=Red>@</font><font color=Cyan>(</font>Success <font color=Green><u>_</u></font> <font color=Green><u>_</u></font><font color=Cyan>)</font>    <font color=Red>-&gt;</font> r+<a name="line-85"></a>                           r<font color=Red>@</font><font color=Cyan>(</font>Committed <font color=Green><u>_</u></font><font color=Cyan>)</font>    <font color=Red>-&gt;</font> r <font color=Cyan>)</font>+<a name="line-86"></a>            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+<a name="line-87"></a>+<a name="line-88"></a><a name="next"></a><font color=Blue>------------------------------------------------------------------------</font>+<a name="line-89"></a><font color=Blue>next</font> <font color=Red>::</font> Parser Char+<a name="line-90"></a><font color=Blue>next</font> <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>bs<font color=Red>-&gt;</font> <font color=Green><u>case</u></font> BS<font color=Cyan>.</font>uncons bs <font color=Green><u>of</u></font>+<a name="line-91"></a>                Nothing <font color=Red>-&gt;</font> Failure bs <font color=Magenta>"Ran out of input (EOF)"</font>+<a name="line-92"></a>                Just <font color=Cyan>(</font>c<font color=Cyan>,</font> bs'<font color=Cyan>)</font> <font color=Red>-&gt;</font> Success bs' c <font color=Cyan>)</font>+<a name="line-93"></a>+<a name="line-94"></a><a name="eof"></a><font color=Blue>eof</font> <font color=Red>::</font> Parser ()+<a name="line-95"></a><font color=Blue>eof</font> <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>bs <font color=Red>-&gt;</font> <font color=Green><u>if</u></font> BS<font color=Cyan>.</font>null bs+<a name="line-96"></a>                <font color=Green><u>then</u></font> Success bs ()+<a name="line-97"></a>                <font color=Green><u>else</u></font> Failure bs <font color=Magenta>"Expected end of input (EOF)"</font> <font color=Cyan>)</font>+<a name="line-98"></a>+<a name="line-99"></a><a name="satisfy"></a><font color=Blue>satisfy</font> <font color=Red>::</font> <font color=Cyan>(</font>Char <font color=Red>-&gt;</font> Bool<font color=Cyan>)</font> <font color=Red>-&gt;</font> Parser Char+<a name="line-100"></a><font color=Blue>satisfy</font> f <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font> x <font color=Red>&lt;-</font> next+<a name="line-101"></a>               <font color=Cyan>;</font> <font color=Green><u>if</u></font> f 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>+<a name="line-102"></a>               <font color=Cyan>}</font>+<a name="line-103"></a>+<a name="line-104"></a><a name="reparse"></a><font color=Blue>------------------------------------------------------------------------</font>+<a name="line-105"></a><font color=Blue>-- | Push some tokens back onto the front of the input stream and reparse.</font>+<a name="line-106"></a><font color=Blue>--   This is useful e.g. for recursively expanding macros.  When the</font>+<a name="line-107"></a><font color=Blue>--   user-parser recognises a macro use, it can lookup the macro</font>+<a name="line-108"></a><font color=Blue>--   expansion from the parse state, lex it, and then stuff the</font>+<a name="line-109"></a><font color=Blue>--   lexed expansion back down into the parser.</font>+<a name="line-110"></a><font color=Blue>reparse</font>    <font color=Red>::</font> ByteString <font color=Red>-&gt;</font> Parser ()+<a name="line-111"></a><font color=Blue>reparse</font> ts  <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>inp<font color=Red>-&gt;</font> Success <font color=Cyan>(</font>ts <font color=Cyan>`</font>BS<font color=Cyan>.</font>append<font color=Cyan>`</font> inp<font color=Cyan>)</font> ()<font color=Cyan>)</font>+<a name="line-112"></a>+<a name="line-113"></a><font color=Blue>------------------------------------------------------------------------</font>+</pre>+</html>
+ docs/haddock/src/Text/ParserCombinators/Poly/Lazy.html view
@@ -0,0 +1,139 @@+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">+<html>+<pre><a name="line-1"></a><font color=Green><u>module</u></font> Text<font color=Cyan>.</font>ParserCombinators<font color=Cyan>.</font>Poly<font color=Cyan>.</font>Lazy+<a name="line-2"></a>  <font color=Cyan>(</font> <font color=Blue>-- * The Parser datatype</font>+<a name="line-3"></a>    Parser<font color=Cyan>(</font>P<font color=Cyan>)</font>	<font color=Blue>-- datatype, instance of: Functor, Monad, PolyParse</font>+<a name="line-4"></a>  <font color=Cyan>,</font> Result<font color=Cyan>(</font><font color=Red>..</font><font color=Cyan>)</font>	<font color=Blue>-- internal to the parser monad</font>+<a name="line-5"></a>  <font color=Cyan>,</font> runParser	<font color=Blue>-- :: Parser t a -&gt; [t] -&gt; (Either String a, [t])</font>+<a name="line-6"></a>    <font color=Blue>-- ** basic parsers</font>+<a name="line-7"></a>  <font color=Cyan>,</font> next	<font color=Blue>-- :: Parser t t</font>+<a name="line-8"></a>  <font color=Cyan>,</font> eof		<font color=Blue>-- :: Parser t ()</font>+<a name="line-9"></a>  <font color=Cyan>,</font> satisfy	<font color=Blue>-- :: (t-&gt;Bool) -&gt; Parser t t</font>+<a name="line-10"></a>+<a name="line-11"></a>    <font color=Blue>-- ** re-parsing</font>+<a name="line-12"></a>  <font color=Cyan>,</font> reparse	<font color=Blue>-- :: [t] -&gt; Parser t ()</font>+<a name="line-13"></a>    <font color=Blue>-- * Re-export all more general combinators</font>+<a name="line-14"></a>  <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>Base+<a name="line-15"></a>  <font color=Cyan>)</font> <font color=Green><u>where</u></font>+<a name="line-16"></a>+<a name="line-17"></a>+<a name="line-18"></a><font color=Green><u>import</u></font> Text<font color=Cyan>.</font>ParserCombinators<font color=Cyan>.</font>Poly<font color=Cyan>.</font>Base+<a name="line-19"></a>+<a name="line-20"></a><font color=Magenta><em>#if __GLASGOW_HASKELL__</em></font>+<a name="line-21"></a><font color=Green><u>import</u></font> Control<font color=Cyan>.</font>Exception hiding <font color=Cyan>(</font>bracket<font color=Cyan>)</font>+<a name="line-22"></a><a name="throwE"></a><font color=Blue>throwE</font> <font color=Red>::</font> String <font color=Red>-&gt;</font> a+<a name="line-23"></a><font color=Blue>throwE</font> msg <font color=Red>=</font> throw <font color=Cyan>(</font>ErrorCall msg<font color=Cyan>)</font>+<a name="line-24"></a><font color=Magenta><em>#else</em></font>+<a name="line-25"></a><font color=Blue>throwE</font> <font color=Red>::</font> String <font color=Red>-&gt;</font> a+<a name="line-26"></a><font color=Blue>throwE</font> msg <font color=Red>=</font> error msg+<a name="line-27"></a><font color=Magenta><em>#endif</em></font>+<a name="line-28"></a>+<a name="line-29"></a>+<a name="line-30"></a><a name="Parser"></a><font color=Blue>-- | This @Parser@ datatype is a fairly generic parsing monad with error</font>+<a name="line-31"></a><a name="Parser"></a><font color=Blue>--   reporting.  It can be used for arbitrary token types, not just</font>+<a name="line-32"></a><a name="Parser"></a><font color=Blue>--   String input.  (If you require a running state, use module PolyState</font>+<a name="line-33"></a><a name="Parser"></a><font color=Blue>--   instead)</font>+<a name="line-34"></a><a name="Parser"></a><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>-&gt;</font> Result <font color=Red>[</font>t<font color=Red>]</font> a<font color=Cyan>)</font>+<a name="line-35"></a>+<a name="line-36"></a><a name="Result"></a><font color=Blue>-- |  A return type like Either, that distinguishes not only between</font>+<a name="line-37"></a><a name="Result"></a><font color=Blue>--   right and wrong answers, but also has gradations of wrongness.</font>+<a name="line-38"></a><a name="Result"></a><font color=Blue>--   This should only be used for writing very primitive</font>+<a name="line-39"></a><a name="Result"></a><font color=Blue>--   parsers - really it is an internal detail of the library.</font>+<a name="line-40"></a><a name="Result"></a><font color=Green><u>data</u></font> Result z a <font color=Red>=</font> Success    z a+<a name="line-41"></a>                <font color=Red>|</font> Failure    z String+<a name="line-42"></a>                <font color=Red>|</font> Committed  <font color=Cyan>(</font>Result z a<font color=Cyan>)</font> <font color=Blue>-- still needed</font>+<a name="line-43"></a>+<a name="line-44"></a><font color=Green><u>instance</u></font> Functor <font color=Cyan>(</font>Result z<font color=Cyan>)</font> <font color=Green><u>where</u></font>+<a name="line-45"></a>    fmap f <font color=Cyan>(</font>Success z a<font color=Cyan>)</font>  <font color=Red>=</font> Success z <font color=Cyan>(</font>f a<font color=Cyan>)</font>+<a name="line-46"></a>    fmap f <font color=Cyan>(</font>Failure z e<font color=Cyan>)</font>  <font color=Red>=</font> Failure z e+<a name="line-47"></a>    fmap f <font color=Cyan>(</font>Committed r<font color=Cyan>)</font>  <font color=Red>=</font> Committed <font color=Cyan>(</font>fmap f r<font color=Cyan>)</font>+<a name="line-48"></a>+<a name="line-49"></a><a name="runParser"></a><font color=Blue>-- | Apply a parser to an input token sequence.</font>+<a name="line-50"></a><font color=Blue>runParser</font> <font color=Red>::</font> Parser t a <font color=Red>-&gt;</font> <font color=Red>[</font>t<font color=Red>]</font> <font color=Red>-&gt;</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="line-51"></a><font color=Blue>runParser</font> <font color=Cyan>(</font>P p<font color=Cyan>)</font> <font color=Red>=</font> fromResult <font color=Cyan>.</font> p+<a name="line-52"></a>  <font color=Green><u>where</u></font>+<a name="line-53"></a>    fromResult <font color=Red>::</font> Result z a <font color=Red>-&gt;</font> <font color=Cyan>(</font>a<font color=Cyan>,</font> z<font color=Cyan>)</font>+<a name="line-54"></a>    fromResult <font color=Cyan>(</font>Success z a<font color=Cyan>)</font>  <font color=Red>=</font>  <font color=Cyan>(</font>a<font color=Cyan>,</font> z<font color=Cyan>)</font>+<a name="line-55"></a>    fromResult <font color=Cyan>(</font>Failure z e<font color=Cyan>)</font>  <font color=Red>=</font>  throwE e+<a name="line-56"></a>    fromResult <font color=Cyan>(</font>Committed r<font color=Cyan>)</font>  <font color=Red>=</font>  fromResult r+<a name="line-57"></a>+<a name="line-58"></a><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>+<a name="line-59"></a>    fmap f <font color=Cyan>(</font>P p<font color=Cyan>)</font> <font color=Red>=</font> P <font color=Cyan>(</font>fmap f <font color=Cyan>.</font> p<font color=Cyan>)</font>+<a name="line-60"></a>+<a name="line-61"></a><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>+<a name="line-62"></a>    return x     <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>ts<font color=Red>-&gt;</font> Success ts x<font color=Cyan>)</font>+<a name="line-63"></a>    fail e       <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>ts<font color=Red>-&gt;</font> Failure ts e<font color=Cyan>)</font>+<a name="line-64"></a>    <font color=Cyan>(</font>P f<font color=Cyan>)</font> <font color=Cyan>&gt;&gt;=</font> g  <font color=Red>=</font> P <font color=Cyan>(</font>continue <font color=Cyan>.</font> f<font color=Cyan>)</font>+<a name="line-65"></a>      <font color=Green><u>where</u></font>+<a name="line-66"></a>        continue <font color=Cyan>(</font>Success ts x<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+<a name="line-67"></a>        continue <font color=Cyan>(</font>Committed <font color=Cyan>(</font>Committed r<font color=Cyan>)</font><font color=Cyan>)</font>  <font color=Red>=</font> continue <font color=Cyan>(</font>Committed r<font color=Cyan>)</font>+<a name="line-68"></a>        continue <font color=Cyan>(</font>Committed r<font color=Cyan>)</font>              <font color=Red>=</font> Committed <font color=Cyan>(</font>continue r<font color=Cyan>)</font>+<a name="line-69"></a>        continue <font color=Cyan>(</font>Failure ts e<font color=Cyan>)</font>             <font color=Red>=</font> Failure ts e+<a name="line-70"></a>+<a name="line-71"></a><font color=Green><u>instance</u></font> PolyParse <font color=Cyan>(</font>Parser t<font color=Cyan>)</font> <font color=Green><u>where</u></font>+<a name="line-72"></a>    commit <font color=Cyan>(</font>P p<font color=Cyan>)</font>         <font color=Red>=</font> P <font color=Cyan>(</font>Committed <font color=Cyan>.</font> p<font color=Cyan>)</font>+<a name="line-73"></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>adjust <font color=Cyan>.</font> p<font color=Cyan>)</font>+<a name="line-74"></a>      <font color=Green><u>where</u></font>+<a name="line-75"></a>        adjust <font color=Cyan>(</font>Failure z e<font color=Cyan>)</font>  <font color=Red>=</font> Failure z <font color=Cyan>(</font>f e<font color=Cyan>)</font>+<a name="line-76"></a>        adjust <font color=Cyan>(</font>Committed r<font color=Cyan>)</font>  <font color=Red>=</font> Committed <font color=Cyan>(</font>adjust r<font color=Cyan>)</font>+<a name="line-77"></a>        adjust  good          <font color=Red>=</font> good+<a name="line-78"></a>+<a name="line-79"></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>-&gt;</font> continue ts <font color=Cyan>$</font> p ts<font color=Cyan>)</font>+<a name="line-80"></a>      <font color=Green><u>where</u></font>+<a name="line-81"></a>        continue ts <font color=Cyan>(</font>Failure z e<font color=Cyan>)</font> <font color=Red>=</font> q ts+<a name="line-82"></a>     <font color=Blue>-- continue _  (Committed r) = r	-- no, remain Committed</font>+<a name="line-83"></a>        continue <font color=Green><u>_</u></font>  r             <font color=Red>=</font> r+<a name="line-84"></a>+<a name="line-85"></a>    oneOf' <font color=Red>=</font> accum []+<a name="line-86"></a>      <font color=Green><u>where</u></font> accum errs [] <font color=Red>=</font>+<a name="line-87"></a>                fail <font color=Cyan>(</font><font color=Magenta>"failed to parse any of the possible choices:\n"</font>+<a name="line-88"></a>                            <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>+<a name="line-89"></a>            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>+<a name="line-90"></a>                P <font color=Cyan>(</font><font color=Red>\</font>ts<font color=Red>-&gt;</font> <font color=Green><u>case</u></font> p ts <font color=Green><u>of</u></font>+<a name="line-91"></a>                           Failure <font color=Green><u>_</u></font> err <font color=Red>-&gt;</font>+<a name="line-92"></a>                                       <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+<a name="line-93"></a>                                       <font color=Green><u>in</u></font> p ts+<a name="line-94"></a>                           r<font color=Red>@</font><font color=Cyan>(</font>Success z a<font color=Cyan>)</font>    <font color=Red>-&gt;</font> r+<a name="line-95"></a>                           r<font color=Red>@</font><font color=Cyan>(</font>Committed <font color=Green><u>_</u></font><font color=Cyan>)</font>    <font color=Red>-&gt;</font> r <font color=Cyan>)</font>+<a name="line-96"></a>            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+<a name="line-97"></a>+<a name="line-98"></a>    <font color=Blue>--   Apply a parsed function to a parsed value.  This version</font>+<a name="line-99"></a>    <font color=Blue>--   is strict in the result of the function parser, but</font>+<a name="line-100"></a>    <font color=Blue>--   lazy in the result of the argument parser.  (Argument laziness is</font>+<a name="line-101"></a>    <font color=Blue>--   the distinctive feature over other implementations.)</font>+<a name="line-102"></a>    <font color=Cyan>(</font>P pf<font color=Cyan>)</font> <font color=Cyan>`apply`</font> px <font color=Red>=</font> P <font color=Cyan>(</font>continue <font color=Cyan>.</font> pf<font color=Cyan>)</font>+<a name="line-103"></a>      <font color=Green><u>where</u></font>+<a name="line-104"></a>        continue <font color=Cyan>(</font>Success z f<font color=Cyan>)</font>  <font color=Red>=</font> <font color=Green><u>let</u></font> <font color=Cyan>(</font>x<font color=Cyan>,</font>z'<font color=Cyan>)</font> <font color=Red>=</font> runParser px z+<a name="line-105"></a>                                  <font color=Green><u>in</u></font> Success z' <font color=Cyan>(</font>f x<font color=Cyan>)</font>+<a name="line-106"></a>        continue <font color=Cyan>(</font>Committed r<font color=Cyan>)</font>  <font color=Red>=</font> Committed <font color=Cyan>(</font>continue r<font color=Cyan>)</font>+<a name="line-107"></a>        continue <font color=Cyan>(</font>Failure z e<font color=Cyan>)</font>  <font color=Red>=</font> Failure z e+<a name="line-108"></a>+<a name="line-109"></a>+<a name="line-110"></a><a name="next"></a><font color=Blue>------------------------------------------------------------------------</font>+<a name="line-111"></a><font color=Blue>next</font> <font color=Red>::</font> Parser t t+<a name="line-112"></a><font color=Blue>next</font> <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>ts<font color=Red>-&gt;</font> <font color=Green><u>case</u></font> ts <font color=Green><u>of</u></font>+<a name="line-113"></a>                  []      <font color=Red>-&gt;</font> Failure [] <font color=Magenta>"Ran out of input (EOF)"</font>+<a name="line-114"></a>                  <font color=Cyan>(</font>t<font color=Red><b>:</b></font>ts'<font color=Cyan>)</font> <font color=Red>-&gt;</font> Success ts' t <font color=Cyan>)</font>+<a name="line-115"></a>+<a name="line-116"></a><a name="eof"></a><font color=Blue>eof</font>  <font color=Red>::</font> Parser t ()+<a name="line-117"></a><font color=Blue>eof</font>  <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>ts<font color=Red>-&gt;</font> <font color=Green><u>case</u></font> ts <font color=Green><u>of</u></font>+<a name="line-118"></a>                  []      <font color=Red>-&gt;</font> Success [] ()+<a name="line-119"></a>                  <font color=Cyan>(</font>t<font color=Red><b>:</b></font>ts'<font color=Cyan>)</font> <font color=Red>-&gt;</font> Failure ts <font color=Magenta>"Expected end of input (EOF)"</font> <font color=Cyan>)</font>+<a name="line-120"></a>+<a name="line-121"></a><a name="satisfy"></a><font color=Blue>satisfy</font> <font color=Red>::</font> <font color=Cyan>(</font>t<font color=Red>-&gt;</font>Bool<font color=Cyan>)</font> <font color=Red>-&gt;</font> Parser t t+<a name="line-122"></a><font color=Blue>satisfy</font> pred <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font> x <font color=Red>&lt;-</font> next+<a name="line-123"></a>                  <font color=Cyan>;</font> <font color=Green><u>if</u></font> pred 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>+<a name="line-124"></a>                  <font color=Cyan>}</font>+<a name="line-125"></a>+<a name="line-126"></a><a name="reparse"></a><font color=Blue>------------------------------------------------------------------------</font>+<a name="line-127"></a><font color=Blue>-- | Push some tokens back onto the front of the input stream and reparse.</font>+<a name="line-128"></a><font color=Blue>--   This is useful e.g. for recursively expanding macros.  When the</font>+<a name="line-129"></a><font color=Blue>--   user-parser recognises a macro use, it can lookup the macro</font>+<a name="line-130"></a><font color=Blue>--   expansion from the parse state, lex it, and then stuff the</font>+<a name="line-131"></a><font color=Blue>--   lexed expansion back down into the parser.</font>+<a name="line-132"></a><font color=Blue>reparse</font>    <font color=Red>::</font> <font color=Red>[</font>t<font color=Red>]</font> <font color=Red>-&gt;</font> Parser t ()+<a name="line-133"></a><font color=Blue>reparse</font> ts  <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>inp<font color=Red>-&gt;</font> Success <font color=Cyan>(</font>ts<font color=Cyan>++</font>inp<font color=Cyan>)</font> ()<font color=Cyan>)</font>+<a name="line-134"></a>+<a name="line-135"></a><font color=Blue>------------------------------------------------------------------------</font>+</pre>+</html>
+ docs/haddock/src/Text/ParserCombinators/Poly/Plain.html view
@@ -0,0 +1,117 @@+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">+<html>+<pre><a name="line-1"></a><font color=Green><u>module</u></font> Text<font color=Cyan>.</font>ParserCombinators<font color=Cyan>.</font>Poly<font color=Cyan>.</font>Plain+<a name="line-2"></a>  <font color=Cyan>(</font> <font color=Blue>-- * The Parser datatype</font>+<a name="line-3"></a>    Parser<font color=Cyan>(</font>P<font color=Cyan>)</font>	<font color=Blue>-- datatype, instance of: Functor, Monad, PolyParse</font>+<a name="line-4"></a>  <font color=Cyan>,</font> Result<font color=Cyan>(</font><font color=Red>..</font><font color=Cyan>)</font>	<font color=Blue>-- internal to the Parser Monad.</font>+<a name="line-5"></a>  <font color=Cyan>,</font> runParser	<font color=Blue>-- :: Parser t a -&gt; [t] -&gt; (Either String a, [t])</font>+<a name="line-6"></a>    <font color=Blue>-- ** basic parsers</font>+<a name="line-7"></a>  <font color=Cyan>,</font> next	<font color=Blue>-- :: Parser t t</font>+<a name="line-8"></a>  <font color=Cyan>,</font> eof		<font color=Blue>-- :: Parser t ()</font>+<a name="line-9"></a>  <font color=Cyan>,</font> satisfy	<font color=Blue>-- :: (t-&gt;Bool) -&gt; Parser t t</font>+<a name="line-10"></a>+<a name="line-11"></a>    <font color=Blue>-- ** re-parsing</font>+<a name="line-12"></a>  <font color=Cyan>,</font> reparse	<font color=Blue>-- :: [t] -&gt; Parser t ()</font>+<a name="line-13"></a>    <font color=Blue>-- * Re-export all more general combinators</font>+<a name="line-14"></a>  <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>Base+<a name="line-15"></a>  <font color=Cyan>)</font> <font color=Green><u>where</u></font>+<a name="line-16"></a>+<a name="line-17"></a>+<a name="line-18"></a><font color=Green><u>import</u></font> Text<font color=Cyan>.</font>ParserCombinators<font color=Cyan>.</font>Poly<font color=Cyan>.</font>Base+<a name="line-19"></a>+<a name="line-20"></a><a name="Parser"></a><font color=Blue>-- | This @Parser@ datatype is a fairly generic parsing monad with error</font>+<a name="line-21"></a><a name="Parser"></a><font color=Blue>--   reporting.  It can be used for arbitrary token types, not just</font>+<a name="line-22"></a><a name="Parser"></a><font color=Blue>--   String input.  (If you require a running state, use module PolyState</font>+<a name="line-23"></a><a name="Parser"></a><font color=Blue>--   instead)</font>+<a name="line-24"></a><a name="Parser"></a><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>-&gt;</font> Result <font color=Red>[</font>t<font color=Red>]</font> a<font color=Cyan>)</font>+<a name="line-25"></a>+<a name="line-26"></a><a name="Result"></a><font color=Blue>-- | A return type like Either, that distinguishes not only between</font>+<a name="line-27"></a><a name="Result"></a><font color=Blue>--   right and wrong answers, but also has commitment, so that a failure</font>+<a name="line-28"></a><a name="Result"></a><font color=Blue>--   cannot be undone.  This should only be used for writing very primitive</font>+<a name="line-29"></a><a name="Result"></a><font color=Blue>--   parsers - really it is an internal detail of the library.</font>+<a name="line-30"></a><a name="Result"></a><font color=Green><u>data</u></font> Result z a <font color=Red>=</font> Success   z a+<a name="line-31"></a>                <font color=Red>|</font> Failure   z String+<a name="line-32"></a>                <font color=Red>|</font> Committed <font color=Cyan>(</font>Result z a<font color=Cyan>)</font>+<a name="line-33"></a>+<a name="line-34"></a><font color=Green><u>instance</u></font> Functor <font color=Cyan>(</font>Result z<font color=Cyan>)</font> <font color=Green><u>where</u></font>+<a name="line-35"></a>    fmap f <font color=Cyan>(</font>Success z a<font color=Cyan>)</font> <font color=Red>=</font> Success z <font color=Cyan>(</font>f a<font color=Cyan>)</font>+<a name="line-36"></a>    fmap f <font color=Cyan>(</font>Failure z e<font color=Cyan>)</font> <font color=Red>=</font> Failure z e+<a name="line-37"></a>    fmap f <font color=Cyan>(</font>Committed r<font color=Cyan>)</font> <font color=Red>=</font> Committed <font color=Cyan>(</font>fmap f r<font color=Cyan>)</font>+<a name="line-38"></a>+<a name="line-39"></a><a name="runParser"></a><font color=Blue>-- | Apply a parser to an input token sequence.</font>+<a name="line-40"></a><font color=Blue>runParser</font> <font color=Red>::</font> Parser t a <font color=Red>-&gt;</font> <font color=Red>[</font>t<font color=Red>]</font> <font color=Red>-&gt;</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="line-41"></a><font color=Blue>runParser</font> <font color=Cyan>(</font>P p<font color=Cyan>)</font> <font color=Red>=</font> resultToEither <font color=Cyan>.</font> p+<a name="line-42"></a>  <font color=Green><u>where</u></font>+<a name="line-43"></a>    resultToEither <font color=Red>::</font> Result z a <font color=Red>-&gt;</font> <font color=Cyan>(</font>Either String a<font color=Cyan>,</font> z<font color=Cyan>)</font>+<a name="line-44"></a>    resultToEither <font color=Cyan>(</font>Success z a<font color=Cyan>)</font>  <font color=Red>=</font>  <font color=Cyan>(</font>Right a<font color=Cyan>,</font> z<font color=Cyan>)</font>+<a name="line-45"></a>    resultToEither <font color=Cyan>(</font>Failure z e<font color=Cyan>)</font>  <font color=Red>=</font>  <font color=Cyan>(</font>Left e<font color=Cyan>,</font> z<font color=Cyan>)</font>+<a name="line-46"></a>    resultToEither <font color=Cyan>(</font>Committed r<font color=Cyan>)</font>  <font color=Red>=</font>  resultToEither r+<a name="line-47"></a>+<a name="line-48"></a><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>+<a name="line-49"></a>    fmap f <font color=Cyan>(</font>P p<font color=Cyan>)</font> <font color=Red>=</font> P <font color=Cyan>(</font>fmap f <font color=Cyan>.</font> p<font color=Cyan>)</font>+<a name="line-50"></a>+<a name="line-51"></a><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>+<a name="line-52"></a>    return x     <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>ts<font color=Red>-&gt;</font> Success ts x<font color=Cyan>)</font>+<a name="line-53"></a>    fail e       <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>ts<font color=Red>-&gt;</font> Failure ts e<font color=Cyan>)</font>+<a name="line-54"></a>    <font color=Cyan>(</font>P f<font color=Cyan>)</font> <font color=Cyan>&gt;&gt;=</font> g  <font color=Red>=</font> P <font color=Cyan>(</font>continue <font color=Cyan>.</font> f<font color=Cyan>)</font>+<a name="line-55"></a>      <font color=Green><u>where</u></font>+<a name="line-56"></a>        continue <font color=Cyan>(</font>Success ts x<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+<a name="line-57"></a>        continue <font color=Cyan>(</font>Committed <font color=Cyan>(</font>Committed r<font color=Cyan>)</font><font color=Cyan>)</font>  <font color=Red>=</font> continue <font color=Cyan>(</font>Committed r<font color=Cyan>)</font>+<a name="line-58"></a>        continue <font color=Cyan>(</font>Committed r<font color=Cyan>)</font>              <font color=Red>=</font> Committed <font color=Cyan>(</font>continue r<font color=Cyan>)</font>+<a name="line-59"></a>        continue <font color=Cyan>(</font>Failure ts e<font color=Cyan>)</font>             <font color=Red>=</font> Failure ts e+<a name="line-60"></a>+<a name="line-61"></a><font color=Green><u>instance</u></font> PolyParse <font color=Cyan>(</font>Parser t<font color=Cyan>)</font> <font color=Green><u>where</u></font>+<a name="line-62"></a>    commit <font color=Cyan>(</font>P p<font color=Cyan>)</font>         <font color=Red>=</font> P <font color=Cyan>(</font>Committed <font color=Cyan>.</font> p<font color=Cyan>)</font>+<a name="line-63"></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>adjust <font color=Cyan>.</font> p<font color=Cyan>)</font>+<a name="line-64"></a>      <font color=Green><u>where</u></font>+<a name="line-65"></a>        adjust <font color=Cyan>(</font>Failure z e<font color=Cyan>)</font> <font color=Red>=</font> Failure z <font color=Cyan>(</font>f e<font color=Cyan>)</font>+<a name="line-66"></a>        adjust <font color=Cyan>(</font>Committed r<font color=Cyan>)</font> <font color=Red>=</font> Committed <font color=Cyan>(</font>adjust r<font color=Cyan>)</font>+<a name="line-67"></a>        adjust  good         <font color=Red>=</font> good+<a name="line-68"></a>+<a name="line-69"></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>-&gt;</font> continue ts <font color=Cyan>$</font> p ts<font color=Cyan>)</font>+<a name="line-70"></a>      <font color=Green><u>where</u></font>+<a name="line-71"></a>        continue ts <font color=Cyan>(</font>Failure z e<font color=Cyan>)</font> <font color=Red>=</font> q ts+<a name="line-72"></a>    <font color=Blue>--  continue _  (Committed r) = r	-- no, remain Committed</font>+<a name="line-73"></a>        continue <font color=Green><u>_</u></font>  r             <font color=Red>=</font> r+<a name="line-74"></a>+<a name="line-75"></a>    oneOf' <font color=Red>=</font> accum []+<a name="line-76"></a>      <font color=Green><u>where</u></font> accum errs [] <font color=Red>=</font>+<a name="line-77"></a>                fail <font color=Cyan>(</font><font color=Magenta>"failed to parse any of the possible choices:\n"</font>+<a name="line-78"></a>                            <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>+<a name="line-79"></a>            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>+<a name="line-80"></a>                P <font color=Cyan>(</font><font color=Red>\</font>ts<font color=Red>-&gt;</font> <font color=Green><u>case</u></font> p ts <font color=Green><u>of</u></font>+<a name="line-81"></a>                           Failure <font color=Green><u>_</u></font> err <font color=Red>-&gt;</font>+<a name="line-82"></a>                                       <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+<a name="line-83"></a>                                       <font color=Green><u>in</u></font> p ts+<a name="line-84"></a>                           r<font color=Red>@</font><font color=Cyan>(</font>Success z a<font color=Cyan>)</font>    <font color=Red>-&gt;</font> r+<a name="line-85"></a>                           r<font color=Red>@</font><font color=Cyan>(</font>Committed <font color=Green><u>_</u></font><font color=Cyan>)</font>    <font color=Red>-&gt;</font> r <font color=Cyan>)</font>+<a name="line-86"></a>            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+<a name="line-87"></a>+<a name="line-88"></a><a name="next"></a><font color=Blue>------------------------------------------------------------------------</font>+<a name="line-89"></a><font color=Blue>next</font> <font color=Red>::</font> Parser t t+<a name="line-90"></a><font color=Blue>next</font> <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>ts<font color=Red>-&gt;</font> <font color=Green><u>case</u></font> ts <font color=Green><u>of</u></font>+<a name="line-91"></a>                  []      <font color=Red>-&gt;</font> Failure [] <font color=Magenta>"Ran out of input (EOF)"</font>+<a name="line-92"></a>                  <font color=Cyan>(</font>t<font color=Red><b>:</b></font>ts'<font color=Cyan>)</font> <font color=Red>-&gt;</font> Success ts' t <font color=Cyan>)</font>+<a name="line-93"></a>+<a name="line-94"></a><a name="eof"></a><font color=Blue>eof</font>  <font color=Red>::</font> Parser t ()+<a name="line-95"></a><font color=Blue>eof</font>  <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>ts<font color=Red>-&gt;</font> <font color=Green><u>case</u></font> ts <font color=Green><u>of</u></font>+<a name="line-96"></a>                  []      <font color=Red>-&gt;</font> Success [] ()+<a name="line-97"></a>                  <font color=Cyan>(</font>t<font color=Red><b>:</b></font>ts'<font color=Cyan>)</font> <font color=Red>-&gt;</font> Failure ts <font color=Magenta>"Expected end of input (EOF)"</font> <font color=Cyan>)</font>+<a name="line-98"></a>+<a name="line-99"></a><a name="satisfy"></a><font color=Blue>satisfy</font> <font color=Red>::</font> <font color=Cyan>(</font>t<font color=Red>-&gt;</font>Bool<font color=Cyan>)</font> <font color=Red>-&gt;</font> Parser t t+<a name="line-100"></a><font color=Blue>satisfy</font> pred <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font> x <font color=Red>&lt;-</font> next+<a name="line-101"></a>                  <font color=Cyan>;</font> <font color=Green><u>if</u></font> pred 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>+<a name="line-102"></a>                  <font color=Cyan>}</font>+<a name="line-103"></a>+<a name="line-104"></a><a name="reparse"></a><font color=Blue>------------------------------------------------------------------------</font>+<a name="line-105"></a><font color=Blue>-- | Push some tokens back onto the front of the input stream and reparse.</font>+<a name="line-106"></a><font color=Blue>--   This is useful e.g. for recursively expanding macros.  When the</font>+<a name="line-107"></a><font color=Blue>--   user-parser recognises a macro use, it can lookup the macro</font>+<a name="line-108"></a><font color=Blue>--   expansion from the parse state, lex it, and then stuff the</font>+<a name="line-109"></a><font color=Blue>--   lexed expansion back down into the parser.</font>+<a name="line-110"></a><font color=Blue>reparse</font>    <font color=Red>::</font> <font color=Red>[</font>t<font color=Red>]</font> <font color=Red>-&gt;</font> Parser t ()+<a name="line-111"></a><font color=Blue>reparse</font> ts  <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>inp<font color=Red>-&gt;</font> Success <font color=Cyan>(</font>ts<font color=Cyan>++</font>inp<font color=Cyan>)</font> ()<font color=Cyan>)</font>+<a name="line-112"></a>+<a name="line-113"></a><font color=Blue>------------------------------------------------------------------------</font>+</pre>+</html>
+ docs/haddock/src/Text/ParserCombinators/Poly/State.html view
@@ -0,0 +1,136 @@+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">+<html>+<pre><a name="line-1"></a><font color=Green><u>module</u></font> Text<font color=Cyan>.</font>ParserCombinators<font color=Cyan>.</font>Poly<font color=Cyan>.</font>State+<a name="line-2"></a>  <font color=Cyan>(</font> <font color=Blue>-- * The Parser datatype</font>+<a name="line-3"></a>    Parser<font color=Cyan>(</font>P<font color=Cyan>)</font>	<font color=Blue>-- datatype, instance of: Functor, Monad, PolyParse</font>+<a name="line-4"></a>  <font color=Cyan>,</font> Result<font color=Cyan>(</font><font color=Red>..</font><font color=Cyan>)</font>	<font color=Blue>-- internal to the parser monad</font>+<a name="line-5"></a>  <font color=Cyan>,</font> runParser	<font color=Blue>-- :: Parser s t a -&gt; s -&gt; [t] -&gt; (Either String a, s, [t])</font>+<a name="line-6"></a>    <font color=Blue>-- ** basic parsers</font>+<a name="line-7"></a>  <font color=Cyan>,</font> next	<font color=Blue>-- :: Parser s t t</font>+<a name="line-8"></a>  <font color=Cyan>,</font> eof		<font color=Blue>-- :: Parser s t ()</font>+<a name="line-9"></a>  <font color=Cyan>,</font> satisfy	<font color=Blue>-- :: (t-&gt;Bool) -&gt; Parser s t t</font>+<a name="line-10"></a>    <font color=Blue>-- ** State-handling</font>+<a name="line-11"></a>  <font color=Cyan>,</font> stUpdate    <font color=Blue>-- :: (s-&gt;s) -&gt; Parser s t ()</font>+<a name="line-12"></a>  <font color=Cyan>,</font> stQuery     <font color=Blue>-- :: (s-&gt;a) -&gt; Parser s t a</font>+<a name="line-13"></a>  <font color=Cyan>,</font> stGet       <font color=Blue>-- :: Parser s t s</font>+<a name="line-14"></a>    <font color=Blue>-- ** re-parsing</font>+<a name="line-15"></a>  <font color=Cyan>,</font> reparse	<font color=Blue>-- :: [t] -&gt; Parser s t ()</font>+<a name="line-16"></a>    <font color=Blue>-- * Re-export all more general combinators</font>+<a name="line-17"></a>  <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>Base+<a name="line-18"></a>  <font color=Cyan>)</font> <font color=Green><u>where</u></font>+<a name="line-19"></a>+<a name="line-20"></a>+<a name="line-21"></a><font color=Green><u>import</u></font> Text<font color=Cyan>.</font>ParserCombinators<font color=Cyan>.</font>Poly<font color=Cyan>.</font>Base+<a name="line-22"></a>+<a name="line-23"></a><a name="Parser"></a><font color=Blue>-- | This @Parser@ datatype is a fairly generic parsing monad with error</font>+<a name="line-24"></a><a name="Parser"></a><font color=Blue>--   reporting.  It can be used for arbitrary token types, not just</font>+<a name="line-25"></a><a name="Parser"></a><font color=Blue>--   String input.  (If you require a running state, use module PolyState</font>+<a name="line-26"></a><a name="Parser"></a><font color=Blue>--   instead)</font>+<a name="line-27"></a><a name="Parser"></a><font color=Green><u>newtype</u></font> Parser s t a <font color=Red>=</font> P <font color=Cyan>(</font>s <font color=Red>-&gt;</font> <font color=Red>[</font>t<font color=Red>]</font> <font color=Red>-&gt;</font> Result <font color=Red>[</font>t<font color=Red>]</font> s a<font color=Cyan>)</font>+<a name="line-28"></a>+<a name="line-29"></a><a name="Result"></a><font color=Blue>-- | A return type like Either, that distinguishes not only between</font>+<a name="line-30"></a><a name="Result"></a><font color=Blue>--   right and wrong answers, but also has gradations of wrongness.</font>+<a name="line-31"></a><a name="Result"></a><font color=Blue>--   This should only be used for writing very primitive</font>+<a name="line-32"></a><a name="Result"></a><font color=Blue>--   parsers - really it is an internal detail of the library.</font>+<a name="line-33"></a><a name="Result"></a><font color=Green><u>data</u></font> Result z s a <font color=Red>=</font> Success    z s a+<a name="line-34"></a>                  <font color=Red>|</font> Failure    z s String+<a name="line-35"></a>                  <font color=Red>|</font> Committed  <font color=Cyan>(</font>Result z s a<font color=Cyan>)</font>+<a name="line-36"></a>+<a name="line-37"></a><font color=Green><u>instance</u></font> Functor <font color=Cyan>(</font>Result z s<font color=Cyan>)</font> <font color=Green><u>where</u></font>+<a name="line-38"></a>    fmap f <font color=Cyan>(</font>Success z s a<font color=Cyan>)</font> <font color=Red>=</font> Success z s <font color=Cyan>(</font>f a<font color=Cyan>)</font>+<a name="line-39"></a>    fmap f <font color=Cyan>(</font>Failure z s e<font color=Cyan>)</font> <font color=Red>=</font> Failure z s e+<a name="line-40"></a>    fmap f <font color=Cyan>(</font>Committed r<font color=Cyan>)</font>   <font color=Red>=</font> Committed <font color=Cyan>(</font>fmap f r<font color=Cyan>)</font>+<a name="line-41"></a>+<a name="line-42"></a><a name="runParser"></a><font color=Blue>-- | Apply a parser to an input token sequence.</font>+<a name="line-43"></a><font color=Blue>runParser</font> <font color=Red>::</font> Parser s t a <font color=Red>-&gt;</font> s <font color=Red>-&gt;</font> <font color=Red>[</font>t<font color=Red>]</font> <font color=Red>-&gt;</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="line-44"></a><font color=Blue>runParser</font> <font color=Cyan>(</font>P p<font color=Cyan>)</font> <font color=Red>=</font> <font color=Red>\</font>s<font color=Red>-&gt;</font> resultToEither <font color=Cyan>.</font> p s+<a name="line-45"></a>  <font color=Green><u>where</u></font>+<a name="line-46"></a>    resultToEither <font color=Red>::</font> Result z s a <font color=Red>-&gt;</font> <font color=Cyan>(</font>Either String a<font color=Cyan>,</font> s<font color=Cyan>,</font> z<font color=Cyan>)</font>+<a name="line-47"></a>    resultToEither <font color=Cyan>(</font>Success z s a<font color=Cyan>)</font> <font color=Red>=</font>  <font color=Cyan>(</font>Right a<font color=Cyan>,</font> s<font color=Cyan>,</font> z<font color=Cyan>)</font>+<a name="line-48"></a>    resultToEither <font color=Cyan>(</font>Failure z s e<font color=Cyan>)</font> <font color=Red>=</font>  <font color=Cyan>(</font>Left e<font color=Cyan>,</font>  s<font color=Cyan>,</font> z<font color=Cyan>)</font>+<a name="line-49"></a>    resultToEither <font color=Cyan>(</font>Committed r<font color=Cyan>)</font>   <font color=Red>=</font>  resultToEither r+<a name="line-50"></a>+<a name="line-51"></a><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>+<a name="line-52"></a>    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<font color=Red>-&gt;</font> fmap f <font color=Cyan>.</font> p s<font color=Cyan>)</font>+<a name="line-53"></a>+<a name="line-54"></a><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>+<a name="line-55"></a>    return x     <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>s ts<font color=Red>-&gt;</font> Success ts s x<font color=Cyan>)</font>+<a name="line-56"></a>    fail e       <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>s ts<font color=Red>-&gt;</font> Failure ts s e<font color=Cyan>)</font>+<a name="line-57"></a>    <font color=Cyan>(</font>P f<font color=Cyan>)</font> <font color=Cyan>&gt;&gt;=</font> g  <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>s<font color=Red>-&gt;</font> continue <font color=Cyan>.</font> f s<font color=Cyan>)</font>+<a name="line-58"></a>      <font color=Green><u>where</u></font>+<a name="line-59"></a>        continue <font color=Cyan>(</font>Success ts s x<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+<a name="line-60"></a>        continue <font color=Cyan>(</font>Committed <font color=Cyan>(</font>Committed r<font color=Cyan>)</font><font color=Cyan>)</font> <font color=Red>=</font> continue <font color=Cyan>(</font>Committed r<font color=Cyan>)</font>+<a name="line-61"></a>        continue <font color=Cyan>(</font>Committed r<font color=Cyan>)</font>             <font color=Red>=</font> Committed <font color=Cyan>(</font>continue r<font color=Cyan>)</font>+<a name="line-62"></a>        continue <font color=Cyan>(</font>Failure ts s e<font color=Cyan>)</font>          <font color=Red>=</font> Failure ts s e+<a name="line-63"></a>+<a name="line-64"></a><font color=Green><u>instance</u></font> PolyParse <font color=Cyan>(</font>Parser s t<font color=Cyan>)</font> <font color=Green><u>where</u></font>+<a name="line-65"></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<font color=Red>-&gt;</font> Committed <font color=Cyan>.</font> p s<font color=Cyan>)</font>+<a name="line-66"></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<font color=Red>-&gt;</font> adjust <font color=Cyan>.</font> p s<font color=Cyan>)</font>+<a name="line-67"></a>      <font color=Green><u>where</u></font>+<a name="line-68"></a>        adjust <font color=Cyan>(</font>Failure z s e<font color=Cyan>)</font> <font color=Red>=</font> Failure z s <font color=Cyan>(</font>f e<font color=Cyan>)</font>+<a name="line-69"></a>        adjust <font color=Cyan>(</font>Committed r<font color=Cyan>)</font>   <font color=Red>=</font> Committed <font color=Cyan>(</font>adjust r<font color=Cyan>)</font>+<a name="line-70"></a>        adjust  good           <font color=Red>=</font> good+<a name="line-71"></a>+<a name="line-72"></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>-&gt;</font> continue s ts <font color=Cyan>$</font> p s ts<font color=Cyan>)</font>+<a name="line-73"></a>      <font color=Green><u>where</u></font>+<a name="line-74"></a>        continue s ts <font color=Cyan>(</font>Failure <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> q s ts+<a name="line-75"></a>    <font color=Blue>--  continue _ _  (Committed r)   = r	-- no, remain Committed</font>+<a name="line-76"></a>        continue <font color=Green><u>_</u></font> <font color=Green><u>_</u></font>  r               <font color=Red>=</font> r+<a name="line-77"></a>+<a name="line-78"></a>    oneOf' <font color=Red>=</font> accum []+<a name="line-79"></a>      <font color=Green><u>where</u></font> accum errs [] <font color=Red>=</font>+<a name="line-80"></a>                fail <font color=Cyan>(</font><font color=Magenta>"failed to parse any of the possible choices:\n"</font>+<a name="line-81"></a>                            <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>+<a name="line-82"></a>            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>+<a name="line-83"></a>                P <font color=Cyan>(</font><font color=Red>\</font>s ts<font color=Red>-&gt;</font> <font color=Green><u>case</u></font> p s ts <font color=Green><u>of</u></font>+<a name="line-84"></a>                           Failure <font color=Green><u>_</u></font> <font color=Green><u>_</u></font> err <font color=Red>-&gt;</font>+<a name="line-85"></a>                                       <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+<a name="line-86"></a>                                       <font color=Green><u>in</u></font> p s ts+<a name="line-87"></a>                           r<font color=Red>@</font><font color=Cyan>(</font>Success z <font color=Green><u>_</u></font> a<font color=Cyan>)</font>    <font color=Red>-&gt;</font> r+<a name="line-88"></a>                           r<font color=Red>@</font><font color=Cyan>(</font>Committed <font color=Green><u>_</u></font><font color=Cyan>)</font>      <font color=Red>-&gt;</font> r <font color=Cyan>)</font>+<a name="line-89"></a>            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+<a name="line-90"></a>+<a name="line-91"></a><a name="next"></a><font color=Blue>------------------------------------------------------------------------</font>+<a name="line-92"></a><font color=Blue>next</font> <font color=Red>::</font> Parser s t t+<a name="line-93"></a><font color=Blue>next</font> <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>s ts<font color=Red>-&gt;</font> <font color=Green><u>case</u></font> ts <font color=Green><u>of</u></font>+<a name="line-94"></a>                  []      <font color=Red>-&gt;</font> Failure [] s <font color=Magenta>"Ran out of input (EOF)"</font>+<a name="line-95"></a>                  <font color=Cyan>(</font>t<font color=Red><b>:</b></font>ts'<font color=Cyan>)</font> <font color=Red>-&gt;</font> Success ts' s t <font color=Cyan>)</font>+<a name="line-96"></a>+<a name="line-97"></a><a name="eof"></a><font color=Blue>eof</font>  <font color=Red>::</font> Parser s t ()+<a name="line-98"></a><font color=Blue>eof</font>  <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>s ts<font color=Red>-&gt;</font> <font color=Green><u>case</u></font> ts <font color=Green><u>of</u></font>+<a name="line-99"></a>                  []      <font color=Red>-&gt;</font> Success [] s ()+<a name="line-100"></a>                  <font color=Cyan>(</font>t<font color=Red><b>:</b></font>ts'<font color=Cyan>)</font> <font color=Red>-&gt;</font> Failure ts s <font color=Magenta>"Expected end of input (eof)"</font> <font color=Cyan>)</font>+<a name="line-101"></a>+<a name="line-102"></a>+<a name="line-103"></a><a name="satisfy"></a><font color=Blue>satisfy</font> <font color=Red>::</font> <font color=Cyan>(</font>t<font color=Red>-&gt;</font>Bool<font color=Cyan>)</font> <font color=Red>-&gt;</font> Parser s t t+<a name="line-104"></a><font color=Blue>satisfy</font> pred <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font> x <font color=Red>&lt;-</font> next+<a name="line-105"></a>                  <font color=Cyan>;</font> <font color=Green><u>if</u></font> pred 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>+<a name="line-106"></a>                  <font color=Cyan>}</font>+<a name="line-107"></a><font color=Blue>------------------------------------------------------------------------</font>+<a name="line-108"></a><font color=Blue>-- State handling</font>+<a name="line-109"></a>+<a name="line-110"></a><a name="stUpdate"></a><font color=Blue>-- | Update the internal state.</font>+<a name="line-111"></a><font color=Blue>stUpdate</font>   <font color=Red>::</font> <font color=Cyan>(</font>s<font color=Red>-&gt;</font>s<font color=Cyan>)</font> <font color=Red>-&gt;</font> Parser s t ()+<a name="line-112"></a><font color=Blue>stUpdate</font> f  <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>s ts<font color=Red>-&gt;</font> Success ts <font color=Cyan>(</font>f s<font color=Cyan>)</font> ()<font color=Cyan>)</font>+<a name="line-113"></a>+<a name="line-114"></a><a name="stQuery"></a><font color=Blue>-- | Query the internal state.</font>+<a name="line-115"></a><font color=Blue>stQuery</font>    <font color=Red>::</font> <font color=Cyan>(</font>s<font color=Red>-&gt;</font>a<font color=Cyan>)</font> <font color=Red>-&gt;</font> Parser s t a+<a name="line-116"></a><font color=Blue>stQuery</font> f   <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>s ts<font color=Red>-&gt;</font> Success ts s <font color=Cyan>(</font>f s<font color=Cyan>)</font><font color=Cyan>)</font>+<a name="line-117"></a>+<a name="line-118"></a><a name="stGet"></a><font color=Blue>-- | Deliver the entire internal state.</font>+<a name="line-119"></a><font color=Blue>stGet</font>      <font color=Red>::</font> Parser s t s+<a name="line-120"></a><font color=Blue>stGet</font>       <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>s ts<font color=Red>-&gt;</font> Success ts s s<font color=Cyan>)</font>+<a name="line-121"></a>+<a name="line-122"></a>+<a name="line-123"></a><a name="reparse"></a><font color=Blue>------------------------------------------------------------------------</font>+<a name="line-124"></a><font color=Blue>-- | Push some tokens back onto the front of the input stream and reparse.</font>+<a name="line-125"></a><font color=Blue>--   This is useful e.g. for recursively expanding macros.  When the</font>+<a name="line-126"></a><font color=Blue>--   user-parser recognises a macro use, it can lookup the macro</font>+<a name="line-127"></a><font color=Blue>--   expansion from the parse state, lex it, and then stuff the</font>+<a name="line-128"></a><font color=Blue>--   lexed expansion back down into the parser.</font>+<a name="line-129"></a><font color=Blue>reparse</font>    <font color=Red>::</font> <font color=Red>[</font>t<font color=Red>]</font> <font color=Red>-&gt;</font> Parser s t ()+<a name="line-130"></a><font color=Blue>reparse</font> ts  <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>s inp<font color=Red>-&gt;</font> Success <font color=Cyan>(</font>ts<font color=Cyan>++</font>inp<font color=Cyan>)</font> s ()<font color=Cyan>)</font>+<a name="line-131"></a>+<a name="line-132"></a><font color=Blue>------------------------------------------------------------------------</font>+</pre>+</html>
+ docs/haddock/src/Text/ParserCombinators/Poly/StateLazy.html view
@@ -0,0 +1,185 @@+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">+<html>+<pre><a name="line-1"></a><font color=Green><u>module</u></font> Text<font color=Cyan>.</font>ParserCombinators<font color=Cyan>.</font>Poly<font color=Cyan>.</font>StateLazy+<a name="line-2"></a>  <font color=Cyan>(</font> <font color=Blue>-- * The Parser datatype</font>+<a name="line-3"></a>    Parser<font color=Cyan>(</font>P<font color=Cyan>)</font>	<font color=Blue>-- datatype, instance of: Functor, Monad, PolyParse</font>+<a name="line-4"></a>  <font color=Cyan>,</font> Result<font color=Cyan>(</font><font color=Red>..</font><font color=Cyan>)</font>	<font color=Blue>-- internal to the parser monad</font>+<a name="line-5"></a>  <font color=Cyan>,</font> runParser	<font color=Blue>-- :: Parser s t a -&gt; s -&gt; [t] -&gt; (Either String a, s, [t])</font>+<a name="line-6"></a>    <font color=Blue>-- ** basic parsers</font>+<a name="line-7"></a>  <font color=Cyan>,</font> next	<font color=Blue>-- :: Parser s t t</font>+<a name="line-8"></a>  <font color=Cyan>,</font> eof		<font color=Blue>-- :: Parser s t ()</font>+<a name="line-9"></a>  <font color=Cyan>,</font> satisfy	<font color=Blue>-- :: (t-&gt;Bool) -&gt; Parser s t t</font>+<a name="line-10"></a>  <font color=Cyan>,</font> manyFinally	<font color=Blue>-- :: Parser s t a -&gt; Parser s t z -&gt; Parser s t [a]</font>+<a name="line-11"></a>    <font color=Blue>-- ** State-handling</font>+<a name="line-12"></a>  <font color=Cyan>,</font> stUpdate    <font color=Blue>-- :: (s-&gt;s) -&gt; Parser s t ()</font>+<a name="line-13"></a>  <font color=Cyan>,</font> stQuery     <font color=Blue>-- :: (s-&gt;a) -&gt; Parser s t a</font>+<a name="line-14"></a>  <font color=Cyan>,</font> stGet       <font color=Blue>-- :: Parser s t s</font>+<a name="line-15"></a>    <font color=Blue>-- ** re-parsing</font>+<a name="line-16"></a>  <font color=Cyan>,</font> reparse	<font color=Blue>-- :: [t] -&gt; Parser s t ()</font>+<a name="line-17"></a>    <font color=Blue>-- * Re-export all more general combinators</font>+<a name="line-18"></a>  <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>Base+<a name="line-19"></a>  <font color=Cyan>)</font> <font color=Green><u>where</u></font>+<a name="line-20"></a>+<a name="line-21"></a>+<a name="line-22"></a><font color=Green><u>import</u></font> Text<font color=Cyan>.</font>ParserCombinators<font color=Cyan>.</font>Poly<font color=Cyan>.</font>Base hiding <font color=Cyan>(</font>manyFinally<font color=Cyan>)</font>+<a name="line-23"></a>+<a name="line-24"></a><font color=Magenta><em>#if __GLASGOW_HASKELL__</em></font>+<a name="line-25"></a><font color=Green><u>import</u></font> Control<font color=Cyan>.</font>Exception hiding <font color=Cyan>(</font>bracket<font color=Cyan>)</font>+<a name="line-26"></a><a name="throwE"></a><font color=Blue>throwE</font> <font color=Red>::</font> String <font color=Red>-&gt;</font> a+<a name="line-27"></a><font color=Blue>throwE</font> msg <font color=Red>=</font> throw <font color=Cyan>(</font>ErrorCall msg<font color=Cyan>)</font>+<a name="line-28"></a><font color=Magenta><em>#else</em></font>+<a name="line-29"></a><font color=Blue>throwE</font> <font color=Red>::</font> String <font color=Red>-&gt;</font> a+<a name="line-30"></a><font color=Blue>throwE</font> msg <font color=Red>=</font> error msg+<a name="line-31"></a><font color=Magenta><em>#endif</em></font>+<a name="line-32"></a>+<a name="line-33"></a>+<a name="line-34"></a><a name="Parser"></a><font color=Blue>-- | This @Parser@ datatype is a fairly generic parsing monad with error</font>+<a name="line-35"></a><a name="Parser"></a><font color=Blue>--   reporting.  It can be used for arbitrary token types, not just</font>+<a name="line-36"></a><a name="Parser"></a><font color=Blue>--   String input.  (If you require a running state, use module PolyState</font>+<a name="line-37"></a><a name="Parser"></a><font color=Blue>--   instead)</font>+<a name="line-38"></a><a name="Parser"></a><font color=Green><u>newtype</u></font> Parser s t a <font color=Red>=</font> P <font color=Cyan>(</font>s <font color=Red>-&gt;</font> <font color=Red>[</font>t<font color=Red>]</font> <font color=Red>-&gt;</font> Result <font color=Red>[</font>t<font color=Red>]</font> s a<font color=Cyan>)</font>+<a name="line-39"></a>+<a name="line-40"></a><a name="Result"></a><font color=Blue>-- | A return type like Either, that distinguishes not only between</font>+<a name="line-41"></a><a name="Result"></a><font color=Blue>--   right and wrong answers, but also has gradations of wrongness.</font>+<a name="line-42"></a><a name="Result"></a><font color=Blue>--   This should only be used for writing very primitive</font>+<a name="line-43"></a><a name="Result"></a><font color=Blue>--   parsers - really it is an internal detail of the library.</font>+<a name="line-44"></a><a name="Result"></a><font color=Green><u>data</u></font> Result z s a <font color=Red>=</font> Success    z s a+<a name="line-45"></a>                  <font color=Red>|</font> Failure    z s String+<a name="line-46"></a>                  <font color=Red>|</font> Committed  <font color=Cyan>(</font>Result z s a<font color=Cyan>)</font>+<a name="line-47"></a>+<a name="line-48"></a><font color=Green><u>instance</u></font> Functor <font color=Cyan>(</font>Result z s<font color=Cyan>)</font> <font color=Green><u>where</u></font>+<a name="line-49"></a>    fmap f <font color=Cyan>(</font>Success z s a<font color=Cyan>)</font> <font color=Red>=</font> Success z s <font color=Cyan>(</font>f a<font color=Cyan>)</font>+<a name="line-50"></a>    fmap f <font color=Cyan>(</font>Failure z s e<font color=Cyan>)</font> <font color=Red>=</font> Failure z s e+<a name="line-51"></a>    fmap f <font color=Cyan>(</font>Committed r<font color=Cyan>)</font>   <font color=Red>=</font> Committed <font color=Cyan>(</font>fmap f r<font color=Cyan>)</font>+<a name="line-52"></a>+<a name="line-53"></a><a name="runParser"></a><font color=Blue>-- | Apply a parser to an input token sequence.</font>+<a name="line-54"></a><font color=Blue>runParser</font> <font color=Red>::</font> Parser s t a <font color=Red>-&gt;</font> s <font color=Red>-&gt;</font> <font color=Red>[</font>t<font color=Red>]</font> <font color=Red>-&gt;</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="line-55"></a><font color=Blue>runParser</font> <font color=Cyan>(</font>P p<font color=Cyan>)</font> <font color=Red>=</font> <font color=Red>\</font>s <font color=Red>-&gt;</font> fromResult <font color=Cyan>.</font> p s+<a name="line-56"></a>  <font color=Green><u>where</u></font>+<a name="line-57"></a>    fromResult <font color=Red>::</font> Result z s a <font color=Red>-&gt;</font> <font color=Cyan>(</font>a<font color=Cyan>,</font> s<font color=Cyan>,</font> z<font color=Cyan>)</font>+<a name="line-58"></a>    fromResult <font color=Cyan>(</font>Success z s a<font color=Cyan>)</font>  <font color=Red>=</font>  <font color=Cyan>(</font>a<font color=Cyan>,</font> s<font color=Cyan>,</font> z<font color=Cyan>)</font>+<a name="line-59"></a>    fromResult <font color=Cyan>(</font>Failure z s e<font color=Cyan>)</font>  <font color=Red>=</font>  throwE e+<a name="line-60"></a>    fromResult <font color=Cyan>(</font>Committed r<font color=Cyan>)</font>    <font color=Red>=</font>  fromResult r+<a name="line-61"></a>+<a name="line-62"></a><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>+<a name="line-63"></a>    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 <font color=Red>-&gt;</font> fmap f <font color=Cyan>.</font> p s<font color=Cyan>)</font>+<a name="line-64"></a>+<a name="line-65"></a><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>+<a name="line-66"></a>    return x     <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>s ts<font color=Red>-&gt;</font> Success ts s x<font color=Cyan>)</font>+<a name="line-67"></a>    fail e       <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>s ts<font color=Red>-&gt;</font> Failure ts s e<font color=Cyan>)</font>+<a name="line-68"></a>    <font color=Cyan>(</font>P f<font color=Cyan>)</font> <font color=Cyan>&gt;&gt;=</font> g  <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>s<font color=Red>-&gt;</font> continue <font color=Cyan>.</font> f s<font color=Cyan>)</font>+<a name="line-69"></a>      <font color=Green><u>where</u></font>+<a name="line-70"></a>        continue <font color=Cyan>(</font>Success ts s x<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+<a name="line-71"></a>        continue <font color=Cyan>(</font>Committed <font color=Cyan>(</font>Committed r<font color=Cyan>)</font><font color=Cyan>)</font> <font color=Red>=</font> continue <font color=Cyan>(</font>Committed r<font color=Cyan>)</font>+<a name="line-72"></a>        continue <font color=Cyan>(</font>Committed r<font color=Cyan>)</font>             <font color=Red>=</font> Committed <font color=Cyan>(</font>continue r<font color=Cyan>)</font>+<a name="line-73"></a>        continue <font color=Cyan>(</font>Failure ts s e<font color=Cyan>)</font>          <font color=Red>=</font> Failure ts s e+<a name="line-74"></a>+<a name="line-75"></a><font color=Green><u>instance</u></font> PolyParse <font color=Cyan>(</font>Parser s t<font color=Cyan>)</font> <font color=Green><u>where</u></font>+<a name="line-76"></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<font color=Red>-&gt;</font> Committed <font color=Cyan>.</font> p s<font color=Cyan>)</font>+<a name="line-77"></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<font color=Red>-&gt;</font> adjust <font color=Cyan>.</font> p s<font color=Cyan>)</font>+<a name="line-78"></a>      <font color=Green><u>where</u></font>+<a name="line-79"></a>        adjust <font color=Cyan>(</font>Failure z s e<font color=Cyan>)</font> <font color=Red>=</font> Failure z s <font color=Cyan>(</font>f e<font color=Cyan>)</font>+<a name="line-80"></a>        adjust <font color=Cyan>(</font>Committed r<font color=Cyan>)</font>   <font color=Red>=</font> Committed <font color=Cyan>(</font>adjust r<font color=Cyan>)</font>+<a name="line-81"></a>        adjust  good           <font color=Red>=</font> good+<a name="line-82"></a>+<a name="line-83"></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>-&gt;</font> continue s ts <font color=Cyan>$</font> p s ts<font color=Cyan>)</font>+<a name="line-84"></a>      <font color=Green><u>where</u></font>+<a name="line-85"></a>        continue s ts <font color=Cyan>(</font>Failure <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> q s ts+<a name="line-86"></a>     <font color=Blue>-- continue _ _  (Committed r)   = r	-- no, remain Committed</font>+<a name="line-87"></a>        continue <font color=Green><u>_</u></font> <font color=Green><u>_</u></font>  r               <font color=Red>=</font> r+<a name="line-88"></a>+<a name="line-89"></a>    oneOf' <font color=Red>=</font> accum []+<a name="line-90"></a>      <font color=Green><u>where</u></font> accum errs [] <font color=Red>=</font>+<a name="line-91"></a>                fail <font color=Cyan>(</font><font color=Magenta>"failed to parse any of the possible choices:\n"</font>+<a name="line-92"></a>                            <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>+<a name="line-93"></a>            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>+<a name="line-94"></a>                P <font color=Cyan>(</font><font color=Red>\</font>s ts<font color=Red>-&gt;</font> <font color=Green><u>case</u></font> p s ts <font color=Green><u>of</u></font>+<a name="line-95"></a>                           Failure <font color=Green><u>_</u></font> <font color=Green><u>_</u></font> err <font color=Red>-&gt;</font>+<a name="line-96"></a>                                       <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+<a name="line-97"></a>                                       <font color=Green><u>in</u></font> p s ts+<a name="line-98"></a>                           r<font color=Red>@</font><font color=Cyan>(</font>Success z <font color=Green><u>_</u></font> a<font color=Cyan>)</font>    <font color=Red>-&gt;</font> r+<a name="line-99"></a>                           r<font color=Red>@</font><font color=Cyan>(</font>Committed <font color=Green><u>_</u></font><font color=Cyan>)</font>      <font color=Red>-&gt;</font> r <font color=Cyan>)</font>+<a name="line-100"></a>            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+<a name="line-101"></a>+<a name="line-102"></a>    <font color=Blue>--   Apply a parsed function to a parsed value.  This version</font>+<a name="line-103"></a>    <font color=Blue>--   is strict in the result of the function parser, but</font>+<a name="line-104"></a>    <font color=Blue>--   lazy in the result of the argument parser.  (Argument laziness is</font>+<a name="line-105"></a>    <font color=Blue>--   the distinctive feature over other implementations.)</font>+<a name="line-106"></a>    <font color=Cyan>(</font>P pf<font color=Cyan>)</font> <font color=Cyan>`apply`</font> px <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>s<font color=Red>-&gt;</font> continue <font color=Cyan>.</font> pf s<font color=Cyan>)</font>+<a name="line-107"></a>      <font color=Green><u>where</u></font>+<a name="line-108"></a>        continue <font color=Cyan>(</font>Success z s f<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>z'<font color=Cyan>)</font> <font color=Red>=</font> runParser px s z+<a name="line-109"></a>                                   <font color=Green><u>in</u></font> Success z' s' <font color=Cyan>(</font>f x<font color=Cyan>)</font>+<a name="line-110"></a>        continue <font color=Cyan>(</font>Failure z s e<font color=Cyan>)</font> <font color=Red>=</font> Failure z s e+<a name="line-111"></a>        continue <font color=Cyan>(</font>Committed r<font color=Cyan>)</font>   <font color=Red>=</font> Committed <font color=Cyan>(</font>continue r<font color=Cyan>)</font>+<a name="line-112"></a>+<a name="line-113"></a><a name="manyFinally"></a><font color=Blue>manyFinally</font> <font color=Red>::</font> Parser s t a <font color=Red>-&gt;</font> Parser s t z <font color=Red>-&gt;</font> Parser s t <font color=Red>[</font>a<font color=Red>]</font>+<a name="line-114"></a><font color=Blue>{-+<a name="line-115"></a>manyFinally pp@(P p) pt@(P t) = P (\s ts -&gt; item s ts (p s ts))+<a name="line-116"></a>    where+<a name="line-117"></a>      item _ _  (Success ts s x) = success ts s x+<a name="line-118"></a>      item s ts (Failure _ _ e)  = terminate (t s ts)+<a name="line-119"></a>      item s ts (Committed r)    = Committed (within r)+<a name="line-120"></a>+<a name="line-121"></a>      success ts s x =+<a name="line-122"></a>            let (tail,s',ts') = runParser (manyFinally pp pt) s ts+<a name="line-123"></a>            in Success ts' s' (x:tail)+<a name="line-124"></a>+<a name="line-125"></a>      terminate (Success ts s _) = Success ts s []+<a name="line-126"></a>      terminate (Failure ts s e) = Failure ts s e+<a name="line-127"></a>      terminate (Committed r)    = Committed (terminate r)+<a name="line-128"></a>+<a name="line-129"></a>      within (Success ts s x)    = success ts s x+<a name="line-130"></a>      within (Failure ts s e)    = Failure ts s e+<a name="line-131"></a>      within (Committed r)       = within r+<a name="line-132"></a>-}</font>+<a name="line-133"></a>+<a name="line-134"></a><font color=Blue>manyFinally</font> p z <font color=Red>=</font>+<a name="line-135"></a>    <font color=Cyan>(</font><font color=Green><u>do</u></font> x <font color=Red>&lt;-</font> p<font color=Cyan>;</font> return <font color=Cyan>(</font>x<font color=Red><b>:</b></font><font color=Cyan>)</font> <font color=Cyan>`apply`</font> manyFinally p z<font color=Cyan>)</font>+<a name="line-136"></a>      <font color=Cyan>`onFail`</font>+<a name="line-137"></a>    <font color=Cyan>(</font><font color=Green><u>do</u></font> z<font color=Cyan>;</font> return []<font color=Cyan>)</font>+<a name="line-138"></a>      <font color=Cyan>`onFail`</font>+<a name="line-139"></a>    oneOf' <font color=Red>[</font> <font color=Cyan>(</font><font color=Magenta>"item in sequence"</font><font color=Cyan>,</font>    <font color=Cyan>(</font><font color=Green><u>do</u></font> p<font color=Cyan>;</font> return []<font color=Cyan>)</font><font color=Cyan>)</font>+<a name="line-140"></a>           <font color=Cyan>,</font> <font color=Cyan>(</font><font color=Magenta>"sequence terminator"</font><font color=Cyan>,</font> <font color=Cyan>(</font><font color=Green><u>do</u></font> z<font color=Cyan>;</font> return []<font color=Cyan>)</font><font color=Cyan>)</font> <font color=Red>]</font>+<a name="line-141"></a>+<a name="line-142"></a><a name="next"></a><font color=Blue>------------------------------------------------------------------------</font>+<a name="line-143"></a><font color=Blue>next</font> <font color=Red>::</font> Parser s t t+<a name="line-144"></a><font color=Blue>next</font> <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>s ts<font color=Red>-&gt;</font> <font color=Green><u>case</u></font> ts <font color=Green><u>of</u></font>+<a name="line-145"></a>                  []      <font color=Red>-&gt;</font> Failure []  s <font color=Magenta>"Ran out of input (EOF)"</font>+<a name="line-146"></a>                  <font color=Cyan>(</font>t<font color=Red><b>:</b></font>ts'<font color=Cyan>)</font> <font color=Red>-&gt;</font> Success ts' s t <font color=Cyan>)</font>+<a name="line-147"></a>+<a name="line-148"></a><a name="eof"></a><font color=Blue>eof</font>  <font color=Red>::</font> Parser s t ()+<a name="line-149"></a><font color=Blue>eof</font>  <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>s ts<font color=Red>-&gt;</font> <font color=Green><u>case</u></font> ts <font color=Green><u>of</u></font>+<a name="line-150"></a>                  []      <font color=Red>-&gt;</font> Success [] s ()+<a name="line-151"></a>                  <font color=Cyan>(</font>t<font color=Red><b>:</b></font>ts'<font color=Cyan>)</font> <font color=Red>-&gt;</font> Failure ts s <font color=Magenta>"Expected end of input (eof)"</font> <font color=Cyan>)</font>+<a name="line-152"></a>+<a name="line-153"></a><a name="satisfy"></a><font color=Blue>satisfy</font> <font color=Red>::</font> <font color=Cyan>(</font>t<font color=Red>-&gt;</font>Bool<font color=Cyan>)</font> <font color=Red>-&gt;</font> Parser s t t+<a name="line-154"></a><font color=Blue>satisfy</font> pred <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font> x <font color=Red>&lt;-</font> next+<a name="line-155"></a>                  <font color=Cyan>;</font> <font color=Green><u>if</u></font> pred 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>+<a name="line-156"></a>                  <font color=Cyan>}</font>+<a name="line-157"></a><font color=Blue>------------------------------------------------------------------------</font>+<a name="line-158"></a><font color=Blue>-- State handling</font>+<a name="line-159"></a>+<a name="line-160"></a><a name="stUpdate"></a><font color=Blue>-- | Update the internal state.</font>+<a name="line-161"></a><font color=Blue>stUpdate</font>   <font color=Red>::</font> <font color=Cyan>(</font>s<font color=Red>-&gt;</font>s<font color=Cyan>)</font> <font color=Red>-&gt;</font> Parser s t ()+<a name="line-162"></a><font color=Blue>stUpdate</font> f  <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>s ts<font color=Red>-&gt;</font> Success ts <font color=Cyan>(</font>f s<font color=Cyan>)</font> ()<font color=Cyan>)</font>+<a name="line-163"></a>+<a name="line-164"></a><a name="stQuery"></a><font color=Blue>-- | Query the internal state.</font>+<a name="line-165"></a><font color=Blue>stQuery</font>    <font color=Red>::</font> <font color=Cyan>(</font>s<font color=Red>-&gt;</font>a<font color=Cyan>)</font> <font color=Red>-&gt;</font> Parser s t a+<a name="line-166"></a><font color=Blue>stQuery</font> f   <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>s ts<font color=Red>-&gt;</font> Success ts s <font color=Cyan>(</font>f s<font color=Cyan>)</font><font color=Cyan>)</font>+<a name="line-167"></a>+<a name="line-168"></a><a name="stGet"></a><font color=Blue>-- | Deliver the entire internal state.</font>+<a name="line-169"></a><font color=Blue>stGet</font>      <font color=Red>::</font> Parser s t s+<a name="line-170"></a><font color=Blue>stGet</font>       <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>s ts<font color=Red>-&gt;</font> Success ts s s<font color=Cyan>)</font>+<a name="line-171"></a>+<a name="line-172"></a><a name="reparse"></a><font color=Blue>------------------------------------------------------------------------</font>+<a name="line-173"></a><font color=Blue>-- | Push some tokens back onto the front of the input stream and reparse.</font>+<a name="line-174"></a><font color=Blue>--   This is useful e.g. for recursively expanding macros.  When the</font>+<a name="line-175"></a><font color=Blue>--   user-parser recognises a macro use, it can lookup the macro</font>+<a name="line-176"></a><font color=Blue>--   expansion from the parse state, lex it, and then stuff the</font>+<a name="line-177"></a><font color=Blue>--   lexed expansion back down into the parser.</font>+<a name="line-178"></a><font color=Blue>reparse</font>    <font color=Red>::</font> <font color=Red>[</font>t<font color=Red>]</font> <font color=Red>-&gt;</font> Parser s t ()+<a name="line-179"></a><font color=Blue>reparse</font> ts  <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>s inp<font color=Red>-&gt;</font> Success <font color=Cyan>(</font>ts<font color=Cyan>++</font>inp<font color=Cyan>)</font> s ()<font color=Cyan>)</font>+<a name="line-180"></a>+<a name="line-181"></a><font color=Blue>------------------------------------------------------------------------</font>+</pre>+</html>
+ docs/index.html view
@@ -0,0 +1,345 @@+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">+<html>+<head>+<title>+  polyparse: alternative parser combinator libraries+</title>+</head>++<body bgcolor='#ffffff'>++<center>+<h1>polyparse</h1>+<table><tr><td width=200 align=center>+<a href="#what">What is polyparse?</a><br>+<a href="#how">How do I use it?</a><br>+<a href="#download">Downloads</a><br>+</td><td width=200 align=center>+<a href="#news">Recent news</a><br>+<a href="#who">Contacts</a><br>+<a href="#related">Related Work</a><br>+</td></tr></table>+</center>++<hr>+<center><h3><a name="what">What is polyparse?</a></h3></center>+<p>+<b>polyparse</b> is a collection of parser combinator libraries in+Haskell.  It is distributed as a package, but you are likely to use only+one of the included modules at any one time - they are generally+alternatives to each other, as well as an alternative to other+widely-used parser libraries available elsewhere.++<ul>+<li> <b>Text.Parse</b>  The Text.Read class from Haskell'98 is widely+     recognised to have many problems.  It is inefficient.  If a read+     fails, there is no indication of why.  Worst of all, a read failure+     crashes your whole program!  Text.Parse is a proposed replacement+     for the Read class.  It defines a new class, Parse, with methods+     that return an explicit notification of errors, through the Either+     type.  It also defines a number of useful helper functions to+     enable the construction of parsers for textual representations of+     Haskell data structures, e.g. named fields.  Unsurprisingly,+     Text.Parse is really just a specialisation of the Poly combinators+     for String input, and the entire Poly API is also re-exported.+     The <a href="http://repetae.net/~john/computer/haskell/DrIFT">DrIFT</a>+     tool can derive instances of the Parse class for you+     automatically.  (Use the syntax <tt>{-! derive : Parse !-}</tt>)+<li> <b>Text.Parse.ByteString</b>  is a variant of Text.Parse, where+     the input is simply ByteString instead of String.+<li> <b>Text.ParserCombinators.Poly</b>+     Currently re-exports Text.ParserCombinators.Poly.Plain.+     The name Poly comes from the arbitrary token type.  Thus, you can+     write your own lexer if you wish, rather than needing to encode+     lexical analysis within the parser itself.+<li> <b>Text.ParserCombinators.Poly.Plain</b> This is a fresh+     set of combinators, improving on the HuttonMeijer variety by+     keeping only a single success, not a list of them.  This is+     more space-efficient, whilst still permitting backtracking.+     Error-handling is also much improved: there are essentially two+     kinds of failure, soft and hard.  Soft failure just means that the+     current parse did not work out, but another parse might be OK.+     Hard failure means that no parse will succeed, because we have+     already passed a point of commitment.  Thus you can give far more+     accurate error messages to the user, including multi-layered+     locations.+<li> <b>Text.ParserCombinators.Poly.State</b>  is just like Poly, except it+     adds an arbitrary running state parameter.+<li> <b>Text.ParserCombinators.Poly.Lazy</b>  is just like Poly, except it+     does not return explicit failures.  Instead, an exception is raised.+     Thus, it can return a partial parse result, before a full parse is+     complete.  The word partial indicates that, having committed to+     return some outer data constructor, we might later discover some+     parse error further inside, so the value will be partial, as in+     incomplete: containing bottom.  However, if you are confident that+     the input is error-free, then you will gain hugely in+     space-efficiency - essentially you can stream-process your parsed+     data-structure within very small constant space.  This is especially+     useful for large structures like e.g. XML trees.+<li> <b>Text.ParserCombinators.Poly.StateLazy</b>  combines Poly.State and+     Poly.Lazy.+<li> <b>Text.ParserCombinators.Poly.Base</b>+     All of the Poly variations (Plain, Lazy, State, etc)+     share a lot in common: many of the+     combinators are indeed implemented identically.  To reduce code+     duplication in the library, we provide a class-based interface+     here.  The actual implementations for strict, lazy, and so on, are+     instances of the class, defined in modules at the same level in the+     hierarchy (e.g. T.P.Poly.Lazy etc).  Every individual variation+     re-exports these base combinators, so there should be no need to+     import this module directly.+<li> <b>Text.ParserCombinators.Poly.ByteString</b>  is a specialised+     version of the Poly parser for ByteString input only.+<li> <b>Text.ParserCombinators.HuttonMeijer</b>  The most venerable of all+     monadic parser combinator libraries, this version dates from 1996.+     Originally distributed with Gofer, then Hugs, as ParseLib.  It uses+     the idea of "failure as a list of successes" to give multiple+     possible parses through backtracking.  (But in practice, almost+     nobody wants any parse except the first complete one.)+<li> <b>Text.ParserCombinators.HuttonMeijerWallace</b>  The+     Hutton/Meijer combinators, extended to take an arbitrary token type+     as input (not just characters), plus a running state (e.g. to+     collect a symbol table, or macros), plus some facilities for+     simple error-reporting.+</ul>+<p>+All the <b>Poly*</b> variations share the same basic API, so it is easy+to switch from one set to another, when you discover you need an extra+facility, just by changing a single import.++<hr>+<center><h3><a name="how">How do I use it?</a></h3></center>+<p>+<a href="haddock/index.html">Detailed documentation of the polyparse APIs</a>+is generated automatically by Haddock directly from the source code.++<p>+In general, you can just add an import of the relevant module to your+source code, and everything should just compile OK.  However, if the+package is not 'exposed' (in ghc-pkg terminology), then you might need+to use a command-line option <tt>--package polyparse</tt> at compile+time.++<p>+The original Hutton/Meijer combinators are described in a very nice+tutorial tech report:+<a href="http://eprints.nottingham.ac.uk/archive/00000237/">NOTTCS-TR-96-4</a>++<p>+I wrote some motivation for <tt>Text.Parse</tt> (including simple examples)+on my blog a while back. <a href="http://nhc98.blogspot.com/2005/11/replacement-for-read-class.html">Here is the posting.</a>++<p>+If you are familiar with the Parsec library, then the key insight for+using PolyParse is that the two libraries' approach to backtracking are+the duals of each another.  In Parsec, you must explicitly add a+<tt>try</tt> combinator at any location where backtracking might be+necessary.  Users often find this a bit of a black art.  In PolyParse+by contrast, all parsers are backtracking unless you explicitly add a+<tt>commit</tt> (or one of its variations).  It is easy to tell where to+add a commit point, because you have already parsed enough of a data+structure to know that only one outcome is possible.  For instance, if+you are parsing a Haskell value produced by 'show', then as soon as you+have parsed the initial constructor, you know that no other constructor+of that datatype is possible, so you can commit to returning it.++<p>+User-contributed documentation for polyparse is on the Haskell wiki at:+<a href="http://haskell.org/haskellwiki/Polyparse">http://haskell.org/haskellwiki/Polyparse</a>+Please edit the wiki if you discover any nice tricks!++<p>+<b>Known problems:</b>+<ul>+<li> No problems currently known.+<li> Report bugs to <tt>Malcolm.Wallace@cs.york.ac.uk</tt>+<li> Even better, fix any bugs you find, and then <tt>darcs send</tt> a patch.+</ul>++<hr>+<center><h3><a name="download">Downloads</a></h3></center>+<p>+<b>Development version:</b><br>+<br><tt><a href="http://darcs.net/">darcs</a> get+    http://www.cs.york.ac.uk/fp/darcs/polyparse</tt>++<p>+<b>Current released version:</b><br>+polyparse-1.4.1, release date 2010.05.29<br>+By HTTP:+<a href="http://www.cs.york.ac.uk/fp/polyparse/polyparse-1.4.1.tar.gz">.tar.gz</a>,+<a href="http://www.cs.york.ac.uk/fp/polyparse/polyparse-1.4.1.zip">.zip</a>.+<br>+By FTP: +<a href="ftp://ftp.cs.york.ac.uk/pub/haskell/polyparse/">+ftp://ftp.cs.york.ac.uk/pub/haskell/polyparse/</a>++<p>+<b>Older versions:</b><br>+polyparse-1.4, release date 2009.12.10<br>+By HTTP:+<a href="http://www.cs.york.ac.uk/fp/polyparse/polyparse-1.4.tar.gz">.tar.gz</a>,+<a href="http://www.cs.york.ac.uk/fp/polyparse/polyparse-1.4.zip">.zip</a>.+<br>+polyparse-1.3, release date 2009.03.09<br>+By HTTP:+<a href="http://www.cs.york.ac.uk/fp/polyparse/polyparse-1.3.tar.gz">.tar.gz</a>,+<a href="http://www.cs.york.ac.uk/fp/polyparse/polyparse-1.3.zip">.zip</a>.+<br>+polyparse-1.2, release date 2009.03.04<br>+By HTTP:+<a href="http://www.cs.york.ac.uk/fp/polyparse/polyparse-1.2.tar.gz">.tar.gz</a>,+<a href="http://www.cs.york.ac.uk/fp/polyparse/polyparse-1.2.zip">.zip</a>.+<br>+polyparse-1.1, release date 2007.10.23<br>+By HTTP:+<a href="http://www.cs.york.ac.uk/fp/polyparse/polyparse-1.1.tar.gz">.tar.gz</a>,+<a href="http://www.cs.york.ac.uk/fp/polyparse/polyparse-1.1.zip">.zip</a>.+<br>+polyparse-1.0, release date 2007.01.26<br>+By HTTP:+<a href="http://www.cs.york.ac.uk/fp/polyparse/polyparse-1.0.tar.gz">.tar.gz</a>,+<a href="http://www.cs.york.ac.uk/fp/polyparse/polyparse-1.0.zip">.zip</a>.+<br>+All older versions by FTP: +<a href="ftp://ftp.cs.york.ac.uk/pub/haskell/polyparse/">+ftp://ftp.cs.york.ac.uk/pub/haskell/polyparse/</a>+++<hr>+<center><h3><a name="install">Installation</a></h3></center>+<p>+To install polyparse, you must have a Haskell compiler: <em>ghc-6.2</em>+or later, and/or <em>nhc98-1.16/hmake-3.06</em> or later, and/or+<em>Hugs98 (Sept 2003)</em> or later.  For more recent compilers,+use the standard Cabal method of installation:+<pre>+    cabal install polyparse+</pre>+or+<pre>+    runhaskell Setup.hs configure [--prefix=...] [--buildwith=...]+    runhaskell Setup.hs build+    runhaskell Setup.hs install+</pre>++For older compilers, use:+<pre>+    sh configure [--prefix=...] [--buildwith=...]+    make+    make install+</pre>+to configure, build, and install polyparse as a package for your+compiler(s).  If you don't use the --prefix option, you may need write+permission on the library installation directories of your compiler(s).+Afterwards, to gain access to the polyparse libraries, you only need to+add the option <tt>-package polyparse</tt> to your compiler commandline+(no option required for Hugs).++<hr>+<center><h3><a name="news">Recent news</a></h3></center>++<p>+Version 1.4.1 has two minor bugfixes: for `discard`, especially in the Lazy+variant, and for 'optionalParens' in Text.Parse.++<p>+Version 1.4 has several bugfixes, improvements, and API additions.  See+the <a href="changelog.html">complete changelog</a><br> for fuller+details.  The main headline is new ByteString functionality.++<p>+Version 1.3 has a single bugfix: Text.Parse.parseFloat now accepts+ordinary floating point notation, in addition to scientific (exponent)+notation.++<p>+Version 1.2 improves the Text.Parse implementation significantly.  Where+previously all the parsers for builtin basic datatype (Int,Float,Char)+were just thin wrappers over the H'98 Read instances, now they are all+proper parsers, therefore they should (a) be faster; (b) give better+error messages.++<p>+Version 1.1 much improves the laziness characteristics of the Poly*+combinators.  There are also a lot of new implementations of the Poly*+parser types, all of which attempt to preserve exactly the same+combinator interface, so it is easy to switch between them.++<p>+Version 1.00 is the first release of polyparse as a separate package.+It was previously part of the HaXml suite.  HaXml continues to use+polyparse, but polyparse will be useful more widely.  If you are looking+for examples of the usage of polyparse, the implementations of+Text.XML.HaXml.Parse, Text.XML.HaXml.ParseLazy, and+Text.XML.HaXml.XmlContent are good places to look.++<br>+<a href="changelog.html">Complete Changelog</a><br>++<hr>+<center><h3><a name="who">Contacts</a></h3></center>+<p>+We are interested in hearing your feedback on these parser combinators -+suggestions for improvements, comments, criticisms, bug reports.  Please mail+<ul>+<li>    <a href="mailto:Malcolm.Wallace@cs.york.ac.uk">+        Malcolm.Wallace@cs.york.ac.uk</a>+</ul>++<p>++<p><b>Licence:</b> The library is Free and Open Source Software,+i.e., the bits we wrote are copyright to us, but freely licensed+for your use, modification, and re-distribution, provided you don't+restrict anyone else's use of it.  The polyparse library is distributed+under the GNU Lesser General Public Licence (LGPL) - see file+<a href="LICENCE-LGPL">LICENCE-LGPL</a> for more details.  We allow one+special exception to the LGPL - see <a href="COPYRIGHT">COPYRIGHT</a>.+(If you don't like any of these licensing conditions, please contact us+to discuss your requirements.)++<hr>+<p>+<center><h3><a name="related">Related work</a></h3></center>+<ul>+<li>+Parser combinators have a long history in Haskell.  The first(?) monadic+combinator tutorial was introduced by+<a href="http://eprints.nottingham.ac.uk/archive/00000237/">Hutton and+Meijer</a> in 1996, and the accompanying library was distributed with+Gofer (a precursor to Hugs), and known simply as ParseLib.  That library+lives on here as Text.ParserCombinators.HuttonMeijer.++<li>+<a href="http://www.cs.chalmers.se/~rojemo/thesis.html">Niklas Rojemo's+combinators.</a> The parser combinators developed and used in the+implementation of the nhc98 compiler are monadic and space-efficient.+However, they do not use the standard do-notation, because in fact they+are more general than the standard monad category.++<li>+<a href="http://research.microsoft.com/~emeijer/Papers/Parsec.pdf">+Daan Leijen's parsec.</a> The parsec library is widely used, since it is+distributed with ghc.  Its combinators are fairly robust, but you need+to place explicit backtracking into your parsers, using the <tt>try</tt>+operator.  This can be tricky.++<li><a href="http://www.cs.uu.nl/wiki/HUT/ParserCombinators">Doaitse+Swierstra's UU_Parse.</a>+An all-singing, all-dancing parsing library.  Deeply sophisticated.+Allows on-line results, which is closely related to lazy parsing.++<li><a href="http://cvs.haskell.org/Hugs/pages/libraries/base/Text-ParserCombinators-ReadP.html">Koen Claessen's ReadP.</a>+This is a different proposed replacement for the standard Haskell'98+Read class.  It is a whole lot more efficient that Read, but because it+is also API-compatible with Read, that unfortunately means it suffers+from not giving good error messages.  Also, it requires rank-2 types,+which is a non-Haskell'98 extension.++</ul>++<hr>++</body>+</html>
polyparse.cabal view
@@ -1,5 +1,5 @@ name:		polyparse-version:	1.4+version:	1.4.1 license:	LGPL license-file:	COPYRIGHT author:		Malcolm Wallace <Malcolm.Wallace@cs.york.ac.uk>@@ -35,6 +35,6 @@     exposed-modules:         Text.ParserCombinators.Poly.ByteString,         Text.Parse.ByteString-  cpp-options:		-DVERSION="1.4"+  cpp-options:		-DVERSION="1.4.1"   nhc98-options:	-K6M   extensions:		CPP
+ script/echo.c view
@@ -0,0 +1,20 @@+#include <stdio.h>++int main (int argc, char** argv) {+  int i=0;+  if (argc>1) {+    if (strcmp(argv[1],"-n")==0) {+      for (i=2; i<argc; i++) {+        fputs(argv[i],stdout);+        if (i+1!=argc) putchar(' ');+      }+    } else {+      for (i=1; i<argc; i++) {+        fputs(argv[i],stdout);+        if (i+1!=argc) putchar(' ');+      }+      putchar('\n');+    }+  } else putchar('\n');+  exit(0);+}
+ src/Makefile view
@@ -0,0 +1,88 @@+SOFTWARE = polyparse+VERSION = 1.4.1++LIBSRCS = \+	Text/ParserCombinators/HuttonMeijer.hs \+	Text/ParserCombinators/HuttonMeijerWallace.hs \+	Text/ParserCombinators/Poly.hs \+        Text/ParserCombinators/Poly/Base.hs \+        Text/ParserCombinators/Poly/Plain.hs \+        Text/ParserCombinators/Poly/Lazy.hs \+        Text/ParserCombinators/Poly/State.hs \+        Text/ParserCombinators/Poly/StateLazy.hs \+        Text/ParserCombinators/Poly/ByteString.hs \+	Text/Parse.hs \+	Text/Parse/ByteString.hs \++LIBOBJS = $(patsubst %.hs, %.o, $(LIBSRCS))++OUT = $(shell cat ../out)+INSTALLDIR = $(shell cat ../prefix)+WHOLEARCHIVE = $(shell cat ../ldopt)++# The caller *must* set the HC variable.+COMPILER := $(findstring ghc, $(HC))+ifeq "$(COMPILER)" "ghc"+COMPILE  = $(HC) --make -cpp -i. $(shell cat ghcpkgs) \+		-package-name $(SOFTWARE)-$(VERSION) -DVERSION=$(VERSION)+RENAME   = mv $(OUT)+endif+COMPILER := $(findstring nhc98, $(HC))+ifeq "$(COMPILER)" "nhc98"+COMPILE  = hmake -hc=$(HC) -I. -K4M +CTS -H8M -CTS -package base \+		-DVERSION=$(VERSION)+RENAME   = echo Built+endif++.PHONY: all libs++all: libs toolset+toolset:+	#cp $(TOOLSET) $(INSTALLDIR)+libs: libHS$(SOFTWARE).a+install-filesonly-ghc: libs $(INSTALLDIR)+	cp libHS$(SOFTWARE).a `cat ghclibdir`+	-ranlib `cat ghclibdir`/libHS$(SOFTWARE).a	# ignore if fails on Linux+	-cp HS$(SOFTWARE).o `cat ghclibdir`		# file may not exist on MacOS X+	rm -rf `cat ghcincdir`/$(SOFTWARE)+	mkdir -p `cat ghcincdir`/$(SOFTWARE)+	cp interfaces.tar `cat ghcincdir`/$(SOFTWARE)+	cd `cat ghcincdir`/$(SOFTWARE); tar xf interfaces.tar; rm interfaces.tar+install-filesonly-nhc98: libs $(INSTALLDIR)+	cp libHS$(SOFTWARE).a `cat nhc98libdir`/`harch`+	-ranlib `cat nhc98libdir`/`harch`/libHS$(SOFTWARE).a+	rm -rf `cat nhc98incdir`/packages/$(SOFTWARE)+	mkdir -p `cat nhc98incdir`/packages/$(SOFTWARE)+	cp interfaces.tar `cat nhc98incdir`/packages/$(SOFTWARE)+	cd `cat nhc98incdir`/packages/$(SOFTWARE); tar xf interfaces.tar; rm interfaces.tar+install-ghc: install-filesonly-ghc $(SOFTWARE).pkgconf+	`cat ghcpkgcmd` --remove-package=$(SOFTWARE) || true	# ignore any error+	`cat ghcpkgcmd` --add-package <pkg.conf || \+	`cat ghcpkgcmd` register $(SOFTWARE).pkgconf+	@echo "you can safely ignore any errors from --add-package"+install-nhc98: install-filesonly-nhc98+install-tools-hugs: toolset-hugs $(INSTALLDIR)+	cp $(patsubst ../../%, %, ${TOOLSET}) $(INSTALLDIR)++# update the sources if necessary+$(LIBSRCS) $(TOOLSRCS) Makefile: %: ../../src/%+	cp $< $@+$(SOFTWARE).pkgconf: ../../$(SOFTWARE).cabal ghcincdirraw ghclibdirraw+	cp ../../$(SOFTWARE).cabal $@+	echo "import-dirs:	`cat ghcincdirraw`$(SOFTWARE)" >>$@+	echo "library-dirs:	`cat ghclibdirraw`" >>$@+	echo "depends:		base, haskell98" >>$@+	echo "hs-libraries:	HS$(SOFTWARE)" >>$@++++# packaged library+libHS$(SOFTWARE).a: $(LIBSRCS)+	$(COMPILE) $(LIBSRCS)+	ar r libHS$(SOFTWARE).a $(LIBOBJS)+	-ld -r $(WHOLEARCHIVE) -o $(SOFTWARE).o libHS$(SOFTWARE).a	# for GHCi only+	tar cf interfaces.tar `find Text -name *.hi -print`++$(INSTALLDIR):+	if [ ! -d $(INSTALLDIR) ] ; then mkdir -p $(INSTALLDIR); fi+
src/Text/Parse.hs view
@@ -58,7 +58,7 @@     --   any surrounding expression.  (Precedence determines whether     --   parentheses are mandatory or optional.)     parsePrec :: Int -> TextParser a-    parsePrec _ = parens False parse+    parsePrec _ = optionalParens parse     -- | Parsing a list of items by default accepts the [] and comma syntax,     --   except when the list is really a character string using \"\".     parseList :: TextParser [a]	-- only to distinguish [] and ""@@ -66,7 +66,8 @@                    `onFail`                  do { isWord "["; isWord "]"; return [] }                    `onFail`-                 bracketSep (isWord "[") (isWord ",") (isWord "]") parse+                 bracketSep (isWord "[") (isWord ",") (isWord "]")+                            (optionalParens parse)                    `adjustErr` ("Expected a list, but\n"++)  -- | If there already exists a Read instance for a type, then we can make@@ -165,9 +166,9 @@               ; if w'==w then return w else fail ("expected "++w++" got "++w')               } --- | Allow true string parens around an item.+-- | Allow nested parens around an item. optionalParens :: TextParser a -> TextParser a-optionalParens p = bracket (isWord "(") (isWord ")") p `onFail` p+optionalParens p = parens False p  -- | Allow nested parens around an item (one set required when Bool is True). parens :: Bool -> TextParser a -> TextParser a@@ -410,9 +411,9 @@  instance Parse a => Parse (Maybe a) where     parsePrec p =-            parens False (do { isWord "Nothing"; return Nothing })+            optionalParens (do { isWord "Nothing"; return Nothing })             `onFail`-            parens (p>9) (do { isWord "Just"+            parens (p>9)   (do { isWord "Just"                                ; fmap Just $ parsePrec 10                                      `adjustErrBad` ("but within Just, "++) })             `adjustErr` (("expected a Maybe (Just or Nothing)\n"++).indent 2)
src/Text/Parse/ByteString.hs view
@@ -65,7 +65,7 @@     --   any surrounding expression.  (Precedence determines whether     --   parentheses are mandatory or optional.)     parsePrec :: Int -> TextParser a-    parsePrec _ = parens False parse+    parsePrec _ = optionalParens parse     -- | Parsing a list of items by default accepts the [] and comma syntax,     --   except when the list is really a character string using \"\".     parseList :: TextParser [a]	-- only to distinguish [] and ""@@ -73,7 +73,8 @@                    `onFail`                  do { isWord "["; isWord "]"; return [] }                    `onFail`-                 bracketSep (isWord "[") (isWord ",") (isWord "]") parse+                 bracketSep (isWord "[") (isWord ",") (isWord "]")+                            (optionalParens parse)                    `adjustErr` ("Expected a list, but\n"++)  -- | If there already exists a Read instance for a type, then we can make@@ -126,9 +127,9 @@               ; if w'==w then return w else fail ("expected "++w++" got "++w')               } --- | Allow true string parens around an item.+-- | Allow optional nested string parens around an item. optionalParens :: TextParser a -> TextParser a-optionalParens p = bracket (isWord "(") (isWord ")") p `onFail` p+optionalParens p = parens False p  -- | Allow nested parens around an item (one set required when Bool is True). parens :: Bool -> TextParser a -> TextParser a@@ -376,9 +377,9 @@  instance Parse a => Parse (Maybe a) where     parsePrec p =-            parens False (do { isWord "Nothing"; return Nothing })+            optionalParens (do { isWord "Nothing"; return Nothing })             `onFail`-            parens (p>9) (do { isWord "Just"+            parens (p>9)   (do { isWord "Just"                                ; fmap Just $ parsePrec 10                                      `adjustErrBad` ("but within Just, "++) })             `adjustErr` (("expected a Maybe (Just or Nothing)\n"++).indent 2)
src/Text/ParserCombinators/Poly/Base.hs view
@@ -96,7 +96,7 @@ -- | @x `discard` y@ parses both x and y, but discards the result of y. --   Rather like @const@ lifted into parsers. discard :: PolyParse p => p a -> p b -> p a-px `discard` py = do { x <- px; x `seq` (return (const x) `apply` py); }+px `discard` py = do { x <- px; py; return x; }  -- | @adjustErrBad@ is just like @adjustErr@ except it also raises the --   severity of the error.
src/Text/ParserCombinators/Poly/ByteString.hs view
@@ -18,10 +18,9 @@ import qualified Data.ByteString.Lazy.Char8 as BS import Data.ByteString.Lazy.Char8 (ByteString) --- | This @Parser@ 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)+-- | This @Parser@ datatype is a specialised parsing monad with error+--   reporting.  Whereas the standard version can be used for arbitrary+--   token types, this version is specialised to ByteString input only. newtype Parser a = P (ByteString -> Result ByteString a)  -- | A return type like Either, that distinguishes not only between
+ src/pkg.conf view
@@ -0,0 +1,16 @@+Package+  { name            = "polyparse"+  , auto            = True+  , import_dirs     = ["$libdir/imports/polyparse"]+  , source_dirs     = []+  , library_dirs    = ["$libdir"]+  , hs_libraries    = ["HSpolyparse" ]+  , extra_libraries = []+  , include_dirs    = []+  , c_includes      = []+  , package_deps    = ["base"]+  , extra_ghc_opts  = []+  , extra_cc_opts   = []+  , extra_ld_opts   = []+  }+