polyparse (empty) → 1.0
raw patch · 60 files changed
+19095/−0 lines, 60 filesdep +basedep +haskell98build-type:Customsetup-changedbinary-added
Dependencies added: base, haskell98
Files
- Build.bat +98/−0
- COPYRIGHT +32/−0
- LICENCE-LGPL +507/−0
- Makefile +104/−0
- README +48/−0
- Setup.hs +2/−0
- configure +320/−0
- docs/changelog.html +56/−0
- docs/haddock/Text-Parse.html +803/−0
- docs/haddock/Text-ParserCombinators-HuttonMeijer.html +1572/−0
- docs/haddock/Text-ParserCombinators-HuttonMeijerWallace.html +1352/−0
- docs/haddock/Text-ParserCombinators-Poly.html +1382/−0
- docs/haddock/Text-ParserCombinators-PolyLazy.html +1402/−0
- docs/haddock/Text-ParserCombinators-PolyState.html +1471/−0
- docs/haddock/Text-ParserCombinators-PolyStateLazy.html +1535/−0
- docs/haddock/doc-index-43.html +150/−0
- docs/haddock/doc-index-A.html +246/−0
- docs/haddock/doc-index-B.html +218/−0
- docs/haddock/doc-index-C.html +270/−0
- docs/haddock/doc-index-D.html +174/−0
- docs/haddock/doc-index-E.html +154/−0
- docs/haddock/doc-index-F.html +182/−0
- docs/haddock/doc-index-I.html +226/−0
- docs/haddock/doc-index-J.html +138/−0
- docs/haddock/doc-index-L.html +146/−0
- docs/haddock/doc-index-M.html +270/−0
- docs/haddock/doc-index-N.html +190/−0
- docs/haddock/doc-index-O.html +294/−0
- docs/haddock/doc-index-P.html +294/−0
- docs/haddock/doc-index-R.html +210/−0
- docs/haddock/doc-index-S.html +402/−0
- docs/haddock/doc-index-T.html +162/−0
- docs/haddock/doc-index-U.html +138/−0
- docs/haddock/doc-index-W.html +138/−0
- docs/haddock/doc-index.html +124/−0
- docs/haddock/haddock.css +260/−0
- docs/haddock/haddock.js +15/−0
- docs/haddock/haskell_icon.gif binary
- docs/haddock/index.html +158/−0
- docs/haddock/minus.gif binary
- docs/haddock/plus.gif binary
- docs/haddock/src/Text/Parse.html +179/−0
- docs/haddock/src/Text/ParserCombinators/HuttonMeijer.html +219/−0
- docs/haddock/src/Text/ParserCombinators/HuttonMeijerWallace.html +298/−0
- docs/haddock/src/Text/ParserCombinators/Poly.html +239/−0
- docs/haddock/src/Text/ParserCombinators/PolyLazy.html +268/−0
- docs/haddock/src/Text/ParserCombinators/PolyState.html +249/−0
- docs/haddock/src/Text/ParserCombinators/PolyStateLazy.html +282/−0
- docs/index.html +242/−0
- polyparse.cabal +29/−0
- script/echo.c +20/−0
- src/Makefile +84/−0
- src/Text/Parse.hs +178/−0
- src/Text/ParserCombinators/HuttonMeijer.hs +218/−0
- src/Text/ParserCombinators/HuttonMeijerWallace.hs +297/−0
- src/Text/ParserCombinators/Poly.hs +238/−0
- src/Text/ParserCombinators/PolyLazy.hs +267/−0
- src/Text/ParserCombinators/PolyState.hs +248/−0
- src/Text/ParserCombinators/PolyStateLazy.hs +281/−0
- src/pkg.conf +16/−0
+ 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.10\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 +set OBJS=Text/ParserCombinators/Poly.o Text/ParserCombinators/PolyState.o Text/ParserCombinators/TextParser.o Text/ParserCombinators/PolyLazy.o Text/ParserCombinators/PolyStateLazy.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.00 %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.00 + +goto Exit + +rem -- All done -- + +:Exit
+ COPYRIGHT view
@@ -0,0 +1,32 @@+The module Text.ParserCombinators.HuttonMeijer is+ (c) copyright 1996 Graham Hutton and Erik Meijer+The module Text.ParserCombinators.HuttonMeijerWallace is+ (c) copyright 1996 Graham Hutton and Erik Meijer+ with modifications+ (c) copyright 1998-2000 Malcolm Wallace+The modules Text.ParserCombinators.Poly* and Text.Parse+are+ (c) copyright 2006-2007 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, with the following special exception:++----+As a relaxation of clause 6 of the LGPL, the copyright holders of this+library give permission to use, copy, link, modify, and distribute,+binary-only object-code versions of an executable linked with the+original unmodified Library, without requiring the supply of any+mechanism to modify or replace the Library and relink (clauses 6a,+6b, 6c, 6d, 6e), provided that all the other terms of clause 6 are+complied with.+----++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+Licence for more details.++If these licensing terms are not acceptable to you, please contact me for+negotiation. :-)+ Malcolm.Wallace@cs.york.ac.uk
+ 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,104 @@+SOFTWARE = polyparse+VERSION = 1.0++CPP = cpp -traditional+#CPP = cpphs --text # useful e.g. on MacOS X++DIRS = Text Text/ParserCombinators++SRCS = \+ src/Text/ParserCombinators/HuttonMeijer.hs \+ src/Text/ParserCombinators/HuttonMeijerWallace.hs \+ src/Text/ParserCombinators/Poly.hs \+ src/Text/ParserCombinators/PolyState.hs \+ src/Text/ParserCombinators/PolyLazy.hs \+ src/Text/ParserCombinators/PolyStateLazy.hs \+ src/Text/Parse.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) -D__NHC__ $$file >$$file.uncpp; \+ HsColour -anchorHTML $$file >docs/haddock/`dirname $$file`/`basename $$file .hs`.html; \+ done+ haddock --html --title=$(SOFTWARE) --odir=docs/haddock \+ --package=$(SOFTWARE) \+ --source-module="src/%{MODULE/.//}.html" \+ --source-entity="src/%{MODULE/.//}.html#%{NAME}" \+ $(patsubst %, %.uncpp, $(SRCS))+ rm -f $(patsubst %, %.uncpp, $(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,48 @@+ 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.+ src/Text/ParserCombinators+ HuttonMeijer Early parser combinators from 1996.+ HuttonMeijerWallace Extended for arbitrary token type + running+ state + error msgs.+ Poly Space-efficient combinators that allow arbitrary+ token type.+ PolyState arbitrary token type + running state.+ PolyLazy arbitrary token type + lazy return of results.+ PolyStateLazy arbitrary token type + running state + lazy results.++----
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ 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,56 @@+<!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.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.html view
@@ -0,0 +1,803 @@+<!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.js" TYPE="text/javascript"+></SCRIPT+></HEAD+><BODY+><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"+><TR+><TD CLASS="topbar"+><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"+><TR+><TD+><IMG SRC="haskell_icon.gif" WIDTH="16" HEIGHT="16" ALT=" "+></TD+><TD CLASS="title"+>polyparse</TD+><TD CLASS="topbut"+><A HREF="src/Text/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"+>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.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%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 => String -> <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%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 -> <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 -> <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 => String -> <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)] -> <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 => String -> [a] -> <A HREF="Text-Parse.html#t%3ATextParser"+>TextParser</A+> a</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+>module <A HREF="Text-ParserCombinators-Poly.html"+>Text.ParserCombinators.Poly</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="section1"+><A NAME="1"+>The Parse class is a replacement for the standard Read class. +</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%3ATextParser"+></A+><B+>TextParser</B+> a = <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"+>Parser</A+> Char a</TD+><TD CLASS="declbut"+><A HREF="src/Text/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%3AParse"+></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%3Aparse"+></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="s8"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3AparseList"+></A+><B+>parseList</B+> :: <A HREF="Text-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+></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, <A HREF="Text-Parse.html#t%3AParse"+>Parse</A+> b) => <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) => <A HREF="Text-Parse.html#t%3AParse"+>Parse</A+> (a, b, c)</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+> (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+> [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) => <A HREF="Text-Parse.html#t%3AParse"+>Parse</A+> (Either a b)</TD+></TR+></TABLE+></DIV+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3AparseByRead"+></A+><B+>parseByRead</B+> :: Read a => String -> <A HREF="Text-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.+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="section2"+><A NAME="2"+>Combinators specific to string input, lexed haskell-style+</A+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3Aword"+></A+><B+>word</B+> :: <A HREF="Text-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 (Haskell-style lexing).+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3AisWord"+></A+><B+>isWord</B+> :: String -> <A HREF="Text-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%3AoptionalParens"+></A+><B+>optionalParens</B+> :: <A HREF="Text-Parse.html#t%3ATextParser"+>TextParser</A+> a -> <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 true string parens around an item.+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3Afield"+></A+><B+>field</B+> :: <A HREF="Text-Parse.html#t%3AParse"+>Parse</A+> a => String -> <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%3Aconstructors"+></A+><B+>constructors</B+> :: [(String, <A HREF="Text-Parse.html#t%3ATextParser"+>TextParser</A+> a)] -> <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%3Aenumeration"+></A+><B+>enumeration</B+> :: Show a => String -> [a] -> <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"+>Re-export all the more general combinators from Poly too+</A+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="decl"+>module <A HREF="Text-ParserCombinators-Poly.html"+>Text.ParserCombinators.Poly</A+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="botbar"+>Produced by <A HREF="http://www.haskell.org/haddock/"+>Haddock</A+> version 0.8</TD+></TR+></TABLE+></BODY+></HTML+>
+ docs/haddock/Text-ParserCombinators-HuttonMeijer.html view
@@ -0,0 +1,1572 @@+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">+<!--Rendered using the Haskell Html Library v0.2-->+<HTML+><HEAD+><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8"+><TITLE+>Text.ParserCombinators.HuttonMeijer</TITLE+><LINK HREF="haddock.css" REL="stylesheet" TYPE="text/css"+><SCRIPT SRC="haddock.js" TYPE="text/javascript"+></SCRIPT+></HEAD+><BODY+><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"+><TR+><TD CLASS="topbar"+><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"+><TR+><TD+><IMG SRC="haskell_icon.gif" WIDTH="16" HEIGHT="16" ALT=" "+></TD+><TD CLASS="title"+>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 <Malcolm.Wallace@cs.york.ac.uk></TD+></TR+></TABLE+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD+><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"+></TABLE+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="section1"+>Description</TD+></TR+><TR+><TD CLASS="doc"+><P+>This Haskell script defines a library of parser combinators, and is+ taken from sections 1-6 of our article <A HREF="Monadic Parser Combinators.html"+>Monadic Parser Combinators</A+>.+ Some changes to the library have been made in the move from Gofer+ to Haskell:+</P+><UL+><LI+> Do notation is used in place of monad comprehension notation;+</LI+><LI+> The parser datatype is defined using <A HREF="newtype.html"+>newtype</A+>, to avoid the overhead+ of tagging and untagging parsers with the P constructor.+</LI+></UL+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="section1"+>Synopsis</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="body"+><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"+><TR+><TD CLASS="decl"+><SPAN CLASS="keyword"+>newtype</SPAN+> <A HREF="#t%3AParser"+>Parser</A+> a = <A HREF="#v%3AP"+>P</A+> ([Token] -> [(a, [Token])])</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3Aitem"+>item</A+> :: <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> Token</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3Afirst"+>first</A+> :: <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> a -> <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> a</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3Apapply"+>papply</A+> :: <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> a -> [Token] -> [(a, [Token])]</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3A%2B%2B%2B"+>(+++)</A+> :: <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> a -> <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> a -> <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> a</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3Asat"+>sat</A+> :: (Token -> Bool) -> <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> Token</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3Amany"+>many</A+> :: <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> a -> <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> [a]</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3Amany1"+>many1</A+> :: <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> a -> <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> [a]</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3Asepby"+>sepby</A+> :: <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> a -> <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> b -> <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> [a]</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3Asepby1"+>sepby1</A+> :: <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> a -> <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> b -> <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> [a]</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3Achainl"+>chainl</A+> :: <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> a -> <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> (a -> a -> a) -> a -> <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> a</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3Achainl1"+>chainl1</A+> :: <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> a -> <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> (a -> a -> a) -> <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> a</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3Achainr"+>chainr</A+> :: <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> a -> <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> (a -> a -> a) -> a -> <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> a</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3Achainr1"+>chainr1</A+> :: <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> a -> <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> (a -> a -> a) -> <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> a</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3Aops"+>ops</A+> :: [(<A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> a, b)] -> <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> b</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3Abracket"+>bracket</A+> :: <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> a -> <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> b -> <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> c -> <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> b</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3Achar"+>char</A+> :: Char -> <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> Char</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3Adigit"+>digit</A+> :: <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> Char</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3Alower"+>lower</A+> :: <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> Char</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3Aupper"+>upper</A+> :: <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> Char</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3Aletter"+>letter</A+> :: <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> Char</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3Aalphanum"+>alphanum</A+> :: <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> Char</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3Astring"+>string</A+> :: String -> <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> String</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3Aident"+>ident</A+> :: <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> String</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3Anat"+>nat</A+> :: <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> Int</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3Aint"+>int</A+> :: <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> Int</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3Aspaces"+>spaces</A+> :: <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> ()</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3Acomment"+>comment</A+> :: <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> ()</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3Ajunk"+>junk</A+> :: <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> ()</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3Askip"+>skip</A+> :: <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> a -> <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> a</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3Atoken"+>token</A+> :: <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> a -> <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> a</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3Anatural"+>natural</A+> :: <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> Int</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3Ainteger"+>integer</A+> :: <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> Int</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3Asymbol"+>symbol</A+> :: String -> <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> String</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3Aidentifier"+>identifier</A+> :: [String] -> <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> String</TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="section1"+>Documentation</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><SPAN CLASS="keyword"+>newtype</SPAN+> <A NAME="t%3AParser"+></A+><B+>Parser</B+> a</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/HuttonMeijer.html#Parser"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="body"+><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"+><TR+><TD CLASS="ndoc"+>The parser monad+</TD+></TR+><TR+><TD CLASS="section4"+>Constructors</TD+></TR+><TR+><TD CLASS="body"+><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0"+><TR+><TD CLASS="arg"+><A NAME="v%3AP"+></A+><B+>P</B+> ([Token] -> [(a, [Token])])</TD+><TD CLASS="rdoc"+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="section4"+><IMG SRC="minus.gif" CLASS="coll" ONCLICK="toggle(this,'i:Parser')" ALT="show/hide"+> Instances</TD+></TR+><TR+><TD CLASS="body"+><DIV ID="i:Parser" STYLE="display:block;"+><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0"+><TR+><TD CLASS="decl"+>Functor <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+></TD+></TR+><TR+><TD CLASS="decl"+>Monad <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+></TD+></TR+><TR+><TD CLASS="decl"+>MonadPlus <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+></TD+></TR+></TABLE+></DIV+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3Aitem"+></A+><B+>item</B+> :: <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> Token</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/HuttonMeijer.html#item"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3Afirst"+></A+><B+>first</B+> :: <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> a -> <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> a</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/HuttonMeijer.html#first"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3Apapply"+></A+><B+>papply</B+> :: <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> a -> [Token] -> [(a, [Token])]</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/HuttonMeijer.html#papply"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3A%2B%2B%2B"+></A+><B+>(+++)</B+> :: <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> a -> <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> a -> <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> a</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/HuttonMeijer.html#%2B%2B%2B"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3Asat"+></A+><B+>sat</B+> :: (Token -> Bool) -> <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> Token</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/HuttonMeijer.html#sat"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3Amany"+></A+><B+>many</B+> :: <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> a -> <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> [a]</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/HuttonMeijer.html#many"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3Amany1"+></A+><B+>many1</B+> :: <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> a -> <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> [a]</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/HuttonMeijer.html#many1"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3Asepby"+></A+><B+>sepby</B+> :: <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> a -> <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> b -> <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> [a]</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/HuttonMeijer.html#sepby"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3Asepby1"+></A+><B+>sepby1</B+> :: <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> a -> <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> b -> <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> [a]</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/HuttonMeijer.html#sepby1"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3Achainl"+></A+><B+>chainl</B+> :: <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> a -> <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> (a -> a -> a) -> a -> <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> a</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/HuttonMeijer.html#chainl"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3Achainl1"+></A+><B+>chainl1</B+> :: <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> a -> <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> (a -> a -> a) -> <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> a</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/HuttonMeijer.html#chainl1"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3Achainr"+></A+><B+>chainr</B+> :: <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> a -> <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> (a -> a -> a) -> a -> <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> a</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/HuttonMeijer.html#chainr"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3Achainr1"+></A+><B+>chainr1</B+> :: <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> a -> <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> (a -> a -> a) -> <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> a</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/HuttonMeijer.html#chainr1"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3Aops"+></A+><B+>ops</B+> :: [(<A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> a, b)] -> <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> b</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/HuttonMeijer.html#ops"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3Abracket"+></A+><B+>bracket</B+> :: <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> a -> <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> b -> <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> c -> <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> b</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/HuttonMeijer.html#bracket"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3Achar"+></A+><B+>char</B+> :: Char -> <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> Char</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/HuttonMeijer.html#char"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3Adigit"+></A+><B+>digit</B+> :: <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> Char</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/HuttonMeijer.html#digit"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3Alower"+></A+><B+>lower</B+> :: <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> Char</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/HuttonMeijer.html#lower"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3Aupper"+></A+><B+>upper</B+> :: <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> Char</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/HuttonMeijer.html#upper"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3Aletter"+></A+><B+>letter</B+> :: <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> Char</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/HuttonMeijer.html#letter"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3Aalphanum"+></A+><B+>alphanum</B+> :: <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> Char</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/HuttonMeijer.html#alphanum"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3Astring"+></A+><B+>string</B+> :: String -> <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> String</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/HuttonMeijer.html#string"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3Aident"+></A+><B+>ident</B+> :: <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> String</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/HuttonMeijer.html#ident"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3Anat"+></A+><B+>nat</B+> :: <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> Int</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/HuttonMeijer.html#nat"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3Aint"+></A+><B+>int</B+> :: <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> Int</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/HuttonMeijer.html#int"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3Aspaces"+></A+><B+>spaces</B+> :: <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> ()</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/HuttonMeijer.html#spaces"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3Acomment"+></A+><B+>comment</B+> :: <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> ()</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/HuttonMeijer.html#comment"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3Ajunk"+></A+><B+>junk</B+> :: <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> ()</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/HuttonMeijer.html#junk"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3Askip"+></A+><B+>skip</B+> :: <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> a -> <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> a</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/HuttonMeijer.html#skip"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3Atoken"+></A+><B+>token</B+> :: <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> a -> <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> a</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/HuttonMeijer.html#token"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3Anatural"+></A+><B+>natural</B+> :: <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> Int</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/HuttonMeijer.html#natural"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3Ainteger"+></A+><B+>integer</B+> :: <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> Int</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/HuttonMeijer.html#integer"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3Asymbol"+></A+><B+>symbol</B+> :: String -> <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> String</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/HuttonMeijer.html#symbol"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3Aidentifier"+></A+><B+>identifier</B+> :: [String] -> <A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Parser</A+> String</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/HuttonMeijer.html#identifier"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="botbar"+>Produced by <A HREF="http://www.haskell.org/haddock/"+>Haddock</A+> version 0.8</TD+></TR+></TABLE+></BODY+></HTML+>
+ docs/haddock/Text-ParserCombinators-HuttonMeijerWallace.html view
@@ -0,0 +1,1352 @@+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">+<!--Rendered using the Haskell Html Library v0.2-->+<HTML+><HEAD+><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8"+><TITLE+>Text.ParserCombinators.HuttonMeijerWallace</TITLE+><LINK HREF="haddock.css" REL="stylesheet" TYPE="text/css"+><SCRIPT SRC="haddock.js" TYPE="text/javascript"+></SCRIPT+></HEAD+><BODY+><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"+><TR+><TD CLASS="topbar"+><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"+><TR+><TD+><IMG SRC="haskell_icon.gif" WIDTH="16" HEIGHT="16" ALT=" "+></TD+><TD CLASS="title"+>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 a State Transformer monad, useful+ for symbol tables, macros, and so on. Basic facilities for error+ reporting have also been added, and later extended by Graham Klyne+ to return the errors through an <TT+>Either</TT+> type, rather than just+ calling <TT+>error</TT+>.+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="section1"+>Synopsis</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="body"+><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"+><TR+><TD CLASS="decl"+><SPAN CLASS="keyword"+>newtype</SPAN+> <A HREF="#t%3AParser"+>Parser</A+> s t e a = <A HREF="#v%3AP"+>P</A+> (s -> [Either e t] -> ParseResult s t e a)</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3Aitem"+>item</A+> :: <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s t e t</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3Aeof"+>eof</A+> :: Show p => <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s (p, t) String ()</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3Apapply"+>papply</A+> :: <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s t String a -> s -> [Either String t] -> [(a, s, [Either String t])]</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3Apapply%27"+>papply'</A+> :: <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s t e a -> s -> [Either e t] -> Either e [(a, s, [Either e t])]</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3A%2B%2B%2B"+>(+++)</A+> :: <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s t e a -> <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s t e a -> <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s t e a</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3Atok"+>tok</A+> :: Eq t => t -> <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s (p, t) e t</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3Anottok"+>nottok</A+> :: Eq t => [t] -> <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s (p, t) e t</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3Amany"+>many</A+> :: <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s t e a -> <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s t e [a]</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3Amany1"+>many1</A+> :: <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s t e a -> <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s t e [a]</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3Asepby"+>sepby</A+> :: <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s t e a -> <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s t e b -> <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s t e [a]</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3Asepby1"+>sepby1</A+> :: <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s t e a -> <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s t e b -> <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s t e [a]</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3Achainl"+>chainl</A+> :: <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s t e a -> <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s t e (a -> a -> a) -> a -> <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s t e a</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3Achainl1"+>chainl1</A+> :: <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s t e a -> <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s t e (a -> a -> a) -> <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s t e a</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3Achainr"+>chainr</A+> :: <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s t e a -> <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s t e (a -> a -> a) -> a -> <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s t e a</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3Achainr1"+>chainr1</A+> :: <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s t e a -> <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s t e (a -> a -> a) -> <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s t e a</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3Aops"+>ops</A+> :: [(<A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s t e a, b)] -> <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s t e b</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3Abracket"+>bracket</A+> :: (Show p, Show t) => <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s (p, t) e a -> <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s (p, t) e b -> <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s (p, t) e c -> <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s (p, t) e b</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3AtoEOF"+>toEOF</A+> :: Show p => <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s (p, t) String a -> <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s (p, t) String a</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3Aelserror"+>elserror</A+> :: (Show p, Show t) => <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s (p, t) String a -> String -> <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s (p, t) String a</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3Astupd"+>stupd</A+> :: (s -> s) -> <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s t e ()</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3Astquery"+>stquery</A+> :: (s -> a) -> <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s t e a</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3Astget"+>stget</A+> :: <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s t e s</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3Areparse"+>reparse</A+> :: [Either e t] -> <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s t e ()</TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="section1"+><A NAME="1"+>The parser monad+</A+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><SPAN CLASS="keyword"+>newtype</SPAN+> <A NAME="t%3AParser"+></A+><B+>Parser</B+> s t e a</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/HuttonMeijerWallace.html#Parser"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="body"+><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"+><TR+><TD CLASS="section4"+>Constructors</TD+></TR+><TR+><TD CLASS="body"+><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0"+><TR+><TD CLASS="arg"+><A NAME="v%3AP"+></A+><B+>P</B+> (s -> [Either e t] -> ParseResult s t e a)</TD+><TD CLASS="rdoc"+>The parser type is parametrised on the types of the state <TT+>s</TT+>,+ the input tokens <TT+>t</TT+>, error-type <TT+>e</TT+>, and the result value <TT+>a</TT+>.+ The state and remaining input are threaded through the monad.+</TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="section4"+><IMG SRC="minus.gif" CLASS="coll" ONCLICK="toggle(this,'i:Parser')" ALT="show/hide"+> Instances</TD+></TR+><TR+><TD CLASS="body"+><DIV ID="i:Parser" STYLE="display:block;"+><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0"+><TR+><TD CLASS="decl"+>Functor (<A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s t e)</TD+></TR+><TR+><TD CLASS="decl"+>Monad (<A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s t e)</TD+></TR+><TR+><TD CLASS="decl"+>MonadPlus (<A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s t e)</TD+></TR+></TABLE+></DIV+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="section1"+><A NAME="2"+>Primitive parser combinators+</A+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3Aitem"+></A+><B+>item</B+> :: <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s t e t</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/HuttonMeijerWallace.html#item"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+>Deliver the first remaining token.+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3Aeof"+></A+><B+>eof</B+> :: Show p => <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s (p, t) String ()</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/HuttonMeijerWallace.html#eof"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+>Fail if end of input is not reached+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3Apapply"+></A+><B+>papply</B+> :: <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s t String a -> s -> [Either String t] -> [(a, s, [Either String t])]</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/HuttonMeijerWallace.html#papply"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+>Apply the parser to some real input, given an initial state value.+ If the parser fails, raise error to halt the program.+ (This is the original exported behaviour - to allow the caller to+ deal with the error differently, see <TT+>papply'</TT+>.)+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3Apapply%27"+></A+><B+>papply'</B+> :: <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s t e a -> s -> [Either e t] -> Either e [(a, s, [Either e t])]</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/HuttonMeijerWallace.html#papply%27"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+>Apply the parser to some real input, given an initial state value.+ If the parser fails, return a diagnostic message to the caller.+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="section1"+><A NAME="3"+>Derived combinators+</A+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3A%2B%2B%2B"+></A+><B+>(+++)</B+> :: <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s t e a -> <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s t e a -> <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s t e a</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/HuttonMeijerWallace.html#%2B%2B%2B"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+>A choice between parsers. Keep only the first success.+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3Atok"+></A+><B+>tok</B+> :: Eq t => t -> <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s (p, t) e t</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/HuttonMeijerWallace.html#tok"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+>Deliver the first token if it equals the argument.+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3Anottok"+></A+><B+>nottok</B+> :: Eq t => [t] -> <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s (p, t) e t</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/HuttonMeijerWallace.html#nottok"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+>Deliver the first token if it does not equal the argument.+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3Amany"+></A+><B+>many</B+> :: <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s t e a -> <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s t e [a]</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/HuttonMeijerWallace.html#many"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+>Deliver zero or more values of <TT+>a</TT+>.+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3Amany1"+></A+><B+>many1</B+> :: <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s t e a -> <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s t e [a]</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/HuttonMeijerWallace.html#many1"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+>Deliver one or more values of <TT+>a</TT+>.+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3Asepby"+></A+><B+>sepby</B+> :: <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s t e a -> <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s t e b -> <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s t e [a]</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/HuttonMeijerWallace.html#sepby"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+>Deliver zero or more values of <TT+>a</TT+> separated by <TT+>b</TT+>'s.+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3Asepby1"+></A+><B+>sepby1</B+> :: <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s t e a -> <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s t e b -> <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s t e [a]</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/HuttonMeijerWallace.html#sepby1"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+>Deliver one or more values of <TT+>a</TT+> separated by <TT+>b</TT+>'s.+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3Achainl"+></A+><B+>chainl</B+> :: <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s t e a -> <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s t e (a -> a -> a) -> a -> <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s t e a</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/HuttonMeijerWallace.html#chainl"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3Achainl1"+></A+><B+>chainl1</B+> :: <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s t e a -> <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s t e (a -> a -> a) -> <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s t e a</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/HuttonMeijerWallace.html#chainl1"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3Achainr"+></A+><B+>chainr</B+> :: <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s t e a -> <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s t e (a -> a -> a) -> a -> <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s t e a</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/HuttonMeijerWallace.html#chainr"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3Achainr1"+></A+><B+>chainr1</B+> :: <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s t e a -> <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s t e (a -> a -> a) -> <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s t e a</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/HuttonMeijerWallace.html#chainr1"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3Aops"+></A+><B+>ops</B+> :: [(<A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s t e a, b)] -> <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s t e b</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/HuttonMeijerWallace.html#ops"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3Abracket"+></A+><B+>bracket</B+> :: (Show p, Show t) => <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s (p, t) e a -> <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s (p, t) e b -> <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s (p, t) e c -> <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s (p, t) e b</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/HuttonMeijerWallace.html#bracket"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3AtoEOF"+></A+><B+>toEOF</B+> :: Show p => <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s (p, t) String a -> <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s (p, t) String a</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/HuttonMeijerWallace.html#toEOF"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+>Accept a complete parse of the input only, no partial parses.+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="section1"+><A NAME="4"+>Error handling+</A+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3Aelserror"+></A+><B+>elserror</B+> :: (Show p, Show t) => <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s (p, t) String a -> String -> <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s (p, t) String a</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/HuttonMeijerWallace.html#elserror"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+>If the parser fails, generate an error message.+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="section1"+><A NAME="5"+>State handling+</A+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3Astupd"+></A+><B+>stupd</B+> :: (s -> s) -> <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s t e ()</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/HuttonMeijerWallace.html#stupd"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+>Update the internal state.+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3Astquery"+></A+><B+>stquery</B+> :: (s -> a) -> <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s t e a</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/HuttonMeijerWallace.html#stquery"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+>Query the internal state.+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3Astget"+></A+><B+>stget</B+> :: <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s t e s</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/HuttonMeijerWallace.html#stget"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+>Deliver the entire internal state.+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="section1"+><A NAME="6"+>Re-parsing+</A+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3Areparse"+></A+><B+>reparse</B+> :: [Either e t] -> <A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Parser</A+> s t e ()</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/HuttonMeijerWallace.html#reparse"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+>This is useful for recursively expanding macros. When the+ user-parser recognises a macro use, it can lookup the macro+ expansion from the parse state, lex it, and then stuff the+ lexed expansion back down into the parser.+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="botbar"+>Produced by <A HREF="http://www.haskell.org/haddock/"+>Haddock</A+> version 0.8</TD+></TR+></TABLE+></BODY+></HTML+>
+ docs/haddock/Text-ParserCombinators-Poly.html view
@@ -0,0 +1,1382 @@+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">+<!--Rendered using the Haskell Html Library v0.2-->+<HTML+><HEAD+><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8"+><TITLE+>Text.ParserCombinators.Poly</TITLE+><LINK HREF="haddock.css" REL="stylesheet" TYPE="text/css"+><SCRIPT SRC="haddock.js" TYPE="text/javascript"+></SCRIPT+></HEAD+><BODY+><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"+><TR+><TD CLASS="topbar"+><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"+><TR+><TD+><IMG SRC="haskell_icon.gif" WIDTH="16" HEIGHT="16" ALT=" "+></TD+><TD CLASS="title"+>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+><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+><DT+><A HREF="#2"+>Combinators:+</A+></DT+><DD+><DL+><DT+><A HREF="#3"+>Primitives+</A+></DT+><DT+><A HREF="#4"+>Error-handling+</A+></DT+><DT+><A HREF="#5"+>Choices+</A+></DT+><DT+><A HREF="#6"+>Sequences+</A+></DT+><DT+><A HREF="#7"+>re-parsing+</A+></DT+></DL+></DD+></DL+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="section1"+>Synopsis</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="body"+><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"+><TR+><TD CLASS="decl"+><SPAN CLASS="keyword"+>newtype</SPAN+> <A HREF="#t%3AParser"+>Parser</A+> t a = <A HREF="#v%3AP"+>P</A+> ([t] -> (EitherE String a, [t]))</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3ArunParser"+>runParser</A+> :: <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"+>Parser</A+> t a -> [t] -> (Either String a, [t])</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3AfailBad"+>failBad</A+> :: String -> <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"+>Parser</A+> t a</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3Acommit"+>commit</A+> :: <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"+>Parser</A+> t a -> <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"+>Parser</A+> t a</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3Anext"+>next</A+> :: <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"+>Parser</A+> t t</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3Asatisfy"+>satisfy</A+> :: (t -> Bool) -> <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"+>Parser</A+> t t</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3Aapply"+>apply</A+> :: <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"+>Parser</A+> t (a -> b) -> <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"+>Parser</A+> t a -> <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"+>Parser</A+> t b</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3Adiscard"+>discard</A+> :: <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"+>Parser</A+> t a -> <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"+>Parser</A+> t b -> <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"+>Parser</A+> t a</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3AadjustErr"+>adjustErr</A+> :: <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"+>Parser</A+> t a -> (String -> String) -> <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"+>Parser</A+> t a</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3AadjustErrBad"+>adjustErrBad</A+> :: <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"+>Parser</A+> t a -> (String -> String) -> <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"+>Parser</A+> t a</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3Aindent"+>indent</A+> :: Int -> String -> String</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3AonFail"+>onFail</A+> :: <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"+>Parser</A+> t a -> <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"+>Parser</A+> t a -> <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"+>Parser</A+> t a</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3AoneOf"+>oneOf</A+> :: [<A HREF="Text-ParserCombinators-Poly.html#t%3AParser"+>Parser</A+> t a] -> <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"+>Parser</A+> t a</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3AoneOf%27"+>oneOf'</A+> :: [(String, <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"+>Parser</A+> t a)] -> <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"+>Parser</A+> t a</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3Aoptional"+>optional</A+> :: <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"+>Parser</A+> t a -> <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"+>Parser</A+> t (Maybe a)</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3Amany"+>many</A+> :: <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"+>Parser</A+> t a -> <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"+>Parser</A+> t [a]</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3Amany1"+>many1</A+> :: <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"+>Parser</A+> t a -> <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"+>Parser</A+> t [a]</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3AsepBy"+>sepBy</A+> :: <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"+>Parser</A+> t a -> <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"+>Parser</A+> t sep -> <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"+>Parser</A+> t [a]</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3AsepBy1"+>sepBy1</A+> :: <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"+>Parser</A+> t a -> <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"+>Parser</A+> t sep -> <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"+>Parser</A+> t [a]</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3AbracketSep"+>bracketSep</A+> :: <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"+>Parser</A+> t bra -> <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"+>Parser</A+> t sep -> <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"+>Parser</A+> t ket -> <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"+>Parser</A+> t a -> <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"+>Parser</A+> t [a]</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3Abracket"+>bracket</A+> :: <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"+>Parser</A+> t bra -> <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"+>Parser</A+> t ket -> <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"+>Parser</A+> t a -> <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"+>Parser</A+> t a</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3AmanyFinally"+>manyFinally</A+> :: <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"+>Parser</A+> t a -> <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"+>Parser</A+> t z -> <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"+>Parser</A+> t [a]</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3Areparse"+>reparse</A+> :: [t] -> <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"+>Parser</A+> t ()</TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="section1"+><A NAME="1"+>The Parser datatype+</A+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><SPAN CLASS="keyword"+>newtype</SPAN+> <A NAME="t%3AParser"+></A+><B+>Parser</B+> t a</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/Poly.html#Parser"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="body"+><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"+><TR+><TD CLASS="ndoc"+>The <TT+>Parser</TT+> datatype is a fairly generic parsing monad with error+ reporting. It can be used for arbitrary token types, not just+ String input. (If you require a running state, use module PolyState+ instead)+</TD+></TR+><TR+><TD CLASS="section4"+>Constructors</TD+></TR+><TR+><TD CLASS="body"+><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0"+><TR+><TD CLASS="arg"+><A NAME="v%3AP"+></A+><B+>P</B+> ([t] -> (EitherE String a, [t]))</TD+><TD CLASS="rdoc"+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="section4"+><IMG SRC="minus.gif" CLASS="coll" ONCLICK="toggle(this,'i:Parser')" ALT="show/hide"+> Instances</TD+></TR+><TR+><TD CLASS="body"+><DIV ID="i:Parser" STYLE="display:block;"+><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0"+><TR+><TD CLASS="decl"+>Functor (<A HREF="Text-ParserCombinators-Poly.html#t%3AParser"+>Parser</A+> t)</TD+></TR+><TR+><TD CLASS="decl"+>Monad (<A HREF="Text-ParserCombinators-Poly.html#t%3AParser"+>Parser</A+> t)</TD+></TR+></TABLE+></DIV+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3ArunParser"+></A+><B+>runParser</B+> :: <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"+>Parser</A+> t a -> [t] -> (Either String a, [t])</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/Poly.html#runParser"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+>Apply a parser to an input token sequence.+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3AfailBad"+></A+><B+>failBad</B+> :: String -> <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"+>Parser</A+> t a</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/Poly.html#failBad"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+>When a simple fail is not strong enough, use failBad for emphasis.+ An emphasised (severe) error can propagate out through choice operators.+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3Acommit"+></A+><B+>commit</B+> :: <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"+>Parser</A+> t a -> <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"+>Parser</A+> t a</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/Poly.html#commit"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+>Commit is a way of raising the severity of any errors found within+ its argument. Used in the middle of a parser definition, it means that+ any operations prior to commitment fail softly, but after commitment,+ they fail hard.+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="section1"+><A NAME="2"+>Combinators:+</A+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="section2"+><A NAME="3"+>Primitives+</A+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3Anext"+></A+><B+>next</B+> :: <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"+>Parser</A+> t t</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/Poly.html#next"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+>One token+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3Asatisfy"+></A+><B+>satisfy</B+> :: (t -> Bool) -> <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"+>Parser</A+> t t</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/Poly.html#satisfy"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+>One token satifying a predicate+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3Aapply"+></A+><B+>apply</B+> :: <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"+>Parser</A+> t (a -> b) -> <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"+>Parser</A+> t a -> <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"+>Parser</A+> t b</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/Poly.html#apply"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+>Apply a parsed function to a parsed value+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3Adiscard"+></A+><B+>discard</B+> :: <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"+>Parser</A+> t a -> <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"+>Parser</A+> t b -> <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"+>Parser</A+> t a</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/Poly.html#discard"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+><TT+>x <TT+><A HREF="Text-ParserCombinators-Poly.html#v%3Adiscard"+>discard</A+></TT+> y</TT+> parses both x and y, but discards the result of y+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="section2"+><A NAME="4"+>Error-handling+</A+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3AadjustErr"+></A+><B+>adjustErr</B+> :: <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"+>Parser</A+> t a -> (String -> String) -> <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"+>Parser</A+> t a</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/Poly.html#adjustErr"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+><TT+>p <TT+><A HREF="Text-ParserCombinators-Poly.html#v%3AadjustErr"+>adjustErr</A+></TT+> f</TT+> applies the transformation <TT+>f</TT+> to any error message+ generated in <TT+>p</TT+>, having no effect if <TT+>p</TT+> succeeds.+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3AadjustErrBad"+></A+><B+>adjustErrBad</B+> :: <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"+>Parser</A+> t a -> (String -> String) -> <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"+>Parser</A+> t a</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/Poly.html#adjustErrBad"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+><TT+>adjustErrBad</TT+> is just like <TT+>adjustErr</TT+> except it also raises the+ severity of the error.+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3Aindent"+></A+><B+>indent</B+> :: Int -> String -> String</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/Poly.html#indent"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+>Helper for formatting error messages: indents all lines by a fixed amount.+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="section2"+><A NAME="5"+>Choices+</A+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3AonFail"+></A+><B+>onFail</B+> :: <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"+>Parser</A+> t a -> <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"+>Parser</A+> t a -> <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"+>Parser</A+> t a</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/Poly.html#onFail"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+><TT+>p <TT+><A HREF="Text-ParserCombinators-Poly.html#v%3AonFail"+>onFail</A+></TT+> q</TT+> means parse p unless p fails in which case parse q instead.+ Can be chained together to give multiple attempts to parse something.+ (Note that q could itself be a failing parser, e.g. to change the error+ message from that defined in p to something different.)+ However, a *severe* failure in p cannot be ignored.+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3AoneOf"+></A+><B+>oneOf</B+> :: [<A HREF="Text-ParserCombinators-Poly.html#t%3AParser"+>Parser</A+> t a] -> <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"+>Parser</A+> t a</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/Poly.html#oneOf"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+>Parse the first alternative in the list that succeeds.+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3AoneOf%27"+></A+><B+>oneOf'</B+> :: [(String, <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"+>Parser</A+> t a)] -> <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"+>Parser</A+> t a</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/Poly.html#oneOf%27"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+>Parse the first alternative that succeeds, but if none succeed,+ report only the severe errors, and if none of those, then report+ all the soft errors.+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3Aoptional"+></A+><B+>optional</B+> :: <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"+>Parser</A+> t a -> <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"+>Parser</A+> t (Maybe a)</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/Poly.html#optional"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+><TT+><A HREF="Text-ParserCombinators-Poly.html#v%3Aoptional"+>optional</A+></TT+> indicates whether the parser succeeded through the Maybe type.+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="section2"+><A NAME="6"+>Sequences+</A+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3Amany"+></A+><B+>many</B+> :: <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"+>Parser</A+> t a -> <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"+>Parser</A+> t [a]</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/Poly.html#many"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+>'many p' parses a list of elements with individual parser p.+ Cannot fail, since an empty list is a valid return value.+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3Amany1"+></A+><B+>many1</B+> :: <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"+>Parser</A+> t a -> <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"+>Parser</A+> t [a]</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/Poly.html#many1"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+>Parse a non-empty list of items.+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3AsepBy"+></A+><B+>sepBy</B+> :: <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"+>Parser</A+> t a -> <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"+>Parser</A+> t sep -> <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"+>Parser</A+> t [a]</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/Poly.html#sepBy"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+>Parse a list of items separated by discarded junk.+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3AsepBy1"+></A+><B+>sepBy1</B+> :: <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"+>Parser</A+> t a -> <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"+>Parser</A+> t sep -> <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"+>Parser</A+> t [a]</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/Poly.html#sepBy1"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+>Parse a non-empty list of items separated by discarded junk.+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3AbracketSep"+></A+><B+>bracketSep</B+> :: <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"+>Parser</A+> t bra -> <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"+>Parser</A+> t sep -> <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"+>Parser</A+> t ket -> <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"+>Parser</A+> t a -> <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"+>Parser</A+> t [a]</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/Poly.html#bracketSep"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+>Parse a list of items, discarding the start, end, and separator+ items.+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3Abracket"+></A+><B+>bracket</B+> :: <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"+>Parser</A+> t bra -> <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"+>Parser</A+> t ket -> <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"+>Parser</A+> t a -> <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"+>Parser</A+> t a</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/Poly.html#bracket"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+>Parse a bracketed item, discarding the brackets.+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3AmanyFinally"+></A+><B+>manyFinally</B+> :: <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"+>Parser</A+> t a -> <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"+>Parser</A+> t z -> <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"+>Parser</A+> t [a]</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/Poly.html#manyFinally"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+>'manyFinally e t' parses a possibly-empty sequence of e's,+ terminated by a t. Any parse failures could be due either to+ a badly-formed terminator or a badly-formed element, so raise+ both possible errors.+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="section2"+><A NAME="7"+>re-parsing+</A+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3Areparse"+></A+><B+>reparse</B+> :: [t] -> <A HREF="Text-ParserCombinators-Poly.html#t%3AParser"+>Parser</A+> t ()</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/Poly.html#reparse"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+>Push some tokens back onto the front of the input stream and reparse.+ This is useful e.g. for recursively expanding macros. When the+ user-parser recognises a macro use, it can lookup the macro+ expansion from the parse state, lex it, and then stuff the+ lexed expansion back down into the parser.+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="botbar"+>Produced by <A HREF="http://www.haskell.org/haddock/"+>Haddock</A+> version 0.8</TD+></TR+></TABLE+></BODY+></HTML+>
+ docs/haddock/Text-ParserCombinators-PolyLazy.html view
@@ -0,0 +1,1402 @@+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">+<!--Rendered using the Haskell Html Library v0.2-->+<HTML+><HEAD+><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8"+><TITLE+>Text.ParserCombinators.PolyLazy</TITLE+><LINK HREF="haddock.css" REL="stylesheet" TYPE="text/css"+><SCRIPT SRC="haddock.js" TYPE="text/javascript"+></SCRIPT+></HEAD+><BODY+><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"+><TR+><TD CLASS="topbar"+><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"+><TR+><TD+><IMG SRC="haskell_icon.gif" WIDTH="16" HEIGHT="16" ALT=" "+></TD+><TD CLASS="title"+>polyparse</TD+><TD CLASS="topbut"+><A HREF="src/Text/ParserCombinators/PolyLazy.html"+>Source code</A+></TD+><TD CLASS="topbut"+><A HREF="index.html"+>Contents</A+></TD+><TD CLASS="topbut"+><A HREF="doc-index.html"+>Index</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="modulebar"+><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"+><TR+><TD+><FONT SIZE="6"+>Text.ParserCombinators.PolyLazy</FONT+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD+><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"+><TR+><TD CLASS="section4"+><B+>Contents</B+></TD+></TR+><TR+><TD+><DL+><DT+><A HREF="#1"+>The Parser datatype.+</A+></DT+><DT+><A HREF="#2"+>Combinators:+</A+></DT+><DD+><DL+><DT+><A HREF="#3"+>Primitives+</A+></DT+><DT+><A HREF="#4"+>Error-handling+</A+></DT+><DT+><A HREF="#5"+>Choices+</A+></DT+><DT+><A HREF="#6"+>Sequences+</A+></DT+><DT+><A HREF="#7"+>Re-parsing+</A+></DT+></DL+></DD+></DL+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="section1"+>Synopsis</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="body"+><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"+><TR+><TD CLASS="decl"+><SPAN CLASS="keyword"+>newtype</SPAN+> <A HREF="#t%3AParser"+>Parser</A+> t a = <A HREF="#v%3AP"+>P</A+> ([t] -> (Either String a, [t]))</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3ArunParser"+>runParser</A+> :: <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"+>Parser</A+> t a -> [t] -> (a, [t])</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3AfailBad"+>failBad</A+> :: String -> <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"+>Parser</A+> t a</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3Acommit"+>commit</A+> :: <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"+>Parser</A+> t a -> <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"+>Parser</A+> t a</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3Anext"+>next</A+> :: <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"+>Parser</A+> t t</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3Asatisfy"+>satisfy</A+> :: (t -> Bool) -> <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"+>Parser</A+> t t</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3Aapply"+>apply</A+> :: <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"+>Parser</A+> t (a -> b) -> <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"+>Parser</A+> t a -> <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"+>Parser</A+> t b</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3Adiscard"+>discard</A+> :: <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"+>Parser</A+> t a -> <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"+>Parser</A+> t b -> <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"+>Parser</A+> t a</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3AadjustErr"+>adjustErr</A+> :: <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"+>Parser</A+> t a -> (String -> String) -> <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"+>Parser</A+> t a</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3AadjustErrBad"+>adjustErrBad</A+> :: <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"+>Parser</A+> t a -> (String -> String) -> <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"+>Parser</A+> t a</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3Aindent"+>indent</A+> :: Int -> String -> String</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3AonFail"+>onFail</A+> :: <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"+>Parser</A+> t a -> <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"+>Parser</A+> t a -> <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"+>Parser</A+> t a</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3AoneOf"+>oneOf</A+> :: [<A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"+>Parser</A+> t a] -> <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"+>Parser</A+> t a</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3AoneOf%27"+>oneOf'</A+> :: [(String, <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"+>Parser</A+> t a)] -> <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"+>Parser</A+> t a</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3Aoptional"+>optional</A+> :: <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"+>Parser</A+> t a -> <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"+>Parser</A+> t (Maybe a)</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3Amany"+>many</A+> :: <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"+>Parser</A+> t a -> <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"+>Parser</A+> t [a]</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3Amany1"+>many1</A+> :: <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"+>Parser</A+> t a -> <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"+>Parser</A+> t [a]</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3AsepBy"+>sepBy</A+> :: <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"+>Parser</A+> t a -> <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"+>Parser</A+> t sep -> <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"+>Parser</A+> t [a]</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3AsepBy1"+>sepBy1</A+> :: <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"+>Parser</A+> t a -> <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"+>Parser</A+> t sep -> <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"+>Parser</A+> t [a]</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3AbracketSep"+>bracketSep</A+> :: <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"+>Parser</A+> t bra -> <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"+>Parser</A+> t sep -> <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"+>Parser</A+> t ket -> <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"+>Parser</A+> t a -> <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"+>Parser</A+> t [a]</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3Abracket"+>bracket</A+> :: <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"+>Parser</A+> t bra -> <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"+>Parser</A+> t ket -> <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"+>Parser</A+> t a -> <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"+>Parser</A+> t a</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3AmanyFinally"+>manyFinally</A+> :: <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"+>Parser</A+> t a -> <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"+>Parser</A+> t z -> <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"+>Parser</A+> t [a]</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3Areparse"+>reparse</A+> :: [t] -> <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"+>Parser</A+> t ()</TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="section1"+><A NAME="1"+>The Parser datatype.+</A+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="doc"+>When applied, these parsers do not return explicit failure.+ An exception is+ raised instead. This allows partial results to be returned+ before a full parse is complete.+ One of the key ways to ensure that your parser is properly lazy,+ is to parse the initial portion of text returning a function, then+ use the <TT+>apply</TT+> combinator to build the final value.+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><SPAN CLASS="keyword"+>newtype</SPAN+> <A NAME="t%3AParser"+></A+><B+>Parser</B+> t a</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/PolyLazy.html#Parser"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="body"+><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"+><TR+><TD CLASS="ndoc"+>The <TT+>Parser</TT+> datatype is a fairly generic parsing monad with error+ reporting. It can be used for arbitrary token types, not just+ String input. (If you require a running state, use module PolyStateLazy+ instead.)+</TD+></TR+><TR+><TD CLASS="section4"+>Constructors</TD+></TR+><TR+><TD CLASS="body"+><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0"+><TR+><TD CLASS="arg"+><A NAME="v%3AP"+></A+><B+>P</B+> ([t] -> (Either String a, [t]))</TD+><TD CLASS="rdoc"+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="section4"+><IMG SRC="minus.gif" CLASS="coll" ONCLICK="toggle(this,'i:Parser')" ALT="show/hide"+> Instances</TD+></TR+><TR+><TD CLASS="body"+><DIV ID="i:Parser" STYLE="display:block;"+><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0"+><TR+><TD CLASS="decl"+>Functor (<A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"+>Parser</A+> t)</TD+></TR+><TR+><TD CLASS="decl"+>Monad (<A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"+>Parser</A+> t)</TD+></TR+></TABLE+></DIV+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3ArunParser"+></A+><B+>runParser</B+> :: <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"+>Parser</A+> t a -> [t] -> (a, [t])</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/PolyLazy.html#runParser"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+>Apply a parser to an input token sequence. The parser cannot return+ an error value explicitly, so errors raise an exception. Thus, results+ can be partial (lazily constructed, but containing undefined).+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3AfailBad"+></A+><B+>failBad</B+> :: String -> <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"+>Parser</A+> t a</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/PolyLazy.html#failBad"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+>Simple failure can be corrected, but when a simple fail is not strong+ enough, use failBad for emphasis. It guarantees parsing will+ terminate with an exception.+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3Acommit"+></A+><B+>commit</B+> :: <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"+>Parser</A+> t a -> <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"+>Parser</A+> t a</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/PolyLazy.html#commit"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+>Commit is a way of raising the severity of any errors found within+ its argument. Used in the middle of a parser definition, it means that+ any operations prior to commitment fail softly, but after commitment,+ they fail hard.+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="section1"+><A NAME="2"+>Combinators:+</A+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="section2"+><A NAME="3"+>Primitives+</A+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3Anext"+></A+><B+>next</B+> :: <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"+>Parser</A+> t t</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/PolyLazy.html#next"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+>One token+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3Asatisfy"+></A+><B+>satisfy</B+> :: (t -> Bool) -> <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"+>Parser</A+> t t</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/PolyLazy.html#satisfy"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+>One token satifying a predicate+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3Aapply"+></A+><B+>apply</B+> :: <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"+>Parser</A+> t (a -> b) -> <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"+>Parser</A+> t a -> <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"+>Parser</A+> t b</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/PolyLazy.html#apply"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+>Apply a parsed function to a parsed value+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3Adiscard"+></A+><B+>discard</B+> :: <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"+>Parser</A+> t a -> <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"+>Parser</A+> t b -> <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"+>Parser</A+> t a</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/PolyLazy.html#discard"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+><TT+>x <TT+><A HREF="Text-ParserCombinators-PolyLazy.html#v%3Adiscard"+>discard</A+></TT+> y</TT+> parses both x and y, but discards the result of y+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="section2"+><A NAME="4"+>Error-handling+</A+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3AadjustErr"+></A+><B+>adjustErr</B+> :: <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"+>Parser</A+> t a -> (String -> String) -> <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"+>Parser</A+> t a</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/PolyLazy.html#adjustErr"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+><TT+>p <TT+><A HREF="Text-ParserCombinators-PolyLazy.html#v%3AadjustErr"+>adjustErr</A+></TT+> f</TT+> applies the transformation <TT+>f</TT+> to any error message+ generated in <TT+>p</TT+>, having no effect if <TT+>p</TT+> succeeds.+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3AadjustErrBad"+></A+><B+>adjustErrBad</B+> :: <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"+>Parser</A+> t a -> (String -> String) -> <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"+>Parser</A+> t a</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/PolyLazy.html#adjustErrBad"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+><TT+>adjustErrBad</TT+> is just like <TT+>adjustErr</TT+> except it also raises the+ severity of the error.+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3Aindent"+></A+><B+>indent</B+> :: Int -> String -> String</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/PolyLazy.html#indent"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+>Helper for formatting error messages: indents all lines by a fixed amount.+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="section2"+><A NAME="5"+>Choices+</A+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3AonFail"+></A+><B+>onFail</B+> :: <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"+>Parser</A+> t a -> <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"+>Parser</A+> t a -> <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"+>Parser</A+> t a</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/PolyLazy.html#onFail"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+><TT+>p <TT+><A HREF="Text-ParserCombinators-PolyLazy.html#v%3AonFail"+>onFail</A+></TT+> q</TT+> means parse p unless p fails in which case parse q instead.+ Can be chained together to give multiple attempts to parse something.+ (Note that q could itself be a failing parser, e.g. to change the error+ message from that defined in p to something different.)+ However, a *severe* failure in p cannot be ignored.+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3AoneOf"+></A+><B+>oneOf</B+> :: [<A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"+>Parser</A+> t a] -> <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"+>Parser</A+> t a</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/PolyLazy.html#oneOf"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+>Parse the first alternative in the list that succeeds.+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3AoneOf%27"+></A+><B+>oneOf'</B+> :: [(String, <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"+>Parser</A+> t a)] -> <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"+>Parser</A+> t a</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/PolyLazy.html#oneOf%27"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+>Parse the first alternative that succeeds, but if none succeed,+ report only the severe errors, and if none of those, then report+ all the soft errors.+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3Aoptional"+></A+><B+>optional</B+> :: <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"+>Parser</A+> t a -> <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"+>Parser</A+> t (Maybe a)</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/PolyLazy.html#optional"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+><TT+><A HREF="Text-ParserCombinators-PolyLazy.html#v%3Aoptional"+>optional</A+></TT+> indicates whether the parser succeeded through the Maybe type.+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="section2"+><A NAME="6"+>Sequences+</A+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3Amany"+></A+><B+>many</B+> :: <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"+>Parser</A+> t a -> <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"+>Parser</A+> t [a]</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/PolyLazy.html#many"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+>'many p' parses a list of elements with individual parser p.+ Cannot fail, since an empty list is a valid return value.+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3Amany1"+></A+><B+>many1</B+> :: <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"+>Parser</A+> t a -> <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"+>Parser</A+> t [a]</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/PolyLazy.html#many1"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+>Parse a non-empty list of items.+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3AsepBy"+></A+><B+>sepBy</B+> :: <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"+>Parser</A+> t a -> <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"+>Parser</A+> t sep -> <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"+>Parser</A+> t [a]</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/PolyLazy.html#sepBy"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+>Parse a list of items separated by discarded junk.+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3AsepBy1"+></A+><B+>sepBy1</B+> :: <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"+>Parser</A+> t a -> <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"+>Parser</A+> t sep -> <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"+>Parser</A+> t [a]</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/PolyLazy.html#sepBy1"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+>Parse a non-empty list of items separated by discarded junk.+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3AbracketSep"+></A+><B+>bracketSep</B+> :: <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"+>Parser</A+> t bra -> <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"+>Parser</A+> t sep -> <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"+>Parser</A+> t ket -> <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"+>Parser</A+> t a -> <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"+>Parser</A+> t [a]</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/PolyLazy.html#bracketSep"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+>Parse a list of items, discarding the start, end, and separator+ items.+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3Abracket"+></A+><B+>bracket</B+> :: <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"+>Parser</A+> t bra -> <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"+>Parser</A+> t ket -> <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"+>Parser</A+> t a -> <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"+>Parser</A+> t a</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/PolyLazy.html#bracket"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+>Parse a bracketed item, discarding the brackets.+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3AmanyFinally"+></A+><B+>manyFinally</B+> :: <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"+>Parser</A+> t a -> <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"+>Parser</A+> t z -> <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"+>Parser</A+> t [a]</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/PolyLazy.html#manyFinally"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+>'manyFinally e t' parses a possibly-empty sequence of e's,+ terminated by a t. Any parse failures could be due either to+ a badly-formed terminator or a badly-formed element, so raise+ both possible errors.+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="section2"+><A NAME="7"+>Re-parsing+</A+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3Areparse"+></A+><B+>reparse</B+> :: [t] -> <A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"+>Parser</A+> t ()</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/PolyLazy.html#reparse"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+>Push some tokens back onto the front of the input stream and reparse.+ This is useful e.g. for recursively expanding macros. When the+ user-parser recognises a macro use, it can lookup the macro+ expansion from the parse state, lex it, and then stuff the+ lexed expansion back down into the parser.+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="botbar"+>Produced by <A HREF="http://www.haskell.org/haddock/"+>Haddock</A+> version 0.8</TD+></TR+></TABLE+></BODY+></HTML+>
+ docs/haddock/Text-ParserCombinators-PolyState.html view
@@ -0,0 +1,1471 @@+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">+<!--Rendered using the Haskell Html Library v0.2-->+<HTML+><HEAD+><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8"+><TITLE+>Text.ParserCombinators.PolyState</TITLE+><LINK HREF="haddock.css" REL="stylesheet" TYPE="text/css"+><SCRIPT SRC="haddock.js" TYPE="text/javascript"+></SCRIPT+></HEAD+><BODY+><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"+><TR+><TD CLASS="topbar"+><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"+><TR+><TD+><IMG SRC="haskell_icon.gif" WIDTH="16" HEIGHT="16" ALT=" "+></TD+><TD CLASS="title"+>polyparse</TD+><TD CLASS="topbut"+><A HREF="src/Text/ParserCombinators/PolyState.html"+>Source code</A+></TD+><TD CLASS="topbut"+><A HREF="index.html"+>Contents</A+></TD+><TD CLASS="topbut"+><A HREF="doc-index.html"+>Index</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="modulebar"+><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"+><TR+><TD+><FONT SIZE="6"+>Text.ParserCombinators.PolyState</FONT+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD+><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"+><TR+><TD CLASS="section4"+><B+>Contents</B+></TD+></TR+><TR+><TD+><DL+><DT+><A HREF="#1"+>The Parser datatype+</A+></DT+><DT+><A HREF="#2"+>Combinators:+</A+></DT+><DD+><DL+><DT+><A HREF="#3"+>Primitives+</A+></DT+><DT+><A HREF="#4"+>Error-handling+</A+></DT+><DT+><A HREF="#5"+>Choices+</A+></DT+><DT+><A HREF="#6"+>Sequences+</A+></DT+><DT+><A HREF="#7"+>State-handling+</A+></DT+><DT+><A HREF="#8"+>Re-parsing+</A+></DT+></DL+></DD+></DL+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="section1"+>Synopsis</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="body"+><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"+><TR+><TD CLASS="decl"+><SPAN CLASS="keyword"+>newtype</SPAN+> <A HREF="#t%3AParser"+>Parser</A+> s t a = <A HREF="#v%3AP"+>P</A+> (s -> [t] -> (EitherE String a, s, [t]))</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3ArunParser"+>runParser</A+> :: <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"+>Parser</A+> s t a -> s -> [t] -> (Either String a, s, [t])</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3AfailBad"+>failBad</A+> :: String -> <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"+>Parser</A+> s t a</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3Acommit"+>commit</A+> :: <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"+>Parser</A+> s t a -> <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"+>Parser</A+> s t a</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3Anext"+>next</A+> :: <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"+>Parser</A+> s t t</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3Asatisfy"+>satisfy</A+> :: (t -> Bool) -> <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"+>Parser</A+> s t t</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3Aapply"+>apply</A+> :: <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"+>Parser</A+> s t (a -> b) -> <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"+>Parser</A+> s t a -> <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"+>Parser</A+> s t b</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3Adiscard"+>discard</A+> :: <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"+>Parser</A+> s t a -> <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"+>Parser</A+> s t b -> <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"+>Parser</A+> s t a</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3AadjustErr"+>adjustErr</A+> :: <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"+>Parser</A+> s t a -> (String -> String) -> <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"+>Parser</A+> s t a</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3AadjustErrBad"+>adjustErrBad</A+> :: <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"+>Parser</A+> s t a -> (String -> String) -> <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"+>Parser</A+> s t a</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3Aindent"+>indent</A+> :: Int -> String -> String</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3AonFail"+>onFail</A+> :: <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"+>Parser</A+> s t a -> <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"+>Parser</A+> s t a -> <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"+>Parser</A+> s t a</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3AoneOf"+>oneOf</A+> :: [<A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"+>Parser</A+> s t a] -> <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"+>Parser</A+> s t a</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3AoneOf%27"+>oneOf'</A+> :: [(String, <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"+>Parser</A+> s t a)] -> <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"+>Parser</A+> s t a</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3Amany"+>many</A+> :: <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"+>Parser</A+> s t a -> <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"+>Parser</A+> s t [a]</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3Amany1"+>many1</A+> :: <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"+>Parser</A+> s t a -> <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"+>Parser</A+> s t [a]</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3AsepBy"+>sepBy</A+> :: <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"+>Parser</A+> s t a -> <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"+>Parser</A+> s t sep -> <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"+>Parser</A+> s t [a]</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3AsepBy1"+>sepBy1</A+> :: <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"+>Parser</A+> s t a -> <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"+>Parser</A+> s t sep -> <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"+>Parser</A+> s t [a]</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3AbracketSep"+>bracketSep</A+> :: <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"+>Parser</A+> s t bra -> <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"+>Parser</A+> s t sep -> <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"+>Parser</A+> s t ket -> <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"+>Parser</A+> s t a -> <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"+>Parser</A+> s t [a]</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3Abracket"+>bracket</A+> :: <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"+>Parser</A+> s t bra -> <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"+>Parser</A+> s t ket -> <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"+>Parser</A+> s t a -> <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"+>Parser</A+> s t a</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3AmanyFinally"+>manyFinally</A+> :: <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"+>Parser</A+> s t a -> <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"+>Parser</A+> s t z -> <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"+>Parser</A+> s t [a]</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3AstUpdate"+>stUpdate</A+> :: (s -> s) -> <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"+>Parser</A+> s t ()</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3AstQuery"+>stQuery</A+> :: (s -> a) -> <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"+>Parser</A+> s t a</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3AstGet"+>stGet</A+> :: <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"+>Parser</A+> s t s</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3Areparse"+>reparse</A+> :: [t] -> <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"+>Parser</A+> s t ()</TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="section1"+><A NAME="1"+>The Parser datatype+</A+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><SPAN CLASS="keyword"+>newtype</SPAN+> <A NAME="t%3AParser"+></A+><B+>Parser</B+> s t a</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/PolyState.html#Parser"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="body"+><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"+><TR+><TD CLASS="ndoc"+>The <TT+>Parser</TT+> datatype is a fairly generic parsing monad with error+ reporting and a running state. It can be used for arbitrary token+ types, not just String input.+</TD+></TR+><TR+><TD CLASS="section4"+>Constructors</TD+></TR+><TR+><TD CLASS="body"+><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0"+><TR+><TD CLASS="arg"+><A NAME="v%3AP"+></A+><B+>P</B+> (s -> [t] -> (EitherE String a, s, [t]))</TD+><TD CLASS="rdoc"+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="section4"+><IMG SRC="minus.gif" CLASS="coll" ONCLICK="toggle(this,'i:Parser')" ALT="show/hide"+> Instances</TD+></TR+><TR+><TD CLASS="body"+><DIV ID="i:Parser" STYLE="display:block;"+><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0"+><TR+><TD CLASS="decl"+>Functor (<A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"+>Parser</A+> s t)</TD+></TR+><TR+><TD CLASS="decl"+>Monad (<A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"+>Parser</A+> s t)</TD+></TR+></TABLE+></DIV+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3ArunParser"+></A+><B+>runParser</B+> :: <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"+>Parser</A+> s t a -> s -> [t] -> (Either String a, s, [t])</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/PolyState.html#runParser"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+>Apply a parser to an initial state and input token sequence.+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3AfailBad"+></A+><B+>failBad</B+> :: String -> <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"+>Parser</A+> s t a</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/PolyState.html#failBad"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+>When a simple fail is not strong enough, use failBad for emphasis.+ An emphasised (severe) error can propagate out through choice operators.+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3Acommit"+></A+><B+>commit</B+> :: <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"+>Parser</A+> s t a -> <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"+>Parser</A+> s t a</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/PolyState.html#commit"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+>Commit is a way of raising the severity of any errors found within+ its argument. Used in the middle of a parser definition, it means that+ any operations prior to commitment fail softly, but after commitment,+ they fail hard.+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="section1"+><A NAME="2"+>Combinators:+</A+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="section2"+><A NAME="3"+>Primitives+</A+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3Anext"+></A+><B+>next</B+> :: <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"+>Parser</A+> s t t</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/PolyState.html#next"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+>One token+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3Asatisfy"+></A+><B+>satisfy</B+> :: (t -> Bool) -> <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"+>Parser</A+> s t t</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/PolyState.html#satisfy"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+>One token satifying a predicate+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3Aapply"+></A+><B+>apply</B+> :: <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"+>Parser</A+> s t (a -> b) -> <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"+>Parser</A+> s t a -> <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"+>Parser</A+> s t b</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/PolyState.html#apply"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+>Apply a parsed function to a parsed value+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3Adiscard"+></A+><B+>discard</B+> :: <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"+>Parser</A+> s t a -> <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"+>Parser</A+> s t b -> <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"+>Parser</A+> s t a</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/PolyState.html#discard"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+><TT+>x <TT+><A HREF="Text-ParserCombinators-PolyState.html#v%3Adiscard"+>discard</A+></TT+> y</TT+> parses both x and y, but discards the result of y+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="section2"+><A NAME="4"+>Error-handling+</A+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3AadjustErr"+></A+><B+>adjustErr</B+> :: <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"+>Parser</A+> s t a -> (String -> String) -> <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"+>Parser</A+> s t a</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/PolyState.html#adjustErr"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+><TT+>p <TT+><A HREF="Text-ParserCombinators-PolyState.html#v%3AadjustErr"+>adjustErr</A+></TT+> f</TT+> applies the transformation <TT+>f</TT+> to any error message+ generated in <TT+>p</TT+>, having no effect if <TT+>p</TT+> succeeds.+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3AadjustErrBad"+></A+><B+>adjustErrBad</B+> :: <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"+>Parser</A+> s t a -> (String -> String) -> <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"+>Parser</A+> s t a</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/PolyState.html#adjustErrBad"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+><TT+>adjustErrBad</TT+> is just like <TT+>adjustErr</TT+> except it also raises the+ severity of the error.+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3Aindent"+></A+><B+>indent</B+> :: Int -> String -> String</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/PolyState.html#indent"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+>Helper for formatting error messages: indents all lines by a fixed amount.+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="section2"+><A NAME="5"+>Choices+</A+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3AonFail"+></A+><B+>onFail</B+> :: <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"+>Parser</A+> s t a -> <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"+>Parser</A+> s t a -> <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"+>Parser</A+> s t a</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/PolyState.html#onFail"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+><TT+>p <TT+><A HREF="Text-ParserCombinators-PolyState.html#v%3AonFail"+>onFail</A+></TT+> q</TT+> means parse p unless p fails in which case parse q instead.+ Can be chained together to give multiple attempts to parse something.+ (Note that q could itself be a failing parser, e.g. to change the error+ message from that defined in p to something different.)+ However, a severe failure in p cannot be ignored.+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3AoneOf"+></A+><B+>oneOf</B+> :: [<A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"+>Parser</A+> s t a] -> <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"+>Parser</A+> s t a</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/PolyState.html#oneOf"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+>Parse the first alternative in the list that succeeds.+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3AoneOf%27"+></A+><B+>oneOf'</B+> :: [(String, <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"+>Parser</A+> s t a)] -> <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"+>Parser</A+> s t a</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/PolyState.html#oneOf%27"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+>Parse the first alternative that succeeds, but if none succeed,+ report only the severe errors, and if none of those, then report+ all the soft errors.+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="section2"+><A NAME="6"+>Sequences+</A+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3Amany"+></A+><B+>many</B+> :: <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"+>Parser</A+> s t a -> <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"+>Parser</A+> s t [a]</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/PolyState.html#many"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+>'many p' parses a list of elements with individual parser p.+ Cannot fail, since an empty list is a valid return value.+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3Amany1"+></A+><B+>many1</B+> :: <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"+>Parser</A+> s t a -> <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"+>Parser</A+> s t [a]</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/PolyState.html#many1"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+>Parse a non-empty list of items.+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3AsepBy"+></A+><B+>sepBy</B+> :: <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"+>Parser</A+> s t a -> <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"+>Parser</A+> s t sep -> <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"+>Parser</A+> s t [a]</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/PolyState.html#sepBy"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+>Parse a list of items separated by discarded junk.+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3AsepBy1"+></A+><B+>sepBy1</B+> :: <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"+>Parser</A+> s t a -> <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"+>Parser</A+> s t sep -> <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"+>Parser</A+> s t [a]</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/PolyState.html#sepBy1"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+>Parse a non-empty list of items separated by discarded junk.+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3AbracketSep"+></A+><B+>bracketSep</B+> :: <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"+>Parser</A+> s t bra -> <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"+>Parser</A+> s t sep -> <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"+>Parser</A+> s t ket -> <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"+>Parser</A+> s t a -> <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"+>Parser</A+> s t [a]</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/PolyState.html#bracketSep"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+>Parse a list of items, discarding the start, end, and separator+ items.+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3Abracket"+></A+><B+>bracket</B+> :: <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"+>Parser</A+> s t bra -> <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"+>Parser</A+> s t ket -> <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"+>Parser</A+> s t a -> <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"+>Parser</A+> s t a</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/PolyState.html#bracket"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+>Parse a bracketed item, discarding the brackets.+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3AmanyFinally"+></A+><B+>manyFinally</B+> :: <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"+>Parser</A+> s t a -> <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"+>Parser</A+> s t z -> <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"+>Parser</A+> s t [a]</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/PolyState.html#manyFinally"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+>'manyFinally e t' parses a possibly-empty sequence of e's,+ terminated by a t. Any parse failures could be due either to+ a badly-formed terminator or a badly-formed element, so raise+ both possible errors.+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="section2"+><A NAME="7"+>State-handling+</A+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3AstUpdate"+></A+><B+>stUpdate</B+> :: (s -> s) -> <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"+>Parser</A+> s t ()</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/PolyState.html#stUpdate"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+>Update the internal state.+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3AstQuery"+></A+><B+>stQuery</B+> :: (s -> a) -> <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"+>Parser</A+> s t a</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/PolyState.html#stQuery"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+>Query the internal state.+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3AstGet"+></A+><B+>stGet</B+> :: <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"+>Parser</A+> s t s</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/PolyState.html#stGet"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+>Deliver the entire internal state.+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="section2"+><A NAME="8"+>Re-parsing+</A+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3Areparse"+></A+><B+>reparse</B+> :: [t] -> <A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"+>Parser</A+> s t ()</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/PolyState.html#reparse"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+>Push some tokens back onto the front of the input stream and reparse.+ This is useful e.g. for recursively expanding macros. When the+ user-parser recognises a macro use, it can lookup the macro+ expansion from the parse state, lex it, and then stuff the+ lexed expansion back down into the parser.+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="botbar"+>Produced by <A HREF="http://www.haskell.org/haddock/"+>Haddock</A+> version 0.8</TD+></TR+></TABLE+></BODY+></HTML+>
+ docs/haddock/Text-ParserCombinators-PolyStateLazy.html view
@@ -0,0 +1,1535 @@+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">+<!--Rendered using the Haskell Html Library v0.2-->+<HTML+><HEAD+><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8"+><TITLE+>Text.ParserCombinators.PolyStateLazy</TITLE+><LINK HREF="haddock.css" REL="stylesheet" TYPE="text/css"+><SCRIPT SRC="haddock.js" TYPE="text/javascript"+></SCRIPT+></HEAD+><BODY+><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"+><TR+><TD CLASS="topbar"+><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"+><TR+><TD+><IMG SRC="haskell_icon.gif" WIDTH="16" HEIGHT="16" ALT=" "+></TD+><TD CLASS="title"+>polyparse</TD+><TD CLASS="topbut"+><A HREF="src/Text/ParserCombinators/PolyStateLazy.html"+>Source code</A+></TD+><TD CLASS="topbut"+><A HREF="index.html"+>Contents</A+></TD+><TD CLASS="topbut"+><A HREF="doc-index.html"+>Index</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="modulebar"+><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"+><TR+><TD+><FONT SIZE="6"+>Text.ParserCombinators.PolyStateLazy</FONT+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD+><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"+><TR+><TD CLASS="section4"+><B+>Contents</B+></TD+></TR+><TR+><TD+><DL+><DT+><A HREF="#1"+>The Parser datatype.+</A+></DT+><DT+><A HREF="#2"+>Combinators:+</A+></DT+><DD+><DL+><DT+><A HREF="#3"+>Primitives+</A+></DT+><DT+><A HREF="#4"+>Error-handling+</A+></DT+><DT+><A HREF="#5"+>Choices+</A+></DT+><DT+><A HREF="#6"+>Sequences+</A+></DT+><DT+><A HREF="#7"+>State-handling+</A+></DT+><DT+><A HREF="#8"+>Re-parsing+</A+></DT+></DL+></DD+></DL+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="section1"+>Synopsis</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="body"+><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"+><TR+><TD CLASS="decl"+><SPAN CLASS="keyword"+>newtype</SPAN+> <A HREF="#t%3AParser"+>Parser</A+> s t a = <A HREF="#v%3AP"+>P</A+> (s -> [t] -> (Either String a, s, [t]))</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3ArunParser"+>runParser</A+> :: <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"+>Parser</A+> s t a -> s -> [t] -> (a, s, [t])</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3AfailBad"+>failBad</A+> :: String -> <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"+>Parser</A+> s t a</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3Acommit"+>commit</A+> :: <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"+>Parser</A+> s t a -> <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"+>Parser</A+> s t a</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3Anext"+>next</A+> :: <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"+>Parser</A+> s t t</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3Asatisfy"+>satisfy</A+> :: (t -> Bool) -> <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"+>Parser</A+> s t t</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3Aapply"+>apply</A+> :: <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"+>Parser</A+> s t (a -> b) -> <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"+>Parser</A+> s t a -> <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"+>Parser</A+> s t b</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3Adiscard"+>discard</A+> :: <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"+>Parser</A+> s t a -> <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"+>Parser</A+> s t b -> <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"+>Parser</A+> s t a</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3AadjustErr"+>adjustErr</A+> :: <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"+>Parser</A+> s t a -> (String -> String) -> <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"+>Parser</A+> s t a</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3AadjustErrBad"+>adjustErrBad</A+> :: <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"+>Parser</A+> s t a -> (String -> String) -> <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"+>Parser</A+> s t a</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3Aindent"+>indent</A+> :: Int -> String -> String</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3AonFail"+>onFail</A+> :: <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"+>Parser</A+> s t a -> <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"+>Parser</A+> s t a -> <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"+>Parser</A+> s t a</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3AoneOf"+>oneOf</A+> :: [<A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"+>Parser</A+> s t a] -> <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"+>Parser</A+> s t a</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3AoneOf%27"+>oneOf'</A+> :: [(String, <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"+>Parser</A+> s t a)] -> <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"+>Parser</A+> s t a</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3Aoptional"+>optional</A+> :: <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"+>Parser</A+> s t a -> <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"+>Parser</A+> s t (Maybe a)</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3Amany"+>many</A+> :: <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"+>Parser</A+> s t a -> <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"+>Parser</A+> s t [a]</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3Amany1"+>many1</A+> :: <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"+>Parser</A+> s t a -> <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"+>Parser</A+> s t [a]</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3AsepBy"+>sepBy</A+> :: <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"+>Parser</A+> s t a -> <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"+>Parser</A+> s t sep -> <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"+>Parser</A+> s t [a]</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3AsepBy1"+>sepBy1</A+> :: <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"+>Parser</A+> s t a -> <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"+>Parser</A+> s t sep -> <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"+>Parser</A+> s t [a]</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3AbracketSep"+>bracketSep</A+> :: <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"+>Parser</A+> s t bra -> <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"+>Parser</A+> s t sep -> <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"+>Parser</A+> s t ket -> <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"+>Parser</A+> s t a -> <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"+>Parser</A+> s t [a]</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3Abracket"+>bracket</A+> :: <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"+>Parser</A+> s t bra -> <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"+>Parser</A+> s t ket -> <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"+>Parser</A+> s t a -> <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"+>Parser</A+> s t a</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3AmanyFinally"+>manyFinally</A+> :: <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"+>Parser</A+> s t a -> <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"+>Parser</A+> s t z -> <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"+>Parser</A+> s t [a]</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3AstUpdate"+>stUpdate</A+> :: (s -> s) -> <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"+>Parser</A+> s t ()</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3AstQuery"+>stQuery</A+> :: (s -> a) -> <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"+>Parser</A+> s t a</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3AstGet"+>stGet</A+> :: <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"+>Parser</A+> s t s</TD+></TR+><TR+><TD CLASS="s8"+></TD+></TR+><TR+><TD CLASS="decl"+><A HREF="#v%3Areparse"+>reparse</A+> :: [t] -> <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"+>Parser</A+> s t ()</TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="section1"+><A NAME="1"+>The Parser datatype.+</A+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="doc"+>Parsers do not return explicit failure. An exception is raised+ instead. This allows partial results to be returned before a+ full parse is complete.+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><SPAN CLASS="keyword"+>newtype</SPAN+> <A NAME="t%3AParser"+></A+><B+>Parser</B+> s t a</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/PolyStateLazy.html#Parser"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="body"+><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"+><TR+><TD CLASS="ndoc"+>The <TT+>Parser</TT+> datatype is a fairly generic parsing monad with error+ reporting and a running state. It can be used for arbitrary token+ types, not just String input.+</TD+></TR+><TR+><TD CLASS="section4"+>Constructors</TD+></TR+><TR+><TD CLASS="body"+><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0"+><TR+><TD CLASS="arg"+><A NAME="v%3AP"+></A+><B+>P</B+> (s -> [t] -> (Either String a, s, [t]))</TD+><TD CLASS="rdoc"+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="section4"+><IMG SRC="minus.gif" CLASS="coll" ONCLICK="toggle(this,'i:Parser')" ALT="show/hide"+> Instances</TD+></TR+><TR+><TD CLASS="body"+><DIV ID="i:Parser" STYLE="display:block;"+><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0"+><TR+><TD CLASS="decl"+>Functor (<A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"+>Parser</A+> s t)</TD+></TR+><TR+><TD CLASS="decl"+>Monad (<A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"+>Parser</A+> s t)</TD+></TR+></TABLE+></DIV+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3ArunParser"+></A+><B+>runParser</B+> :: <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"+>Parser</A+> s t a -> s -> [t] -> (a, s, [t])</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/PolyStateLazy.html#runParser"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+>Apply a parser to an initial state and input token sequence.+ The parser cannot return an error value explicitly, so errors+ raise an exception. Thus, results can be partial (lazily constructed,+ but containing undefined).+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3AfailBad"+></A+><B+>failBad</B+> :: String -> <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"+>Parser</A+> s t a</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/PolyStateLazy.html#failBad"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+>Simple failure can be corrected, but when a simple fail is not strong+ enough, use failBad for emphasis. It guarantees parsing will terminate+ with an exception.+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3Acommit"+></A+><B+>commit</B+> :: <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"+>Parser</A+> s t a -> <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"+>Parser</A+> s t a</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/PolyStateLazy.html#commit"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+>Commit is a way of raising the severity of any errors found within+ its argument. Used in the middle of a parser definition, it means that+ any operations prior to commitment fail softly, but after commitment,+ they fail hard.+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="section1"+><A NAME="2"+>Combinators:+</A+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="section2"+><A NAME="3"+>Primitives+</A+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3Anext"+></A+><B+>next</B+> :: <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"+>Parser</A+> s t t</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/PolyStateLazy.html#next"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+>One token+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3Asatisfy"+></A+><B+>satisfy</B+> :: (t -> Bool) -> <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"+>Parser</A+> s t t</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/PolyStateLazy.html#satisfy"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+>One token satifying a predicate+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3Aapply"+></A+><B+>apply</B+> :: <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"+>Parser</A+> s t (a -> b) -> <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"+>Parser</A+> s t a -> <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"+>Parser</A+> s t b</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/PolyStateLazy.html#apply"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+>Apply a parsed function to a parsed value+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3Adiscard"+></A+><B+>discard</B+> :: <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"+>Parser</A+> s t a -> <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"+>Parser</A+> s t b -> <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"+>Parser</A+> s t a</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/PolyStateLazy.html#discard"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+><TT+>x <TT+><A HREF="Text-ParserCombinators-PolyStateLazy.html#v%3Adiscard"+>discard</A+></TT+> y</TT+> parses both x and y, but discards the result of y+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="section2"+><A NAME="4"+>Error-handling+</A+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3AadjustErr"+></A+><B+>adjustErr</B+> :: <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"+>Parser</A+> s t a -> (String -> String) -> <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"+>Parser</A+> s t a</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/PolyStateLazy.html#adjustErr"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+><TT+>p <TT+><A HREF="Text-ParserCombinators-PolyStateLazy.html#v%3AadjustErr"+>adjustErr</A+></TT+> f</TT+> applies the transformation <TT+>f</TT+> to any error message+ generated in <TT+>p</TT+>, having no effect if <TT+>p</TT+> succeeds.+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3AadjustErrBad"+></A+><B+>adjustErrBad</B+> :: <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"+>Parser</A+> s t a -> (String -> String) -> <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"+>Parser</A+> s t a</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/PolyStateLazy.html#adjustErrBad"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+><TT+>adjustErrBad</TT+> is just like <TT+>adjustErr</TT+> except it also raises the+ severity of the error.+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3Aindent"+></A+><B+>indent</B+> :: Int -> String -> String</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/PolyStateLazy.html#indent"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+>Helper for formatting error messages: indents all lines by a fixed amount.+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="section2"+><A NAME="5"+>Choices+</A+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3AonFail"+></A+><B+>onFail</B+> :: <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"+>Parser</A+> s t a -> <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"+>Parser</A+> s t a -> <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"+>Parser</A+> s t a</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/PolyStateLazy.html#onFail"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+><TT+>p <TT+><A HREF="Text-ParserCombinators-PolyStateLazy.html#v%3AonFail"+>onFail</A+></TT+> q</TT+> means parse p unless p fails in which case parse q instead.+ Can be chained together to give multiple attempts to parse something.+ (Note that q could itself be a failing parser, e.g. to change the error+ message from that defined in p to something different.)+ However, a *severe* failure in p cannot be ignored.+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3AoneOf"+></A+><B+>oneOf</B+> :: [<A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"+>Parser</A+> s t a] -> <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"+>Parser</A+> s t a</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/PolyStateLazy.html#oneOf"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+>Parse the first alternative in the list that succeeds.+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3AoneOf%27"+></A+><B+>oneOf'</B+> :: [(String, <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"+>Parser</A+> s t a)] -> <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"+>Parser</A+> s t a</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/PolyStateLazy.html#oneOf%27"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+>Parse the first alternative that succeeds, but if none succeed,+ report only the severe errors, and if none of those, then report+ all the soft errors.+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3Aoptional"+></A+><B+>optional</B+> :: <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"+>Parser</A+> s t a -> <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"+>Parser</A+> s t (Maybe a)</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/PolyStateLazy.html#optional"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+><TT+><A HREF="Text-ParserCombinators-PolyStateLazy.html#v%3Aoptional"+>optional</A+></TT+> indicates whether the parser succeeded through the Maybe type.+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="section2"+><A NAME="6"+>Sequences+</A+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3Amany"+></A+><B+>many</B+> :: <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"+>Parser</A+> s t a -> <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"+>Parser</A+> s t [a]</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/PolyStateLazy.html#many"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+>'many p' parses a list of elements with individual parser p.+ Cannot fail, since an empty list is a valid return value.+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3Amany1"+></A+><B+>many1</B+> :: <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"+>Parser</A+> s t a -> <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"+>Parser</A+> s t [a]</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/PolyStateLazy.html#many1"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+>Parse a non-empty list of items.+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3AsepBy"+></A+><B+>sepBy</B+> :: <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"+>Parser</A+> s t a -> <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"+>Parser</A+> s t sep -> <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"+>Parser</A+> s t [a]</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/PolyStateLazy.html#sepBy"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+>Parse a list of items separated by discarded junk.+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3AsepBy1"+></A+><B+>sepBy1</B+> :: <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"+>Parser</A+> s t a -> <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"+>Parser</A+> s t sep -> <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"+>Parser</A+> s t [a]</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/PolyStateLazy.html#sepBy1"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+>Parse a non-empty list of items separated by discarded junk.+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3AbracketSep"+></A+><B+>bracketSep</B+> :: <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"+>Parser</A+> s t bra -> <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"+>Parser</A+> s t sep -> <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"+>Parser</A+> s t ket -> <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"+>Parser</A+> s t a -> <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"+>Parser</A+> s t [a]</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/PolyStateLazy.html#bracketSep"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+>Parse a list of items, discarding the start, end, and separator+ items.+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3Abracket"+></A+><B+>bracket</B+> :: <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"+>Parser</A+> s t bra -> <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"+>Parser</A+> s t ket -> <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"+>Parser</A+> s t a -> <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"+>Parser</A+> s t a</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/PolyStateLazy.html#bracket"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+>Parse a bracketed item, discarding the brackets.+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3AmanyFinally"+></A+><B+>manyFinally</B+> :: <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"+>Parser</A+> s t a -> <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"+>Parser</A+> s t z -> <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"+>Parser</A+> s t [a]</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/PolyStateLazy.html#manyFinally"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+>'manyFinally e t' parses a possibly-empty sequence of e's,+ terminated by a t. Any parse failures could be due either to+ a badly-formed terminator or a badly-formed element, so raise+ both possible errors.+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="section2"+><A NAME="7"+>State-handling+</A+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3AstUpdate"+></A+><B+>stUpdate</B+> :: (s -> s) -> <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"+>Parser</A+> s t ()</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/PolyStateLazy.html#stUpdate"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+>Update the internal state.+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3AstQuery"+></A+><B+>stQuery</B+> :: (s -> a) -> <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"+>Parser</A+> s t a</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/PolyStateLazy.html#stQuery"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+>Query the internal state.+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3AstGet"+></A+><B+>stGet</B+> :: <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"+>Parser</A+> s t s</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/PolyStateLazy.html#stGet"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+>Deliver the entire internal state.+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="section2"+><A NAME="8"+>Re-parsing+</A+></TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="topdecl"+><TABLE CLASS="declbar"+><TR+><TD CLASS="declname"+><A NAME="v%3Areparse"+></A+><B+>reparse</B+> :: [t] -> <A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"+>Parser</A+> s t ()</TD+><TD CLASS="declbut"+><A HREF="src/Text/ParserCombinators/PolyStateLazy.html#reparse"+>Source</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="doc"+>Push some tokens back onto the front of the input stream and reparse.+ This is useful e.g. for recursively expanding macros. When the+ user-parser recognises a macro use, it can lookup the macro+ expansion from the parse state, lex it, and then stuff the+ lexed expansion back down into the parser.+</TD+></TR+><TR+><TD CLASS="s15"+></TD+></TR+><TR+><TD CLASS="botbar"+>Produced by <A HREF="http://www.haskell.org/haddock/"+>Haddock</A+> version 0.8</TD+></TR+></TABLE+></BODY+></HTML+>
+ docs/haddock/doc-index-43.html view
@@ -0,0 +1,150 @@+<!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"+></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+><TABLE CELLPADDING="0" CELLSPACING="5"+><TR+><TD+><A HREF="doc-index-A.html"+>A</A+></TD+><TD+><A HREF="doc-index-B.html"+>B</A+></TD+><TD+><A HREF="doc-index-C.html"+>C</A+></TD+><TD+><A HREF="doc-index-D.html"+>D</A+></TD+><TD+><A HREF="doc-index-E.html"+>E</A+></TD+><TD+><A HREF="doc-index-F.html"+>F</A+></TD+><TD+><A HREF="doc-index-I.html"+>I</A+></TD+><TD+><A HREF="doc-index-J.html"+>J</A+></TD+><TD+><A HREF="doc-index-L.html"+>L</A+></TD+><TD+><A HREF="doc-index-M.html"+>M</A+></TD+><TD+><A HREF="doc-index-N.html"+>N</A+></TD+><TD+><A HREF="doc-index-O.html"+>O</A+></TD+><TD+><A HREF="doc-index-P.html"+>P</A+></TD+><TD+><A HREF="doc-index-R.html"+>R</A+></TD+><TD+><A HREF="doc-index-S.html"+>S</A+></TD+><TD+><A HREF="doc-index-T.html"+>T</A+></TD+><TD+><A HREF="doc-index-U.html"+>U</A+></TD+><TD+><A HREF="doc-index-W.html"+>W</A+></TD+><TD+><A HREF="doc-index-43.html"+>+</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="section1"+>Index (+)</TD+></TR+><TR+><TD+><TABLE CELLPADDING="0" CELLSPACING="5"+><TR+><TD CLASS="indexentry" COLSPAN="2"+>+++</TD+></TR+><TR+><TD CLASS="indexannot"+>1 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-HuttonMeijer.html#v%3A%2B%2B%2B"+>Text.ParserCombinators.HuttonMeijer</A+></TD+></TR+><TR+><TD CLASS="indexannot"+>2 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#v%3A%2B%2B%2B"+>Text.ParserCombinators.HuttonMeijerWallace</A+></TD+></TR+></TABLE+></TD+></TR+></TABLE+></BODY+></HTML+>
+ docs/haddock/doc-index-A.html view
@@ -0,0 +1,246 @@+<!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"+></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+><TABLE CELLPADDING="0" CELLSPACING="5"+><TR+><TD+><A HREF="doc-index-A.html"+>A</A+></TD+><TD+><A HREF="doc-index-B.html"+>B</A+></TD+><TD+><A HREF="doc-index-C.html"+>C</A+></TD+><TD+><A HREF="doc-index-D.html"+>D</A+></TD+><TD+><A HREF="doc-index-E.html"+>E</A+></TD+><TD+><A HREF="doc-index-F.html"+>F</A+></TD+><TD+><A HREF="doc-index-I.html"+>I</A+></TD+><TD+><A HREF="doc-index-J.html"+>J</A+></TD+><TD+><A HREF="doc-index-L.html"+>L</A+></TD+><TD+><A HREF="doc-index-M.html"+>M</A+></TD+><TD+><A HREF="doc-index-N.html"+>N</A+></TD+><TD+><A HREF="doc-index-O.html"+>O</A+></TD+><TD+><A HREF="doc-index-P.html"+>P</A+></TD+><TD+><A HREF="doc-index-R.html"+>R</A+></TD+><TD+><A HREF="doc-index-S.html"+>S</A+></TD+><TD+><A HREF="doc-index-T.html"+>T</A+></TD+><TD+><A HREF="doc-index-U.html"+>U</A+></TD+><TD+><A HREF="doc-index-W.html"+>W</A+></TD+><TD+><A HREF="doc-index-43.html"+>+</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="section1"+>Index (A)</TD+></TR+><TR+><TD+><TABLE CELLPADDING="0" CELLSPACING="5"+><TR+><TD CLASS="indexentry" COLSPAN="2"+>adjustErr</TD+></TR+><TR+><TD CLASS="indexannot"+>1 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-Poly.html#v%3AadjustErr"+>Text.ParserCombinators.Poly</A+>, Text.Parse</TD+></TR+><TR+><TD CLASS="indexannot"+>2 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-PolyLazy.html#v%3AadjustErr"+>Text.ParserCombinators.PolyLazy</A+></TD+></TR+><TR+><TD CLASS="indexannot"+>3 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-PolyState.html#v%3AadjustErr"+>Text.ParserCombinators.PolyState</A+></TD+></TR+><TR+><TD CLASS="indexannot"+>4 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-PolyStateLazy.html#v%3AadjustErr"+>Text.ParserCombinators.PolyStateLazy</A+></TD+></TR+><TR+><TD CLASS="indexentry" COLSPAN="2"+>adjustErrBad</TD+></TR+><TR+><TD CLASS="indexannot"+>1 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-Poly.html#v%3AadjustErrBad"+>Text.ParserCombinators.Poly</A+>, Text.Parse</TD+></TR+><TR+><TD CLASS="indexannot"+>2 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-PolyLazy.html#v%3AadjustErrBad"+>Text.ParserCombinators.PolyLazy</A+></TD+></TR+><TR+><TD CLASS="indexannot"+>3 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-PolyState.html#v%3AadjustErrBad"+>Text.ParserCombinators.PolyState</A+></TD+></TR+><TR+><TD CLASS="indexannot"+>4 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-PolyStateLazy.html#v%3AadjustErrBad"+>Text.ParserCombinators.PolyStateLazy</A+></TD+></TR+><TR+><TD CLASS="indexentry"+>alphanum</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-HuttonMeijer.html#v%3Aalphanum"+>Text.ParserCombinators.HuttonMeijer</A+></TD+></TR+><TR+><TD CLASS="indexentry" COLSPAN="2"+>apply</TD+></TR+><TR+><TD CLASS="indexannot"+>1 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-Poly.html#v%3Aapply"+>Text.ParserCombinators.Poly</A+>, Text.Parse</TD+></TR+><TR+><TD CLASS="indexannot"+>2 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-PolyLazy.html#v%3Aapply"+>Text.ParserCombinators.PolyLazy</A+></TD+></TR+><TR+><TD CLASS="indexannot"+>3 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-PolyState.html#v%3Aapply"+>Text.ParserCombinators.PolyState</A+></TD+></TR+><TR+><TD CLASS="indexannot"+>4 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-PolyStateLazy.html#v%3Aapply"+>Text.ParserCombinators.PolyStateLazy</A+></TD+></TR+></TABLE+></TD+></TR+></TABLE+></BODY+></HTML+>
+ docs/haddock/doc-index-B.html view
@@ -0,0 +1,218 @@+<!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"+></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+><TABLE CELLPADDING="0" CELLSPACING="5"+><TR+><TD+><A HREF="doc-index-A.html"+>A</A+></TD+><TD+><A HREF="doc-index-B.html"+>B</A+></TD+><TD+><A HREF="doc-index-C.html"+>C</A+></TD+><TD+><A HREF="doc-index-D.html"+>D</A+></TD+><TD+><A HREF="doc-index-E.html"+>E</A+></TD+><TD+><A HREF="doc-index-F.html"+>F</A+></TD+><TD+><A HREF="doc-index-I.html"+>I</A+></TD+><TD+><A HREF="doc-index-J.html"+>J</A+></TD+><TD+><A HREF="doc-index-L.html"+>L</A+></TD+><TD+><A HREF="doc-index-M.html"+>M</A+></TD+><TD+><A HREF="doc-index-N.html"+>N</A+></TD+><TD+><A HREF="doc-index-O.html"+>O</A+></TD+><TD+><A HREF="doc-index-P.html"+>P</A+></TD+><TD+><A HREF="doc-index-R.html"+>R</A+></TD+><TD+><A HREF="doc-index-S.html"+>S</A+></TD+><TD+><A HREF="doc-index-T.html"+>T</A+></TD+><TD+><A HREF="doc-index-U.html"+>U</A+></TD+><TD+><A HREF="doc-index-W.html"+>W</A+></TD+><TD+><A HREF="doc-index-43.html"+>+</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="section1"+>Index (B)</TD+></TR+><TR+><TD+><TABLE CELLPADDING="0" CELLSPACING="5"+><TR+><TD CLASS="indexentry" COLSPAN="2"+>bracket</TD+></TR+><TR+><TD CLASS="indexannot"+>1 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-HuttonMeijer.html#v%3Abracket"+>Text.ParserCombinators.HuttonMeijer</A+></TD+></TR+><TR+><TD CLASS="indexannot"+>2 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#v%3Abracket"+>Text.ParserCombinators.HuttonMeijerWallace</A+></TD+></TR+><TR+><TD CLASS="indexannot"+>3 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-Poly.html#v%3Abracket"+>Text.ParserCombinators.Poly</A+>, Text.Parse</TD+></TR+><TR+><TD CLASS="indexannot"+>4 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-PolyLazy.html#v%3Abracket"+>Text.ParserCombinators.PolyLazy</A+></TD+></TR+><TR+><TD CLASS="indexannot"+>5 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-PolyState.html#v%3Abracket"+>Text.ParserCombinators.PolyState</A+></TD+></TR+><TR+><TD CLASS="indexannot"+>6 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-PolyStateLazy.html#v%3Abracket"+>Text.ParserCombinators.PolyStateLazy</A+></TD+></TR+><TR+><TD CLASS="indexentry" COLSPAN="2"+>bracketSep</TD+></TR+><TR+><TD CLASS="indexannot"+>1 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-Poly.html#v%3AbracketSep"+>Text.ParserCombinators.Poly</A+>, Text.Parse</TD+></TR+><TR+><TD CLASS="indexannot"+>2 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-PolyLazy.html#v%3AbracketSep"+>Text.ParserCombinators.PolyLazy</A+></TD+></TR+><TR+><TD CLASS="indexannot"+>3 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-PolyState.html#v%3AbracketSep"+>Text.ParserCombinators.PolyState</A+></TD+></TR+><TR+><TD CLASS="indexannot"+>4 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-PolyStateLazy.html#v%3AbracketSep"+>Text.ParserCombinators.PolyStateLazy</A+></TD+></TR+></TABLE+></TD+></TR+></TABLE+></BODY+></HTML+>
+ docs/haddock/doc-index-C.html view
@@ -0,0 +1,270 @@+<!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"+></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+><TABLE CELLPADDING="0" CELLSPACING="5"+><TR+><TD+><A HREF="doc-index-A.html"+>A</A+></TD+><TD+><A HREF="doc-index-B.html"+>B</A+></TD+><TD+><A HREF="doc-index-C.html"+>C</A+></TD+><TD+><A HREF="doc-index-D.html"+>D</A+></TD+><TD+><A HREF="doc-index-E.html"+>E</A+></TD+><TD+><A HREF="doc-index-F.html"+>F</A+></TD+><TD+><A HREF="doc-index-I.html"+>I</A+></TD+><TD+><A HREF="doc-index-J.html"+>J</A+></TD+><TD+><A HREF="doc-index-L.html"+>L</A+></TD+><TD+><A HREF="doc-index-M.html"+>M</A+></TD+><TD+><A HREF="doc-index-N.html"+>N</A+></TD+><TD+><A HREF="doc-index-O.html"+>O</A+></TD+><TD+><A HREF="doc-index-P.html"+>P</A+></TD+><TD+><A HREF="doc-index-R.html"+>R</A+></TD+><TD+><A HREF="doc-index-S.html"+>S</A+></TD+><TD+><A HREF="doc-index-T.html"+>T</A+></TD+><TD+><A HREF="doc-index-U.html"+>U</A+></TD+><TD+><A HREF="doc-index-W.html"+>W</A+></TD+><TD+><A HREF="doc-index-43.html"+>+</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="section1"+>Index (C)</TD+></TR+><TR+><TD+><TABLE CELLPADDING="0" CELLSPACING="5"+><TR+><TD CLASS="indexentry" COLSPAN="2"+>chainl</TD+></TR+><TR+><TD CLASS="indexannot"+>1 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-HuttonMeijer.html#v%3Achainl"+>Text.ParserCombinators.HuttonMeijer</A+></TD+></TR+><TR+><TD CLASS="indexannot"+>2 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#v%3Achainl"+>Text.ParserCombinators.HuttonMeijerWallace</A+></TD+></TR+><TR+><TD CLASS="indexentry" COLSPAN="2"+>chainl1</TD+></TR+><TR+><TD CLASS="indexannot"+>1 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-HuttonMeijer.html#v%3Achainl1"+>Text.ParserCombinators.HuttonMeijer</A+></TD+></TR+><TR+><TD CLASS="indexannot"+>2 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#v%3Achainl1"+>Text.ParserCombinators.HuttonMeijerWallace</A+></TD+></TR+><TR+><TD CLASS="indexentry" COLSPAN="2"+>chainr</TD+></TR+><TR+><TD CLASS="indexannot"+>1 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-HuttonMeijer.html#v%3Achainr"+>Text.ParserCombinators.HuttonMeijer</A+></TD+></TR+><TR+><TD CLASS="indexannot"+>2 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#v%3Achainr"+>Text.ParserCombinators.HuttonMeijerWallace</A+></TD+></TR+><TR+><TD CLASS="indexentry" COLSPAN="2"+>chainr1</TD+></TR+><TR+><TD CLASS="indexannot"+>1 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-HuttonMeijer.html#v%3Achainr1"+>Text.ParserCombinators.HuttonMeijer</A+></TD+></TR+><TR+><TD CLASS="indexannot"+>2 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#v%3Achainr1"+>Text.ParserCombinators.HuttonMeijerWallace</A+></TD+></TR+><TR+><TD CLASS="indexentry"+>char</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-HuttonMeijer.html#v%3Achar"+>Text.ParserCombinators.HuttonMeijer</A+></TD+></TR+><TR+><TD CLASS="indexentry"+>comment</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-HuttonMeijer.html#v%3Acomment"+>Text.ParserCombinators.HuttonMeijer</A+></TD+></TR+><TR+><TD CLASS="indexentry" COLSPAN="2"+>commit</TD+></TR+><TR+><TD CLASS="indexannot"+>1 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-Poly.html#v%3Acommit"+>Text.ParserCombinators.Poly</A+>, Text.Parse</TD+></TR+><TR+><TD CLASS="indexannot"+>2 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-PolyLazy.html#v%3Acommit"+>Text.ParserCombinators.PolyLazy</A+></TD+></TR+><TR+><TD CLASS="indexannot"+>3 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-PolyState.html#v%3Acommit"+>Text.ParserCombinators.PolyState</A+></TD+></TR+><TR+><TD CLASS="indexannot"+>4 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-PolyStateLazy.html#v%3Acommit"+>Text.ParserCombinators.PolyStateLazy</A+></TD+></TR+><TR+><TD CLASS="indexentry"+>constructors</TD+><TD CLASS="indexlinks"+><A HREF="Text-Parse.html#v%3Aconstructors"+>Text.Parse</A+></TD+></TR+></TABLE+></TD+></TR+></TABLE+></BODY+></HTML+>
+ docs/haddock/doc-index-D.html view
@@ -0,0 +1,174 @@+<!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"+></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+><TABLE CELLPADDING="0" CELLSPACING="5"+><TR+><TD+><A HREF="doc-index-A.html"+>A</A+></TD+><TD+><A HREF="doc-index-B.html"+>B</A+></TD+><TD+><A HREF="doc-index-C.html"+>C</A+></TD+><TD+><A HREF="doc-index-D.html"+>D</A+></TD+><TD+><A HREF="doc-index-E.html"+>E</A+></TD+><TD+><A HREF="doc-index-F.html"+>F</A+></TD+><TD+><A HREF="doc-index-I.html"+>I</A+></TD+><TD+><A HREF="doc-index-J.html"+>J</A+></TD+><TD+><A HREF="doc-index-L.html"+>L</A+></TD+><TD+><A HREF="doc-index-M.html"+>M</A+></TD+><TD+><A HREF="doc-index-N.html"+>N</A+></TD+><TD+><A HREF="doc-index-O.html"+>O</A+></TD+><TD+><A HREF="doc-index-P.html"+>P</A+></TD+><TD+><A HREF="doc-index-R.html"+>R</A+></TD+><TD+><A HREF="doc-index-S.html"+>S</A+></TD+><TD+><A HREF="doc-index-T.html"+>T</A+></TD+><TD+><A HREF="doc-index-U.html"+>U</A+></TD+><TD+><A HREF="doc-index-W.html"+>W</A+></TD+><TD+><A HREF="doc-index-43.html"+>+</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="section1"+>Index (D)</TD+></TR+><TR+><TD+><TABLE CELLPADDING="0" CELLSPACING="5"+><TR+><TD CLASS="indexentry"+>digit</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-HuttonMeijer.html#v%3Adigit"+>Text.ParserCombinators.HuttonMeijer</A+></TD+></TR+><TR+><TD CLASS="indexentry" COLSPAN="2"+>discard</TD+></TR+><TR+><TD CLASS="indexannot"+>1 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-Poly.html#v%3Adiscard"+>Text.ParserCombinators.Poly</A+>, Text.Parse</TD+></TR+><TR+><TD CLASS="indexannot"+>2 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-PolyLazy.html#v%3Adiscard"+>Text.ParserCombinators.PolyLazy</A+></TD+></TR+><TR+><TD CLASS="indexannot"+>3 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-PolyState.html#v%3Adiscard"+>Text.ParserCombinators.PolyState</A+></TD+></TR+><TR+><TD CLASS="indexannot"+>4 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-PolyStateLazy.html#v%3Adiscard"+>Text.ParserCombinators.PolyStateLazy</A+></TD+></TR+></TABLE+></TD+></TR+></TABLE+></BODY+></HTML+>
+ docs/haddock/doc-index-E.html view
@@ -0,0 +1,154 @@+<!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"+></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+><TABLE CELLPADDING="0" CELLSPACING="5"+><TR+><TD+><A HREF="doc-index-A.html"+>A</A+></TD+><TD+><A HREF="doc-index-B.html"+>B</A+></TD+><TD+><A HREF="doc-index-C.html"+>C</A+></TD+><TD+><A HREF="doc-index-D.html"+>D</A+></TD+><TD+><A HREF="doc-index-E.html"+>E</A+></TD+><TD+><A HREF="doc-index-F.html"+>F</A+></TD+><TD+><A HREF="doc-index-I.html"+>I</A+></TD+><TD+><A HREF="doc-index-J.html"+>J</A+></TD+><TD+><A HREF="doc-index-L.html"+>L</A+></TD+><TD+><A HREF="doc-index-M.html"+>M</A+></TD+><TD+><A HREF="doc-index-N.html"+>N</A+></TD+><TD+><A HREF="doc-index-O.html"+>O</A+></TD+><TD+><A HREF="doc-index-P.html"+>P</A+></TD+><TD+><A HREF="doc-index-R.html"+>R</A+></TD+><TD+><A HREF="doc-index-S.html"+>S</A+></TD+><TD+><A HREF="doc-index-T.html"+>T</A+></TD+><TD+><A HREF="doc-index-U.html"+>U</A+></TD+><TD+><A HREF="doc-index-W.html"+>W</A+></TD+><TD+><A HREF="doc-index-43.html"+>+</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="section1"+>Index (E)</TD+></TR+><TR+><TD+><TABLE CELLPADDING="0" CELLSPACING="5"+><TR+><TD CLASS="indexentry"+>elserror</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#v%3Aelserror"+>Text.ParserCombinators.HuttonMeijerWallace</A+></TD+></TR+><TR+><TD CLASS="indexentry"+>enumeration</TD+><TD CLASS="indexlinks"+><A HREF="Text-Parse.html#v%3Aenumeration"+>Text.Parse</A+></TD+></TR+><TR+><TD CLASS="indexentry"+>eof</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#v%3Aeof"+>Text.ParserCombinators.HuttonMeijerWallace</A+></TD+></TR+></TABLE+></TD+></TR+></TABLE+></BODY+></HTML+>
+ docs/haddock/doc-index-F.html view
@@ -0,0 +1,182 @@+<!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"+></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+><TABLE CELLPADDING="0" CELLSPACING="5"+><TR+><TD+><A HREF="doc-index-A.html"+>A</A+></TD+><TD+><A HREF="doc-index-B.html"+>B</A+></TD+><TD+><A HREF="doc-index-C.html"+>C</A+></TD+><TD+><A HREF="doc-index-D.html"+>D</A+></TD+><TD+><A HREF="doc-index-E.html"+>E</A+></TD+><TD+><A HREF="doc-index-F.html"+>F</A+></TD+><TD+><A HREF="doc-index-I.html"+>I</A+></TD+><TD+><A HREF="doc-index-J.html"+>J</A+></TD+><TD+><A HREF="doc-index-L.html"+>L</A+></TD+><TD+><A HREF="doc-index-M.html"+>M</A+></TD+><TD+><A HREF="doc-index-N.html"+>N</A+></TD+><TD+><A HREF="doc-index-O.html"+>O</A+></TD+><TD+><A HREF="doc-index-P.html"+>P</A+></TD+><TD+><A HREF="doc-index-R.html"+>R</A+></TD+><TD+><A HREF="doc-index-S.html"+>S</A+></TD+><TD+><A HREF="doc-index-T.html"+>T</A+></TD+><TD+><A HREF="doc-index-U.html"+>U</A+></TD+><TD+><A HREF="doc-index-W.html"+>W</A+></TD+><TD+><A HREF="doc-index-43.html"+>+</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="section1"+>Index (F)</TD+></TR+><TR+><TD+><TABLE CELLPADDING="0" CELLSPACING="5"+><TR+><TD CLASS="indexentry" COLSPAN="2"+>failBad</TD+></TR+><TR+><TD CLASS="indexannot"+>1 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-Poly.html#v%3AfailBad"+>Text.ParserCombinators.Poly</A+>, Text.Parse</TD+></TR+><TR+><TD CLASS="indexannot"+>2 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-PolyLazy.html#v%3AfailBad"+>Text.ParserCombinators.PolyLazy</A+></TD+></TR+><TR+><TD CLASS="indexannot"+>3 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-PolyState.html#v%3AfailBad"+>Text.ParserCombinators.PolyState</A+></TD+></TR+><TR+><TD CLASS="indexannot"+>4 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-PolyStateLazy.html#v%3AfailBad"+>Text.ParserCombinators.PolyStateLazy</A+></TD+></TR+><TR+><TD CLASS="indexentry"+>field</TD+><TD CLASS="indexlinks"+><A HREF="Text-Parse.html#v%3Afield"+>Text.Parse</A+></TD+></TR+><TR+><TD CLASS="indexentry"+>first</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-HuttonMeijer.html#v%3Afirst"+>Text.ParserCombinators.HuttonMeijer</A+></TD+></TR+></TABLE+></TD+></TR+></TABLE+></BODY+></HTML+>
+ docs/haddock/doc-index-I.html view
@@ -0,0 +1,226 @@+<!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"+></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+><TABLE CELLPADDING="0" CELLSPACING="5"+><TR+><TD+><A HREF="doc-index-A.html"+>A</A+></TD+><TD+><A HREF="doc-index-B.html"+>B</A+></TD+><TD+><A HREF="doc-index-C.html"+>C</A+></TD+><TD+><A HREF="doc-index-D.html"+>D</A+></TD+><TD+><A HREF="doc-index-E.html"+>E</A+></TD+><TD+><A HREF="doc-index-F.html"+>F</A+></TD+><TD+><A HREF="doc-index-I.html"+>I</A+></TD+><TD+><A HREF="doc-index-J.html"+>J</A+></TD+><TD+><A HREF="doc-index-L.html"+>L</A+></TD+><TD+><A HREF="doc-index-M.html"+>M</A+></TD+><TD+><A HREF="doc-index-N.html"+>N</A+></TD+><TD+><A HREF="doc-index-O.html"+>O</A+></TD+><TD+><A HREF="doc-index-P.html"+>P</A+></TD+><TD+><A HREF="doc-index-R.html"+>R</A+></TD+><TD+><A HREF="doc-index-S.html"+>S</A+></TD+><TD+><A HREF="doc-index-T.html"+>T</A+></TD+><TD+><A HREF="doc-index-U.html"+>U</A+></TD+><TD+><A HREF="doc-index-W.html"+>W</A+></TD+><TD+><A HREF="doc-index-43.html"+>+</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="section1"+>Index (I)</TD+></TR+><TR+><TD+><TABLE CELLPADDING="0" CELLSPACING="5"+><TR+><TD CLASS="indexentry"+>ident</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-HuttonMeijer.html#v%3Aident"+>Text.ParserCombinators.HuttonMeijer</A+></TD+></TR+><TR+><TD CLASS="indexentry"+>identifier</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-HuttonMeijer.html#v%3Aidentifier"+>Text.ParserCombinators.HuttonMeijer</A+></TD+></TR+><TR+><TD CLASS="indexentry" COLSPAN="2"+>indent</TD+></TR+><TR+><TD CLASS="indexannot"+>1 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-Poly.html#v%3Aindent"+>Text.ParserCombinators.Poly</A+>, Text.Parse</TD+></TR+><TR+><TD CLASS="indexannot"+>2 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-PolyLazy.html#v%3Aindent"+>Text.ParserCombinators.PolyLazy</A+></TD+></TR+><TR+><TD CLASS="indexannot"+>3 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-PolyState.html#v%3Aindent"+>Text.ParserCombinators.PolyState</A+></TD+></TR+><TR+><TD CLASS="indexannot"+>4 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-PolyStateLazy.html#v%3Aindent"+>Text.ParserCombinators.PolyStateLazy</A+></TD+></TR+><TR+><TD CLASS="indexentry"+>int</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-HuttonMeijer.html#v%3Aint"+>Text.ParserCombinators.HuttonMeijer</A+></TD+></TR+><TR+><TD CLASS="indexentry"+>integer</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-HuttonMeijer.html#v%3Ainteger"+>Text.ParserCombinators.HuttonMeijer</A+></TD+></TR+><TR+><TD CLASS="indexentry"+>isWord</TD+><TD CLASS="indexlinks"+><A HREF="Text-Parse.html#v%3AisWord"+>Text.Parse</A+></TD+></TR+><TR+><TD CLASS="indexentry" COLSPAN="2"+>item</TD+></TR+><TR+><TD CLASS="indexannot"+>1 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-HuttonMeijer.html#v%3Aitem"+>Text.ParserCombinators.HuttonMeijer</A+></TD+></TR+><TR+><TD CLASS="indexannot"+>2 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#v%3Aitem"+>Text.ParserCombinators.HuttonMeijerWallace</A+></TD+></TR+></TABLE+></TD+></TR+></TABLE+></BODY+></HTML+>
+ docs/haddock/doc-index-J.html view
@@ -0,0 +1,138 @@+<!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"+></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+><TABLE CELLPADDING="0" CELLSPACING="5"+><TR+><TD+><A HREF="doc-index-A.html"+>A</A+></TD+><TD+><A HREF="doc-index-B.html"+>B</A+></TD+><TD+><A HREF="doc-index-C.html"+>C</A+></TD+><TD+><A HREF="doc-index-D.html"+>D</A+></TD+><TD+><A HREF="doc-index-E.html"+>E</A+></TD+><TD+><A HREF="doc-index-F.html"+>F</A+></TD+><TD+><A HREF="doc-index-I.html"+>I</A+></TD+><TD+><A HREF="doc-index-J.html"+>J</A+></TD+><TD+><A HREF="doc-index-L.html"+>L</A+></TD+><TD+><A HREF="doc-index-M.html"+>M</A+></TD+><TD+><A HREF="doc-index-N.html"+>N</A+></TD+><TD+><A HREF="doc-index-O.html"+>O</A+></TD+><TD+><A HREF="doc-index-P.html"+>P</A+></TD+><TD+><A HREF="doc-index-R.html"+>R</A+></TD+><TD+><A HREF="doc-index-S.html"+>S</A+></TD+><TD+><A HREF="doc-index-T.html"+>T</A+></TD+><TD+><A HREF="doc-index-U.html"+>U</A+></TD+><TD+><A HREF="doc-index-W.html"+>W</A+></TD+><TD+><A HREF="doc-index-43.html"+>+</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="section1"+>Index (J)</TD+></TR+><TR+><TD+><TABLE CELLPADDING="0" CELLSPACING="5"+><TR+><TD CLASS="indexentry"+>junk</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-HuttonMeijer.html#v%3Ajunk"+>Text.ParserCombinators.HuttonMeijer</A+></TD+></TR+></TABLE+></TD+></TR+></TABLE+></BODY+></HTML+>
+ docs/haddock/doc-index-L.html view
@@ -0,0 +1,146 @@+<!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"+></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+><TABLE CELLPADDING="0" CELLSPACING="5"+><TR+><TD+><A HREF="doc-index-A.html"+>A</A+></TD+><TD+><A HREF="doc-index-B.html"+>B</A+></TD+><TD+><A HREF="doc-index-C.html"+>C</A+></TD+><TD+><A HREF="doc-index-D.html"+>D</A+></TD+><TD+><A HREF="doc-index-E.html"+>E</A+></TD+><TD+><A HREF="doc-index-F.html"+>F</A+></TD+><TD+><A HREF="doc-index-I.html"+>I</A+></TD+><TD+><A HREF="doc-index-J.html"+>J</A+></TD+><TD+><A HREF="doc-index-L.html"+>L</A+></TD+><TD+><A HREF="doc-index-M.html"+>M</A+></TD+><TD+><A HREF="doc-index-N.html"+>N</A+></TD+><TD+><A HREF="doc-index-O.html"+>O</A+></TD+><TD+><A HREF="doc-index-P.html"+>P</A+></TD+><TD+><A HREF="doc-index-R.html"+>R</A+></TD+><TD+><A HREF="doc-index-S.html"+>S</A+></TD+><TD+><A HREF="doc-index-T.html"+>T</A+></TD+><TD+><A HREF="doc-index-U.html"+>U</A+></TD+><TD+><A HREF="doc-index-W.html"+>W</A+></TD+><TD+><A HREF="doc-index-43.html"+>+</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="section1"+>Index (L)</TD+></TR+><TR+><TD+><TABLE CELLPADDING="0" CELLSPACING="5"+><TR+><TD CLASS="indexentry"+>letter</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-HuttonMeijer.html#v%3Aletter"+>Text.ParserCombinators.HuttonMeijer</A+></TD+></TR+><TR+><TD CLASS="indexentry"+>lower</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-HuttonMeijer.html#v%3Alower"+>Text.ParserCombinators.HuttonMeijer</A+></TD+></TR+></TABLE+></TD+></TR+></TABLE+></BODY+></HTML+>
+ docs/haddock/doc-index-M.html view
@@ -0,0 +1,270 @@+<!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"+></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+><TABLE CELLPADDING="0" CELLSPACING="5"+><TR+><TD+><A HREF="doc-index-A.html"+>A</A+></TD+><TD+><A HREF="doc-index-B.html"+>B</A+></TD+><TD+><A HREF="doc-index-C.html"+>C</A+></TD+><TD+><A HREF="doc-index-D.html"+>D</A+></TD+><TD+><A HREF="doc-index-E.html"+>E</A+></TD+><TD+><A HREF="doc-index-F.html"+>F</A+></TD+><TD+><A HREF="doc-index-I.html"+>I</A+></TD+><TD+><A HREF="doc-index-J.html"+>J</A+></TD+><TD+><A HREF="doc-index-L.html"+>L</A+></TD+><TD+><A HREF="doc-index-M.html"+>M</A+></TD+><TD+><A HREF="doc-index-N.html"+>N</A+></TD+><TD+><A HREF="doc-index-O.html"+>O</A+></TD+><TD+><A HREF="doc-index-P.html"+>P</A+></TD+><TD+><A HREF="doc-index-R.html"+>R</A+></TD+><TD+><A HREF="doc-index-S.html"+>S</A+></TD+><TD+><A HREF="doc-index-T.html"+>T</A+></TD+><TD+><A HREF="doc-index-U.html"+>U</A+></TD+><TD+><A HREF="doc-index-W.html"+>W</A+></TD+><TD+><A HREF="doc-index-43.html"+>+</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="section1"+>Index (M)</TD+></TR+><TR+><TD+><TABLE CELLPADDING="0" CELLSPACING="5"+><TR+><TD CLASS="indexentry" COLSPAN="2"+>many</TD+></TR+><TR+><TD CLASS="indexannot"+>1 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-HuttonMeijer.html#v%3Amany"+>Text.ParserCombinators.HuttonMeijer</A+></TD+></TR+><TR+><TD CLASS="indexannot"+>2 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#v%3Amany"+>Text.ParserCombinators.HuttonMeijerWallace</A+></TD+></TR+><TR+><TD CLASS="indexannot"+>3 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-Poly.html#v%3Amany"+>Text.ParserCombinators.Poly</A+>, Text.Parse</TD+></TR+><TR+><TD CLASS="indexannot"+>4 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-PolyLazy.html#v%3Amany"+>Text.ParserCombinators.PolyLazy</A+></TD+></TR+><TR+><TD CLASS="indexannot"+>5 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-PolyState.html#v%3Amany"+>Text.ParserCombinators.PolyState</A+></TD+></TR+><TR+><TD CLASS="indexannot"+>6 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-PolyStateLazy.html#v%3Amany"+>Text.ParserCombinators.PolyStateLazy</A+></TD+></TR+><TR+><TD CLASS="indexentry" COLSPAN="2"+>many1</TD+></TR+><TR+><TD CLASS="indexannot"+>1 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-HuttonMeijer.html#v%3Amany1"+>Text.ParserCombinators.HuttonMeijer</A+></TD+></TR+><TR+><TD CLASS="indexannot"+>2 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#v%3Amany1"+>Text.ParserCombinators.HuttonMeijerWallace</A+></TD+></TR+><TR+><TD CLASS="indexannot"+>3 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-Poly.html#v%3Amany1"+>Text.ParserCombinators.Poly</A+>, Text.Parse</TD+></TR+><TR+><TD CLASS="indexannot"+>4 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-PolyLazy.html#v%3Amany1"+>Text.ParserCombinators.PolyLazy</A+></TD+></TR+><TR+><TD CLASS="indexannot"+>5 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-PolyState.html#v%3Amany1"+>Text.ParserCombinators.PolyState</A+></TD+></TR+><TR+><TD CLASS="indexannot"+>6 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-PolyStateLazy.html#v%3Amany1"+>Text.ParserCombinators.PolyStateLazy</A+></TD+></TR+><TR+><TD CLASS="indexentry" COLSPAN="2"+>manyFinally</TD+></TR+><TR+><TD CLASS="indexannot"+>1 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-Poly.html#v%3AmanyFinally"+>Text.ParserCombinators.Poly</A+>, Text.Parse</TD+></TR+><TR+><TD CLASS="indexannot"+>2 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-PolyLazy.html#v%3AmanyFinally"+>Text.ParserCombinators.PolyLazy</A+></TD+></TR+><TR+><TD CLASS="indexannot"+>3 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-PolyState.html#v%3AmanyFinally"+>Text.ParserCombinators.PolyState</A+></TD+></TR+><TR+><TD CLASS="indexannot"+>4 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-PolyStateLazy.html#v%3AmanyFinally"+>Text.ParserCombinators.PolyStateLazy</A+></TD+></TR+></TABLE+></TD+></TR+></TABLE+></BODY+></HTML+>
+ docs/haddock/doc-index-N.html view
@@ -0,0 +1,190 @@+<!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"+></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+><TABLE CELLPADDING="0" CELLSPACING="5"+><TR+><TD+><A HREF="doc-index-A.html"+>A</A+></TD+><TD+><A HREF="doc-index-B.html"+>B</A+></TD+><TD+><A HREF="doc-index-C.html"+>C</A+></TD+><TD+><A HREF="doc-index-D.html"+>D</A+></TD+><TD+><A HREF="doc-index-E.html"+>E</A+></TD+><TD+><A HREF="doc-index-F.html"+>F</A+></TD+><TD+><A HREF="doc-index-I.html"+>I</A+></TD+><TD+><A HREF="doc-index-J.html"+>J</A+></TD+><TD+><A HREF="doc-index-L.html"+>L</A+></TD+><TD+><A HREF="doc-index-M.html"+>M</A+></TD+><TD+><A HREF="doc-index-N.html"+>N</A+></TD+><TD+><A HREF="doc-index-O.html"+>O</A+></TD+><TD+><A HREF="doc-index-P.html"+>P</A+></TD+><TD+><A HREF="doc-index-R.html"+>R</A+></TD+><TD+><A HREF="doc-index-S.html"+>S</A+></TD+><TD+><A HREF="doc-index-T.html"+>T</A+></TD+><TD+><A HREF="doc-index-U.html"+>U</A+></TD+><TD+><A HREF="doc-index-W.html"+>W</A+></TD+><TD+><A HREF="doc-index-43.html"+>+</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="section1"+>Index (N)</TD+></TR+><TR+><TD+><TABLE CELLPADDING="0" CELLSPACING="5"+><TR+><TD CLASS="indexentry"+>nat</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-HuttonMeijer.html#v%3Anat"+>Text.ParserCombinators.HuttonMeijer</A+></TD+></TR+><TR+><TD CLASS="indexentry"+>natural</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-HuttonMeijer.html#v%3Anatural"+>Text.ParserCombinators.HuttonMeijer</A+></TD+></TR+><TR+><TD CLASS="indexentry" COLSPAN="2"+>next</TD+></TR+><TR+><TD CLASS="indexannot"+>1 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-Poly.html#v%3Anext"+>Text.ParserCombinators.Poly</A+>, Text.Parse</TD+></TR+><TR+><TD CLASS="indexannot"+>2 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-PolyLazy.html#v%3Anext"+>Text.ParserCombinators.PolyLazy</A+></TD+></TR+><TR+><TD CLASS="indexannot"+>3 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-PolyState.html#v%3Anext"+>Text.ParserCombinators.PolyState</A+></TD+></TR+><TR+><TD CLASS="indexannot"+>4 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-PolyStateLazy.html#v%3Anext"+>Text.ParserCombinators.PolyStateLazy</A+></TD+></TR+><TR+><TD CLASS="indexentry"+>nottok</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#v%3Anottok"+>Text.ParserCombinators.HuttonMeijerWallace</A+></TD+></TR+></TABLE+></TD+></TR+></TABLE+></BODY+></HTML+>
+ docs/haddock/doc-index-O.html view
@@ -0,0 +1,294 @@+<!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"+></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+><TABLE CELLPADDING="0" CELLSPACING="5"+><TR+><TD+><A HREF="doc-index-A.html"+>A</A+></TD+><TD+><A HREF="doc-index-B.html"+>B</A+></TD+><TD+><A HREF="doc-index-C.html"+>C</A+></TD+><TD+><A HREF="doc-index-D.html"+>D</A+></TD+><TD+><A HREF="doc-index-E.html"+>E</A+></TD+><TD+><A HREF="doc-index-F.html"+>F</A+></TD+><TD+><A HREF="doc-index-I.html"+>I</A+></TD+><TD+><A HREF="doc-index-J.html"+>J</A+></TD+><TD+><A HREF="doc-index-L.html"+>L</A+></TD+><TD+><A HREF="doc-index-M.html"+>M</A+></TD+><TD+><A HREF="doc-index-N.html"+>N</A+></TD+><TD+><A HREF="doc-index-O.html"+>O</A+></TD+><TD+><A HREF="doc-index-P.html"+>P</A+></TD+><TD+><A HREF="doc-index-R.html"+>R</A+></TD+><TD+><A HREF="doc-index-S.html"+>S</A+></TD+><TD+><A HREF="doc-index-T.html"+>T</A+></TD+><TD+><A HREF="doc-index-U.html"+>U</A+></TD+><TD+><A HREF="doc-index-W.html"+>W</A+></TD+><TD+><A HREF="doc-index-43.html"+>+</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="section1"+>Index (O)</TD+></TR+><TR+><TD+><TABLE CELLPADDING="0" CELLSPACING="5"+><TR+><TD CLASS="indexentry" COLSPAN="2"+>onFail</TD+></TR+><TR+><TD CLASS="indexannot"+>1 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-Poly.html#v%3AonFail"+>Text.ParserCombinators.Poly</A+>, Text.Parse</TD+></TR+><TR+><TD CLASS="indexannot"+>2 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-PolyLazy.html#v%3AonFail"+>Text.ParserCombinators.PolyLazy</A+></TD+></TR+><TR+><TD CLASS="indexannot"+>3 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-PolyState.html#v%3AonFail"+>Text.ParserCombinators.PolyState</A+></TD+></TR+><TR+><TD CLASS="indexannot"+>4 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-PolyStateLazy.html#v%3AonFail"+>Text.ParserCombinators.PolyStateLazy</A+></TD+></TR+><TR+><TD CLASS="indexentry" COLSPAN="2"+>oneOf</TD+></TR+><TR+><TD CLASS="indexannot"+>1 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-Poly.html#v%3AoneOf"+>Text.ParserCombinators.Poly</A+>, Text.Parse</TD+></TR+><TR+><TD CLASS="indexannot"+>2 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-PolyLazy.html#v%3AoneOf"+>Text.ParserCombinators.PolyLazy</A+></TD+></TR+><TR+><TD CLASS="indexannot"+>3 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-PolyState.html#v%3AoneOf"+>Text.ParserCombinators.PolyState</A+></TD+></TR+><TR+><TD CLASS="indexannot"+>4 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-PolyStateLazy.html#v%3AoneOf"+>Text.ParserCombinators.PolyStateLazy</A+></TD+></TR+><TR+><TD CLASS="indexentry" COLSPAN="2"+>oneOf'</TD+></TR+><TR+><TD CLASS="indexannot"+>1 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-Poly.html#v%3AoneOf%27"+>Text.ParserCombinators.Poly</A+>, Text.Parse</TD+></TR+><TR+><TD CLASS="indexannot"+>2 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-PolyLazy.html#v%3AoneOf%27"+>Text.ParserCombinators.PolyLazy</A+></TD+></TR+><TR+><TD CLASS="indexannot"+>3 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-PolyState.html#v%3AoneOf%27"+>Text.ParserCombinators.PolyState</A+></TD+></TR+><TR+><TD CLASS="indexannot"+>4 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-PolyStateLazy.html#v%3AoneOf%27"+>Text.ParserCombinators.PolyStateLazy</A+></TD+></TR+><TR+><TD CLASS="indexentry" COLSPAN="2"+>ops</TD+></TR+><TR+><TD CLASS="indexannot"+>1 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-HuttonMeijer.html#v%3Aops"+>Text.ParserCombinators.HuttonMeijer</A+></TD+></TR+><TR+><TD CLASS="indexannot"+>2 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#v%3Aops"+>Text.ParserCombinators.HuttonMeijerWallace</A+></TD+></TR+><TR+><TD CLASS="indexentry" COLSPAN="2"+>optional</TD+></TR+><TR+><TD CLASS="indexannot"+>1 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-Poly.html#v%3Aoptional"+>Text.ParserCombinators.Poly</A+>, Text.Parse</TD+></TR+><TR+><TD CLASS="indexannot"+>2 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-PolyLazy.html#v%3Aoptional"+>Text.ParserCombinators.PolyLazy</A+></TD+></TR+><TR+><TD CLASS="indexannot"+>3 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-PolyStateLazy.html#v%3Aoptional"+>Text.ParserCombinators.PolyStateLazy</A+></TD+></TR+><TR+><TD CLASS="indexentry"+>optionalParens</TD+><TD CLASS="indexlinks"+><A HREF="Text-Parse.html#v%3AoptionalParens"+>Text.Parse</A+></TD+></TR+></TABLE+></TD+></TR+></TABLE+></BODY+></HTML+>
+ docs/haddock/doc-index-P.html view
@@ -0,0 +1,294 @@+<!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"+></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+><TABLE CELLPADDING="0" CELLSPACING="5"+><TR+><TD+><A HREF="doc-index-A.html"+>A</A+></TD+><TD+><A HREF="doc-index-B.html"+>B</A+></TD+><TD+><A HREF="doc-index-C.html"+>C</A+></TD+><TD+><A HREF="doc-index-D.html"+>D</A+></TD+><TD+><A HREF="doc-index-E.html"+>E</A+></TD+><TD+><A HREF="doc-index-F.html"+>F</A+></TD+><TD+><A HREF="doc-index-I.html"+>I</A+></TD+><TD+><A HREF="doc-index-J.html"+>J</A+></TD+><TD+><A HREF="doc-index-L.html"+>L</A+></TD+><TD+><A HREF="doc-index-M.html"+>M</A+></TD+><TD+><A HREF="doc-index-N.html"+>N</A+></TD+><TD+><A HREF="doc-index-O.html"+>O</A+></TD+><TD+><A HREF="doc-index-P.html"+>P</A+></TD+><TD+><A HREF="doc-index-R.html"+>R</A+></TD+><TD+><A HREF="doc-index-S.html"+>S</A+></TD+><TD+><A HREF="doc-index-T.html"+>T</A+></TD+><TD+><A HREF="doc-index-U.html"+>U</A+></TD+><TD+><A HREF="doc-index-W.html"+>W</A+></TD+><TD+><A HREF="doc-index-43.html"+>+</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="section1"+>Index (P)</TD+></TR+><TR+><TD+><TABLE CELLPADDING="0" CELLSPACING="5"+><TR+><TD CLASS="indexentry" COLSPAN="2"+>P</TD+></TR+><TR+><TD CLASS="indexannot"+>1 (Data Constructor)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-HuttonMeijer.html#v%3AP"+>Text.ParserCombinators.HuttonMeijer</A+></TD+></TR+><TR+><TD CLASS="indexannot"+>2 (Data Constructor)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#v%3AP"+>Text.ParserCombinators.HuttonMeijerWallace</A+></TD+></TR+><TR+><TD CLASS="indexannot"+>3 (Data Constructor)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-Poly.html#v%3AP"+>Text.ParserCombinators.Poly</A+>, Text.Parse</TD+></TR+><TR+><TD CLASS="indexannot"+>4 (Data Constructor)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-PolyLazy.html#v%3AP"+>Text.ParserCombinators.PolyLazy</A+></TD+></TR+><TR+><TD CLASS="indexannot"+>5 (Data Constructor)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-PolyState.html#v%3AP"+>Text.ParserCombinators.PolyState</A+></TD+></TR+><TR+><TD CLASS="indexannot"+>6 (Data Constructor)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-PolyStateLazy.html#v%3AP"+>Text.ParserCombinators.PolyStateLazy</A+></TD+></TR+><TR+><TD CLASS="indexentry"+>Parse</TD+><TD CLASS="indexlinks"+><A HREF="Text-Parse.html#t%3AParse"+>Text.Parse</A+></TD+></TR+><TR+><TD CLASS="indexentry" COLSPAN="2"+>Parser</TD+></TR+><TR+><TD CLASS="indexannot"+>1 (Type/Class)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-HuttonMeijer.html#t%3AParser"+>Text.ParserCombinators.HuttonMeijer</A+></TD+></TR+><TR+><TD CLASS="indexannot"+>2 (Type/Class)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#t%3AParser"+>Text.ParserCombinators.HuttonMeijerWallace</A+></TD+></TR+><TR+><TD CLASS="indexannot"+>3 (Type/Class)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-Poly.html#t%3AParser"+>Text.ParserCombinators.Poly</A+>, Text.Parse</TD+></TR+><TR+><TD CLASS="indexannot"+>4 (Type/Class)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-PolyLazy.html#t%3AParser"+>Text.ParserCombinators.PolyLazy</A+></TD+></TR+><TR+><TD CLASS="indexannot"+>5 (Type/Class)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-PolyState.html#t%3AParser"+>Text.ParserCombinators.PolyState</A+></TD+></TR+><TR+><TD CLASS="indexannot"+>6 (Type/Class)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-PolyStateLazy.html#t%3AParser"+>Text.ParserCombinators.PolyStateLazy</A+></TD+></TR+><TR+><TD CLASS="indexentry" COLSPAN="2"+>papply</TD+></TR+><TR+><TD CLASS="indexannot"+>1 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-HuttonMeijer.html#v%3Apapply"+>Text.ParserCombinators.HuttonMeijer</A+></TD+></TR+><TR+><TD CLASS="indexannot"+>2 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#v%3Apapply"+>Text.ParserCombinators.HuttonMeijerWallace</A+></TD+></TR+><TR+><TD CLASS="indexentry"+>papply'</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#v%3Apapply%27"+>Text.ParserCombinators.HuttonMeijerWallace</A+></TD+></TR+><TR+><TD CLASS="indexentry"+>parse</TD+><TD CLASS="indexlinks"+><A HREF="Text-Parse.html#v%3Aparse"+>Text.Parse</A+></TD+></TR+><TR+><TD CLASS="indexentry"+>parseByRead</TD+><TD CLASS="indexlinks"+><A HREF="Text-Parse.html#v%3AparseByRead"+>Text.Parse</A+></TD+></TR+><TR+><TD CLASS="indexentry"+>parseList</TD+><TD CLASS="indexlinks"+><A HREF="Text-Parse.html#v%3AparseList"+>Text.Parse</A+></TD+></TR+></TABLE+></TD+></TR+></TABLE+></BODY+></HTML+>
+ docs/haddock/doc-index-R.html view
@@ -0,0 +1,210 @@+<!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"+></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+><TABLE CELLPADDING="0" CELLSPACING="5"+><TR+><TD+><A HREF="doc-index-A.html"+>A</A+></TD+><TD+><A HREF="doc-index-B.html"+>B</A+></TD+><TD+><A HREF="doc-index-C.html"+>C</A+></TD+><TD+><A HREF="doc-index-D.html"+>D</A+></TD+><TD+><A HREF="doc-index-E.html"+>E</A+></TD+><TD+><A HREF="doc-index-F.html"+>F</A+></TD+><TD+><A HREF="doc-index-I.html"+>I</A+></TD+><TD+><A HREF="doc-index-J.html"+>J</A+></TD+><TD+><A HREF="doc-index-L.html"+>L</A+></TD+><TD+><A HREF="doc-index-M.html"+>M</A+></TD+><TD+><A HREF="doc-index-N.html"+>N</A+></TD+><TD+><A HREF="doc-index-O.html"+>O</A+></TD+><TD+><A HREF="doc-index-P.html"+>P</A+></TD+><TD+><A HREF="doc-index-R.html"+>R</A+></TD+><TD+><A HREF="doc-index-S.html"+>S</A+></TD+><TD+><A HREF="doc-index-T.html"+>T</A+></TD+><TD+><A HREF="doc-index-U.html"+>U</A+></TD+><TD+><A HREF="doc-index-W.html"+>W</A+></TD+><TD+><A HREF="doc-index-43.html"+>+</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="section1"+>Index (R)</TD+></TR+><TR+><TD+><TABLE CELLPADDING="0" CELLSPACING="5"+><TR+><TD CLASS="indexentry" COLSPAN="2"+>reparse</TD+></TR+><TR+><TD CLASS="indexannot"+>1 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#v%3Areparse"+>Text.ParserCombinators.HuttonMeijerWallace</A+></TD+></TR+><TR+><TD CLASS="indexannot"+>2 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-Poly.html#v%3Areparse"+>Text.ParserCombinators.Poly</A+>, Text.Parse</TD+></TR+><TR+><TD CLASS="indexannot"+>3 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-PolyLazy.html#v%3Areparse"+>Text.ParserCombinators.PolyLazy</A+></TD+></TR+><TR+><TD CLASS="indexannot"+>4 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-PolyState.html#v%3Areparse"+>Text.ParserCombinators.PolyState</A+></TD+></TR+><TR+><TD CLASS="indexannot"+>5 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-PolyStateLazy.html#v%3Areparse"+>Text.ParserCombinators.PolyStateLazy</A+></TD+></TR+><TR+><TD CLASS="indexentry" COLSPAN="2"+>runParser</TD+></TR+><TR+><TD CLASS="indexannot"+>1 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-Poly.html#v%3ArunParser"+>Text.ParserCombinators.Poly</A+>, Text.Parse</TD+></TR+><TR+><TD CLASS="indexannot"+>2 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-PolyLazy.html#v%3ArunParser"+>Text.ParserCombinators.PolyLazy</A+></TD+></TR+><TR+><TD CLASS="indexannot"+>3 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-PolyState.html#v%3ArunParser"+>Text.ParserCombinators.PolyState</A+></TD+></TR+><TR+><TD CLASS="indexannot"+>4 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-PolyStateLazy.html#v%3ArunParser"+>Text.ParserCombinators.PolyStateLazy</A+></TD+></TR+></TABLE+></TD+></TR+></TABLE+></BODY+></HTML+>
+ docs/haddock/doc-index-S.html view
@@ -0,0 +1,402 @@+<!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"+></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+><TABLE CELLPADDING="0" CELLSPACING="5"+><TR+><TD+><A HREF="doc-index-A.html"+>A</A+></TD+><TD+><A HREF="doc-index-B.html"+>B</A+></TD+><TD+><A HREF="doc-index-C.html"+>C</A+></TD+><TD+><A HREF="doc-index-D.html"+>D</A+></TD+><TD+><A HREF="doc-index-E.html"+>E</A+></TD+><TD+><A HREF="doc-index-F.html"+>F</A+></TD+><TD+><A HREF="doc-index-I.html"+>I</A+></TD+><TD+><A HREF="doc-index-J.html"+>J</A+></TD+><TD+><A HREF="doc-index-L.html"+>L</A+></TD+><TD+><A HREF="doc-index-M.html"+>M</A+></TD+><TD+><A HREF="doc-index-N.html"+>N</A+></TD+><TD+><A HREF="doc-index-O.html"+>O</A+></TD+><TD+><A HREF="doc-index-P.html"+>P</A+></TD+><TD+><A HREF="doc-index-R.html"+>R</A+></TD+><TD+><A HREF="doc-index-S.html"+>S</A+></TD+><TD+><A HREF="doc-index-T.html"+>T</A+></TD+><TD+><A HREF="doc-index-U.html"+>U</A+></TD+><TD+><A HREF="doc-index-W.html"+>W</A+></TD+><TD+><A HREF="doc-index-43.html"+>+</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="section1"+>Index (S)</TD+></TR+><TR+><TD+><TABLE CELLPADDING="0" CELLSPACING="5"+><TR+><TD CLASS="indexentry"+>sat</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-HuttonMeijer.html#v%3Asat"+>Text.ParserCombinators.HuttonMeijer</A+></TD+></TR+><TR+><TD CLASS="indexentry" COLSPAN="2"+>satisfy</TD+></TR+><TR+><TD CLASS="indexannot"+>1 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-Poly.html#v%3Asatisfy"+>Text.ParserCombinators.Poly</A+>, Text.Parse</TD+></TR+><TR+><TD CLASS="indexannot"+>2 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-PolyLazy.html#v%3Asatisfy"+>Text.ParserCombinators.PolyLazy</A+></TD+></TR+><TR+><TD CLASS="indexannot"+>3 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-PolyState.html#v%3Asatisfy"+>Text.ParserCombinators.PolyState</A+></TD+></TR+><TR+><TD CLASS="indexannot"+>4 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-PolyStateLazy.html#v%3Asatisfy"+>Text.ParserCombinators.PolyStateLazy</A+></TD+></TR+><TR+><TD CLASS="indexentry" COLSPAN="2"+>sepBy</TD+></TR+><TR+><TD CLASS="indexannot"+>1 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-Poly.html#v%3AsepBy"+>Text.ParserCombinators.Poly</A+>, Text.Parse</TD+></TR+><TR+><TD CLASS="indexannot"+>2 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-PolyLazy.html#v%3AsepBy"+>Text.ParserCombinators.PolyLazy</A+></TD+></TR+><TR+><TD CLASS="indexannot"+>3 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-PolyState.html#v%3AsepBy"+>Text.ParserCombinators.PolyState</A+></TD+></TR+><TR+><TD CLASS="indexannot"+>4 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-PolyStateLazy.html#v%3AsepBy"+>Text.ParserCombinators.PolyStateLazy</A+></TD+></TR+><TR+><TD CLASS="indexentry" COLSPAN="2"+>sepBy1</TD+></TR+><TR+><TD CLASS="indexannot"+>1 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-Poly.html#v%3AsepBy1"+>Text.ParserCombinators.Poly</A+>, Text.Parse</TD+></TR+><TR+><TD CLASS="indexannot"+>2 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-PolyLazy.html#v%3AsepBy1"+>Text.ParserCombinators.PolyLazy</A+></TD+></TR+><TR+><TD CLASS="indexannot"+>3 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-PolyState.html#v%3AsepBy1"+>Text.ParserCombinators.PolyState</A+></TD+></TR+><TR+><TD CLASS="indexannot"+>4 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-PolyStateLazy.html#v%3AsepBy1"+>Text.ParserCombinators.PolyStateLazy</A+></TD+></TR+><TR+><TD CLASS="indexentry" COLSPAN="2"+>sepby</TD+></TR+><TR+><TD CLASS="indexannot"+>1 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-HuttonMeijer.html#v%3Asepby"+>Text.ParserCombinators.HuttonMeijer</A+></TD+></TR+><TR+><TD CLASS="indexannot"+>2 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#v%3Asepby"+>Text.ParserCombinators.HuttonMeijerWallace</A+></TD+></TR+><TR+><TD CLASS="indexentry" COLSPAN="2"+>sepby1</TD+></TR+><TR+><TD CLASS="indexannot"+>1 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-HuttonMeijer.html#v%3Asepby1"+>Text.ParserCombinators.HuttonMeijer</A+></TD+></TR+><TR+><TD CLASS="indexannot"+>2 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#v%3Asepby1"+>Text.ParserCombinators.HuttonMeijerWallace</A+></TD+></TR+><TR+><TD CLASS="indexentry"+>skip</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-HuttonMeijer.html#v%3Askip"+>Text.ParserCombinators.HuttonMeijer</A+></TD+></TR+><TR+><TD CLASS="indexentry"+>spaces</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-HuttonMeijer.html#v%3Aspaces"+>Text.ParserCombinators.HuttonMeijer</A+></TD+></TR+><TR+><TD CLASS="indexentry" COLSPAN="2"+>stGet</TD+></TR+><TR+><TD CLASS="indexannot"+>1 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-PolyState.html#v%3AstGet"+>Text.ParserCombinators.PolyState</A+></TD+></TR+><TR+><TD CLASS="indexannot"+>2 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-PolyStateLazy.html#v%3AstGet"+>Text.ParserCombinators.PolyStateLazy</A+></TD+></TR+><TR+><TD CLASS="indexentry" COLSPAN="2"+>stQuery</TD+></TR+><TR+><TD CLASS="indexannot"+>1 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-PolyState.html#v%3AstQuery"+>Text.ParserCombinators.PolyState</A+></TD+></TR+><TR+><TD CLASS="indexannot"+>2 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-PolyStateLazy.html#v%3AstQuery"+>Text.ParserCombinators.PolyStateLazy</A+></TD+></TR+><TR+><TD CLASS="indexentry" COLSPAN="2"+>stUpdate</TD+></TR+><TR+><TD CLASS="indexannot"+>1 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-PolyState.html#v%3AstUpdate"+>Text.ParserCombinators.PolyState</A+></TD+></TR+><TR+><TD CLASS="indexannot"+>2 (Function)</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-PolyStateLazy.html#v%3AstUpdate"+>Text.ParserCombinators.PolyStateLazy</A+></TD+></TR+><TR+><TD CLASS="indexentry"+>stget</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#v%3Astget"+>Text.ParserCombinators.HuttonMeijerWallace</A+></TD+></TR+><TR+><TD CLASS="indexentry"+>stquery</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#v%3Astquery"+>Text.ParserCombinators.HuttonMeijerWallace</A+></TD+></TR+><TR+><TD CLASS="indexentry"+>string</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-HuttonMeijer.html#v%3Astring"+>Text.ParserCombinators.HuttonMeijer</A+></TD+></TR+><TR+><TD CLASS="indexentry"+>stupd</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#v%3Astupd"+>Text.ParserCombinators.HuttonMeijerWallace</A+></TD+></TR+><TR+><TD CLASS="indexentry"+>symbol</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-HuttonMeijer.html#v%3Asymbol"+>Text.ParserCombinators.HuttonMeijer</A+></TD+></TR+></TABLE+></TD+></TR+></TABLE+></BODY+></HTML+>
+ docs/haddock/doc-index-T.html view
@@ -0,0 +1,162 @@+<!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"+></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+><TABLE CELLPADDING="0" CELLSPACING="5"+><TR+><TD+><A HREF="doc-index-A.html"+>A</A+></TD+><TD+><A HREF="doc-index-B.html"+>B</A+></TD+><TD+><A HREF="doc-index-C.html"+>C</A+></TD+><TD+><A HREF="doc-index-D.html"+>D</A+></TD+><TD+><A HREF="doc-index-E.html"+>E</A+></TD+><TD+><A HREF="doc-index-F.html"+>F</A+></TD+><TD+><A HREF="doc-index-I.html"+>I</A+></TD+><TD+><A HREF="doc-index-J.html"+>J</A+></TD+><TD+><A HREF="doc-index-L.html"+>L</A+></TD+><TD+><A HREF="doc-index-M.html"+>M</A+></TD+><TD+><A HREF="doc-index-N.html"+>N</A+></TD+><TD+><A HREF="doc-index-O.html"+>O</A+></TD+><TD+><A HREF="doc-index-P.html"+>P</A+></TD+><TD+><A HREF="doc-index-R.html"+>R</A+></TD+><TD+><A HREF="doc-index-S.html"+>S</A+></TD+><TD+><A HREF="doc-index-T.html"+>T</A+></TD+><TD+><A HREF="doc-index-U.html"+>U</A+></TD+><TD+><A HREF="doc-index-W.html"+>W</A+></TD+><TD+><A HREF="doc-index-43.html"+>+</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="section1"+>Index (T)</TD+></TR+><TR+><TD+><TABLE CELLPADDING="0" CELLSPACING="5"+><TR+><TD CLASS="indexentry"+>TextParser</TD+><TD CLASS="indexlinks"+><A HREF="Text-Parse.html#t%3ATextParser"+>Text.Parse</A+></TD+></TR+><TR+><TD CLASS="indexentry"+>toEOF</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#v%3AtoEOF"+>Text.ParserCombinators.HuttonMeijerWallace</A+></TD+></TR+><TR+><TD CLASS="indexentry"+>tok</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-HuttonMeijerWallace.html#v%3Atok"+>Text.ParserCombinators.HuttonMeijerWallace</A+></TD+></TR+><TR+><TD CLASS="indexentry"+>token</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-HuttonMeijer.html#v%3Atoken"+>Text.ParserCombinators.HuttonMeijer</A+></TD+></TR+></TABLE+></TD+></TR+></TABLE+></BODY+></HTML+>
+ docs/haddock/doc-index-U.html view
@@ -0,0 +1,138 @@+<!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"+></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+><TABLE CELLPADDING="0" CELLSPACING="5"+><TR+><TD+><A HREF="doc-index-A.html"+>A</A+></TD+><TD+><A HREF="doc-index-B.html"+>B</A+></TD+><TD+><A HREF="doc-index-C.html"+>C</A+></TD+><TD+><A HREF="doc-index-D.html"+>D</A+></TD+><TD+><A HREF="doc-index-E.html"+>E</A+></TD+><TD+><A HREF="doc-index-F.html"+>F</A+></TD+><TD+><A HREF="doc-index-I.html"+>I</A+></TD+><TD+><A HREF="doc-index-J.html"+>J</A+></TD+><TD+><A HREF="doc-index-L.html"+>L</A+></TD+><TD+><A HREF="doc-index-M.html"+>M</A+></TD+><TD+><A HREF="doc-index-N.html"+>N</A+></TD+><TD+><A HREF="doc-index-O.html"+>O</A+></TD+><TD+><A HREF="doc-index-P.html"+>P</A+></TD+><TD+><A HREF="doc-index-R.html"+>R</A+></TD+><TD+><A HREF="doc-index-S.html"+>S</A+></TD+><TD+><A HREF="doc-index-T.html"+>T</A+></TD+><TD+><A HREF="doc-index-U.html"+>U</A+></TD+><TD+><A HREF="doc-index-W.html"+>W</A+></TD+><TD+><A HREF="doc-index-43.html"+>+</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="section1"+>Index (U)</TD+></TR+><TR+><TD+><TABLE CELLPADDING="0" CELLSPACING="5"+><TR+><TD CLASS="indexentry"+>upper</TD+><TD CLASS="indexlinks"+><A HREF="Text-ParserCombinators-HuttonMeijer.html#v%3Aupper"+>Text.ParserCombinators.HuttonMeijer</A+></TD+></TR+></TABLE+></TD+></TR+></TABLE+></BODY+></HTML+>
+ docs/haddock/doc-index-W.html view
@@ -0,0 +1,138 @@+<!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"+></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+><TABLE CELLPADDING="0" CELLSPACING="5"+><TR+><TD+><A HREF="doc-index-A.html"+>A</A+></TD+><TD+><A HREF="doc-index-B.html"+>B</A+></TD+><TD+><A HREF="doc-index-C.html"+>C</A+></TD+><TD+><A HREF="doc-index-D.html"+>D</A+></TD+><TD+><A HREF="doc-index-E.html"+>E</A+></TD+><TD+><A HREF="doc-index-F.html"+>F</A+></TD+><TD+><A HREF="doc-index-I.html"+>I</A+></TD+><TD+><A HREF="doc-index-J.html"+>J</A+></TD+><TD+><A HREF="doc-index-L.html"+>L</A+></TD+><TD+><A HREF="doc-index-M.html"+>M</A+></TD+><TD+><A HREF="doc-index-N.html"+>N</A+></TD+><TD+><A HREF="doc-index-O.html"+>O</A+></TD+><TD+><A HREF="doc-index-P.html"+>P</A+></TD+><TD+><A HREF="doc-index-R.html"+>R</A+></TD+><TD+><A HREF="doc-index-S.html"+>S</A+></TD+><TD+><A HREF="doc-index-T.html"+>T</A+></TD+><TD+><A HREF="doc-index-U.html"+>U</A+></TD+><TD+><A HREF="doc-index-W.html"+>W</A+></TD+><TD+><A HREF="doc-index-43.html"+>+</A+></TD+></TR+></TABLE+></TD+></TR+><TR+><TD CLASS="section1"+>Index (W)</TD+></TR+><TR+><TD+><TABLE CELLPADDING="0" CELLSPACING="5"+><TR+><TD CLASS="indexentry"+>word</TD+><TD CLASS="indexlinks"+><A HREF="Text-Parse.html#v%3Aword"+>Text.Parse</A+></TD+></TR+></TABLE+></TD+></TR+></TABLE+></BODY+></HTML+>
+ docs/haddock/doc-index.html view
@@ -0,0 +1,124 @@+<!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"+></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"+>Index</TD+></TR+><TR+><TD+><TABLE CELLPADDING="0" CELLSPACING="5"+><TR+><TD+><A HREF="doc-index-A.html"+>A</A+></TD+><TD+><A HREF="doc-index-B.html"+>B</A+></TD+><TD+><A HREF="doc-index-C.html"+>C</A+></TD+><TD+><A HREF="doc-index-D.html"+>D</A+></TD+><TD+><A HREF="doc-index-E.html"+>E</A+></TD+><TD+><A HREF="doc-index-F.html"+>F</A+></TD+><TD+><A HREF="doc-index-I.html"+>I</A+></TD+><TD+><A HREF="doc-index-J.html"+>J</A+></TD+><TD+><A HREF="doc-index-L.html"+>L</A+></TD+><TD+><A HREF="doc-index-M.html"+>M</A+></TD+><TD+><A HREF="doc-index-N.html"+>N</A+></TD+><TD+><A HREF="doc-index-O.html"+>O</A+></TD+><TD+><A HREF="doc-index-P.html"+>P</A+></TD+><TD+><A HREF="doc-index-R.html"+>R</A+></TD+><TD+><A HREF="doc-index-S.html"+>S</A+></TD+><TD+><A HREF="doc-index-T.html"+>T</A+></TD+><TD+><A HREF="doc-index-U.html"+>U</A+></TD+><TD+><A HREF="doc-index-W.html"+>W</A+></TD+><TD+><A HREF="doc-index-43.html"+>+</A+></TD+></TR+></TABLE+></TD+></TR+></TABLE+></BODY+></HTML+>
+ docs/haddock/haddock.css view
@@ -0,0 +1,260 @@+/* -------- Global things --------- */++BODY { + background-color: #ffffff;+ color: #000000;+ font-family: sans-serif;+ } ++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+}++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+ }+
+ docs/haddock/haddock.js view
@@ -0,0 +1,15 @@+// 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";+ }+}
+ docs/haddock/haskell_icon.gif view
binary file changed (absent → 911 bytes)
+ docs/haddock/index.html view
@@ -0,0 +1,158 @@+<!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.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="padding-left: 1.25em;width: 48em"+><A HREF="Text-Parse.html"+>Text.Parse</A+></TD+><TD+></TD+><TD+></TD+></TR+><TR+><TD STYLE="width: 48em"+><IMG SRC="minus.gif" CLASS="coll" ONCLICK="toggle(this,'n:1')" 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:1" 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="padding-left: 1.25em;width: 46em"+><A HREF="Text-ParserCombinators-Poly.html"+>Text.ParserCombinators.Poly</A+></TD+><TD+></TD+><TD+></TD+></TR+><TR+><TD STYLE="padding-left: 1.25em;width: 46em"+><A HREF="Text-ParserCombinators-PolyLazy.html"+>Text.ParserCombinators.PolyLazy</A+></TD+><TD+></TD+><TD+></TD+></TR+><TR+><TD STYLE="padding-left: 1.25em;width: 46em"+><A HREF="Text-ParserCombinators-PolyState.html"+>Text.ParserCombinators.PolyState</A+></TD+><TD+></TD+><TD+></TD+></TR+><TR+><TD STYLE="padding-left: 1.25em;width: 46em"+><A HREF="Text-ParserCombinators-PolyStateLazy.html"+>Text.ParserCombinators.PolyStateLazy</A+></TD+><TD+></TD+><TD+></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 0.8</TD+></TR+></TABLE+></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,179 @@+<pre><font color=Green><u>module</u></font> Text<font color=Cyan>.</font>Parse+ <font color=Cyan>(</font> <font color=Blue>-- * The Parse class is a replacement for the standard Read class. </font>+ <font color=Blue>-- $parser</font>+ TextParser <font color=Blue>-- synonym for Parser Char, i.e. string input, no state</font>+ <font color=Cyan>,</font> Parse<font color=Cyan>(</font><font color=Red>..</font><font color=Cyan>)</font> <font color=Blue>-- instances: (), (a,b), (a,b,c), Maybe a, Either a, [a],</font>+ <font color=Blue>-- Int, Integer, Float, Double, Char, Bool</font>+ <font color=Cyan>,</font> parseByRead <font color=Blue>-- :: Read a => String -> TextParser a</font>+ <font color=Blue>-- ** Combinators specific to string input, lexed haskell-style</font>+ <font color=Cyan>,</font> word <font color=Blue>-- :: TextParser String</font>+ <font color=Cyan>,</font> isWord <font color=Blue>-- :: String -> TextParser ()</font>+ <font color=Cyan>,</font> optionalParens <font color=Blue>-- :: TextParser a -> TextParser a</font>+ <font color=Cyan>,</font> field <font color=Blue>-- :: Parse a => String -> TextParser a</font>+ <font color=Cyan>,</font> constructors<font color=Blue>-- :: [(String,TextParser a)] -> TextParser a</font>+ <font color=Cyan>,</font> enumeration <font color=Blue>-- :: Show a => String -> [a] -> TextParser a</font>+ <font color=Blue>-- ** Re-export all the more general combinators from Poly too</font>+ <font color=Cyan>,</font> <font color=Green><u>module</u></font> Text<font color=Cyan>.</font>ParserCombinators<font color=Cyan>.</font>Poly+ <font color=Cyan>)</font> <font color=Green><u>where</u></font>++<font color=Green><u>import</u></font> Char <font color=Cyan>(</font>isSpace<font color=Cyan>)</font>+<font color=Green><u>import</u></font> List <font color=Cyan>(</font>intersperse<font color=Cyan>)</font>+<font color=Green><u>import</u></font> Text<font color=Cyan>.</font>ParserCombinators<font color=Cyan>.</font>Poly++<font color=Blue>------------------------------------------------------------------------</font>+<font color=Blue>-- $parser</font>+<font color=Blue>-- The Parse class is a replacement for the standard Read class. It is a</font>+<font color=Blue>-- specialisation of the (poly) Parser monad for String input.</font>+<font color=Blue>-- There are instances defined for all Prelude types.</font>+<font color=Blue>-- For user-defined types, you can write your own instance, or use</font>+<font color=Blue>-- DrIFT to generate them automatically, e.g. {-! derive : Parse !-}</font>++<font color=Blue>-- | A synonym for Parser Char, i.e. string input (no state)</font>+<a name="TextParser"></a><font color=Green><u>type</u></font> TextParser a <font color=Red>=</font> Parser Char a++<font color=Blue>-- | The class @Parse@ is a replacement for @Read@, operating over String input.</font>+<font color=Blue>-- Essentially, it permits better error messages for why something failed to</font>+<font color=Blue>-- parse. It is rather important that @parse@ can read back exactly what</font>+<font color=Blue>-- is generated by the corresponding instance of @show@. To apply a parser</font>+<font color=Blue>-- to some text, use @runParser@.</font>+<a name="Parse"></a><font color=Green><u>class</u></font> Parse a <font color=Green><u>where</u></font>+ parse <font color=Red>::</font> TextParser a+ parseList <font color=Red>::</font> TextParser <font color=Red>[</font>a<font color=Red>]</font> <font color=Blue>-- only to distinguish [] and ""</font>+ parseList <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font> isWord <font color=Magenta>"[]"</font><font color=Cyan>;</font> return <font color=Red>[</font><font color=Red>]</font> <font color=Cyan>}</font>+ <font color=Cyan>`onFail`</font>+ <font color=Green><u>do</u></font> <font color=Cyan>{</font> isWord <font color=Magenta>"["</font><font color=Cyan>;</font> isWord <font color=Magenta>"]"</font><font color=Cyan>;</font> return <font color=Red>[</font><font color=Red>]</font> <font color=Cyan>}</font>+ <font color=Cyan>`onFail`</font>+ bracketSep <font color=Cyan>(</font>isWord <font color=Magenta>"["</font><font color=Cyan>)</font> <font color=Cyan>(</font>isWord <font color=Magenta>","</font><font color=Cyan>)</font> <font color=Cyan>(</font>isWord <font color=Magenta>"]"</font><font color=Cyan>)</font> parse+ <font color=Cyan>`adjustErr`</font> <font color=Cyan>(</font><font color=Magenta>"Expected a list, but\n"</font><font color=Cyan>++</font><font color=Cyan>)</font>++<font color=Blue>-- | If there already exists a Read instance for a type, then we can make</font>+<font color=Blue>-- a Parser for it, but with only poor error-reporting.</font>+parseByRead <font color=Red>::</font> Read a <font color=Red>=></font> String <font color=Red>-></font> TextParser a+<a name="parseByRead"></a>parseByRead name <font color=Red>=</font>+ P <font color=Cyan>(</font><font color=Red>\</font>s<font color=Red>-></font> <font color=Green><u>case</u></font> reads s <font color=Green><u>of</u></font>+ <font color=Red>[</font><font color=Red>]</font> <font color=Red>-></font> <font color=Cyan>(</font>Left <font color=Cyan>(</font>False<font color=Cyan>,</font><font color=Magenta>"no parse, expected a "</font><font color=Cyan>++</font>name<font color=Cyan>)</font><font color=Cyan>,</font> s<font color=Cyan>)</font>+ <font color=Red>[</font><font color=Cyan>(</font>a<font color=Cyan>,</font>s'<font color=Cyan>)</font><font color=Red>]</font> <font color=Red>-></font> <font color=Cyan>(</font>Right a<font color=Cyan>,</font> s'<font color=Cyan>)</font>+ <font color=Green><u>_</u></font> <font color=Red>-></font> <font color=Cyan>(</font>Left <font color=Cyan>(</font>False<font color=Cyan>,</font><font color=Magenta>"ambiguous parse, expected a "</font><font color=Cyan>++</font>name<font color=Cyan>)</font><font color=Cyan>,</font> s<font color=Cyan>)</font>+ <font color=Cyan>)</font>++<font color=Blue>-- | One lexical chunk (Haskell-style lexing).</font>+word <font color=Red>::</font> TextParser String+<a name="word"></a>word <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>s<font color=Red>-></font> <font color=Green><u>case</u></font> lex s <font color=Green><u>of</u></font>+ <font color=Red>[</font><font color=Red>]</font> <font color=Red>-></font> <font color=Cyan>(</font>Left <font color=Cyan>(</font>False<font color=Cyan>,</font><font color=Magenta>"no input? (impossible)"</font><font color=Cyan>)</font><font color=Cyan>,</font> s<font color=Cyan>)</font>+ <font color=Red>[</font><font color=Cyan>(</font><font color=Magenta>""</font><font color=Cyan>,</font>s'<font color=Cyan>)</font><font color=Red>]</font> <font color=Red>-></font> <font color=Cyan>(</font>Left <font color=Cyan>(</font>False<font color=Cyan>,</font><font color=Magenta>"no input?"</font><font color=Cyan>)</font><font color=Cyan>,</font> s'<font color=Cyan>)</font>+ <font color=Cyan>(</font><font color=Cyan>(</font>x<font color=Cyan>,</font>s'<font color=Cyan>)</font><font color=Red><b>:</b></font><font color=Green><u>_</u></font><font color=Cyan>)</font> <font color=Red>-></font> <font color=Cyan>(</font>Right x<font color=Cyan>,</font> s'<font color=Cyan>)</font> <font color=Cyan>)</font>++<font color=Blue>-- | Ensure that the next input word is the given string. (Note the input</font>+<font color=Blue>-- is lexed as haskell, so wordbreaks at spaces, symbols, etc.)</font>+isWord <font color=Red>::</font> String <font color=Red>-></font> TextParser String+<a name="isWord"></a>isWord w <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font> w' <font color=Red><-</font> word+ <font color=Cyan>;</font> <font color=Green><u>if</u></font> w'<font color=Cyan>==</font>w <font color=Green><u>then</u></font> return w <font color=Green><u>else</u></font> fail <font color=Cyan>(</font><font color=Magenta>"expected "</font><font color=Cyan>++</font>w<font color=Cyan>++</font><font color=Magenta>" got "</font><font color=Cyan>++</font>w'<font color=Cyan>)</font>+ <font color=Cyan>}</font>++<font color=Blue>-- | Allow true string parens around an item.</font>+optionalParens <font color=Red>::</font> TextParser a <font color=Red>-></font> TextParser a+<a name="optionalParens"></a>optionalParens p <font color=Red>=</font> bracket <font color=Cyan>(</font>isWord <font color=Magenta>"("</font><font color=Cyan>)</font> <font color=Cyan>(</font>isWord <font color=Magenta>")"</font><font color=Cyan>)</font> p <font color=Cyan>`onFail`</font> p++<font color=Blue>-- | Deal with named field syntax. The string argument is the field name,</font>+<font color=Blue>-- and the parser returns the value of the field.</font>+field <font color=Red>::</font> Parse a <font color=Red>=></font> String <font color=Red>-></font> TextParser a+<a name="field"></a>field name <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font> isWord name<font color=Cyan>;</font> commit <font color=Cyan>$</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font> isWord <font color=Magenta>"="</font><font color=Cyan>;</font> parse <font color=Cyan>}</font> <font color=Cyan>}</font>++<font color=Blue>-- | Parse one of a bunch of alternative constructors. In the list argument,</font>+<font color=Blue>-- the first element of the pair is the constructor name, and</font>+<font color=Blue>-- the second is the parser for the rest of the value. The first matching</font>+<font color=Blue>-- parse is returned.</font>+constructors <font color=Red>::</font> <font color=Red>[</font><font color=Cyan>(</font>String<font color=Cyan>,</font>TextParser a<font color=Cyan>)</font><font color=Red>]</font> <font color=Red>-></font> TextParser a+<a name="constructors"></a>constructors cs <font color=Red>=</font> oneOf' <font color=Cyan>(</font>map cons cs<font color=Cyan>)</font>+ <font color=Green><u>where</u></font> cons <font color=Cyan>(</font>name<font color=Cyan>,</font>p<font color=Cyan>)</font> <font color=Red>=</font>+ <font color=Cyan>(</font> name+ <font color=Cyan>,</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font> isWord name+ <font color=Cyan>;</font> p <font color=Cyan>`adjustErrBad`</font> <font color=Cyan>(</font><font color=Cyan>(</font><font color=Magenta>"got constructor, but within "</font>+ <font color=Cyan>++</font>name<font color=Cyan>++</font><font color=Magenta>",\n"</font><font color=Cyan>)</font><font color=Cyan>++</font><font color=Cyan>)</font>+ <font color=Cyan>}</font>+ <font color=Cyan>)</font>++<font color=Blue>-- | Parse one of the given nullary constructors (an enumeration).</font>+<font color=Blue>-- The string argument is the name of the type, and the list argument</font>+<font color=Blue>-- should contain all of the possible enumeration values.</font>+enumeration <font color=Red>::</font> <font color=Cyan>(</font>Show a<font color=Cyan>)</font> <font color=Red>=></font> String <font color=Red>-></font> <font color=Red>[</font>a<font color=Red>]</font> <font color=Red>-></font> TextParser a+<a name="enumeration"></a>enumeration typ cs <font color=Red>=</font> oneOf <font color=Cyan>(</font>map <font color=Cyan>(</font><font color=Red>\</font>c<font color=Red>-></font> <font color=Green><u>do</u></font> <font color=Cyan>{</font> isWord <font color=Cyan>(</font>show c<font color=Cyan>)</font><font color=Cyan>;</font> return c <font color=Cyan>}</font><font color=Cyan>)</font> cs<font color=Cyan>)</font>+ <font color=Cyan>`adjustErr`</font>+ <font color=Cyan>(</font><font color=Cyan>++</font><font color=Cyan>(</font><font color=Magenta>"\n expected "</font><font color=Cyan>++</font>typ<font color=Cyan>++</font><font color=Magenta>" value ("</font><font color=Cyan>++</font>e<font color=Cyan>++</font><font color=Magenta>")"</font><font color=Cyan>)</font><font color=Cyan>)</font>+ <font color=Green><u>where</u></font> e <font color=Red>=</font> concat <font color=Cyan>(</font>intersperse <font color=Magenta>", "</font> <font color=Cyan>(</font>map show <font color=Cyan>(</font>init cs<font color=Cyan>)</font><font color=Cyan>)</font><font color=Cyan>)</font>+ <font color=Cyan>++</font> <font color=Magenta>", or "</font> <font color=Cyan>++</font> show <font color=Cyan>(</font>last cs<font color=Cyan>)</font>++<font color=Blue>------------------------------------------------------------------------</font>+<font color=Blue>-- Instances for all the Standard Prelude types.</font>++<font color=Blue>-- Basic types</font>+<font color=Green><u>instance</u></font> Parse Int <font color=Green><u>where</u></font>+ parse <font color=Red>=</font> parseByRead <font color=Magenta>"Int"</font>+<font color=Green><u>instance</u></font> Parse Integer <font color=Green><u>where</u></font>+ parse <font color=Red>=</font> parseByRead <font color=Magenta>"Integer"</font>+<font color=Green><u>instance</u></font> Parse Float <font color=Green><u>where</u></font>+ parse <font color=Red>=</font> parseByRead <font color=Magenta>"Float"</font>+<font color=Green><u>instance</u></font> Parse Double <font color=Green><u>where</u></font>+ parse <font color=Red>=</font> parseByRead <font color=Magenta>"Double"</font>+<font color=Green><u>instance</u></font> Parse Char <font color=Green><u>where</u></font>+ parse <font color=Red>=</font> parseByRead <font color=Magenta>"Char"</font>+ <font color=Blue>-- parseList = bracket (isWord "\"") (satisfy (=='"'))</font>+ <font color=Blue>-- (many (satisfy (/='"')))</font>+ <font color=Blue>-- not totally correct for strings...</font>+ parseList <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font> w <font color=Red><-</font> word<font color=Cyan>;</font> <font color=Green><u>if</u></font> head w <font color=Cyan>==</font> <font color=Magenta>'"'</font> <font color=Green><u>then</u></font> return <font color=Cyan>(</font>init <font color=Cyan>(</font>tail w<font color=Cyan>)</font><font color=Cyan>)</font>+ <font color=Green><u>else</u></font> fail <font color=Magenta>"not a string"</font> <font color=Cyan>}</font>++<font color=Green><u>instance</u></font> Parse Bool <font color=Green><u>where</u></font>+ parse <font color=Red>=</font> enumeration <font color=Magenta>"Bool"</font> <font color=Red>[</font>False<font color=Cyan>,</font>True<font color=Red>]</font>++<font color=Green><u>instance</u></font> Parse Ordering <font color=Green><u>where</u></font>+ parse <font color=Red>=</font> enumeration <font color=Magenta>"Ordering"</font> <font color=Red>[</font>LT<font color=Cyan>,</font>EQ<font color=Cyan>,</font>GT<font color=Red>]</font>++<font color=Blue>-- Structural types</font>+<font color=Green><u>instance</u></font> Parse <font color=Cyan>(</font><font color=Cyan>)</font> <font color=Green><u>where</u></font>+ parse <font color=Red>=</font> P p+ <font color=Green><u>where</u></font> p <font color=Red>[</font><font color=Red>]</font> <font color=Red>=</font> <font color=Cyan>(</font>Left <font color=Cyan>(</font>False<font color=Cyan>,</font><font color=Magenta>"no input: expected a ()"</font><font color=Cyan>)</font><font color=Cyan>,</font> <font color=Red>[</font><font color=Red>]</font><font color=Cyan>)</font>+ p <font color=Cyan>(</font><font color=Magenta>'('</font><font color=Red><b>:</b></font>cs<font color=Cyan>)</font> <font color=Red>=</font> <font color=Green><u>case</u></font> dropWhile isSpace cs <font color=Green><u>of</u></font>+ <font color=Cyan>(</font><font color=Magenta>')'</font><font color=Red><b>:</b></font>s<font color=Cyan>)</font> <font color=Red>-></font> <font color=Cyan>(</font>Right <font color=Cyan>(</font><font color=Cyan>)</font><font color=Cyan>,</font> s<font color=Cyan>)</font>+ <font color=Green><u>_</u></font> <font color=Red>-></font> <font color=Cyan>(</font>Left <font color=Cyan>(</font>False<font color=Cyan>,</font><font color=Magenta>"Expected ) after ("</font><font color=Cyan>)</font><font color=Cyan>,</font> cs<font color=Cyan>)</font>+ p <font color=Cyan>(</font>c<font color=Red><b>:</b></font>cs<font color=Cyan>)</font> <font color=Red>|</font> isSpace c <font color=Red>=</font> p cs+ <font color=Red>|</font> otherwise <font color=Red>=</font> <font color=Cyan>(</font> Left <font color=Cyan>(</font>False<font color=Cyan>,</font><font color=Magenta>"Expected a (), got "</font><font color=Cyan>++</font>show c<font color=Cyan>)</font>+ <font color=Cyan>,</font> <font color=Cyan>(</font>c<font color=Red><b>:</b></font>cs<font color=Cyan>)</font><font color=Cyan>)</font>++<font color=Green><u>instance</u></font> <font color=Cyan>(</font>Parse a<font color=Cyan>,</font> Parse b<font color=Cyan>)</font> <font color=Red>=></font> Parse <font color=Cyan>(</font>a<font color=Cyan>,</font>b<font color=Cyan>)</font> <font color=Green><u>where</u></font>+ parse <font color=Red>=</font> <font color=Green><u>do</u></font><font color=Cyan>{</font> isWord <font color=Magenta>"("</font> <font color=Cyan>`adjustErr`</font> <font color=Cyan>(</font><font color=Magenta>"Opening a 2-tuple\n"</font><font color=Cyan>++</font><font color=Cyan>)</font>+ <font color=Cyan>;</font> x <font color=Red><-</font> parse <font color=Cyan>`adjustErr`</font> <font color=Cyan>(</font><font color=Magenta>"In 1st item of a 2-tuple\n"</font><font color=Cyan>++</font><font color=Cyan>)</font>+ <font color=Cyan>;</font> isWord <font color=Magenta>","</font> <font color=Cyan>`adjustErr`</font> <font color=Cyan>(</font><font color=Magenta>"Separating a 2-tuple\n"</font><font color=Cyan>++</font><font color=Cyan>)</font>+ <font color=Cyan>;</font> y <font color=Red><-</font> parse <font color=Cyan>`adjustErr`</font> <font color=Cyan>(</font><font color=Magenta>"In 2nd item of a 2-tuple\n"</font><font color=Cyan>++</font><font color=Cyan>)</font>+ <font color=Cyan>;</font> isWord <font color=Magenta>")"</font> <font color=Cyan>`adjustErr`</font> <font color=Cyan>(</font><font color=Magenta>"Closing a 2-tuple\n"</font><font color=Cyan>++</font><font color=Cyan>)</font>+ <font color=Cyan>;</font> return <font color=Cyan>(</font>x<font color=Cyan>,</font>y<font color=Cyan>)</font> <font color=Cyan>}</font>++<font color=Green><u>instance</u></font> <font color=Cyan>(</font>Parse a<font color=Cyan>,</font> Parse b<font color=Cyan>,</font> Parse c<font color=Cyan>)</font> <font color=Red>=></font> Parse <font color=Cyan>(</font>a<font color=Cyan>,</font>b<font color=Cyan>,</font>c<font color=Cyan>)</font> <font color=Green><u>where</u></font>+ parse <font color=Red>=</font> <font color=Green><u>do</u></font><font color=Cyan>{</font> isWord <font color=Magenta>"("</font> <font color=Cyan>`adjustErr`</font> <font color=Cyan>(</font><font color=Magenta>"Opening a 3-tuple\n"</font><font color=Cyan>++</font><font color=Cyan>)</font>+ <font color=Cyan>;</font> x <font color=Red><-</font> parse <font color=Cyan>`adjustErr`</font> <font color=Cyan>(</font><font color=Magenta>"In 1st item of a 3-tuple\n"</font><font color=Cyan>++</font><font color=Cyan>)</font>+ <font color=Cyan>;</font> isWord <font color=Magenta>","</font> <font color=Cyan>`adjustErr`</font> <font color=Cyan>(</font><font color=Magenta>"Separating(1) a 3-tuple\n"</font><font color=Cyan>++</font><font color=Cyan>)</font>+ <font color=Cyan>;</font> y <font color=Red><-</font> parse <font color=Cyan>`adjustErr`</font> <font color=Cyan>(</font><font color=Magenta>"In 2nd item of a 3-tuple\n"</font><font color=Cyan>++</font><font color=Cyan>)</font>+ <font color=Cyan>;</font> isWord <font color=Magenta>","</font> <font color=Cyan>`adjustErr`</font> <font color=Cyan>(</font><font color=Magenta>"Separating(2) a 3-tuple\n"</font><font color=Cyan>++</font><font color=Cyan>)</font>+ <font color=Cyan>;</font> z <font color=Red><-</font> parse <font color=Cyan>`adjustErr`</font> <font color=Cyan>(</font><font color=Magenta>"In 3rd item of a 3-tuple\n"</font><font color=Cyan>++</font><font color=Cyan>)</font>+ <font color=Cyan>;</font> isWord <font color=Magenta>")"</font> <font color=Cyan>`adjustErr`</font> <font color=Cyan>(</font><font color=Magenta>"Closing a 3-tuple\n"</font><font color=Cyan>++</font><font color=Cyan>)</font>+ <font color=Cyan>;</font> return <font color=Cyan>(</font>x<font color=Cyan>,</font>y<font color=Cyan>,</font>z<font color=Cyan>)</font> <font color=Cyan>}</font>++<font color=Green><u>instance</u></font> Parse a <font color=Red>=></font> Parse <font color=Cyan>(</font>Maybe a<font color=Cyan>)</font> <font color=Green><u>where</u></font>+ parse <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font> isWord <font color=Magenta>"Nothing"</font><font color=Cyan>;</font> return Nothing <font color=Cyan>}</font>+ <font color=Cyan>`onFail`</font>+ <font color=Green><u>do</u></font> <font color=Cyan>{</font> isWord <font color=Magenta>"Just"</font>+ <font color=Cyan>;</font> fmap Just <font color=Cyan>$</font> optionalParens parse+ <font color=Cyan>`adjustErrBad`</font> <font color=Cyan>(</font><font color=Magenta>"but within Just, "</font><font color=Cyan>++</font><font color=Cyan>)</font>+ <font color=Cyan>}</font>+ <font color=Cyan>`adjustErr`</font> <font color=Cyan>(</font><font color=Cyan>(</font><font color=Magenta>"expected a Maybe (Just or Nothing)\n"</font><font color=Cyan>++</font><font color=Cyan>)</font><font color=Cyan>.</font>indent <font color=Magenta>2</font><font color=Cyan>)</font>++<font color=Green><u>instance</u></font> <font color=Cyan>(</font>Parse a<font color=Cyan>,</font> Parse b<font color=Cyan>)</font> <font color=Red>=></font> Parse <font color=Cyan>(</font>Either a b<font color=Cyan>)</font> <font color=Green><u>where</u></font>+ parse <font color=Red>=</font> constructors <font color=Red>[</font> <font color=Cyan>(</font><font color=Magenta>"Left"</font><font color=Cyan>,</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font> fmap Left <font color=Cyan>$</font> optionalParens parse <font color=Cyan>}</font> <font color=Cyan>)</font>+ <font color=Cyan>,</font> <font color=Cyan>(</font><font color=Magenta>"Right"</font><font color=Cyan>,</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font> fmap Right <font color=Cyan>$</font> optionalParens parse <font color=Cyan>}</font> <font color=Cyan>)</font>+ <font color=Red>]</font>++<font color=Green><u>instance</u></font> Parse a <font color=Red>=></font> Parse <font color=Red>[</font>a<font color=Red>]</font> <font color=Green><u>where</u></font>+ parse <font color=Red>=</font> parseList++<font color=Blue>------------------------------------------------------------------------</font>+</pre>
+ docs/haddock/src/Text/ParserCombinators/HuttonMeijer.html view
@@ -0,0 +1,219 @@+<pre><font color=Blue>-----------------------------------------------------------------------------</font>+<font color=Blue>-- |</font>+<font color=Blue>-- Module : Text.ParserCombinators.HuttonMeijer</font>+<font color=Blue>-- Copyright : Graham Hutton (University of Nottingham), Erik Meijer (University of Utrecht)</font>+<font color=Blue>-- Licence : BSD</font>+<font color=Blue>-- </font>+<font color=Blue>-- Maintainer : Malcolm Wallace <Malcolm.Wallace@cs.york.ac.uk></font>+<font color=Blue>-- Stability : Stable</font>+<font color=Blue>-- Portability : All</font>+<font color=Blue>--</font>+<font color=Blue>-- A LIBRARY OF MONADIC PARSER COMBINATORS</font>+<font color=Blue>-- </font>+<font color=Blue>-- 29th July 1996</font>+<font color=Blue>-- </font>+<font color=Blue>-- Graham Hutton Erik Meijer</font>+<font color=Blue>-- University of Nottingham University of Utrecht</font>+<font color=Blue>-- </font>+<font color=Blue>-- This Haskell script defines a library of parser combinators, and is</font>+<font color=Blue>-- taken from sections 1-6 of our article "Monadic Parser Combinators".</font>+<font color=Blue>-- Some changes to the library have been made in the move from Gofer</font>+<font color=Blue>-- to Haskell:</font>+<font color=Blue>-- </font>+<font color=Blue>-- * Do notation is used in place of monad comprehension notation;</font>+<font color=Blue>-- </font>+<font color=Blue>-- * The parser datatype is defined using "newtype", to avoid the overhead</font>+<font color=Blue>-- of tagging and untagging parsers with the P constructor.</font>+<font color=Blue>-----------------------------------------------------------------------------</font>+++<font color=Green><u>module</u></font> Text<font color=Cyan>.</font>ParserCombinators<font color=Cyan>.</font>HuttonMeijer+ <font color=Cyan>(</font>Parser<font color=Cyan>(</font><font color=Red>..</font><font color=Cyan>)</font><font color=Cyan>,</font> item<font color=Cyan>,</font> first<font color=Cyan>,</font> papply<font color=Cyan>,</font> <font color=Cyan>(</font><font color=Cyan>+++</font><font color=Cyan>)</font><font color=Cyan>,</font> sat<font color=Cyan>,</font> <font color=Blue>{-tok,-}</font> many<font color=Cyan>,</font> many1<font color=Cyan>,</font>+ sepby<font color=Cyan>,</font> sepby1<font color=Cyan>,</font> chainl<font color=Cyan>,</font>+ chainl1<font color=Cyan>,</font> chainr<font color=Cyan>,</font> chainr1<font color=Cyan>,</font> ops<font color=Cyan>,</font> bracket<font color=Cyan>,</font> char<font color=Cyan>,</font> digit<font color=Cyan>,</font> lower<font color=Cyan>,</font> upper<font color=Cyan>,</font>+ letter<font color=Cyan>,</font> alphanum<font color=Cyan>,</font> string<font color=Cyan>,</font> ident<font color=Cyan>,</font> nat<font color=Cyan>,</font> int<font color=Cyan>,</font> spaces<font color=Cyan>,</font> comment<font color=Cyan>,</font> junk<font color=Cyan>,</font>+ skip<font color=Cyan>,</font> token<font color=Cyan>,</font> natural<font color=Cyan>,</font> integer<font color=Cyan>,</font> symbol<font color=Cyan>,</font> identifier<font color=Cyan>)</font> <font color=Green><u>where</u></font>++<font color=Green><u>import</u></font> Char+<font color=Green><u>import</u></font> Monad++<font color=Green><u>infixr</u></font> <font color=Magenta>5</font> <font color=Cyan>+++</font>++<a name="Token"></a><font color=Green><u>type</u></font> Token <font color=Red>=</font> Char++<font color=Blue>---------------------------------------------------------</font>+<font color=Blue>-- | The parser monad</font>++<font color=Green><u>newtype</u></font> Parser a <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>[</font>Token<font color=Red>]</font> <font color=Red>-></font> <font color=Red>[</font><font color=Cyan>(</font>a<font color=Cyan>,</font><font color=Red>[</font>Token<font color=Red>]</font><font color=Cyan>)</font><font color=Red>]</font><font color=Cyan>)</font>++<font color=Green><u>instance</u></font> Functor Parser <font color=Green><u>where</u></font>+ <font color=Blue>-- map :: (a -> b) -> (Parser a -> Parser b)</font>+ fmap f <font color=Cyan>(</font>P p<font color=Cyan>)</font> <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>inp <font color=Red>-></font> <font color=Red>[</font><font color=Cyan>(</font>f v<font color=Cyan>,</font> out<font color=Cyan>)</font> <font color=Red>|</font> <font color=Cyan>(</font>v<font color=Cyan>,</font>out<font color=Cyan>)</font> <font color=Red><-</font> p inp<font color=Red>]</font><font color=Cyan>)</font>++<font color=Green><u>instance</u></font> Monad Parser <font color=Green><u>where</u></font>+ <font color=Blue>-- return :: a -> Parser a</font>+ return v <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>inp <font color=Red>-></font> <font color=Red>[</font><font color=Cyan>(</font>v<font color=Cyan>,</font>inp<font color=Cyan>)</font><font color=Red>]</font><font color=Cyan>)</font>++ <font color=Blue>-- >>= :: Parser a -> (a -> Parser b) -> Parser b</font>+ <font color=Cyan>(</font>P p<font color=Cyan>)</font> <font color=Cyan>>>=</font> f <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>inp <font color=Red>-></font> concat <font color=Red>[</font>papply <font color=Cyan>(</font>f v<font color=Cyan>)</font> out <font color=Red>|</font> <font color=Cyan>(</font>v<font color=Cyan>,</font>out<font color=Cyan>)</font> <font color=Red><-</font> p inp<font color=Red>]</font><font color=Cyan>)</font>++ <font color=Blue>-- fail :: String -> Parser a</font>+ fail <font color=Green><u>_</u></font> <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font><font color=Green><u>_</u></font> <font color=Red>-></font> <font color=Red>[</font><font color=Red>]</font><font color=Cyan>)</font>++<font color=Green><u>instance</u></font> MonadPlus Parser <font color=Green><u>where</u></font>+ <font color=Blue>-- mzero :: Parser a</font>+ mzero <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font><font color=Green><u>_</u></font> <font color=Red>-></font> <font color=Red>[</font><font color=Red>]</font><font color=Cyan>)</font>++ <font color=Blue>-- mplus :: Parser a -> Parser a -> Parser a</font>+ <font color=Cyan>(</font>P p<font color=Cyan>)</font> <font color=Cyan>`mplus`</font> <font color=Cyan>(</font>P q<font color=Cyan>)</font> <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>inp <font color=Red>-></font> <font color=Cyan>(</font>p inp <font color=Cyan>++</font> q inp<font color=Cyan>)</font><font color=Cyan>)</font>++<font color=Blue>-- ------------------------------------------------------------</font>+<font color=Blue>-- * Other primitive parser combinators</font>+<font color=Blue>-- ------------------------------------------------------------</font>++item <font color=Red>::</font> Parser Token+<a name="item"></a>item <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>inp <font color=Red>-></font> <font color=Green><u>case</u></font> inp <font color=Green><u>of</u></font>+ <font color=Red>[</font><font color=Red>]</font> <font color=Red>-></font> <font color=Red>[</font><font color=Red>]</font>+ <font color=Cyan>(</font>x<font color=Red><b>:</b></font>xs<font color=Cyan>)</font> <font color=Red>-></font> <font color=Red>[</font><font color=Cyan>(</font>x<font color=Cyan>,</font>xs<font color=Cyan>)</font><font color=Red>]</font><font color=Cyan>)</font>++first <font color=Red>::</font> Parser a <font color=Red>-></font> Parser a+<a name="first"></a>first <font color=Cyan>(</font>P p<font color=Cyan>)</font> <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>inp <font color=Red>-></font> <font color=Green><u>case</u></font> p inp <font color=Green><u>of</u></font>+ <font color=Red>[</font><font color=Red>]</font> <font color=Red>-></font> <font color=Red>[</font><font color=Red>]</font>+ <font color=Cyan>(</font>x<font color=Red><b>:</b></font><font color=Green><u>_</u></font><font color=Cyan>)</font> <font color=Red>-></font> <font color=Red>[</font>x<font color=Red>]</font><font color=Cyan>)</font>++papply <font color=Red>::</font> Parser a <font color=Red>-></font> <font color=Red>[</font>Token<font color=Red>]</font> <font color=Red>-></font> <font color=Red>[</font><font color=Cyan>(</font>a<font color=Cyan>,</font><font color=Red>[</font>Token<font color=Red>]</font><font color=Cyan>)</font><font color=Red>]</font>+<a name="papply"></a>papply <font color=Cyan>(</font>P p<font color=Cyan>)</font> inp <font color=Red>=</font> p inp++<font color=Blue>-- ------------------------------------------------------------</font>+<font color=Blue>-- * Derived combinators</font>+<font color=Blue>-- ------------------------------------------------------------</font>++<a name="+++"></a><font color=Cyan>(</font><font color=Cyan>+++</font><font color=Cyan>)</font> <font color=Red>::</font> Parser a <font color=Red>-></font> Parser a <font color=Red>-></font> Parser a+<a name="p"></a>p <font color=Cyan>+++</font> q <font color=Red>=</font> first <font color=Cyan>(</font>p <font color=Cyan>`mplus`</font> q<font color=Cyan>)</font>++sat <font color=Red>::</font> <font color=Cyan>(</font>Token <font color=Red>-></font> Bool<font color=Cyan>)</font> <font color=Red>-></font> Parser Token+<a name="sat"></a>sat p <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font>x <font color=Red><-</font> item<font color=Cyan>;</font> <font color=Green><u>if</u></font> p x <font color=Green><u>then</u></font> return x <font color=Green><u>else</u></font> mzero<font color=Cyan>}</font>++<font color=Blue>--tok :: Token -> Parser Token</font>+<font color=Blue>--tok t = do {x <- item; if t==snd x then return t else mzero}</font>++many <font color=Red>::</font> Parser a <font color=Red>-></font> Parser <font color=Red>[</font>a<font color=Red>]</font>+<a name="many"></a>many p <font color=Red>=</font> many1 p <font color=Cyan>+++</font> return <font color=Red>[</font><font color=Red>]</font>+<font color=Blue>--many p = force (many1 p +++ return [])</font>++many1 <font color=Red>::</font> Parser a <font color=Red>-></font> Parser <font color=Red>[</font>a<font color=Red>]</font>+<a name="many1"></a>many1 p <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font>x <font color=Red><-</font> p<font color=Cyan>;</font> xs <font color=Red><-</font> many p<font color=Cyan>;</font> return <font color=Cyan>(</font>x<font color=Red><b>:</b></font>xs<font color=Cyan>)</font><font color=Cyan>}</font>++sepby <font color=Red>::</font> Parser a <font color=Red>-></font> Parser b <font color=Red>-></font> Parser <font color=Red>[</font>a<font color=Red>]</font>+<a name="sepby"></a>p <font color=Cyan>`sepby`</font> sep <font color=Red>=</font> <font color=Cyan>(</font>p <font color=Cyan>`sepby1`</font> sep<font color=Cyan>)</font> <font color=Cyan>+++</font> return <font color=Red>[</font><font color=Red>]</font>++sepby1 <font color=Red>::</font> Parser a <font color=Red>-></font> Parser b <font color=Red>-></font> Parser <font color=Red>[</font>a<font color=Red>]</font>+<a name="sepby1"></a>p <font color=Cyan>`sepby1`</font> sep <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font>x <font color=Red><-</font> p<font color=Cyan>;</font> xs <font color=Red><-</font> many <font color=Cyan>(</font><font color=Green><u>do</u></font> <font color=Cyan>{</font>sep<font color=Cyan>;</font> p<font color=Cyan>}</font><font color=Cyan>)</font><font color=Cyan>;</font> return <font color=Cyan>(</font>x<font color=Red><b>:</b></font>xs<font color=Cyan>)</font><font color=Cyan>}</font>++chainl <font color=Red>::</font> Parser a <font color=Red>-></font> Parser <font color=Cyan>(</font>a <font color=Red>-></font> a <font color=Red>-></font> a<font color=Cyan>)</font> <font color=Red>-></font> a <font color=Red>-></font> Parser a+<a name="chainl"></a>chainl p op v <font color=Red>=</font> <font color=Cyan>(</font>p <font color=Cyan>`chainl1`</font> op<font color=Cyan>)</font> <font color=Cyan>+++</font> return v++chainl1 <font color=Red>::</font> Parser a <font color=Red>-></font> Parser <font color=Cyan>(</font>a <font color=Red>-></font> a <font color=Red>-></font> a<font color=Cyan>)</font> <font color=Red>-></font> Parser a+<a name="chainl1"></a>p <font color=Cyan>`chainl1`</font> op <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font>x <font color=Red><-</font> p<font color=Cyan>;</font> rest x<font color=Cyan>}</font>+ <font color=Green><u>where</u></font>+ rest x <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font>f <font color=Red><-</font> op<font color=Cyan>;</font> y <font color=Red><-</font> p<font color=Cyan>;</font> rest <font color=Cyan>(</font>f x y<font color=Cyan>)</font><font color=Cyan>}</font>+ <font color=Cyan>+++</font> return x++chainr <font color=Red>::</font> Parser a <font color=Red>-></font> Parser <font color=Cyan>(</font>a <font color=Red>-></font> a <font color=Red>-></font> a<font color=Cyan>)</font> <font color=Red>-></font> a <font color=Red>-></font> Parser a+<a name="chainr"></a>chainr p op v <font color=Red>=</font> <font color=Cyan>(</font>p <font color=Cyan>`chainr1`</font> op<font color=Cyan>)</font> <font color=Cyan>+++</font> return v++chainr1 <font color=Red>::</font> Parser a <font color=Red>-></font> Parser <font color=Cyan>(</font>a <font color=Red>-></font> a <font color=Red>-></font> a<font color=Cyan>)</font> <font color=Red>-></font> Parser a+<a name="chainr1"></a>p <font color=Cyan>`chainr1`</font> op <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font>x <font color=Red><-</font> p<font color=Cyan>;</font> rest x<font color=Cyan>}</font>+ <font color=Green><u>where</u></font>+ rest x <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font>f <font color=Red><-</font> op<font color=Cyan>;</font> y <font color=Red><-</font> p <font color=Cyan>`chainr1`</font> op<font color=Cyan>;</font> return <font color=Cyan>(</font>f x y<font color=Cyan>)</font><font color=Cyan>}</font>+ <font color=Cyan>+++</font> return x++ops <font color=Red>::</font> <font color=Red>[</font><font color=Cyan>(</font>Parser a<font color=Cyan>,</font> b<font color=Cyan>)</font><font color=Red>]</font> <font color=Red>-></font> Parser b+<a name="ops"></a>ops xs <font color=Red>=</font> foldr1 <font color=Cyan>(</font><font color=Cyan>+++</font><font color=Cyan>)</font> <font color=Red>[</font><font color=Green><u>do</u></font> <font color=Cyan>{</font>p<font color=Cyan>;</font> return op<font color=Cyan>}</font> <font color=Red>|</font> <font color=Cyan>(</font>p<font color=Cyan>,</font>op<font color=Cyan>)</font> <font color=Red><-</font> xs<font color=Red>]</font>++bracket <font color=Red>::</font> Parser a <font color=Red>-></font> Parser b <font color=Red>-></font> Parser c <font color=Red>-></font> Parser b+<a name="bracket"></a>bracket open p close <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font>open<font color=Cyan>;</font> x <font color=Red><-</font> p<font color=Cyan>;</font> close<font color=Cyan>;</font> return x<font color=Cyan>}</font>++<font color=Blue>-- ------------------------------------------------------------</font>+<font color=Blue>-- * Useful parsers</font>+<font color=Blue>-- ------------------------------------------------------------</font>++char <font color=Red>::</font> Char <font color=Red>-></font> Parser Char+<a name="char"></a>char x <font color=Red>=</font> sat <font color=Cyan>(</font><font color=Red>\</font>y <font color=Red>-></font> x <font color=Cyan>==</font> y<font color=Cyan>)</font>++digit <font color=Red>::</font> Parser Char+<a name="digit"></a>digit <font color=Red>=</font> sat isDigit++lower <font color=Red>::</font> Parser Char+<a name="lower"></a>lower <font color=Red>=</font> sat isLower++upper <font color=Red>::</font> Parser Char+<a name="upper"></a>upper <font color=Red>=</font> sat isUpper++letter <font color=Red>::</font> Parser Char+<a name="letter"></a>letter <font color=Red>=</font> sat isAlpha++alphanum <font color=Red>::</font> Parser Char+<a name="alphanum"></a>alphanum <font color=Red>=</font> sat isAlphaNum <font color=Cyan>+++</font> char <font color=Magenta>'_'</font>++string <font color=Red>::</font> String <font color=Red>-></font> Parser String+<a name="string"></a>string <font color=Magenta>""</font> <font color=Red>=</font> return <font color=Magenta>""</font>+string <font color=Cyan>(</font>x<font color=Red><b>:</b></font>xs<font color=Cyan>)</font> <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font>char x<font color=Cyan>;</font> string xs<font color=Cyan>;</font> return <font color=Cyan>(</font>x<font color=Red><b>:</b></font>xs<font color=Cyan>)</font><font color=Cyan>}</font>++ident <font color=Red>::</font> Parser String+<a name="ident"></a>ident <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font>x <font color=Red><-</font> lower<font color=Cyan>;</font> xs <font color=Red><-</font> many alphanum<font color=Cyan>;</font> return <font color=Cyan>(</font>x<font color=Red><b>:</b></font>xs<font color=Cyan>)</font><font color=Cyan>}</font>++nat <font color=Red>::</font> Parser Int+<a name="nat"></a>nat <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font>x <font color=Red><-</font> digit<font color=Cyan>;</font> return <font color=Cyan>(</font>fromEnum x <font color=Blue>-</font> fromEnum <font color=Magenta>'0'</font><font color=Cyan>)</font><font color=Cyan>}</font> <font color=Cyan>`chainl1`</font> return op+ <font color=Green><u>where</u></font>+ m <font color=Cyan>`op`</font> n <font color=Red>=</font> <font color=Magenta>10</font><font color=Cyan>*</font>m <font color=Cyan>+</font> n++int <font color=Red>::</font> Parser Int+<a name="int"></a>int <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font>char <font color=Magenta>'-'</font><font color=Cyan>;</font> n <font color=Red><-</font> nat<font color=Cyan>;</font> return <font color=Cyan>(</font><font color=Blue>-</font>n<font color=Cyan>)</font><font color=Cyan>}</font> <font color=Cyan>+++</font> nat++<font color=Blue>-- ------------------------------------------------------------</font>+<font color=Blue>-- * Lexical combinators</font>+<font color=Blue>-- ------------------------------------------------------------</font>++spaces <font color=Red>::</font> Parser <font color=Cyan>(</font><font color=Cyan>)</font>+<a name="spaces"></a>spaces <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font>many1 <font color=Cyan>(</font>sat isSpace<font color=Cyan>)</font><font color=Cyan>;</font> return <font color=Cyan>(</font><font color=Cyan>)</font><font color=Cyan>}</font>++comment <font color=Red>::</font> Parser <font color=Cyan>(</font><font color=Cyan>)</font>+<font color=Blue>--comment = do {string "--"; many (sat (\x -> x /= '\n')); return ()}</font>+<font color=Blue>--comment = do </font>+<font color=Blue>-- _ <- string "--"</font>+<font color=Blue>-- _ <- many (sat (\x -> x /= '\n'))</font>+<font color=Blue>-- return ()</font>+<a name="comment"></a>comment <font color=Red>=</font> <font color=Green><u>do</u></font>+ bracket <font color=Cyan>(</font>string <font color=Magenta>"/*"</font><font color=Cyan>)</font> <font color=Cyan>(</font>many item<font color=Cyan>)</font> <font color=Cyan>(</font>string <font color=Magenta>"*/"</font><font color=Cyan>)</font>+ return <font color=Cyan>(</font><font color=Cyan>)</font>++junk <font color=Red>::</font> Parser <font color=Cyan>(</font><font color=Cyan>)</font>+<a name="junk"></a>junk <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font>many <font color=Cyan>(</font>spaces <font color=Cyan>+++</font> comment<font color=Cyan>)</font><font color=Cyan>;</font> return <font color=Cyan>(</font><font color=Cyan>)</font><font color=Cyan>}</font>++skip <font color=Red>::</font> Parser a <font color=Red>-></font> Parser a+<a name="skip"></a>skip p <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font>junk<font color=Cyan>;</font> p<font color=Cyan>}</font>++token <font color=Red>::</font> Parser a <font color=Red>-></font> Parser a+<a name="token"></a>token p <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font>v <font color=Red><-</font> p<font color=Cyan>;</font> junk<font color=Cyan>;</font> return v<font color=Cyan>}</font>++<font color=Blue>-- ------------------------------------------------------------</font>+<font color=Blue>-- * Token parsers</font>+<font color=Blue>-- ------------------------------------------------------------</font>++natural <font color=Red>::</font> Parser Int+<a name="natural"></a>natural <font color=Red>=</font> token nat++integer <font color=Red>::</font> Parser Int+<a name="integer"></a>integer <font color=Red>=</font> token int++symbol <font color=Red>::</font> String <font color=Red>-></font> Parser String+<a name="symbol"></a>symbol xs <font color=Red>=</font> token <font color=Cyan>(</font>string xs<font color=Cyan>)</font>++identifier <font color=Red>::</font> <font color=Red>[</font>String<font color=Red>]</font> <font color=Red>-></font> Parser String+<a name="identifier"></a>identifier ks <font color=Red>=</font> token <font color=Cyan>(</font><font color=Green><u>do</u></font> <font color=Cyan>{</font>x <font color=Red><-</font> ident<font color=Cyan>;</font>+ <font color=Green><u>if</u></font> not <font color=Cyan>(</font>elem x ks<font color=Cyan>)</font> <font color=Green><u>then</u></font> return x+ <font color=Green><u>else</u></font> return mzero<font color=Cyan>}</font><font color=Cyan>)</font>++<font color=Blue>------------------------------------------------------------------------------</font>+</pre>
+ docs/haddock/src/Text/ParserCombinators/HuttonMeijerWallace.html view
@@ -0,0 +1,298 @@+<pre><font color=Cyan>{</font><font color=Blue>-----------------------------------------------------------------------------</font>++ A LIBRARY OF MONADIC PARSER COMBINATORS++ <font color=Magenta>29</font>th July <font color=Magenta>1996</font>++ Graham Hutton Erik Meijer+ University <font color=Green><u>of</u></font> Nottingham University <font color=Green><u>of</u></font> Utrecht++This Haskell <font color=Magenta>1.3</font> script defines a library <font color=Green><u>of</u></font> parser combinators<font color=Cyan>,</font> and is taken+<a name="from"></a>from sections <font color=Magenta>1</font><font color=Blue>-</font><font color=Magenta>6</font> <font color=Green><u>of</u></font> our article <font color=Magenta>"Monadic Parser Combinators"</font><font color=Cyan>.</font> Some changes+<a name="to"></a>to the library have been made <font color=Green><u>in</u></font> the move from Gofer to Haskell<font color=Red><b>:</b></font>++ <font color=Cyan>*</font> Do notation is used <font color=Green><u>in</u></font> place <font color=Green><u>of</u></font> monad comprehension notation<font color=Cyan>;</font>++ <font color=Cyan>*</font> The parser datatype is defined using <font color=Magenta>"newtype"</font><font color=Cyan>,</font> to avoid the overhead+ <font color=Green><u>of</u></font> tagging and untagging parsers with the P constructor<font color=Cyan>.</font>++<font color=Blue>------------------------------------------------------------------------------</font>+<font color=Cyan>**</font> Extended to allow a symbol table<font color=Cyan>/</font>state to be threaded through the monad<font color=Cyan>.</font>+<font color=Cyan>**</font> Extended to allow a parameterised token <font color=Green><u>type</u></font><font color=Cyan>,</font> rather than just strings<font color=Cyan>.</font>+<font color=Cyan>**</font> Extended to allow error<font color=Blue>-</font>reporting<font color=Cyan>.</font>++<font color=Cyan>(</font>Extensions<font color=Red><b>:</b></font> <font color=Magenta>1998</font><font color=Blue>-</font><font color=Magenta>2000</font> Malcolm<font color=Cyan>.</font>Wallace<font color=Red>@</font>cs<font color=Cyan>.</font>york<font color=Cyan>.</font>ac<font color=Cyan>.</font>uk<font color=Cyan>)</font>+<a name="------------------------------------------------------------------------------}"></a><font color=Cyan>(</font>More extensions<font color=Red><b>:</b></font> <font color=Magenta>2004</font> gk<font color=Blue>-</font>haskell<font color=Red>@</font>ninebynine<font color=Cyan>.</font>org<font color=Cyan>)</font>++<font color=Cyan>------------------------------------------------------------------------------}</font>++<font color=Blue>-- | This library of monadic parser combinators is based on the ones</font>+<font color=Blue>-- defined by Graham Hutton and Erik Meijer. It has been extended by</font>+<font color=Blue>-- Malcolm Wallace to use an abstract token type (no longer just a</font>+<font color=Blue>-- string) as input, and to incorporate a State Transformer monad, useful</font>+<font color=Blue>-- for symbol tables, macros, and so on. Basic facilities for error</font>+<font color=Blue>-- reporting have also been added, and later extended by Graham Klyne</font>+<font color=Blue>-- to return the errors through an @Either@ type, rather than just</font>+<font color=Blue>-- calling @error@.</font>++<font color=Green><u>module</u></font> Text<font color=Cyan>.</font>ParserCombinators<font color=Cyan>.</font>HuttonMeijerWallace+ <font color=Cyan>(</font>+ <font color=Blue>-- * The parser monad</font>+ Parser<font color=Cyan>(</font><font color=Red>..</font><font color=Cyan>)</font>+ <font color=Blue>-- * Primitive parser combinators</font>+ <font color=Cyan>,</font> item<font color=Cyan>,</font> eof<font color=Cyan>,</font> papply<font color=Cyan>,</font> papply'+ <font color=Blue>-- * Derived combinators</font>+ <font color=Cyan>,</font> <font color=Cyan>(</font><font color=Cyan>+++</font><font color=Cyan>)</font><font color=Cyan>,</font> <font color=Blue>{-sat,-}</font> tok<font color=Cyan>,</font> nottok<font color=Cyan>,</font> many<font color=Cyan>,</font> many1+ <font color=Cyan>,</font> sepby<font color=Cyan>,</font> sepby1<font color=Cyan>,</font> chainl<font color=Cyan>,</font> chainl1<font color=Cyan>,</font> chainr<font color=Cyan>,</font> chainr1<font color=Cyan>,</font> ops<font color=Cyan>,</font> bracket+ <font color=Cyan>,</font> toEOF+ <font color=Blue>-- * Error handling</font>+ <font color=Cyan>,</font> elserror+ <font color=Blue>-- * State handling</font>+ <font color=Cyan>,</font> stupd<font color=Cyan>,</font> stquery<font color=Cyan>,</font> stget+ <font color=Blue>-- * Re-parsing</font>+ <font color=Cyan>,</font> reparse+ <font color=Cyan>)</font> <font color=Green><u>where</u></font>++<font color=Green><u>import</u></font> Char+<font color=Green><u>import</u></font> Monad++<font color=Green><u>infixr</u></font> <font color=Magenta>5</font> <font color=Cyan>+++</font>++<font color=Blue>--- The parser monad ---------------------------------------------------------</font>++<a name="ParseResult"></a><font color=Green><u>type</u></font> ParseResult s t e a <font color=Red>=</font> Either e <font color=Red>[</font><font color=Cyan>(</font>a<font color=Cyan>,</font>s<font color=Cyan>,</font><font color=Red>[</font>Either e t<font color=Red>]</font><font color=Cyan>)</font><font color=Red>]</font>++<font color=Green><u>newtype</u></font> Parser s t e a <font color=Red>=</font> P <font color=Cyan>(</font> s <font color=Red>-></font> <font color=Red>[</font>Either e t<font color=Red>]</font> <font color=Red>-></font> ParseResult s t e a <font color=Cyan>)</font>+ <font color=Blue>-- ^ The parser type is parametrised on the types of the state @s@,</font>+ <font color=Blue>-- the input tokens @t@, error-type @e@, and the result value @a@.</font>+ <font color=Blue>-- The state and remaining input are threaded through the monad.</font>++<font color=Green><u>instance</u></font> Functor <font color=Cyan>(</font>Parser s t e<font color=Cyan>)</font> <font color=Green><u>where</u></font>+ <font color=Blue>-- fmap :: (a -> b) -> (Parser s t e a -> Parser s t e b)</font>+ fmap f <font color=Cyan>(</font>P p<font color=Cyan>)</font> <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>st inp <font color=Red>-></font> <font color=Green><u>case</u></font> p st inp <font color=Green><u>of</u></font>+ Right res <font color=Red>-></font> Right <font color=Red>[</font><font color=Cyan>(</font>f v<font color=Cyan>,</font> s<font color=Cyan>,</font> out<font color=Cyan>)</font> <font color=Red>|</font> <font color=Cyan>(</font>v<font color=Cyan>,</font>s<font color=Cyan>,</font>out<font color=Cyan>)</font> <font color=Red><-</font> res<font color=Red>]</font>+ Left err <font color=Red>-></font> Left err+ <font color=Cyan>)</font>++<font color=Green><u>instance</u></font> Monad <font color=Cyan>(</font>Parser s t e<font color=Cyan>)</font> <font color=Green><u>where</u></font>+ <font color=Blue>-- return :: a -> Parser s t e a</font>+ return v <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>st inp <font color=Red>-></font> Right <font color=Red>[</font><font color=Cyan>(</font>v<font color=Cyan>,</font>st<font color=Cyan>,</font>inp<font color=Cyan>)</font><font color=Red>]</font><font color=Cyan>)</font>+ <font color=Blue>-- >>= :: Parser s t e a -> (a -> Parser s t e b) -> Parser s t e b</font>+ <font color=Cyan>(</font>P p<font color=Cyan>)</font> <font color=Cyan>>>=</font> f <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>st inp <font color=Red>-></font> <font color=Green><u>case</u></font> p st inp <font color=Green><u>of</u></font>+ Right res <font color=Red>-></font> foldr joinresults <font color=Cyan>(</font>Right <font color=Red>[</font><font color=Red>]</font><font color=Cyan>)</font>+ <font color=Red>[</font> papply' <font color=Cyan>(</font>f v<font color=Cyan>)</font> s out <font color=Red>|</font> <font color=Cyan>(</font>v<font color=Cyan>,</font>s<font color=Cyan>,</font>out<font color=Cyan>)</font> <font color=Red><-</font> res <font color=Red>]</font>+ Left err <font color=Red>-></font> Left err+ <font color=Cyan>)</font>+ <font color=Blue>-- fail :: String -> Parser s t e a</font>+ fail err <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>st inp <font color=Red>-></font> Right <font color=Red>[</font><font color=Red>]</font><font color=Cyan>)</font>+ <font color=Blue>-- I know it's counterintuitive, but we want no-parse, not an error.</font>++<font color=Green><u>instance</u></font> MonadPlus <font color=Cyan>(</font>Parser s t e<font color=Cyan>)</font> <font color=Green><u>where</u></font>+ <font color=Blue>-- mzero :: Parser s t e a</font>+ mzero <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>st inp <font color=Red>-></font> Right <font color=Red>[</font><font color=Red>]</font><font color=Cyan>)</font>+ <font color=Blue>-- mplus :: Parser s t e a -> Parser s t e a -> Parser s t e a</font>+ <font color=Cyan>(</font>P p<font color=Cyan>)</font> <font color=Cyan>`mplus`</font> <font color=Cyan>(</font>P q<font color=Cyan>)</font> <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>st inp <font color=Red>-></font> joinresults <font color=Cyan>(</font>p st inp<font color=Cyan>)</font> <font color=Cyan>(</font>q st inp<font color=Cyan>)</font><font color=Cyan>)</font>++<font color=Blue>-- joinresults ensures that explicitly raised errors are dominant,</font>+<font color=Blue>-- provided no parse has yet been found. The commented out code is</font>+<font color=Blue>-- a slightly stricter specification of the real code.</font>+joinresults <font color=Red>::</font> ParseResult s t e a <font color=Red>-></font> ParseResult s t e a <font color=Red>-></font> ParseResult s t e a+<font color=Blue>{-+joinresults (Left p) (Left q) = Left p+joinresults (Left p) (Right _) = Left p+joinresults (Right []) (Left q) = Left q+joinresults (Right p) (Left q) = Right p+joinresults (Right p) (Right q) = Right (p++q)+-}</font>+<a name="joinresults"></a>joinresults <font color=Cyan>(</font>Left p<font color=Cyan>)</font> q <font color=Red>=</font> Left p+joinresults <font color=Cyan>(</font>Right <font color=Red>[</font><font color=Red>]</font><font color=Cyan>)</font> q <font color=Red>=</font> q+joinresults <font color=Cyan>(</font>Right p<font color=Cyan>)</font> q <font color=Red>=</font> Right <font color=Cyan>(</font>p<font color=Cyan>++</font> <font color=Green><u>case</u></font> q <font color=Green><u>of</u></font> Left <font color=Green><u>_</u></font> <font color=Red>-></font> <font color=Red>[</font><font color=Red>]</font>+ Right r <font color=Red>-></font> r<font color=Cyan>)</font>+++<font color=Blue>--- Primitive parser combinators ---------------------------------------------</font>++<font color=Blue>-- | Deliver the first remaining token.</font>+item <font color=Red>::</font> Parser s t e t+<a name="item"></a>item <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>st inp <font color=Red>-></font> <font color=Green><u>case</u></font> inp <font color=Green><u>of</u></font>+ <font color=Red>[</font><font color=Red>]</font> <font color=Red>-></font> Right <font color=Red>[</font><font color=Red>]</font>+ <font color=Cyan>(</font>Left e<font color=Red><b>:</b></font> <font color=Green><u>_</u></font><font color=Cyan>)</font> <font color=Red>-></font> Left e+ <font color=Cyan>(</font>Right x<font color=Red><b>:</b></font> xs<font color=Cyan>)</font> <font color=Red>-></font> Right <font color=Red>[</font><font color=Cyan>(</font>x<font color=Cyan>,</font>st<font color=Cyan>,</font>xs<font color=Cyan>)</font><font color=Red>]</font>+ <font color=Cyan>)</font>++<font color=Blue>-- | Fail if end of input is not reached</font>+eof <font color=Red>::</font> Show p <font color=Red>=></font> Parser s <font color=Cyan>(</font>p<font color=Cyan>,</font>t<font color=Cyan>)</font> String <font color=Cyan>(</font><font color=Cyan>)</font>+<a name="eof"></a>eof <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>st inp <font color=Red>-></font> <font color=Green><u>case</u></font> inp <font color=Green><u>of</u></font>+ <font color=Red>[</font><font color=Red>]</font> <font color=Red>-></font> Right <font color=Red>[</font><font color=Cyan>(</font><font color=Cyan>(</font><font color=Cyan>)</font><font color=Cyan>,</font>st<font color=Cyan>,</font><font color=Red>[</font><font color=Red>]</font><font color=Cyan>)</font><font color=Red>]</font>+ <font color=Cyan>(</font>Left e<font color=Red><b>:</b></font><font color=Green><u>_</u></font><font color=Cyan>)</font> <font color=Red>-></font> Left e+ <font color=Cyan>(</font>Right <font color=Cyan>(</font>p<font color=Cyan>,</font><font color=Green><u>_</u></font><font color=Cyan>)</font><font color=Red><b>:</b></font><font color=Green><u>_</u></font><font color=Cyan>)</font> <font color=Red>-></font> Left <font color=Cyan>(</font><font color=Magenta>"End of input expected at "</font>+ <font color=Cyan>++</font>show p<font color=Cyan>++</font><font color=Magenta>"\n but found text"</font><font color=Cyan>)</font>+ <font color=Cyan>)</font>++<font color=Blue>{-+-- | Ensure the value delivered by the parser is evaluated to WHNF.+force :: Parser s t e a -> Parser s t e a+force (P p) = P (\st inp -> let Right xs = p st inp+ h = head xs in+ h `seq` Right (h: tail xs)+ )+-- [[[GK]]] ^^^^^^+-- WHNF = Weak Head Normal Form, meaning that it has no top-level redex.+-- In this case, I think that means that the first element of the list+-- is fully evaluated.+--+-- NOTE: the original form of this function fails if there is no parse+-- result for p st inp (head xs fails if xs is null), so the modified+-- form can assume a Right value only.+--+-- Why is this needed?+-- It's not exported, and the only use of this I see is commented out.+---------------------------------------+-}</font>+++<font color=Blue>-- | Deliver the first parse result only, eliminating any backtracking.</font>+first <font color=Red>::</font> Parser s t e a <font color=Red>-></font> Parser s t e a+<a name="first"></a>first <font color=Cyan>(</font>P p<font color=Cyan>)</font> <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>st inp <font color=Red>-></font> <font color=Green><u>case</u></font> p st inp <font color=Green><u>of</u></font>+ Right <font color=Cyan>(</font>x<font color=Red><b>:</b></font>xs<font color=Cyan>)</font> <font color=Red>-></font> Right <font color=Red>[</font>x<font color=Red>]</font>+ otherwise <font color=Red>-></font> otherwise+ <font color=Cyan>)</font>++<font color=Blue>-- | Apply the parser to some real input, given an initial state value.</font>+<font color=Blue>-- If the parser fails, raise 'error' to halt the program.</font>+<font color=Blue>-- (This is the original exported behaviour - to allow the caller to</font>+<font color=Blue>-- deal with the error differently, see @papply'@.)</font>+papply <font color=Red>::</font> Parser s t String a <font color=Red>-></font> s <font color=Red>-></font> <font color=Red>[</font>Either String t<font color=Red>]</font>+ <font color=Red>-></font> <font color=Red>[</font><font color=Cyan>(</font>a<font color=Cyan>,</font>s<font color=Cyan>,</font><font color=Red>[</font>Either String t<font color=Red>]</font><font color=Cyan>)</font><font color=Red>]</font>+<a name="papply"></a>papply <font color=Cyan>(</font>P p<font color=Cyan>)</font> st inp <font color=Red>=</font> either error id <font color=Cyan>(</font>p st inp<font color=Cyan>)</font>++<font color=Blue>-- | Apply the parser to some real input, given an initial state value.</font>+<font color=Blue>-- If the parser fails, return a diagnostic message to the caller.</font>+papply' <font color=Red>::</font> Parser s t e a <font color=Red>-></font> s <font color=Red>-></font> <font color=Red>[</font>Either e t<font color=Red>]</font>+ <font color=Red>-></font> Either e <font color=Red>[</font><font color=Cyan>(</font>a<font color=Cyan>,</font>s<font color=Cyan>,</font><font color=Red>[</font>Either e t<font color=Red>]</font><font color=Cyan>)</font><font color=Red>]</font>+<a name="papply'"></a>papply' <font color=Cyan>(</font>P p<font color=Cyan>)</font> st inp <font color=Red>=</font> p st inp++<font color=Blue>--- Derived combinators ------------------------------------------------------</font>++<font color=Blue>-- | A choice between parsers. Keep only the first success.</font>+<a name="+++"></a><font color=Cyan>(</font><font color=Cyan>+++</font><font color=Cyan>)</font> <font color=Red>::</font> Parser s t e a <font color=Red>-></font> Parser s t e a <font color=Red>-></font> Parser s t e a+<a name="p"></a>p <font color=Cyan>+++</font> q <font color=Red>=</font> first <font color=Cyan>(</font>p <font color=Cyan>`mplus`</font> q<font color=Cyan>)</font>++<font color=Blue>-- | Deliver the first token if it satisfies a predicate.</font>+sat <font color=Red>::</font> <font color=Cyan>(</font>t <font color=Red>-></font> Bool<font color=Cyan>)</font> <font color=Red>-></font> Parser s <font color=Cyan>(</font>p<font color=Cyan>,</font>t<font color=Cyan>)</font> e t+<a name="sat"></a>sat p <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font><font color=Cyan>(</font><font color=Green><u>_</u></font><font color=Cyan>,</font>x<font color=Cyan>)</font> <font color=Red><-</font> item<font color=Cyan>;</font> <font color=Green><u>if</u></font> p x <font color=Green><u>then</u></font> return x <font color=Green><u>else</u></font> mzero<font color=Cyan>}</font>++<font color=Blue>-- | Deliver the first token if it equals the argument.</font>+tok <font color=Red>::</font> Eq t <font color=Red>=></font> t <font color=Red>-></font> Parser s <font color=Cyan>(</font>p<font color=Cyan>,</font>t<font color=Cyan>)</font> e t+<a name="tok"></a>tok t <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font><font color=Cyan>(</font><font color=Green><u>_</u></font><font color=Cyan>,</font>x<font color=Cyan>)</font> <font color=Red><-</font> item<font color=Cyan>;</font> <font color=Green><u>if</u></font> x<font color=Cyan>==</font>t <font color=Green><u>then</u></font> return t <font color=Green><u>else</u></font> mzero<font color=Cyan>}</font>++<font color=Blue>-- | Deliver the first token if it does not equal the argument.</font>+nottok <font color=Red>::</font> Eq t <font color=Red>=></font> <font color=Red>[</font>t<font color=Red>]</font> <font color=Red>-></font> Parser s <font color=Cyan>(</font>p<font color=Cyan>,</font>t<font color=Cyan>)</font> e t+<a name="nottok"></a>nottok ts <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font><font color=Cyan>(</font><font color=Green><u>_</u></font><font color=Cyan>,</font>x<font color=Cyan>)</font> <font color=Red><-</font> item<font color=Cyan>;</font> <font color=Green><u>if</u></font> x <font color=Cyan>`notElem`</font> ts <font color=Green><u>then</u></font> return x+ <font color=Green><u>else</u></font> mzero<font color=Cyan>}</font>++<font color=Blue>-- | Deliver zero or more values of @a@.</font>+many <font color=Red>::</font> Parser s t e a <font color=Red>-></font> Parser s t e <font color=Red>[</font>a<font color=Red>]</font>+<a name="many"></a>many p <font color=Red>=</font> many1 p <font color=Cyan>+++</font> return <font color=Red>[</font><font color=Red>]</font>+<font color=Blue>--many p = force (many1 p +++ return [])</font>++<font color=Blue>-- | Deliver one or more values of @a@.</font>+many1 <font color=Red>::</font> Parser s t e a <font color=Red>-></font> Parser s t e <font color=Red>[</font>a<font color=Red>]</font>+<a name="many1"></a>many1 p <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font>x <font color=Red><-</font> p<font color=Cyan>;</font> xs <font color=Red><-</font> many p<font color=Cyan>;</font> return <font color=Cyan>(</font>x<font color=Red><b>:</b></font>xs<font color=Cyan>)</font><font color=Cyan>}</font>++<font color=Blue>-- | Deliver zero or more values of @a@ separated by @b@'s.</font>+sepby <font color=Red>::</font> Parser s t e a <font color=Red>-></font> Parser s t e b <font color=Red>-></font> Parser s t e <font color=Red>[</font>a<font color=Red>]</font>+<a name="sepby"></a>p <font color=Cyan>`sepby`</font> sep <font color=Red>=</font> <font color=Cyan>(</font>p <font color=Cyan>`sepby1`</font> sep<font color=Cyan>)</font> <font color=Cyan>+++</font> return <font color=Red>[</font><font color=Red>]</font>++<font color=Blue>-- | Deliver one or more values of @a@ separated by @b@'s.</font>+sepby1 <font color=Red>::</font> Parser s t e a <font color=Red>-></font> Parser s t e b <font color=Red>-></font> Parser s t e <font color=Red>[</font>a<font color=Red>]</font>+<a name="sepby1"></a>p <font color=Cyan>`sepby1`</font> sep <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font>x <font color=Red><-</font> p<font color=Cyan>;</font> xs <font color=Red><-</font> many <font color=Cyan>(</font><font color=Green><u>do</u></font> <font color=Cyan>{</font>sep<font color=Cyan>;</font> p<font color=Cyan>}</font><font color=Cyan>)</font><font color=Cyan>;</font> return <font color=Cyan>(</font>x<font color=Red><b>:</b></font>xs<font color=Cyan>)</font><font color=Cyan>}</font>++chainl <font color=Red>::</font> Parser s t e a <font color=Red>-></font> Parser s t e <font color=Cyan>(</font>a<font color=Red>-></font>a<font color=Red>-></font>a<font color=Cyan>)</font> <font color=Red>-></font> a+ <font color=Red>-></font> Parser s t e a+<a name="chainl"></a>chainl p op v <font color=Red>=</font> <font color=Cyan>(</font>p <font color=Cyan>`chainl1`</font> op<font color=Cyan>)</font> <font color=Cyan>+++</font> return v++chainl1 <font color=Red>::</font> Parser s t e a <font color=Red>-></font> Parser s t e <font color=Cyan>(</font>a<font color=Red>-></font>a<font color=Red>-></font>a<font color=Cyan>)</font> <font color=Red>-></font> Parser s t e a+<a name="chainl1"></a>p <font color=Cyan>`chainl1`</font> op <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font>x <font color=Red><-</font> p<font color=Cyan>;</font> rest x<font color=Cyan>}</font>+ <font color=Green><u>where</u></font>+ rest x <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font>f <font color=Red><-</font> op<font color=Cyan>;</font> y <font color=Red><-</font> p<font color=Cyan>;</font> rest <font color=Cyan>(</font>f x y<font color=Cyan>)</font><font color=Cyan>}</font>+ <font color=Cyan>+++</font> return x++chainr <font color=Red>::</font> Parser s t e a <font color=Red>-></font> Parser s t e <font color=Cyan>(</font>a<font color=Red>-></font>a<font color=Red>-></font>a<font color=Cyan>)</font> <font color=Red>-></font> a+ <font color=Red>-></font> Parser s t e a+<a name="chainr"></a>chainr p op v <font color=Red>=</font> <font color=Cyan>(</font>p <font color=Cyan>`chainr1`</font> op<font color=Cyan>)</font> <font color=Cyan>+++</font> return v++chainr1 <font color=Red>::</font> Parser s t e a <font color=Red>-></font> Parser s t e <font color=Cyan>(</font>a<font color=Red>-></font>a<font color=Red>-></font>a<font color=Cyan>)</font> <font color=Red>-></font> Parser s t e a+<a name="chainr1"></a>p <font color=Cyan>`chainr1`</font> op <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font>x <font color=Red><-</font> p<font color=Cyan>;</font> rest x<font color=Cyan>}</font>+ <font color=Green><u>where</u></font>+ rest x <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font> f <font color=Red><-</font> op+ <font color=Cyan>;</font> y <font color=Red><-</font> p <font color=Cyan>`chainr1`</font> op+ <font color=Cyan>;</font> return <font color=Cyan>(</font>f x y<font color=Cyan>)</font>+ <font color=Cyan>}</font>+ <font color=Cyan>+++</font> return x++ops <font color=Red>::</font> <font color=Red>[</font><font color=Cyan>(</font>Parser s t e a<font color=Cyan>,</font> b<font color=Cyan>)</font><font color=Red>]</font> <font color=Red>-></font> Parser s t e b+<a name="ops"></a>ops xs <font color=Red>=</font> foldr1 <font color=Cyan>(</font><font color=Cyan>+++</font><font color=Cyan>)</font> <font color=Red>[</font><font color=Green><u>do</u></font> <font color=Cyan>{</font>p<font color=Cyan>;</font> return op<font color=Cyan>}</font> <font color=Red>|</font> <font color=Cyan>(</font>p<font color=Cyan>,</font>op<font color=Cyan>)</font> <font color=Red><-</font> xs<font color=Red>]</font>++bracket <font color=Red>::</font> <font color=Cyan>(</font>Show p<font color=Cyan>,</font>Show t<font color=Cyan>)</font> <font color=Red>=></font>+ Parser s <font color=Cyan>(</font>p<font color=Cyan>,</font>t<font color=Cyan>)</font> e a <font color=Red>-></font> Parser s <font color=Cyan>(</font>p<font color=Cyan>,</font>t<font color=Cyan>)</font> e b <font color=Red>-></font>+ Parser s <font color=Cyan>(</font>p<font color=Cyan>,</font>t<font color=Cyan>)</font> e c <font color=Red>-></font> Parser s <font color=Cyan>(</font>p<font color=Cyan>,</font>t<font color=Cyan>)</font> e b+<a name="bracket"></a>bracket open p close <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font> open+ <font color=Cyan>;</font> x <font color=Red><-</font> p+ <font color=Cyan>;</font> close <font color=Blue>-- `elserror` "improperly matched construct";</font>+ <font color=Cyan>;</font> return x+ <font color=Cyan>}</font>++<font color=Blue>-- | Accept a complete parse of the input only, no partial parses.</font>+toEOF <font color=Red>::</font> Show p <font color=Red>=></font>+ Parser s <font color=Cyan>(</font>p<font color=Cyan>,</font>t<font color=Cyan>)</font> String a <font color=Red>-></font> Parser s <font color=Cyan>(</font>p<font color=Cyan>,</font>t<font color=Cyan>)</font> String a+<a name="toEOF"></a>toEOF p <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font> x <font color=Red><-</font> p<font color=Cyan>;</font> eof<font color=Cyan>;</font> return x <font color=Cyan>}</font>+++<font color=Blue>--- Error handling -----------------------------------------------------------</font>++<font color=Blue>-- | Return an error using the supplied diagnostic string, and a token type</font>+<font color=Blue>-- which includes position information.</font>+parseerror <font color=Red>::</font> <font color=Cyan>(</font>Show p<font color=Cyan>,</font>Show t<font color=Cyan>)</font> <font color=Red>=></font> String <font color=Red>-></font> Parser s <font color=Cyan>(</font>p<font color=Cyan>,</font>t<font color=Cyan>)</font> String a+<a name="parseerror"></a>parseerror err <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>st inp <font color=Red>-></font>+ <font color=Green><u>case</u></font> inp <font color=Green><u>of</u></font>+ <font color=Red>[</font><font color=Red>]</font> <font color=Red>-></font> Left <font color=Magenta>"Parse error: unexpected EOF\n"</font>+ <font color=Cyan>(</font>Left e<font color=Red><b>:</b></font><font color=Green><u>_</u></font><font color=Cyan>)</font> <font color=Red>-></font> Left <font color=Cyan>(</font><font color=Magenta>"Lexical error: "</font><font color=Cyan>++</font>e<font color=Cyan>)</font>+ <font color=Cyan>(</font>Right <font color=Cyan>(</font>p<font color=Cyan>,</font>t<font color=Cyan>)</font><font color=Red><b>:</b></font><font color=Green><u>_</u></font><font color=Cyan>)</font> <font color=Red>-></font>+ Left <font color=Cyan>(</font><font color=Magenta>"Parse error: in "</font><font color=Cyan>++</font>show p<font color=Cyan>++</font><font color=Magenta>"\n "</font>+ <font color=Cyan>++</font>err<font color=Cyan>++</font><font color=Magenta>"\n "</font><font color=Cyan>++</font><font color=Magenta>"Found "</font><font color=Cyan>++</font>show t<font color=Cyan>)</font>+ <font color=Cyan>)</font>+++<font color=Blue>-- | If the parser fails, generate an error message.</font>+elserror <font color=Red>::</font> <font color=Cyan>(</font>Show p<font color=Cyan>,</font>Show t<font color=Cyan>)</font> <font color=Red>=></font> Parser s <font color=Cyan>(</font>p<font color=Cyan>,</font>t<font color=Cyan>)</font> String a <font color=Red>-></font> String+ <font color=Red>-></font> Parser s <font color=Cyan>(</font>p<font color=Cyan>,</font>t<font color=Cyan>)</font> String a+<a name="elserror"></a>p <font color=Cyan>`elserror`</font> s <font color=Red>=</font> p <font color=Cyan>+++</font> parseerror s++<font color=Blue>--- State handling -----------------------------------------------------------</font>++<font color=Blue>-- | Update the internal state.</font>+stupd <font color=Red>::</font> <font color=Cyan>(</font>s<font color=Red>-></font>s<font color=Cyan>)</font> <font color=Red>-></font> Parser s t e <font color=Cyan>(</font><font color=Cyan>)</font>+<a name="stupd"></a>stupd f <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>st inp<font color=Red>-></font> <font color=Blue>{-let newst = f st in newst `seq`-}</font>+ Right <font color=Red>[</font><font color=Cyan>(</font><font color=Cyan>(</font><font color=Cyan>)</font><font color=Cyan>,</font> f st<font color=Cyan>,</font> inp<font color=Cyan>)</font><font color=Red>]</font><font color=Cyan>)</font>++<font color=Blue>-- | Query the internal state.</font>+stquery <font color=Red>::</font> <font color=Cyan>(</font>s<font color=Red>-></font>a<font color=Cyan>)</font> <font color=Red>-></font> Parser s t e a+<a name="stquery"></a>stquery f <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>st inp<font color=Red>-></font> Right <font color=Red>[</font><font color=Cyan>(</font>f st<font color=Cyan>,</font> st<font color=Cyan>,</font> inp<font color=Cyan>)</font><font color=Red>]</font><font color=Cyan>)</font>++<font color=Blue>-- | Deliver the entire internal state.</font>+stget <font color=Red>::</font> Parser s t e s+<a name="stget"></a>stget <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>st inp<font color=Red>-></font> Right <font color=Red>[</font><font color=Cyan>(</font>st<font color=Cyan>,</font> st<font color=Cyan>,</font> inp<font color=Cyan>)</font><font color=Red>]</font><font color=Cyan>)</font>+++<font color=Blue>--- Push some tokens back onto the input stream and reparse ------------------</font>++<font color=Blue>-- | This is useful for recursively expanding macros. When the</font>+<font color=Blue>-- user-parser recognises a macro use, it can lookup the macro</font>+<font color=Blue>-- expansion from the parse state, lex it, and then stuff the</font>+<font color=Blue>-- lexed expansion back down into the parser.</font>+reparse <font color=Red>::</font> <font color=Red>[</font>Either e t<font color=Red>]</font> <font color=Red>-></font> Parser s t e <font color=Cyan>(</font><font color=Cyan>)</font>+<a name="reparse"></a>reparse ts <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>st inp<font color=Red>-></font> Right <font color=Red>[</font><font color=Cyan>(</font><font color=Cyan>(</font><font color=Cyan>)</font><font color=Cyan>,</font> st<font color=Cyan>,</font> ts<font color=Cyan>++</font>inp<font color=Cyan>)</font><font color=Red>]</font><font color=Cyan>)</font>++<font color=Blue>------------------------------------------------------------------------------</font>+</pre>
+ docs/haddock/src/Text/ParserCombinators/Poly.html view
@@ -0,0 +1,239 @@+<pre><font color=Green><u>module</u></font> Text<font color=Cyan>.</font>ParserCombinators<font color=Cyan>.</font>Poly+ <font color=Cyan>(</font> <font color=Blue>-- * The Parser datatype</font>+ Parser<font color=Cyan>(</font>P<font color=Cyan>)</font> <font color=Blue>-- datatype, instance of: Functor, Monad</font>+ <font color=Cyan>,</font> runParser <font color=Blue>-- :: Parser t a -> [t] -> (Either String a, [t])</font>+ <font color=Cyan>,</font> failBad <font color=Blue>-- :: String -> Parser t a</font>+ <font color=Cyan>,</font> commit <font color=Blue>-- :: Parser t a -> Parser t a</font>++ <font color=Blue>-- * Combinators:</font>+ <font color=Blue>-- ** Primitives</font>+ <font color=Cyan>,</font> next <font color=Blue>-- :: Parser t t</font>+ <font color=Cyan>,</font> satisfy <font color=Blue>-- :: (t->Bool) -> Parser t t</font>+ <font color=Cyan>,</font> apply <font color=Blue>-- :: Parser t (a->b) -> Parser t a -> Parser t b</font>+ <font color=Cyan>,</font> discard <font color=Blue>-- :: Parser t a -> Parser t b -> Parser t a</font>+ <font color=Blue>-- ** Error-handling</font>+ <font color=Cyan>,</font> adjustErr <font color=Blue>-- :: Parser t a -> (String->String) -> Parser t a</font>+ <font color=Cyan>,</font> adjustErrBad<font color=Blue>-- :: Parser t a -> (String->String) -> Parser t a</font>+ <font color=Cyan>,</font> indent <font color=Blue>-- :: Int -> String -> String</font>+ <font color=Blue>-- ** Choices</font>+ <font color=Cyan>,</font> onFail <font color=Blue>-- :: Parser t a -> Parser t a -> Parser t a</font>+ <font color=Cyan>,</font> oneOf <font color=Blue>-- :: Show t => [Parser t a] -> Parser t a</font>+ <font color=Cyan>,</font> oneOf' <font color=Blue>-- :: [(String,Parser t a)] -> Parser t a</font>+ <font color=Cyan>,</font> optional <font color=Blue>-- :: Parser t a -> Parser t (Maybe a)</font>+ <font color=Blue>-- ** Sequences</font>+ <font color=Cyan>,</font> many <font color=Blue>-- :: Parser t a -> Parser t [a]</font>+ <font color=Cyan>,</font> many1 <font color=Blue>-- :: Parser t a -> Parser t [a]</font>+ <font color=Cyan>,</font> sepBy <font color=Blue>-- :: Parser t a -> Parser t sep -> Parser t [a]</font>+ <font color=Cyan>,</font> sepBy1 <font color=Blue>-- :: Parser t a -> Parser t sep -> Parser t [a]</font>+ <font color=Cyan>,</font> bracketSep <font color=Blue>-- :: Parser t bra -> Parser t sep -> Parser t ket</font>+ <font color=Blue>-- -> Parser t a -> Parser t [a]</font>+ <font color=Cyan>,</font> bracket <font color=Blue>-- :: Parser t bra -> Parser t ket -> Parser t a</font>+ <font color=Blue>-- -> Parser t a</font>+ <font color=Cyan>,</font> manyFinally <font color=Blue>-- :: Parser t a -> Parser t z -> Parser t [a]</font>+ <font color=Blue>-- ** re-parsing</font>+ <font color=Cyan>,</font> reparse <font color=Blue>-- :: [t] -> Parser t ()</font>+ <font color=Cyan>)</font> <font color=Green><u>where</u></font>+++<font color=Blue>-- | The @Parser@ datatype is a fairly generic parsing monad with error</font>+<font color=Blue>-- reporting. It can be used for arbitrary token types, not just</font>+<font color=Blue>-- String input. (If you require a running state, use module PolyState</font>+<font color=Blue>-- instead)</font>+<font color=Green><u>newtype</u></font> Parser t a <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>[</font>t<font color=Red>]</font> <font color=Red>-></font> <font color=Cyan>(</font>EitherE String a<font color=Cyan>,</font> <font color=Red>[</font>t<font color=Red>]</font><font color=Cyan>)</font><font color=Cyan>)</font>++<font color=Blue>-- A return type like Either, that distinguishes not only between</font>+<font color=Blue>-- right and wrong answers, but also had gradations of wrongness.</font>+<a name="EitherE"></a><font color=Green><u>type</u></font> EitherE a b <font color=Red>=</font> Either <font color=Cyan>(</font>Bool<font color=Cyan>,</font>a<font color=Cyan>)</font> b++<font color=Blue>-- | Apply a parser to an input token sequence.</font>+runParser <font color=Red>::</font> Parser t a <font color=Red>-></font> <font color=Red>[</font>t<font color=Red>]</font> <font color=Red>-></font> <font color=Cyan>(</font>Either String a<font color=Cyan>,</font> <font color=Red>[</font>t<font color=Red>]</font><font color=Cyan>)</font>+<a name="runParser"></a>runParser <font color=Cyan>(</font>P p<font color=Cyan>)</font> <font color=Red>=</font>+ <font color=Cyan>(</font><font color=Red>\</font> <font color=Cyan>(</font>e<font color=Cyan>,</font>ts<font color=Cyan>)</font><font color=Red>-></font> <font color=Cyan>(</font><font color=Green><u>case</u></font> e <font color=Green><u>of</u></font> <font color=Cyan>{</font>Left <font color=Cyan>(</font><font color=Green><u>_</u></font><font color=Cyan>,</font>m<font color=Cyan>)</font><font color=Red>-></font>Left m<font color=Cyan>;</font> Right m<font color=Red>-></font>Right m<font color=Cyan>}</font><font color=Cyan>,</font> ts<font color=Cyan>)</font> <font color=Cyan>)</font>+ <font color=Cyan>.</font> p++<font color=Green><u>instance</u></font> Functor <font color=Cyan>(</font>Parser t<font color=Cyan>)</font> <font color=Green><u>where</u></font>+ fmap f <font color=Cyan>(</font>P p<font color=Cyan>)</font> <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>ts<font color=Red>-></font> <font color=Green><u>case</u></font> p ts <font color=Green><u>of</u></font>+ <font color=Cyan>(</font>Left msg<font color=Cyan>,</font> ts'<font color=Cyan>)</font> <font color=Red>-></font> <font color=Cyan>(</font>Left msg<font color=Cyan>,</font> ts'<font color=Cyan>)</font>+ <font color=Cyan>(</font>Right x<font color=Cyan>,</font> ts'<font color=Cyan>)</font> <font color=Red>-></font> <font color=Cyan>(</font>Right <font color=Cyan>(</font>f x<font color=Cyan>)</font><font color=Cyan>,</font> ts'<font color=Cyan>)</font><font color=Cyan>)</font>+<font color=Green><u>instance</u></font> Monad <font color=Cyan>(</font>Parser t<font color=Cyan>)</font> <font color=Green><u>where</u></font>+ return x <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>ts<font color=Red>-></font> <font color=Cyan>(</font>Right x<font color=Cyan>,</font> ts<font color=Cyan>)</font><font color=Cyan>)</font>+ <font color=Cyan>(</font>P f<font color=Cyan>)</font> <font color=Cyan>>>=</font> g <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>ts<font color=Red>-></font> <font color=Green><u>case</u></font> f ts <font color=Green><u>of</u></font>+ <font color=Cyan>(</font>Left msg<font color=Cyan>,</font> ts'<font color=Cyan>)</font> <font color=Red>-></font> <font color=Cyan>(</font>Left msg<font color=Cyan>,</font> ts'<font color=Cyan>)</font>+ <font color=Cyan>(</font>Right x<font color=Cyan>,</font> ts'<font color=Cyan>)</font> <font color=Red>-></font> <font color=Green><u>let</u></font> <font color=Cyan>(</font>P g'<font color=Cyan>)</font> <font color=Red>=</font> g x <font color=Green><u>in</u></font> g' ts'<font color=Cyan>)</font>+ fail e <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>ts<font color=Red>-></font> <font color=Cyan>(</font>Left <font color=Cyan>(</font>False<font color=Cyan>,</font>e<font color=Cyan>)</font><font color=Cyan>,</font> ts<font color=Cyan>)</font><font color=Cyan>)</font>++<font color=Blue>-- | When a simple fail is not strong enough, use failBad for emphasis.</font>+<font color=Blue>-- An emphasised (severe) error can propagate out through choice operators.</font>+failBad <font color=Red>::</font> String <font color=Red>-></font> Parser t a+<a name="failBad"></a>failBad msg <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>ts<font color=Red>-></font> <font color=Cyan>(</font>Left <font color=Cyan>(</font>True<font color=Cyan>,</font>msg<font color=Cyan>)</font><font color=Cyan>,</font> ts<font color=Cyan>)</font><font color=Cyan>)</font>++<font color=Blue>-- | Commit is a way of raising the severity of any errors found within</font>+<font color=Blue>-- its argument. Used in the middle of a parser definition, it means that</font>+<font color=Blue>-- any operations prior to commitment fail softly, but after commitment,</font>+<font color=Blue>-- they fail hard.</font>+commit <font color=Red>::</font> Parser t a <font color=Red>-></font> Parser t a+<a name="commit"></a>commit <font color=Cyan>(</font>P p<font color=Cyan>)</font> <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>ts<font color=Red>-></font> <font color=Green><u>case</u></font> p ts <font color=Green><u>of</u></font>+ <font color=Cyan>(</font>Left <font color=Cyan>(</font><font color=Green><u>_</u></font><font color=Cyan>,</font>e<font color=Cyan>)</font><font color=Cyan>,</font> ts'<font color=Cyan>)</font> <font color=Red>-></font> <font color=Cyan>(</font>Left <font color=Cyan>(</font>True<font color=Cyan>,</font>e<font color=Cyan>)</font><font color=Cyan>,</font> ts'<font color=Cyan>)</font>+ right <font color=Red>-></font> right <font color=Cyan>)</font>+++<font color=Blue>-- Combinators</font>++<font color=Blue>-- | One token</font>+next <font color=Red>::</font> Parser t t+<a name="next"></a>next <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>ts<font color=Red>-></font> <font color=Green><u>case</u></font> ts <font color=Green><u>of</u></font>+ <font color=Red>[</font><font color=Red>]</font> <font color=Red>-></font> <font color=Cyan>(</font>Left <font color=Cyan>(</font>False<font color=Cyan>,</font><font color=Magenta>"Ran out of input (EOF)"</font><font color=Cyan>)</font><font color=Cyan>,</font> <font color=Red>[</font><font color=Red>]</font><font color=Cyan>)</font>+ <font color=Cyan>(</font>t<font color=Red><b>:</b></font>ts'<font color=Cyan>)</font> <font color=Red>-></font> <font color=Cyan>(</font>Right t<font color=Cyan>,</font> ts'<font color=Cyan>)</font> <font color=Cyan>)</font>++<font color=Blue>-- | One token satifying a predicate</font>+satisfy <font color=Red>::</font> <font color=Cyan>(</font>t<font color=Red>-></font>Bool<font color=Cyan>)</font> <font color=Red>-></font> Parser t t+<a name="satisfy"></a>satisfy p <font color=Red>=</font> <font color=Green><u>do</u></font><font color=Cyan>{</font> x <font color=Red><-</font> next+ <font color=Cyan>;</font> <font color=Green><u>if</u></font> p x <font color=Green><u>then</u></font> return x <font color=Green><u>else</u></font> fail <font color=Magenta>"Parse.satisfy: failed"</font>+ <font color=Cyan>}</font>++<font color=Green><u>infixl</u></font> <font color=Magenta>3</font> <font color=Cyan>`apply`</font>+<font color=Blue>-- | Apply a parsed function to a parsed value</font>+apply <font color=Red>::</font> Parser t <font color=Cyan>(</font>a<font color=Red>-></font>b<font color=Cyan>)</font> <font color=Red>-></font> Parser t a <font color=Red>-></font> Parser t b+<a name="apply"></a>pf <font color=Cyan>`apply`</font> px <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font> f <font color=Red><-</font> pf<font color=Cyan>;</font> x <font color=Red><-</font> px<font color=Cyan>;</font> return <font color=Cyan>(</font>f x<font color=Cyan>)</font> <font color=Cyan>}</font>++<font color=Green><u>infixl</u></font> <font color=Magenta>3</font> <font color=Cyan>`discard`</font>+<font color=Blue>-- | @x `discard` y@ parses both x and y, but discards the result of y</font>+discard <font color=Red>::</font> Parser t a <font color=Red>-></font> Parser t b <font color=Red>-></font> Parser t a+<a name="discard"></a>px <font color=Cyan>`discard`</font> py <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font> x <font color=Red><-</font> px<font color=Cyan>;</font> <font color=Green><u>_</u></font> <font color=Red><-</font> py<font color=Cyan>;</font> return x <font color=Cyan>}</font>++<font color=Blue>-- | @p `adjustErr` f@ applies the transformation @f@ to any error message</font>+<font color=Blue>-- generated in @p@, having no effect if @p@ succeeds.</font>+adjustErr <font color=Red>::</font> Parser t a <font color=Red>-></font> <font color=Cyan>(</font>String<font color=Red>-></font>String<font color=Cyan>)</font> <font color=Red>-></font> Parser t a+<a name="adjustErr"></a><font color=Cyan>(</font>P p<font color=Cyan>)</font> <font color=Cyan>`adjustErr`</font> f <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>ts<font color=Red>-></font> <font color=Green><u>case</u></font> p ts <font color=Green><u>of</u></font>+ <font color=Cyan>(</font>Left <font color=Cyan>(</font>b<font color=Cyan>,</font>msg<font color=Cyan>)</font><font color=Cyan>,</font> ts'<font color=Cyan>)</font> <font color=Red>-></font> <font color=Cyan>(</font>Left <font color=Cyan>(</font>b<font color=Cyan>,</font><font color=Cyan>(</font>f msg<font color=Cyan>)</font><font color=Cyan>)</font><font color=Cyan>,</font> ts'<font color=Cyan>)</font>+ right <font color=Red>-></font> right <font color=Cyan>)</font>++<font color=Blue>-- | @adjustErrBad@ is just like @adjustErr@ except it also raises the</font>+<font color=Blue>-- severity of the error.</font>+adjustErrBad <font color=Red>::</font> Parser t a <font color=Red>-></font> <font color=Cyan>(</font>String<font color=Red>-></font>String<font color=Cyan>)</font> <font color=Red>-></font> Parser t a+<a name="adjustErrBad"></a>p <font color=Cyan>`adjustErrBad`</font> f <font color=Red>=</font> commit <font color=Cyan>(</font>p <font color=Cyan>`adjustErr`</font> f<font color=Cyan>)</font>++<font color=Green><u>infixl</u></font> <font color=Magenta>6</font> <font color=Cyan>`onFail`</font> <font color=Blue>-- not sure about precedence 6?</font>+<font color=Blue>-- | @p `onFail` q@ means parse p unless p fails in which case parse q instead.</font>+<font color=Blue>-- Can be chained together to give multiple attempts to parse something.</font>+<font color=Blue>-- (Note that q could itself be a failing parser, e.g. to change the error</font>+<font color=Blue>-- message from that defined in p to something different.)</font>+<font color=Blue>-- However, a *severe* failure in p cannot be ignored.</font>+onFail <font color=Red>::</font> Parser t a <font color=Red>-></font> Parser t a <font color=Red>-></font> Parser t a+<a name="onFail"></a><font color=Cyan>(</font>P p<font color=Cyan>)</font> <font color=Cyan>`onFail`</font> <font color=Cyan>(</font>P q<font color=Cyan>)</font> <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>ts<font color=Red>-></font> <font color=Green><u>case</u></font> p ts <font color=Green><u>of</u></font>+ r<font color=Red>@</font><font color=Cyan>(</font>Left <font color=Cyan>(</font>True<font color=Cyan>,</font><font color=Green><u>_</u></font><font color=Cyan>)</font><font color=Cyan>,</font> <font color=Green><u>_</u></font><font color=Cyan>)</font> <font color=Red>-></font> r+ <font color=Cyan>(</font>Left <font color=Green><u>_</u></font><font color=Cyan>,</font> <font color=Green><u>_</u></font><font color=Cyan>)</font> <font color=Red>-></font> q ts+ right <font color=Red>-></font> right <font color=Cyan>)</font>++<font color=Blue>-- | Parse the first alternative in the list that succeeds.</font>+oneOf <font color=Red>::</font> <font color=Red>[</font>Parser t a<font color=Red>]</font> <font color=Red>-></font> Parser t a+<a name="oneOf"></a>oneOf <font color=Red>[</font><font color=Red>]</font> <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font> n <font color=Red><-</font> next+ <font color=Cyan>;</font> fail <font color=Cyan>(</font><font color=Magenta>"failed to parse any of the possible choices"</font><font color=Cyan>)</font>+ <font color=Cyan>}</font>+<font color=Blue>--oneOf :: Show t => [Parser t a] -> Parser t a</font>+<font color=Blue>--oneOf [] = do { n <- next</font>+<font color=Blue>-- ; fail ("failed to parse any of the possible choices"</font>+<font color=Blue>-- ++"\n next token is "++show n)</font>+<font color=Blue>-- }</font>+oneOf <font color=Cyan>(</font>p<font color=Red><b>:</b></font>ps<font color=Cyan>)</font> <font color=Red>=</font> p <font color=Cyan>`onFail`</font> oneOf ps++<font color=Blue>-- | Parse the first alternative that succeeds, but if none succeed,</font>+<font color=Blue>-- report only the severe errors, and if none of those, then report</font>+<font color=Blue>-- all the soft errors.</font>+oneOf' <font color=Red>::</font> <font color=Red>[</font><font color=Cyan>(</font>String<font color=Cyan>,</font> Parser t a<font color=Cyan>)</font><font color=Red>]</font> <font color=Red>-></font> Parser t a+<a name="oneOf'"></a>oneOf' <font color=Red>=</font> accum <font color=Red>[</font><font color=Red>]</font>+ <font color=Green><u>where</u></font> accum errs <font color=Red>[</font><font color=Red>]</font> <font color=Red>=</font>+ <font color=Green><u>case</u></font> filter isBad errs <font color=Green><u>of</u></font>+ <font color=Red>[</font><font color=Red>]</font> <font color=Red>-></font> fail <font color=Cyan>(</font><font color=Magenta>"failed to parse any of the possible choices:\n"</font>+ <font color=Cyan>++</font>indent <font color=Magenta>2</font> <font color=Cyan>(</font>concatMap showErr <font color=Cyan>(</font>reverse errs<font color=Cyan>)</font><font color=Cyan>)</font><font color=Cyan>)</font>+ <font color=Red>[</font><font color=Cyan>(</font><font color=Green><u>_</u></font><font color=Cyan>,</font><font color=Cyan>(</font><font color=Green><u>_</u></font><font color=Cyan>,</font>e<font color=Cyan>)</font><font color=Cyan>)</font><font color=Red>]</font> <font color=Red>-></font> failBad e+ es <font color=Red>-></font> failBad <font color=Cyan>(</font><font color=Magenta>"one of the following failures occurred:\n"</font>+ <font color=Cyan>++</font>indent <font color=Magenta>2</font> <font color=Cyan>(</font>concatMap showErr <font color=Cyan>(</font>reverse es<font color=Cyan>)</font><font color=Cyan>)</font><font color=Cyan>)</font>+ accum errs <font color=Cyan>(</font><font color=Cyan>(</font>e<font color=Cyan>,</font>P p<font color=Cyan>)</font><font color=Red><b>:</b></font>ps<font color=Cyan>)</font> <font color=Red>=</font>+ P <font color=Cyan>(</font><font color=Red>\</font>ts<font color=Red>-></font> <font color=Green><u>case</u></font> p ts <font color=Green><u>of</u></font>+ <font color=Cyan>(</font>Left err<font color=Cyan>,</font><font color=Green><u>_</u></font><font color=Cyan>)</font> <font color=Red>-></font> <font color=Green><u>let</u></font> <font color=Cyan>(</font>P p<font color=Cyan>)</font> <font color=Red>=</font> accum <font color=Cyan>(</font><font color=Cyan>(</font>e<font color=Cyan>,</font>err<font color=Cyan>)</font><font color=Red><b>:</b></font>errs<font color=Cyan>)</font> ps+ <font color=Green><u>in</u></font> p ts+ right <font color=Red>-></font> right <font color=Cyan>)</font>+ showErr <font color=Cyan>(</font>name<font color=Cyan>,</font><font color=Cyan>(</font><font color=Green><u>_</u></font><font color=Cyan>,</font>err<font color=Cyan>)</font><font color=Cyan>)</font> <font color=Red>=</font> name<font color=Cyan>++</font><font color=Magenta>":\n"</font><font color=Cyan>++</font>indent <font color=Magenta>2</font> err+ isBad <font color=Cyan>(</font><font color=Green><u>_</u></font><font color=Cyan>,</font><font color=Cyan>(</font>b<font color=Cyan>,</font><font color=Green><u>_</u></font><font color=Cyan>)</font><font color=Cyan>)</font> <font color=Red>=</font> b++<font color=Blue>-- | Helper for formatting error messages: indents all lines by a fixed amount.</font>+indent <font color=Red>::</font> Int <font color=Red>-></font> String <font color=Red>-></font> String+<a name="indent"></a>indent n <font color=Red>=</font> unlines <font color=Cyan>.</font> map <font color=Cyan>(</font>replicate n <font color=Magenta>' '</font> <font color=Cyan>++</font><font color=Cyan>)</font> <font color=Cyan>.</font> lines++<font color=Blue>-- | 'optional' indicates whether the parser succeeded through the Maybe type.</font>+optional <font color=Red>::</font> Parser t a <font color=Red>-></font> Parser t <font color=Cyan>(</font>Maybe a<font color=Cyan>)</font>+<a name="optional"></a>optional p <font color=Red>=</font> fmap Just p <font color=Cyan>`onFail`</font> return Nothing++<font color=Blue>-- | 'many p' parses a list of elements with individual parser p.</font>+<font color=Blue>-- Cannot fail, since an empty list is a valid return value.</font>+many <font color=Red>::</font> Parser t a <font color=Red>-></font> Parser t <font color=Red>[</font>a<font color=Red>]</font>+<a name="many"></a>many p <font color=Red>=</font> many1 p <font color=Cyan>`onFail`</font> return <font color=Red>[</font><font color=Red>]</font>++<font color=Blue>-- | Parse a non-empty list of items.</font>+many1 <font color=Red>::</font> Parser t a <font color=Red>-></font> Parser t <font color=Red>[</font>a<font color=Red>]</font>+<a name="many1"></a>many1 p <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font> x <font color=Red><-</font> p <font color=Cyan>`adjustErr`</font> <font color=Cyan>(</font><font color=Cyan>(</font><font color=Magenta>"In a sequence:\n"</font><font color=Cyan>++</font><font color=Cyan>)</font><font color=Cyan>.</font> indent <font color=Magenta>2</font><font color=Cyan>)</font>+ <font color=Cyan>;</font> xs <font color=Red><-</font> many p+ <font color=Cyan>;</font> return <font color=Cyan>(</font>x<font color=Red><b>:</b></font>xs<font color=Cyan>)</font>+ <font color=Cyan>}</font>+<font color=Blue>-- `adjustErr` ("When looking for a non-empty sequence:\n\t"++)</font>++<font color=Blue>-- | Parse a list of items separated by discarded junk.</font>+sepBy <font color=Red>::</font> Parser t a <font color=Red>-></font> Parser t sep <font color=Red>-></font> Parser t <font color=Red>[</font>a<font color=Red>]</font>+<a name="sepBy"></a>sepBy p sep <font color=Red>=</font> <font color=Green><u>do</u></font> sepBy1 p sep <font color=Cyan>`onFail`</font> return <font color=Red>[</font><font color=Red>]</font>++<font color=Blue>-- | Parse a non-empty list of items separated by discarded junk.</font>+sepBy1 <font color=Red>::</font> Parser t a <font color=Red>-></font> Parser t sep <font color=Red>-></font> Parser t <font color=Red>[</font>a<font color=Red>]</font>+<a name="sepBy1"></a>sepBy1 p sep <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font> x <font color=Red><-</font> p+ <font color=Cyan>;</font> xs <font color=Red><-</font> many <font color=Cyan>(</font><font color=Green><u>do</u></font> <font color=Cyan>{</font>sep<font color=Cyan>;</font> p<font color=Cyan>}</font><font color=Cyan>)</font>+ <font color=Cyan>;</font> return <font color=Cyan>(</font>x<font color=Red><b>:</b></font>xs<font color=Cyan>)</font>+ <font color=Cyan>}</font>+ <font color=Cyan>`adjustErr`</font> <font color=Cyan>(</font><font color=Magenta>"When looking for a non-empty sequence with separators:\n\t"</font><font color=Cyan>++</font><font color=Cyan>)</font>+ +<font color=Blue>-- | Parse a list of items, discarding the start, end, and separator</font>+<font color=Blue>-- items.</font>+bracketSep <font color=Red>::</font> Parser t bra <font color=Red>-></font> Parser t sep <font color=Red>-></font> Parser t ket+ <font color=Red>-></font> Parser t a <font color=Red>-></font> Parser t <font color=Red>[</font>a<font color=Red>]</font>+<a name="bracketSep"></a>bracketSep open sep close p <font color=Red>=</font>+ <font color=Green><u>do</u></font> <font color=Cyan>{</font> open<font color=Cyan>;</font> close<font color=Cyan>;</font> return <font color=Red>[</font><font color=Red>]</font> <font color=Cyan>}</font>+ <font color=Cyan>`onFail`</font>+ <font color=Green><u>do</u></font> <font color=Cyan>{</font> open <font color=Cyan>`adjustErr`</font> <font color=Cyan>(</font><font color=Magenta>"Missing opening bracket:\n\t"</font><font color=Cyan>++</font><font color=Cyan>)</font>+ <font color=Cyan>;</font> x <font color=Red><-</font> p <font color=Cyan>`adjustErr`</font> <font color=Cyan>(</font><font color=Magenta>"After first bracket in a group:\n\t"</font><font color=Cyan>++</font><font color=Cyan>)</font>+ <font color=Cyan>;</font> xs <font color=Red><-</font> many <font color=Cyan>(</font><font color=Green><u>do</u></font> <font color=Cyan>{</font>sep<font color=Cyan>;</font> p<font color=Cyan>}</font><font color=Cyan>)</font>+ <font color=Cyan>;</font> close <font color=Cyan>`adjustErrBad`</font> <font color=Cyan>(</font><font color=Magenta>"When looking for closing bracket:\n\t"</font><font color=Cyan>++</font><font color=Cyan>)</font>+ <font color=Cyan>;</font> return <font color=Cyan>(</font>x<font color=Red><b>:</b></font>xs<font color=Cyan>)</font>+ <font color=Cyan>}</font>++<font color=Blue>-- | Parse a bracketed item, discarding the brackets.</font>+bracket <font color=Red>::</font> Parser t bra <font color=Red>-></font> Parser t ket <font color=Red>-></font> Parser t a <font color=Red>-></font> Parser t a+<a name="bracket"></a>bracket open close p <font color=Red>=</font> <font color=Green><u>do</u></font>+ <font color=Green><u>do</u></font> <font color=Cyan>{</font> open <font color=Cyan>`adjustErr`</font> <font color=Cyan>(</font><font color=Magenta>"Missing opening bracket:\n\t"</font><font color=Cyan>++</font><font color=Cyan>)</font>+ <font color=Cyan>;</font> x <font color=Red><-</font> p+ <font color=Cyan>;</font> close <font color=Cyan>`adjustErrBad`</font> <font color=Cyan>(</font><font color=Magenta>"Missing closing bracket:\n\t"</font><font color=Cyan>++</font><font color=Cyan>)</font>+ <font color=Cyan>;</font> return x+ <font color=Cyan>}</font>++<font color=Blue>-- | 'manyFinally e t' parses a possibly-empty sequence of e's,</font>+<font color=Blue>-- terminated by a t. Any parse failures could be due either to</font>+<font color=Blue>-- a badly-formed terminator or a badly-formed element, so raise</font>+<font color=Blue>-- both possible errors.</font>+manyFinally <font color=Red>::</font> Parser t a <font color=Red>-></font> Parser t z <font color=Red>-></font> Parser t <font color=Red>[</font>a<font color=Red>]</font>+<a name="manyFinally"></a>manyFinally p t <font color=Red>=</font>+ <font color=Green><u>do</u></font> <font color=Cyan>{</font> xs <font color=Red><-</font> many p+ <font color=Cyan>;</font> oneOf' <font color=Red>[</font> <font color=Cyan>(</font><font color=Magenta>"sequence terminator"</font><font color=Cyan>,</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font> t<font color=Cyan>;</font> return <font color=Cyan>(</font><font color=Cyan>)</font> <font color=Cyan>}</font> <font color=Cyan>)</font>+ <font color=Cyan>,</font> <font color=Cyan>(</font><font color=Magenta>"item in a sequence"</font><font color=Cyan>,</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font> p<font color=Cyan>;</font> return <font color=Cyan>(</font><font color=Cyan>)</font> <font color=Cyan>}</font> <font color=Cyan>)</font>+ <font color=Red>]</font>+ <font color=Cyan>;</font> return xs+ <font color=Cyan>}</font>++<font color=Blue>------------------------------------------------------------------------</font>+<font color=Blue>-- | Push some tokens back onto the front of the input stream and reparse.</font>+<font color=Blue>-- This is useful e.g. for recursively expanding macros. When the</font>+<font color=Blue>-- user-parser recognises a macro use, it can lookup the macro</font>+<font color=Blue>-- expansion from the parse state, lex it, and then stuff the</font>+<font color=Blue>-- lexed expansion back down into the parser.</font>+reparse <font color=Red>::</font> <font color=Red>[</font>t<font color=Red>]</font> <font color=Red>-></font> Parser t <font color=Cyan>(</font><font color=Cyan>)</font>+<a name="reparse"></a>reparse ts <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>inp<font color=Red>-></font> <font color=Cyan>(</font>Right <font color=Cyan>(</font><font color=Cyan>)</font><font color=Cyan>,</font> ts<font color=Cyan>++</font>inp<font color=Cyan>)</font><font color=Cyan>)</font>++<font color=Blue>------------------------------------------------------------------------</font>+</pre>
+ docs/haddock/src/Text/ParserCombinators/PolyLazy.html view
@@ -0,0 +1,268 @@+<pre><font color=Green><u>module</u></font> Text<font color=Cyan>.</font>ParserCombinators<font color=Cyan>.</font>PolyLazy+ <font color=Cyan>(</font> <font color=Blue>-- * The Parser datatype.</font>+ <font color=Blue>-- $parser</font>+ Parser<font color=Cyan>(</font>P<font color=Cyan>)</font> <font color=Blue>-- datatype, instance of: Functor, Monad</font>+ <font color=Cyan>,</font> runParser <font color=Blue>-- :: Parser t a -> [t] -> (a, [t])</font>+ <font color=Cyan>,</font> failBad <font color=Blue>-- :: String -> Parser t a</font>+ <font color=Cyan>,</font> commit <font color=Blue>-- :: Parser t a -> Parser t a</font>+ <font color=Blue>-- * Combinators:</font>+ <font color=Blue>-- ** Primitives</font>+ <font color=Cyan>,</font> next <font color=Blue>-- :: Parser t t</font>+ <font color=Cyan>,</font> satisfy <font color=Blue>-- :: (t->Bool) -> Parser t t</font>+ <font color=Cyan>,</font> apply <font color=Blue>-- :: Parser t (a->b) -> Parser t a -> Parser t b</font>+ <font color=Cyan>,</font> discard <font color=Blue>-- :: Parser t a -> Parser t b -> Parser t a</font>+ <font color=Blue>-- ** Error-handling</font>+ <font color=Cyan>,</font> adjustErr <font color=Blue>-- :: Parser t a -> (String->String) -> Parser t a</font>+ <font color=Cyan>,</font> adjustErrBad<font color=Blue>-- :: Parser t a -> (String->String) -> Parser t a</font>+ <font color=Cyan>,</font> indent <font color=Blue>-- :: Int -> String -> String</font>+ <font color=Blue>-- ** Choices</font>+ <font color=Cyan>,</font> onFail <font color=Blue>-- :: Parser t a -> Parser t a -> Parser t a</font>+ <font color=Cyan>,</font> oneOf <font color=Blue>-- :: Show t => [Parser t a] -> Parser t a</font>+ <font color=Cyan>,</font> oneOf' <font color=Blue>-- :: [(String,Parser t a)] -> Parser t a</font>+ <font color=Cyan>,</font> optional <font color=Blue>-- :: Parser t a -> Parser t (Maybe a)</font>+ <font color=Blue>-- ** Sequences</font>+ <font color=Cyan>,</font> many <font color=Blue>-- :: Parser t a -> Parser t [a]</font>+ <font color=Cyan>,</font> many1 <font color=Blue>-- :: Parser t a -> Parser t [a]</font>+ <font color=Cyan>,</font> sepBy <font color=Blue>-- :: Parser t a -> Parser t sep -> Parser t [a]</font>+ <font color=Cyan>,</font> sepBy1 <font color=Blue>-- :: Parser t a -> Parser t sep -> Parser t [a]</font>+ <font color=Cyan>,</font> bracketSep <font color=Blue>-- :: Parser t bra -> Parser t sep -> Parser t ket</font>+ <font color=Blue>-- -> Parser t a -> Parser t [a]</font>+ <font color=Cyan>,</font> bracket <font color=Blue>-- :: Parser t bra -> Parser t ket -> Parser t a</font>+ <font color=Blue>-- -> Parser t a</font>+ <font color=Cyan>,</font> manyFinally <font color=Blue>-- :: Parser t a -> Parser t z -> Parser t [a]</font>+ <font color=Blue>-- ** Re-parsing</font>+ <font color=Cyan>,</font> reparse <font color=Blue>-- :: [t] -> Parser t ()</font>+ <font color=Cyan>)</font> <font color=Green><u>where</u></font>++<font color=Cyan>#</font><font color=Green><u>if</u></font> <b><font color=Magenta>__GLASGOW_HASKELL__</font></b>+<font color=Green><u>import</u></font> Control<font color=Cyan>.</font>Exception hiding <font color=Cyan>(</font>bracket<font color=Cyan>)</font>+throwE <font color=Red>::</font> String <font color=Red>-></font> a+<a name="throwE"></a>throwE msg <font color=Red>=</font> throw <font color=Cyan>(</font>ErrorCall msg<font color=Cyan>)</font>+<font color=Cyan>#</font><font color=Green><u>else</u></font>+throwE <font color=Red>::</font> String <font color=Red>-></font> a+throwE msg <font color=Red>=</font> error msg+<font color=Cyan>#</font>endif++<font color=Blue>-- $parser</font>+<font color=Blue>-- When applied, these parsers do not return explicit failure.</font>+<font color=Blue>-- An exception is</font>+<font color=Blue>-- raised instead. This allows partial results to be returned</font>+<font color=Blue>-- before a full parse is complete.</font>+<font color=Blue>-- One of the key ways to ensure that your parser is properly lazy,</font>+<font color=Blue>-- is to parse the initial portion of text returning a function, then</font>+<font color=Blue>-- use the @apply@ combinator to build the final value.</font>++<font color=Blue>-- | The @Parser@ datatype is a fairly generic parsing monad with error</font>+<font color=Blue>-- reporting. It can be used for arbitrary token types, not just</font>+<font color=Blue>-- String input. (If you require a running state, use module PolyStateLazy</font>+<font color=Blue>-- instead.)</font>+<font color=Green><u>newtype</u></font> Parser t a <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>[</font>t<font color=Red>]</font> <font color=Red>-></font> <font color=Cyan>(</font>Either String a<font color=Cyan>,</font> <font color=Red>[</font>t<font color=Red>]</font><font color=Cyan>)</font><font color=Cyan>)</font>++<font color=Blue>-- A return type like Either, that distinguishes not only between</font>+<font color=Blue>-- right and wrong answers, but also had gradations of wrongness.</font>+<font color=Blue>-- Not used in this library. !!!!!!!!!!!!!!!!!!!!!!!!!!!</font>+<a name="EitherE"></a><font color=Green><u>type</u></font> EitherE a b <font color=Red>=</font> Either <font color=Cyan>(</font>Bool<font color=Cyan>,</font>a<font color=Cyan>)</font> b++<font color=Blue>-- | Apply a parser to an input token sequence. The parser cannot return</font>+<font color=Blue>-- an error value explicitly, so errors raise an exception. Thus, results</font>+<font color=Blue>-- can be partial (lazily constructed, but containing undefined).</font>+runParser <font color=Red>::</font> Parser t a <font color=Red>-></font> <font color=Red>[</font>t<font color=Red>]</font> <font color=Red>-></font> <font color=Cyan>(</font>a<font color=Cyan>,</font> <font color=Red>[</font>t<font color=Red>]</font><font color=Cyan>)</font>+<a name="runParser"></a>runParser <font color=Cyan>(</font>P p<font color=Cyan>)</font> <font color=Red>=</font>+ <font color=Cyan>(</font><font color=Red>\</font> <font color=Cyan>(</font>e<font color=Cyan>,</font>ts<font color=Cyan>)</font><font color=Red>-></font> <font color=Cyan>(</font><font color=Green><u>case</u></font> e <font color=Green><u>of</u></font> <font color=Cyan>{</font>Left m<font color=Red>-></font>throwE m<font color=Cyan>;</font> Right x<font color=Red>-></font>x<font color=Cyan>}</font><font color=Cyan>,</font> ts<font color=Cyan>)</font> <font color=Cyan>)</font>+ <font color=Cyan>.</font> p++<font color=Green><u>instance</u></font> Functor <font color=Cyan>(</font>Parser t<font color=Cyan>)</font> <font color=Green><u>where</u></font>+ fmap f <font color=Cyan>(</font>P p<font color=Cyan>)</font> <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>ts<font color=Red>-></font> <font color=Green><u>case</u></font> p ts <font color=Green><u>of</u></font>+ <font color=Cyan>(</font>Left msg<font color=Cyan>,</font> ts'<font color=Cyan>)</font> <font color=Red>-></font> <font color=Cyan>(</font>Left msg<font color=Cyan>,</font> ts'<font color=Cyan>)</font>+ <font color=Cyan>(</font>Right x<font color=Cyan>,</font> ts'<font color=Cyan>)</font> <font color=Red>-></font> <font color=Cyan>(</font>Right <font color=Cyan>(</font>f x<font color=Cyan>)</font><font color=Cyan>,</font> ts'<font color=Cyan>)</font><font color=Cyan>)</font>+<font color=Green><u>instance</u></font> Monad <font color=Cyan>(</font>Parser t<font color=Cyan>)</font> <font color=Green><u>where</u></font>+ return x <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>ts<font color=Red>-></font> <font color=Cyan>(</font>Right x<font color=Cyan>,</font> ts<font color=Cyan>)</font><font color=Cyan>)</font>+ <font color=Cyan>(</font>P f<font color=Cyan>)</font> <font color=Cyan>>>=</font> g <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>ts<font color=Red>-></font> <font color=Green><u>case</u></font> f ts <font color=Green><u>of</u></font>+ <font color=Cyan>(</font>Left msg<font color=Cyan>,</font> ts'<font color=Cyan>)</font> <font color=Red>-></font> <font color=Cyan>(</font>Left msg<font color=Cyan>,</font> ts'<font color=Cyan>)</font>+ <font color=Cyan>(</font>Right x<font color=Cyan>,</font> ts'<font color=Cyan>)</font> <font color=Red>-></font> <font color=Green><u>let</u></font> <font color=Cyan>(</font>P g'<font color=Cyan>)</font> <font color=Red>=</font> g x <font color=Green><u>in</u></font> g' ts'<font color=Cyan>)</font>+ fail e <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>ts<font color=Red>-></font> <font color=Cyan>(</font>Left e<font color=Cyan>,</font> ts<font color=Cyan>)</font><font color=Cyan>)</font>++<font color=Blue>-- | Simple failure can be corrected, but when a simple fail is not strong</font>+<font color=Blue>-- enough, use failBad for emphasis. It guarantees parsing will</font>+<font color=Blue>-- terminate with an exception.</font>++failBad <font color=Red>::</font> String <font color=Red>-></font> Parser t a+<a name="failBad"></a>failBad msg <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>ts<font color=Red>-></font> <font color=Cyan>(</font>throwE msg<font color=Cyan>,</font> ts<font color=Cyan>)</font><font color=Cyan>)</font>++<font color=Blue>-- | Commit is a way of raising the severity of any errors found within</font>+<font color=Blue>-- its argument. Used in the middle of a parser definition, it means that</font>+<font color=Blue>-- any operations prior to commitment fail softly, but after commitment,</font>+<font color=Blue>-- they fail hard.</font>+commit <font color=Red>::</font> Parser t a <font color=Red>-></font> Parser t a+<a name="commit"></a>commit <font color=Cyan>(</font>P p<font color=Cyan>)</font> <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>ts<font color=Red>-></font> <font color=Green><u>case</u></font> p ts <font color=Green><u>of</u></font>+ <font color=Cyan>(</font>Left e<font color=Cyan>,</font> ts'<font color=Cyan>)</font> <font color=Red>-></font> <font color=Cyan>(</font>throwE e<font color=Cyan>,</font> ts'<font color=Cyan>)</font>+ right <font color=Red>-></font> right <font color=Cyan>)</font>+++<font color=Blue>-- Combinators</font>++<font color=Blue>-- | One token</font>+next <font color=Red>::</font> Parser t t+<a name="next"></a>next <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>ts<font color=Red>-></font> <font color=Green><u>case</u></font> ts <font color=Green><u>of</u></font>+ <font color=Red>[</font><font color=Red>]</font> <font color=Red>-></font> <font color=Cyan>(</font>Left <font color=Magenta>"Ran out of input (EOF)"</font><font color=Cyan>,</font> <font color=Red>[</font><font color=Red>]</font><font color=Cyan>)</font>+ <font color=Cyan>(</font>t<font color=Red><b>:</b></font>ts'<font color=Cyan>)</font> <font color=Red>-></font> <font color=Cyan>(</font>Right t<font color=Cyan>,</font> ts'<font color=Cyan>)</font> <font color=Cyan>)</font>++<font color=Blue>-- | One token satifying a predicate</font>+satisfy <font color=Red>::</font> <font color=Cyan>(</font>t<font color=Red>-></font>Bool<font color=Cyan>)</font> <font color=Red>-></font> Parser t t+<a name="satisfy"></a>satisfy p <font color=Red>=</font> <font color=Green><u>do</u></font><font color=Cyan>{</font> x <font color=Red><-</font> next+ <font color=Cyan>;</font> <font color=Green><u>if</u></font> p x <font color=Green><u>then</u></font> return x <font color=Green><u>else</u></font> fail <font color=Magenta>"Parse.satisfy: failed"</font>+ <font color=Cyan>}</font>++<font color=Green><u>infixl</u></font> <font color=Magenta>3</font> <font color=Cyan>`apply`</font>+<font color=Blue>-- | Apply a parsed function to a parsed value</font>+apply <font color=Red>::</font> Parser t <font color=Cyan>(</font>a<font color=Red>-></font>b<font color=Cyan>)</font> <font color=Red>-></font> Parser t a <font color=Red>-></font> Parser t b+<font color=Blue>--pf `apply` px = do { f <- pf; x <- px; return (f x) }</font>+<font color=Blue>-- Needs to be lazier! Must not force the argument value too early. </font>+<a name="apply"></a><font color=Cyan>(</font>P pf<font color=Cyan>)</font> <font color=Cyan>`apply`</font> <font color=Cyan>(</font>P px<font color=Cyan>)</font> <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>ts<font color=Red>-></font>+ <font color=Green><u>case</u></font> pf ts <font color=Green><u>of</u></font>+ <font color=Cyan>(</font>Left msg<font color=Cyan>,</font> ts'<font color=Cyan>)</font> <font color=Red>-></font> <font color=Cyan>(</font>Left msg<font color=Cyan>,</font> ts'<font color=Cyan>)</font>+ <font color=Cyan>(</font>Right f<font color=Cyan>,</font> ts'<font color=Cyan>)</font> <font color=Red>-></font> <font color=Green><u>let</u></font> <font color=Cyan>(</font>x'<font color=Cyan>,</font>ts''<font color=Cyan>)</font> <font color=Red>=</font> px ts'+ x <font color=Red>=</font> <font color=Green><u>case</u></font> x' <font color=Green><u>of</u></font> <font color=Cyan>{</font> Right x <font color=Red>-></font> x<font color=Cyan>;</font> Left e <font color=Red>-></font> throwE e <font color=Cyan>}</font>+ <font color=Green><u>in</u></font> <font color=Cyan>(</font>Right <font color=Cyan>(</font>f x<font color=Cyan>)</font><font color=Cyan>,</font> ts''<font color=Cyan>)</font> <font color=Cyan>)</font>++<font color=Green><u>infixl</u></font> <font color=Magenta>3</font> <font color=Cyan>`discard`</font>+<font color=Blue>-- | @x `discard` y@ parses both x and y, but discards the result of y</font>+discard <font color=Red>::</font> Parser t a <font color=Red>-></font> Parser t b <font color=Red>-></font> Parser t a+<a name="discard"></a>px <font color=Cyan>`discard`</font> py <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font> x <font color=Red><-</font> px<font color=Cyan>;</font> <font color=Green><u>_</u></font> <font color=Red><-</font> py<font color=Cyan>;</font> return x <font color=Cyan>}</font>++<font color=Blue>-- | @p `adjustErr` f@ applies the transformation @f@ to any error message</font>+<font color=Blue>-- generated in @p@, having no effect if @p@ succeeds.</font>+adjustErr <font color=Red>::</font> Parser t a <font color=Red>-></font> <font color=Cyan>(</font>String<font color=Red>-></font>String<font color=Cyan>)</font> <font color=Red>-></font> Parser t a+<a name="adjustErr"></a><font color=Cyan>(</font>P p<font color=Cyan>)</font> <font color=Cyan>`adjustErr`</font> f <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>ts<font color=Red>-></font> <font color=Green><u>case</u></font> p ts <font color=Green><u>of</u></font>+ <font color=Cyan>(</font>Left msg<font color=Cyan>,</font> ts'<font color=Cyan>)</font> <font color=Red>-></font> <font color=Cyan>(</font>Left <font color=Cyan>(</font>f msg<font color=Cyan>)</font><font color=Cyan>,</font> ts'<font color=Cyan>)</font>+ right <font color=Red>-></font> right <font color=Cyan>)</font>++<font color=Blue>-- | @adjustErrBad@ is just like @adjustErr@ except it also raises the</font>+<font color=Blue>-- severity of the error.</font>+adjustErrBad <font color=Red>::</font> Parser t a <font color=Red>-></font> <font color=Cyan>(</font>String<font color=Red>-></font>String<font color=Cyan>)</font> <font color=Red>-></font> Parser t a+<a name="adjustErrBad"></a>p <font color=Cyan>`adjustErrBad`</font> f <font color=Red>=</font> commit <font color=Cyan>(</font>p <font color=Cyan>`adjustErr`</font> f<font color=Cyan>)</font>++<font color=Green><u>infixl</u></font> <font color=Magenta>6</font> <font color=Cyan>`onFail`</font> <font color=Blue>-- not sure about precedence 6?</font>+<font color=Blue>-- | @p `onFail` q@ means parse p unless p fails in which case parse q instead.</font>+<font color=Blue>-- Can be chained together to give multiple attempts to parse something.</font>+<font color=Blue>-- (Note that q could itself be a failing parser, e.g. to change the error</font>+<font color=Blue>-- message from that defined in p to something different.)</font>+<font color=Blue>-- However, a *severe* failure in p cannot be ignored.</font>+onFail <font color=Red>::</font> Parser t a <font color=Red>-></font> Parser t a <font color=Red>-></font> Parser t a+<a name="onFail"></a><font color=Cyan>(</font>P p<font color=Cyan>)</font> <font color=Cyan>`onFail`</font> <font color=Cyan>(</font>P q<font color=Cyan>)</font> <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>ts<font color=Red>-></font> <font color=Green><u>case</u></font> p ts <font color=Green><u>of</u></font>+ <font color=Cyan>(</font>Left <font color=Green><u>_</u></font><font color=Cyan>,</font> <font color=Green><u>_</u></font><font color=Cyan>)</font> <font color=Red>-></font> q ts+ right <font color=Red>-></font> right <font color=Cyan>)</font>++<font color=Blue>-- | Parse the first alternative in the list that succeeds.</font>+oneOf <font color=Red>::</font> <font color=Red>[</font>Parser t a<font color=Red>]</font> <font color=Red>-></font> Parser t a+<a name="oneOf"></a>oneOf <font color=Red>[</font><font color=Red>]</font> <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font> n <font color=Red><-</font> next+ <font color=Cyan>;</font> fail <font color=Cyan>(</font><font color=Magenta>"failed to parse any of the possible choices"</font><font color=Cyan>)</font>+ <font color=Cyan>}</font>+<font color=Blue>--oneOf :: Show t => [Parser t a] -> Parser t a</font>+<font color=Blue>--oneOf [] = do { n <- next</font>+<font color=Blue>-- ; fail ("failed to parse any of the possible choices"</font>+<font color=Blue>-- ++"\n next token is "++show n)</font>+<font color=Blue>-- }</font>+oneOf <font color=Cyan>(</font>p<font color=Red><b>:</b></font>ps<font color=Cyan>)</font> <font color=Red>=</font> p <font color=Cyan>`onFail`</font> oneOf ps++<font color=Blue>-- | Parse the first alternative that succeeds, but if none succeed,</font>+<font color=Blue>-- report only the severe errors, and if none of those, then report</font>+<font color=Blue>-- all the soft errors.</font>+oneOf' <font color=Red>::</font> <font color=Red>[</font><font color=Cyan>(</font>String<font color=Cyan>,</font> Parser t a<font color=Cyan>)</font><font color=Red>]</font> <font color=Red>-></font> Parser t a+<a name="oneOf'"></a>oneOf' ps <font color=Red>=</font> accum <font color=Red>[</font><font color=Red>]</font> ps+ <font color=Green><u>where</u></font> accum errs <font color=Red>[</font><font color=Red>]</font> <font color=Red>=</font>+ <font color=Green><u>case</u></font> errs <font color=Green><u>of</u></font>+ <font color=Red>[</font><font color=Red>]</font> <font color=Red>-></font> failBad <font color=Cyan>(</font><font color=Magenta>"internal failure in parser (oneOf'):\n"</font>+ <font color=Cyan>++</font>indent <font color=Magenta>2</font> <font color=Cyan>(</font>show <font color=Cyan>(</font>map fst ps<font color=Cyan>)</font><font color=Cyan>)</font><font color=Cyan>)</font>+ <font color=Red>[</font><font color=Cyan>(</font><font color=Green><u>_</u></font><font color=Cyan>,</font>e<font color=Cyan>)</font><font color=Red>]</font> <font color=Red>-></font> fail e+ es <font color=Red>-></font> fail <font color=Cyan>(</font><font color=Magenta>"one of the following failures occurred:\n"</font>+ <font color=Cyan>++</font>indent <font color=Magenta>2</font> <font color=Cyan>(</font>concatMap showErr <font color=Cyan>(</font>reverse es<font color=Cyan>)</font><font color=Cyan>)</font><font color=Cyan>)</font>+ accum errs <font color=Cyan>(</font><font color=Cyan>(</font>e<font color=Cyan>,</font>P p<font color=Cyan>)</font><font color=Red><b>:</b></font>ps<font color=Cyan>)</font> <font color=Red>=</font>+ P <font color=Cyan>(</font><font color=Red>\</font>ts<font color=Red>-></font> <font color=Green><u>case</u></font> p ts <font color=Green><u>of</u></font>+ <font color=Cyan>(</font>Left err<font color=Cyan>,</font><font color=Green><u>_</u></font><font color=Cyan>)</font> <font color=Red>-></font> <font color=Green><u>let</u></font> <font color=Cyan>(</font>P p<font color=Cyan>)</font> <font color=Red>=</font> accum <font color=Cyan>(</font><font color=Cyan>(</font>e<font color=Cyan>,</font>err<font color=Cyan>)</font><font color=Red><b>:</b></font>errs<font color=Cyan>)</font> ps+ <font color=Green><u>in</u></font> p ts+ right <font color=Red>-></font> right <font color=Cyan>)</font>+ showErr <font color=Cyan>(</font>name<font color=Cyan>,</font>err<font color=Cyan>)</font> <font color=Red>=</font> name<font color=Cyan>++</font><font color=Magenta>":\n"</font><font color=Cyan>++</font>indent <font color=Magenta>2</font> err++<font color=Blue>-- | Helper for formatting error messages: indents all lines by a fixed amount.</font>+indent <font color=Red>::</font> Int <font color=Red>-></font> String <font color=Red>-></font> String+<a name="indent"></a>indent n <font color=Red>=</font> unlines <font color=Cyan>.</font> map <font color=Cyan>(</font>replicate n <font color=Magenta>' '</font> <font color=Cyan>++</font><font color=Cyan>)</font> <font color=Cyan>.</font> lines++<font color=Blue>-- | 'optional' indicates whether the parser succeeded through the Maybe type.</font>+optional <font color=Red>::</font> Parser t a <font color=Red>-></font> Parser t <font color=Cyan>(</font>Maybe a<font color=Cyan>)</font>+<a name="optional"></a>optional p <font color=Red>=</font> fmap Just p <font color=Cyan>`onFail`</font> return Nothing++<font color=Blue>-- | 'many p' parses a list of elements with individual parser p.</font>+<font color=Blue>-- Cannot fail, since an empty list is a valid return value.</font>+many <font color=Red>::</font> Parser t a <font color=Red>-></font> Parser t <font color=Red>[</font>a<font color=Red>]</font>+<a name="many"></a>many p <font color=Red>=</font> many1 p <font color=Cyan>`onFail`</font> return <font color=Red>[</font><font color=Red>]</font>++<font color=Blue>-- | Parse a non-empty list of items.</font>+many1 <font color=Red>::</font> Parser t a <font color=Red>-></font> Parser t <font color=Red>[</font>a<font color=Red>]</font>+<a name="many1"></a>many1 p <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font> x <font color=Red><-</font> p <font color=Cyan>`adjustErr`</font> <font color=Cyan>(</font><font color=Cyan>(</font><font color=Magenta>"In a sequence:\n"</font><font color=Cyan>++</font><font color=Cyan>)</font><font color=Cyan>.</font> indent <font color=Magenta>2</font><font color=Cyan>)</font>+ <font color=Cyan>;</font> xs <font color=Red><-</font> many p+ <font color=Cyan>;</font> return <font color=Cyan>(</font>x<font color=Red><b>:</b></font>xs<font color=Cyan>)</font>+ <font color=Cyan>}</font>+<font color=Blue>-- `adjustErr` ("When looking for a non-empty sequence:\n\t"++)</font>++<font color=Blue>-- | Parse a list of items separated by discarded junk.</font>+sepBy <font color=Red>::</font> Parser t a <font color=Red>-></font> Parser t sep <font color=Red>-></font> Parser t <font color=Red>[</font>a<font color=Red>]</font>+<a name="sepBy"></a>sepBy p sep <font color=Red>=</font> <font color=Green><u>do</u></font> sepBy1 p sep <font color=Cyan>`onFail`</font> return <font color=Red>[</font><font color=Red>]</font>++<font color=Blue>-- | Parse a non-empty list of items separated by discarded junk.</font>+sepBy1 <font color=Red>::</font> Parser t a <font color=Red>-></font> Parser t sep <font color=Red>-></font> Parser t <font color=Red>[</font>a<font color=Red>]</font>+<a name="sepBy1"></a>sepBy1 p sep <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font> x <font color=Red><-</font> p+ <font color=Cyan>;</font> xs <font color=Red><-</font> many <font color=Cyan>(</font><font color=Green><u>do</u></font> <font color=Cyan>{</font>sep<font color=Cyan>;</font> p<font color=Cyan>}</font><font color=Cyan>)</font>+ <font color=Cyan>;</font> return <font color=Cyan>(</font>x<font color=Red><b>:</b></font>xs<font color=Cyan>)</font>+ <font color=Cyan>}</font>+ <font color=Cyan>`adjustErr`</font> <font color=Cyan>(</font><font color=Magenta>"When looking for a non-empty sequence with separators:\n\t"</font><font color=Cyan>++</font><font color=Cyan>)</font>+ +<font color=Blue>-- | Parse a list of items, discarding the start, end, and separator</font>+<font color=Blue>-- items.</font>+bracketSep <font color=Red>::</font> Parser t bra <font color=Red>-></font> Parser t sep <font color=Red>-></font> Parser t ket+ <font color=Red>-></font> Parser t a <font color=Red>-></font> Parser t <font color=Red>[</font>a<font color=Red>]</font>+<a name="bracketSep"></a>bracketSep open sep close p <font color=Red>=</font>+ <font color=Green><u>do</u></font> <font color=Cyan>{</font> open<font color=Cyan>;</font> close<font color=Cyan>;</font> return <font color=Red>[</font><font color=Red>]</font> <font color=Cyan>}</font>+ <font color=Cyan>`onFail`</font>+ <font color=Green><u>do</u></font> <font color=Cyan>{</font> open <font color=Cyan>`adjustErr`</font> <font color=Cyan>(</font><font color=Magenta>"Missing opening bracket:\n\t"</font><font color=Cyan>++</font><font color=Cyan>)</font>+ <font color=Cyan>;</font> x <font color=Red><-</font> p <font color=Cyan>`adjustErr`</font> <font color=Cyan>(</font><font color=Magenta>"After first bracket in a group:\n\t"</font><font color=Cyan>++</font><font color=Cyan>)</font>+ <font color=Cyan>;</font> xs <font color=Red><-</font> many <font color=Cyan>(</font><font color=Green><u>do</u></font> <font color=Cyan>{</font>sep<font color=Cyan>;</font> p<font color=Cyan>}</font><font color=Cyan>)</font>+ <font color=Cyan>;</font> close <font color=Cyan>`adjustErrBad`</font> <font color=Cyan>(</font><font color=Magenta>"When looking for closing bracket:\n\t"</font><font color=Cyan>++</font><font color=Cyan>)</font>+ <font color=Cyan>;</font> return <font color=Cyan>(</font>x<font color=Red><b>:</b></font>xs<font color=Cyan>)</font>+ <font color=Cyan>}</font>++<font color=Blue>-- | Parse a bracketed item, discarding the brackets.</font>+bracket <font color=Red>::</font> Parser t bra <font color=Red>-></font> Parser t ket <font color=Red>-></font> Parser t a <font color=Red>-></font> Parser t a+<a name="bracket"></a>bracket open close p <font color=Red>=</font> <font color=Green><u>do</u></font>+ <font color=Green><u>do</u></font> <font color=Cyan>{</font> open <font color=Cyan>`adjustErr`</font> <font color=Cyan>(</font><font color=Magenta>"Missing opening bracket:\n\t"</font><font color=Cyan>++</font><font color=Cyan>)</font>+ <font color=Cyan>;</font> x <font color=Red><-</font> p+ <font color=Cyan>;</font> close <font color=Cyan>`adjustErrBad`</font> <font color=Cyan>(</font><font color=Magenta>"Missing closing bracket:\n\t"</font><font color=Cyan>++</font><font color=Cyan>)</font>+ <font color=Cyan>;</font> return x+ <font color=Cyan>}</font>++<font color=Blue>-- | 'manyFinally e t' parses a possibly-empty sequence of e's,</font>+<font color=Blue>-- terminated by a t. Any parse failures could be due either to</font>+<font color=Blue>-- a badly-formed terminator or a badly-formed element, so raise</font>+<font color=Blue>-- both possible errors.</font>+manyFinally <font color=Red>::</font> Parser t a <font color=Red>-></font> Parser t z <font color=Red>-></font> Parser t <font color=Red>[</font>a<font color=Red>]</font>+<a name="manyFinally"></a>manyFinally pp<font color=Red>@</font><font color=Cyan>(</font>P p<font color=Cyan>)</font> pt<font color=Red>@</font><font color=Cyan>(</font>P t<font color=Cyan>)</font> <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>ts <font color=Red>-></font>+ <font color=Green><u>case</u></font> p ts <font color=Green><u>of</u></font>+ <font color=Cyan>(</font>Left e<font color=Cyan>,</font> <font color=Green><u>_</u></font><font color=Cyan>)</font> <font color=Red>-></font>+ <font color=Green><u>case</u></font> t ts <font color=Green><u>of</u></font>+ <font color=Cyan>(</font>Right <font color=Green><u>_</u></font><font color=Cyan>,</font> ts'<font color=Cyan>)</font> <font color=Red>-></font> <font color=Cyan>(</font>Right <font color=Red>[</font><font color=Red>]</font><font color=Cyan>,</font> ts'<font color=Cyan>)</font>+ <font color=Cyan>(</font>Left e<font color=Cyan>,</font> ts'<font color=Cyan>)</font> <font color=Red>-></font> <font color=Cyan>(</font>Left e<font color=Cyan>,</font> ts'<font color=Cyan>)</font>+ <font color=Cyan>(</font>Right x<font color=Cyan>,</font> ts'<font color=Cyan>)</font> <font color=Red>-></font>+ <font color=Green><u>let</u></font> <font color=Cyan>(</font>tail<font color=Cyan>,</font>ts''<font color=Cyan>)</font> <font color=Red>=</font> runParser <font color=Cyan>(</font>manyFinally pp pt<font color=Cyan>)</font> ts'+ <font color=Green><u>in</u></font> <font color=Cyan>(</font>Right <font color=Cyan>(</font>x<font color=Red><b>:</b></font>tail<font color=Cyan>)</font><font color=Cyan>,</font> ts''<font color=Cyan>)</font> <font color=Cyan>)</font>++<font color=Blue>------------------------------------------------------------------------</font>+<font color=Blue>-- | Push some tokens back onto the front of the input stream and reparse.</font>+<font color=Blue>-- This is useful e.g. for recursively expanding macros. When the</font>+<font color=Blue>-- user-parser recognises a macro use, it can lookup the macro</font>+<font color=Blue>-- expansion from the parse state, lex it, and then stuff the</font>+<font color=Blue>-- lexed expansion back down into the parser.</font>+reparse <font color=Red>::</font> <font color=Red>[</font>t<font color=Red>]</font> <font color=Red>-></font> Parser t <font color=Cyan>(</font><font color=Cyan>)</font>+<a name="reparse"></a>reparse ts <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>inp<font color=Red>-></font> <font color=Cyan>(</font>Right <font color=Cyan>(</font><font color=Cyan>)</font><font color=Cyan>,</font> ts<font color=Cyan>++</font>inp<font color=Cyan>)</font><font color=Cyan>)</font>++<font color=Blue>------------------------------------------------------------------------</font>+</pre>
+ docs/haddock/src/Text/ParserCombinators/PolyState.html view
@@ -0,0 +1,249 @@+<pre><font color=Green><u>module</u></font> Text<font color=Cyan>.</font>ParserCombinators<font color=Cyan>.</font>PolyState+ <font color=Cyan>(</font> <font color=Blue>-- * The Parser datatype</font>+ Parser<font color=Cyan>(</font>P<font color=Cyan>)</font> <font color=Blue>-- datatype, instance of: Functor, Monad</font>+ <font color=Cyan>,</font> runParser <font color=Blue>-- :: Parser s t a -> s -> [t] -> (Either String a, s, [t])</font>+ <font color=Cyan>,</font> failBad <font color=Blue>-- :: String -> Parser s t a</font>+ <font color=Cyan>,</font> commit <font color=Blue>-- :: Parser s t a -> Parser s t a</font>+ <font color=Blue>-- * Combinators:</font>+ <font color=Blue>-- ** Primitives</font>+ <font color=Cyan>,</font> next <font color=Blue>-- :: Parser s t t</font>+ <font color=Cyan>,</font> satisfy <font color=Blue>-- :: (t->Bool) -> Parser s t t</font>+ <font color=Cyan>,</font> apply <font color=Blue>-- :: Parser t (a->b) -> Parser s t a -> Parser s t b</font>+ <font color=Cyan>,</font> discard <font color=Blue>-- :: Parser s t a -> Parser s t b -> Parser s t a</font>+ <font color=Blue>-- ** Error-handling</font>+ <font color=Cyan>,</font> adjustErr <font color=Blue>-- :: Parser s t a -> (String->String) -> Parser s t a</font>+ <font color=Cyan>,</font> adjustErrBad<font color=Blue>-- :: Parser s t a -> (String->String) -> Parser s t a</font>+ <font color=Cyan>,</font> indent <font color=Blue>-- :: Int -> String -> String</font>+ <font color=Blue>-- ** Choices</font>+ <font color=Cyan>,</font> onFail <font color=Blue>-- :: Parser s t a -> Parser s t a -> Parser s t a</font>+ <font color=Cyan>,</font> oneOf <font color=Blue>-- :: [Parser s t a] -> Parser s t a</font>+ <font color=Cyan>,</font> oneOf' <font color=Blue>-- :: [(String, Parser s t a)] -> Parser s t a</font>+ <font color=Blue>-- ** Sequences</font>+ <font color=Cyan>,</font> many <font color=Blue>-- :: Parser s t a -> Parser s t [a]</font>+ <font color=Cyan>,</font> many1 <font color=Blue>-- :: Parser s t a -> Parser s t [a]</font>+ <font color=Cyan>,</font> sepBy <font color=Blue>-- :: Parser s t a -> Parser s t sep -> Parser s t [a]</font>+ <font color=Cyan>,</font> sepBy1 <font color=Blue>-- :: Parser s t a -> Parser s t sep -> Parser s t [a]</font>+ <font color=Cyan>,</font> bracketSep <font color=Blue>-- :: Parser s t bra -> Parser s t sep -> Parser s t ket</font>+ <font color=Blue>-- -> Parser s t a -> Parser s t [a]</font>+ <font color=Cyan>,</font> bracket <font color=Blue>-- :: Parser s t bra -> Parser s t ket -> Parser s t a</font>+ <font color=Blue>-- -> Parser s t a</font>+ <font color=Cyan>,</font> manyFinally <font color=Blue>-- :: Parser s t a -> Parser s t z -> Parser s t [a]</font>+ <font color=Blue>-- ** State-handling</font>+ <font color=Cyan>,</font> stUpdate <font color=Blue>-- :: (s->s) -> Parser s t ()</font>+ <font color=Cyan>,</font> stQuery <font color=Blue>-- :: (s->a) -> Parser s t a</font>+ <font color=Cyan>,</font> stGet <font color=Blue>-- :: Parser s t s</font>+ <font color=Blue>-- ** Re-parsing</font>+ <font color=Cyan>,</font> reparse <font color=Blue>-- :: [t] -> Parser s t ()</font>+ <font color=Cyan>)</font> <font color=Green><u>where</u></font>++<font color=Blue>-- | The @Parser@ datatype is a fairly generic parsing monad with error</font>+<font color=Blue>-- reporting and a running state. It can be used for arbitrary token</font>+<font color=Blue>-- types, not just String input.</font>+<font color=Green><u>newtype</u></font> Parser s t a <font color=Red>=</font> P <font color=Cyan>(</font>s <font color=Red>-></font> <font color=Red>[</font>t<font color=Red>]</font> <font color=Red>-></font> <font color=Cyan>(</font>EitherE String a<font color=Cyan>,</font> s<font color=Cyan>,</font> <font color=Red>[</font>t<font color=Red>]</font><font color=Cyan>)</font><font color=Cyan>)</font>++<font color=Blue>-- | A return type like Either, that distinguishes not only between</font>+<font color=Blue>-- right and wrong answers, but also had gradations of wrongness.</font>+<a name="EitherE"></a><font color=Green><u>type</u></font> EitherE a b <font color=Red>=</font> Either <font color=Cyan>(</font>Bool<font color=Cyan>,</font>a<font color=Cyan>)</font> b++<font color=Blue>-- | Apply a parser to an initial state and input token sequence.</font>+runParser <font color=Red>::</font> Parser s t a <font color=Red>-></font> s <font color=Red>-></font> <font color=Red>[</font>t<font color=Red>]</font> <font color=Red>-></font> <font color=Cyan>(</font>Either String a<font color=Cyan>,</font> s<font color=Cyan>,</font> <font color=Red>[</font>t<font color=Red>]</font><font color=Cyan>)</font>+<a name="runParser"></a>runParser <font color=Cyan>(</font>P p<font color=Cyan>)</font> s <font color=Red>=</font>+ <font color=Cyan>(</font><font color=Red>\</font> <font color=Cyan>(</font>e<font color=Cyan>,</font>s<font color=Cyan>,</font>ts<font color=Cyan>)</font><font color=Red>-></font> <font color=Cyan>(</font><font color=Green><u>case</u></font> e <font color=Green><u>of</u></font> Left <font color=Cyan>(</font><font color=Green><u>_</u></font><font color=Cyan>,</font>m<font color=Cyan>)</font><font color=Red>-></font>Left m<font color=Cyan>;</font> Right m<font color=Red>-></font>Right m+ <font color=Cyan>,</font>s<font color=Cyan>,</font>ts<font color=Cyan>)</font><font color=Cyan>)</font>+ <font color=Cyan>.</font> p s++<font color=Green><u>instance</u></font> Functor <font color=Cyan>(</font>Parser s t<font color=Cyan>)</font> <font color=Green><u>where</u></font>+ fmap f <font color=Cyan>(</font>P p<font color=Cyan>)</font> <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>s ts<font color=Red>-></font> <font color=Green><u>case</u></font> p s ts <font color=Green><u>of</u></font>+ <font color=Cyan>(</font>Left msg<font color=Cyan>,</font> s'<font color=Cyan>,</font> ts'<font color=Cyan>)</font> <font color=Red>-></font> <font color=Cyan>(</font>Left msg<font color=Cyan>,</font> s'<font color=Cyan>,</font> ts'<font color=Cyan>)</font>+ <font color=Cyan>(</font>Right x<font color=Cyan>,</font> s'<font color=Cyan>,</font> ts'<font color=Cyan>)</font> <font color=Red>-></font> <font color=Cyan>(</font>Right <font color=Cyan>(</font>f x<font color=Cyan>)</font><font color=Cyan>,</font> s'<font color=Cyan>,</font> ts'<font color=Cyan>)</font><font color=Cyan>)</font>+<font color=Green><u>instance</u></font> Monad <font color=Cyan>(</font>Parser s t<font color=Cyan>)</font> <font color=Green><u>where</u></font>+ return x <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>s ts<font color=Red>-></font> <font color=Cyan>(</font>Right x<font color=Cyan>,</font> s<font color=Cyan>,</font> ts<font color=Cyan>)</font><font color=Cyan>)</font>+ <font color=Cyan>(</font>P f<font color=Cyan>)</font> <font color=Cyan>>>=</font> g <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>s ts<font color=Red>-></font> <font color=Green><u>case</u></font> f s ts <font color=Green><u>of</u></font>+ <font color=Cyan>(</font>Left msg<font color=Cyan>,</font> s'<font color=Cyan>,</font> ts'<font color=Cyan>)</font> <font color=Red>-></font> <font color=Cyan>(</font>Left msg<font color=Cyan>,</font> s'<font color=Cyan>,</font> ts'<font color=Cyan>)</font>+ <font color=Cyan>(</font>Right x<font color=Cyan>,</font> s'<font color=Cyan>,</font> ts'<font color=Cyan>)</font> <font color=Red>-></font> <font color=Green><u>let</u></font> <font color=Cyan>(</font>P g'<font color=Cyan>)</font> <font color=Red>=</font> g x+ <font color=Green><u>in</u></font> g' s' ts'<font color=Cyan>)</font>+ fail msg <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>s ts<font color=Red>-></font> <font color=Cyan>(</font>Left <font color=Cyan>(</font>False<font color=Cyan>,</font>msg<font color=Cyan>)</font><font color=Cyan>,</font> s<font color=Cyan>,</font> ts<font color=Cyan>)</font><font color=Cyan>)</font>++<font color=Blue>-- | When a simple fail is not strong enough, use failBad for emphasis.</font>+<font color=Blue>-- An emphasised (severe) error can propagate out through choice operators.</font>+failBad <font color=Red>::</font> String <font color=Red>-></font> Parser s t a+<a name="failBad"></a>failBad msg <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>s ts<font color=Red>-></font> <font color=Cyan>(</font>Left <font color=Cyan>(</font>True<font color=Cyan>,</font>msg<font color=Cyan>)</font><font color=Cyan>,</font> s<font color=Cyan>,</font> ts<font color=Cyan>)</font><font color=Cyan>)</font>++<font color=Blue>-- | Commit is a way of raising the severity of any errors found within</font>+<font color=Blue>-- its argument. Used in the middle of a parser definition, it means that</font>+<font color=Blue>-- any operations prior to commitment fail softly, but after commitment,</font>+<font color=Blue>-- they fail hard.</font>+commit <font color=Red>::</font> Parser s t a <font color=Red>-></font> Parser s t a+<a name="commit"></a>commit <font color=Cyan>(</font>P p<font color=Cyan>)</font> <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>s ts<font color=Red>-></font> <font color=Green><u>case</u></font> p s ts <font color=Green><u>of</u></font>+ <font color=Cyan>(</font>Left <font color=Cyan>(</font><font color=Green><u>_</u></font><font color=Cyan>,</font>e<font color=Cyan>)</font><font color=Cyan>,</font> s'<font color=Cyan>,</font> ts'<font color=Cyan>)</font> <font color=Red>-></font> <font color=Cyan>(</font>Left <font color=Cyan>(</font>True<font color=Cyan>,</font>e<font color=Cyan>)</font><font color=Cyan>,</font> s'<font color=Cyan>,</font> ts'<font color=Cyan>)</font>+ right <font color=Red>-></font> right <font color=Cyan>)</font>++<font color=Blue>-- Combinators</font>++<font color=Blue>-- | One token</font>+next <font color=Red>::</font> Parser s t t+<a name="next"></a>next <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>s ts<font color=Red>-></font> <font color=Green><u>case</u></font> ts <font color=Green><u>of</u></font>+ <font color=Red>[</font><font color=Red>]</font> <font color=Red>-></font> <font color=Cyan>(</font>Left <font color=Cyan>(</font>False<font color=Cyan>,</font><font color=Magenta>"Ran out of input (EOF)"</font><font color=Cyan>)</font><font color=Cyan>,</font> s<font color=Cyan>,</font> <font color=Red>[</font><font color=Red>]</font><font color=Cyan>)</font>+ <font color=Cyan>(</font>t<font color=Red><b>:</b></font>ts'<font color=Cyan>)</font> <font color=Red>-></font> <font color=Cyan>(</font>Right t<font color=Cyan>,</font> s<font color=Cyan>,</font> ts'<font color=Cyan>)</font> <font color=Cyan>)</font>++<font color=Blue>-- | One token satifying a predicate</font>+satisfy <font color=Red>::</font> <font color=Cyan>(</font>t<font color=Red>-></font>Bool<font color=Cyan>)</font> <font color=Red>-></font> Parser s t t+<a name="satisfy"></a>satisfy p <font color=Red>=</font> <font color=Green><u>do</u></font><font color=Cyan>{</font> x <font color=Red><-</font> next+ <font color=Cyan>;</font> <font color=Green><u>if</u></font> p x <font color=Green><u>then</u></font> return x <font color=Green><u>else</u></font> fail <font color=Magenta>"Parse.satisfy: failed"</font>+ <font color=Cyan>}</font>++<font color=Green><u>infixl</u></font> <font color=Magenta>3</font> <font color=Cyan>`apply`</font>+<font color=Blue>-- | Apply a parsed function to a parsed value</font>+apply <font color=Red>::</font> Parser s t <font color=Cyan>(</font>a<font color=Red>-></font>b<font color=Cyan>)</font> <font color=Red>-></font> Parser s t a <font color=Red>-></font> Parser s t b+<a name="apply"></a>pf <font color=Cyan>`apply`</font> px <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font> f <font color=Red><-</font> pf<font color=Cyan>;</font> x <font color=Red><-</font> px<font color=Cyan>;</font> return <font color=Cyan>(</font>f x<font color=Cyan>)</font> <font color=Cyan>}</font>++<font color=Green><u>infixl</u></font> <font color=Magenta>3</font> <font color=Cyan>`discard`</font>+<font color=Blue>-- | @x `discard` y@ parses both x and y, but discards the result of y</font>+discard <font color=Red>::</font> Parser s t a <font color=Red>-></font> Parser s t b <font color=Red>-></font> Parser s t a+<a name="discard"></a>px <font color=Cyan>`discard`</font> py <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font> x <font color=Red><-</font> px<font color=Cyan>;</font> <font color=Green><u>_</u></font> <font color=Red><-</font> py<font color=Cyan>;</font> return x <font color=Cyan>}</font>++<font color=Blue>-- | @p `adjustErr` f@ applies the transformation @f@ to any error message</font>+<font color=Blue>-- generated in @p@, having no effect if @p@ succeeds.</font>+adjustErr <font color=Red>::</font> Parser s t a <font color=Red>-></font> <font color=Cyan>(</font>String<font color=Red>-></font>String<font color=Cyan>)</font> <font color=Red>-></font> Parser s t a+<a name="adjustErr"></a><font color=Cyan>(</font>P p<font color=Cyan>)</font> <font color=Cyan>`adjustErr`</font> f <font color=Red>=</font>+ P <font color=Cyan>(</font><font color=Red>\</font>s ts<font color=Red>-></font> <font color=Green><u>case</u></font> p s ts <font color=Green><u>of</u></font>+ <font color=Cyan>(</font>Left <font color=Cyan>(</font>b<font color=Cyan>,</font>msg<font color=Cyan>)</font><font color=Cyan>,</font> s'<font color=Cyan>,</font> ts'<font color=Cyan>)</font> <font color=Red>-></font> <font color=Cyan>(</font>Left <font color=Cyan>(</font>b<font color=Cyan>,</font><font color=Cyan>(</font>f msg<font color=Cyan>)</font><font color=Cyan>)</font><font color=Cyan>,</font> s<font color=Cyan>,</font> ts'<font color=Cyan>)</font>+ right <font color=Red>-></font> right <font color=Cyan>)</font>++<font color=Blue>-- | @adjustErrBad@ is just like @adjustErr@ except it also raises the</font>+<font color=Blue>-- severity of the error.</font>+adjustErrBad <font color=Red>::</font> Parser s t a <font color=Red>-></font> <font color=Cyan>(</font>String<font color=Red>-></font>String<font color=Cyan>)</font> <font color=Red>-></font> Parser s t a+<font color=Blue>-- p `adjustErrBad` f = commit (p `adjustErr` f)</font>+<a name="adjustErrBad"></a><font color=Cyan>(</font>P p<font color=Cyan>)</font> <font color=Cyan>`adjustErrBad`</font> f <font color=Red>=</font>+ P <font color=Cyan>(</font><font color=Red>\</font>s ts<font color=Red>-></font> <font color=Green><u>case</u></font> p s ts <font color=Green><u>of</u></font>+ <font color=Cyan>(</font>Left <font color=Cyan>(</font><font color=Green><u>_</u></font><font color=Cyan>,</font>msg<font color=Cyan>)</font><font color=Cyan>,</font> s'<font color=Cyan>,</font> ts'<font color=Cyan>)</font> <font color=Red>-></font> <font color=Cyan>(</font>Left <font color=Cyan>(</font>True<font color=Cyan>,</font><font color=Cyan>(</font>f msg<font color=Cyan>)</font><font color=Cyan>)</font><font color=Cyan>,</font> s<font color=Cyan>,</font> ts'<font color=Cyan>)</font>+ right <font color=Red>-></font> right <font color=Cyan>)</font>++<font color=Green><u>infixl</u></font> <font color=Magenta>6</font> <font color=Cyan>`onFail`</font> <font color=Blue>-- not sure about precedence 6?</font>+<font color=Blue>-- | @p `onFail` q@ means parse p unless p fails in which case parse q instead.</font>+<font color=Blue>-- Can be chained together to give multiple attempts to parse something.</font>+<font color=Blue>-- (Note that q could itself be a failing parser, e.g. to change the error</font>+<font color=Blue>-- message from that defined in p to something different.)</font>+<font color=Blue>-- However, a severe failure in p cannot be ignored.</font>+onFail <font color=Red>::</font> Parser s t a <font color=Red>-></font> Parser s t a <font color=Red>-></font> Parser s t a+<a name="onFail"></a><font color=Cyan>(</font>P p<font color=Cyan>)</font> <font color=Cyan>`onFail`</font> <font color=Cyan>(</font>P q<font color=Cyan>)</font> <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>s ts<font color=Red>-></font> <font color=Green><u>case</u></font> p s ts <font color=Green><u>of</u></font>+ r<font color=Red>@</font><font color=Cyan>(</font>Left <font color=Cyan>(</font>True<font color=Cyan>,</font><font color=Green><u>_</u></font><font color=Cyan>)</font><font color=Cyan>,</font> <font color=Green><u>_</u></font><font color=Cyan>,</font> <font color=Green><u>_</u></font><font color=Cyan>)</font> <font color=Red>-></font> r+ <font color=Cyan>(</font>Left <font color=Green><u>_</u></font><font color=Cyan>,</font> <font color=Green><u>_</u></font><font color=Cyan>,</font> <font color=Green><u>_</u></font><font color=Cyan>)</font> <font color=Red>-></font> q s ts+ right <font color=Red>-></font> right <font color=Cyan>)</font>++<font color=Blue>-- | Parse the first alternative in the list that succeeds.</font>+oneOf <font color=Red>::</font> <font color=Red>[</font>Parser s t a<font color=Red>]</font> <font color=Red>-></font> Parser s t a+<a name="oneOf"></a>oneOf <font color=Red>[</font><font color=Red>]</font> <font color=Red>=</font> fail <font color=Cyan>(</font><font color=Magenta>"Failed to parse any of the possible choices"</font><font color=Cyan>)</font>+oneOf <font color=Cyan>(</font>p<font color=Red><b>:</b></font>ps<font color=Cyan>)</font> <font color=Red>=</font> p <font color=Cyan>`onFail`</font> oneOf ps++<font color=Blue>-- | Parse the first alternative that succeeds, but if none succeed,</font>+<font color=Blue>-- report only the severe errors, and if none of those, then report</font>+<font color=Blue>-- all the soft errors.</font>+oneOf' <font color=Red>::</font> <font color=Red>[</font><font color=Cyan>(</font>String<font color=Cyan>,</font> Parser s t a<font color=Cyan>)</font><font color=Red>]</font> <font color=Red>-></font> Parser s t a+<a name="oneOf'"></a>oneOf' <font color=Red>=</font> accum <font color=Red>[</font><font color=Red>]</font>+ <font color=Green><u>where</u></font> accum errs <font color=Red>[</font><font color=Red>]</font> <font color=Red>=</font>+ <font color=Green><u>case</u></font> filter isBad errs <font color=Green><u>of</u></font>+ <font color=Red>[</font><font color=Red>]</font> <font color=Red>-></font> fail <font color=Cyan>(</font><font color=Magenta>"failed to parse any of the possible choices:\n"</font>+ <font color=Cyan>++</font>indent <font color=Magenta>2</font> <font color=Cyan>(</font>concatMap showErr <font color=Cyan>(</font>reverse errs<font color=Cyan>)</font><font color=Cyan>)</font><font color=Cyan>)</font>+ <font color=Red>[</font><font color=Cyan>(</font><font color=Green><u>_</u></font><font color=Cyan>,</font><font color=Cyan>(</font><font color=Green><u>_</u></font><font color=Cyan>,</font>e<font color=Cyan>)</font><font color=Cyan>)</font><font color=Red>]</font> <font color=Red>-></font> failBad e+ es <font color=Red>-></font> failBad <font color=Cyan>(</font><font color=Magenta>"one of the following failures occurred:\n"</font>+ <font color=Cyan>++</font>indent <font color=Magenta>2</font> <font color=Cyan>(</font>concatMap showErr <font color=Cyan>(</font>reverse es<font color=Cyan>)</font><font color=Cyan>)</font><font color=Cyan>)</font>+ accum errs <font color=Cyan>(</font><font color=Cyan>(</font>e<font color=Cyan>,</font>P p<font color=Cyan>)</font><font color=Red><b>:</b></font>ps<font color=Cyan>)</font> <font color=Red>=</font>+ P <font color=Cyan>(</font><font color=Red>\</font>u ts<font color=Red>-></font> <font color=Green><u>case</u></font> p u ts <font color=Green><u>of</u></font>+ <font color=Cyan>(</font>Left err<font color=Cyan>,</font><font color=Green><u>_</u></font><font color=Cyan>,</font><font color=Green><u>_</u></font><font color=Cyan>)</font> <font color=Red>-></font> <font color=Green><u>let</u></font> <font color=Cyan>(</font>P p<font color=Cyan>)</font> <font color=Red>=</font> accum <font color=Cyan>(</font><font color=Cyan>(</font>e<font color=Cyan>,</font>err<font color=Cyan>)</font><font color=Red><b>:</b></font>errs<font color=Cyan>)</font> ps+ <font color=Green><u>in</u></font> p u ts+ right <font color=Red>-></font> right <font color=Cyan>)</font>+ showErr <font color=Cyan>(</font>name<font color=Cyan>,</font><font color=Cyan>(</font><font color=Green><u>_</u></font><font color=Cyan>,</font>err<font color=Cyan>)</font><font color=Cyan>)</font> <font color=Red>=</font> name<font color=Cyan>++</font><font color=Magenta>":\n"</font><font color=Cyan>++</font>indent <font color=Magenta>2</font> err+ isBad <font color=Cyan>(</font><font color=Green><u>_</u></font><font color=Cyan>,</font><font color=Cyan>(</font>b<font color=Cyan>,</font><font color=Green><u>_</u></font><font color=Cyan>)</font><font color=Cyan>)</font> <font color=Red>=</font> b++<font color=Blue>-- | Helper for formatting error messages: indents all lines by a fixed amount.</font>+indent <font color=Red>::</font> Int <font color=Red>-></font> String <font color=Red>-></font> String+<a name="indent"></a>indent n <font color=Red>=</font> unlines <font color=Cyan>.</font> map <font color=Cyan>(</font>replicate n <font color=Magenta>' '</font> <font color=Cyan>++</font><font color=Cyan>)</font> <font color=Cyan>.</font> lines++<font color=Blue>-- | 'many p' parses a list of elements with individual parser p.</font>+<font color=Blue>-- Cannot fail, since an empty list is a valid return value.</font>+many <font color=Red>::</font> Parser s t a <font color=Red>-></font> Parser s t <font color=Red>[</font>a<font color=Red>]</font>+<a name="many"></a>many p <font color=Red>=</font> many1 p <font color=Cyan>`onFail`</font> return <font color=Red>[</font><font color=Red>]</font>++<font color=Blue>-- | Parse a non-empty list of items.</font>+many1 <font color=Red>::</font> Parser s t a <font color=Red>-></font> Parser s t <font color=Red>[</font>a<font color=Red>]</font>+<a name="many1"></a>many1 p <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font> x <font color=Red><-</font> p <font color=Cyan>`adjustErr`</font> <font color=Cyan>(</font><font color=Cyan>(</font><font color=Magenta>"In a sequence:\n"</font><font color=Cyan>++</font><font color=Cyan>)</font><font color=Cyan>.</font> indent <font color=Magenta>2</font><font color=Cyan>)</font>+ <font color=Cyan>;</font> xs <font color=Red><-</font> many p+ <font color=Cyan>;</font> return <font color=Cyan>(</font>x<font color=Red><b>:</b></font>xs<font color=Cyan>)</font>+ <font color=Cyan>}</font>+<font color=Blue>-- `adjustErr` ("When looking for a non-empty sequence:\n"++)</font>++<font color=Blue>-- | Parse a list of items separated by discarded junk.</font>+sepBy <font color=Red>::</font> Parser s t a <font color=Red>-></font> Parser s t sep <font color=Red>-></font> Parser s t <font color=Red>[</font>a<font color=Red>]</font>+<a name="sepBy"></a>sepBy p sep <font color=Red>=</font> <font color=Green><u>do</u></font> sepBy1 p sep <font color=Cyan>`onFail`</font> return <font color=Red>[</font><font color=Red>]</font>++<font color=Blue>-- | Parse a non-empty list of items separated by discarded junk.</font>+sepBy1 <font color=Red>::</font> Parser s t a <font color=Red>-></font> Parser s t sep <font color=Red>-></font> Parser s t <font color=Red>[</font>a<font color=Red>]</font>+<a name="sepBy1"></a>sepBy1 p sep <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font> x <font color=Red><-</font> p+ <font color=Cyan>;</font> xs <font color=Red><-</font> many <font color=Cyan>(</font><font color=Green><u>do</u></font> <font color=Cyan>{</font>sep<font color=Cyan>;</font> p<font color=Cyan>}</font><font color=Cyan>)</font>+ <font color=Cyan>;</font> return <font color=Cyan>(</font>x<font color=Red><b>:</b></font>xs<font color=Cyan>)</font>+ <font color=Cyan>}</font>+ <font color=Cyan>`adjustErr`</font> <font color=Cyan>(</font><font color=Magenta>"When looking for a non-empty sequence with separators:\n"</font><font color=Cyan>++</font><font color=Cyan>)</font>+ +<font color=Blue>-- | Parse a list of items, discarding the start, end, and separator</font>+<font color=Blue>-- items.</font>+bracketSep <font color=Red>::</font> Parser s t bra <font color=Red>-></font> Parser s t sep <font color=Red>-></font> Parser s t ket+ <font color=Red>-></font> Parser s t a <font color=Red>-></font> Parser s t <font color=Red>[</font>a<font color=Red>]</font>+<a name="bracketSep"></a>bracketSep open sep close p <font color=Red>=</font>+ <font color=Green><u>do</u></font> <font color=Cyan>{</font> open<font color=Cyan>;</font> close<font color=Cyan>;</font> return <font color=Red>[</font><font color=Red>]</font> <font color=Cyan>}</font>+ <font color=Cyan>`onFail`</font>+ <font color=Green><u>do</u></font> <font color=Cyan>{</font> open <font color=Cyan>`adjustErr`</font> <font color=Cyan>(</font><font color=Magenta>"Missing opening bracket:\n"</font><font color=Cyan>++</font><font color=Cyan>)</font>+ <font color=Cyan>;</font> x <font color=Red><-</font> p <font color=Cyan>`adjustErr`</font> <font color=Cyan>(</font><font color=Magenta>"After first bracket in a group:\n"</font><font color=Cyan>++</font><font color=Cyan>)</font>+ <font color=Cyan>;</font> xs <font color=Red><-</font> many <font color=Cyan>(</font><font color=Green><u>do</u></font> <font color=Cyan>{</font>sep<font color=Cyan>;</font> p<font color=Cyan>}</font><font color=Cyan>)</font>+ <font color=Cyan>;</font> close <font color=Cyan>`adjustErrBad`</font> <font color=Cyan>(</font><font color=Magenta>"When looking for closing bracket:\n"</font><font color=Cyan>++</font><font color=Cyan>)</font>+ <font color=Cyan>;</font> return <font color=Cyan>(</font>x<font color=Red><b>:</b></font>xs<font color=Cyan>)</font>+ <font color=Cyan>}</font>++<font color=Blue>-- | Parse a bracketed item, discarding the brackets.</font>+bracket <font color=Red>::</font> Parser s t bra <font color=Red>-></font> Parser s t ket <font color=Red>-></font> Parser s t a <font color=Red>-></font> Parser s t a+<a name="bracket"></a>bracket open close p <font color=Red>=</font> <font color=Green><u>do</u></font>+ <font color=Green><u>do</u></font> <font color=Cyan>{</font> open <font color=Cyan>`adjustErr`</font> <font color=Cyan>(</font><font color=Magenta>"Missing opening bracket:\n"</font><font color=Cyan>++</font><font color=Cyan>)</font>+ <font color=Cyan>;</font> x <font color=Red><-</font> p+ <font color=Cyan>;</font> close <font color=Cyan>`adjustErrBad`</font> <font color=Cyan>(</font><font color=Magenta>"Missing closing bracket:\n"</font><font color=Cyan>++</font><font color=Cyan>)</font>+ <font color=Cyan>;</font> return x+ <font color=Cyan>}</font>++<font color=Blue>-- | 'manyFinally e t' parses a possibly-empty sequence of e's,</font>+<font color=Blue>-- terminated by a t. Any parse failures could be due either to</font>+<font color=Blue>-- a badly-formed terminator or a badly-formed element, so raise</font>+<font color=Blue>-- both possible errors.</font>+manyFinally <font color=Red>::</font> Parser s t a <font color=Red>-></font> Parser s t z <font color=Red>-></font> Parser s t <font color=Red>[</font>a<font color=Red>]</font>+<a name="manyFinally"></a>manyFinally p t <font color=Red>=</font>+ <font color=Green><u>do</u></font> <font color=Cyan>{</font> xs <font color=Red><-</font> many p+ <font color=Cyan>;</font> oneOf' <font color=Red>[</font> <font color=Cyan>(</font><font color=Magenta>"sequence terminator"</font><font color=Cyan>,</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font> t<font color=Cyan>;</font> return <font color=Cyan>(</font><font color=Cyan>)</font> <font color=Cyan>}</font> <font color=Cyan>)</font>+ <font color=Cyan>,</font> <font color=Cyan>(</font><font color=Magenta>"item in a sequence"</font><font color=Cyan>,</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font> p<font color=Cyan>;</font> return <font color=Cyan>(</font><font color=Cyan>)</font> <font color=Cyan>}</font> <font color=Cyan>)</font>+ <font color=Red>]</font>+ <font color=Cyan>;</font> return xs+ <font color=Cyan>}</font>++<font color=Blue>------------------------------------------------------------------------</font>+<font color=Blue>-- State handling</font>++<font color=Blue>-- | Update the internal state.</font>+stUpdate <font color=Red>::</font> <font color=Cyan>(</font>s<font color=Red>-></font>s<font color=Cyan>)</font> <font color=Red>-></font> Parser s t <font color=Cyan>(</font><font color=Cyan>)</font>+<a name="stUpdate"></a>stUpdate f <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>s ts<font color=Red>-></font> <font color=Cyan>(</font>Right <font color=Cyan>(</font><font color=Cyan>)</font><font color=Cyan>,</font> f s<font color=Cyan>,</font> ts<font color=Cyan>)</font><font color=Cyan>)</font>++<font color=Blue>-- | Query the internal state.</font>+stQuery <font color=Red>::</font> <font color=Cyan>(</font>s<font color=Red>-></font>a<font color=Cyan>)</font> <font color=Red>-></font> Parser s t a+<a name="stQuery"></a>stQuery f <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>s ts<font color=Red>-></font> <font color=Cyan>(</font>Right <font color=Cyan>(</font>f s<font color=Cyan>)</font><font color=Cyan>,</font> s<font color=Cyan>,</font> ts<font color=Cyan>)</font><font color=Cyan>)</font>++<font color=Blue>-- | Deliver the entire internal state.</font>+stGet <font color=Red>::</font> Parser s t s+<a name="stGet"></a>stGet <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>s ts<font color=Red>-></font> <font color=Cyan>(</font>Right s<font color=Cyan>,</font> s<font color=Cyan>,</font> ts<font color=Cyan>)</font><font color=Cyan>)</font>++<font color=Blue>------------------------------------------------------------------------</font>+<font color=Blue>-- | Push some tokens back onto the front of the input stream and reparse.</font>+<font color=Blue>-- This is useful e.g. for recursively expanding macros. When the</font>+<font color=Blue>-- user-parser recognises a macro use, it can lookup the macro</font>+<font color=Blue>-- expansion from the parse state, lex it, and then stuff the</font>+<font color=Blue>-- lexed expansion back down into the parser.</font>+reparse <font color=Red>::</font> <font color=Red>[</font>t<font color=Red>]</font> <font color=Red>-></font> Parser s t <font color=Cyan>(</font><font color=Cyan>)</font>+<a name="reparse"></a>reparse ts <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>s inp<font color=Red>-></font> <font color=Cyan>(</font>Right <font color=Cyan>(</font><font color=Cyan>)</font><font color=Cyan>,</font> s<font color=Cyan>,</font> ts<font color=Cyan>++</font>inp<font color=Cyan>)</font><font color=Cyan>)</font>++<font color=Blue>------------------------------------------------------------------------</font>+</pre>
+ docs/haddock/src/Text/ParserCombinators/PolyStateLazy.html view
@@ -0,0 +1,282 @@+<pre><font color=Green><u>module</u></font> Text<font color=Cyan>.</font>ParserCombinators<font color=Cyan>.</font>PolyStateLazy+ <font color=Cyan>(</font> <font color=Blue>-- * The Parser datatype.</font>+ <font color=Blue>-- $parser</font>+ Parser<font color=Cyan>(</font>P<font color=Cyan>)</font> <font color=Blue>-- datatype, instance of: Functor, Monad</font>+ <font color=Cyan>,</font> runParser <font color=Blue>-- :: Parser s t a -> s -> [t] -> (a, s, [t])</font>+ <font color=Cyan>,</font> failBad <font color=Blue>-- :: String -> Parser s t a</font>+ <font color=Cyan>,</font> commit <font color=Blue>-- :: Parser s t a -> Parser s t a</font>+ <font color=Blue>-- * Combinators:</font>+ <font color=Blue>-- ** Primitives</font>+ <font color=Cyan>,</font> next <font color=Blue>-- :: Parser s t t</font>+ <font color=Cyan>,</font> satisfy <font color=Blue>-- :: (t->Bool) -> Parser s t t</font>+ <font color=Cyan>,</font> apply <font color=Blue>-- :: Parser t (a->b) -> Parser s t a -> Parser s t b</font>+ <font color=Cyan>,</font> discard <font color=Blue>-- :: Parser s t a -> Parser s t b -> Parser s t a</font>+ <font color=Blue>-- ** Error-handling</font>+ <font color=Cyan>,</font> adjustErr <font color=Blue>-- :: Parser s t a -> (String->String) -> Parser s t a</font>+ <font color=Cyan>,</font> adjustErrBad<font color=Blue>-- :: Parser s t a -> (String->String) -> Parser s t a</font>+ <font color=Cyan>,</font> indent <font color=Blue>-- :: Int -> String -> String</font>+ <font color=Blue>-- ** Choices</font>+ <font color=Cyan>,</font> onFail <font color=Blue>-- :: Parser s t a -> Parser s t a -> Parser s t a</font>+ <font color=Cyan>,</font> oneOf <font color=Blue>-- :: [Parser s t a] -> Parser s t a</font>+ <font color=Cyan>,</font> oneOf' <font color=Blue>-- :: [(String, Parser s t a)] -> Parser s t a</font>+ <font color=Cyan>,</font> optional <font color=Blue>-- :: Parser s t a -> Parser s t (Maybe a)</font>+ <font color=Blue>-- ** Sequences</font>+ <font color=Cyan>,</font> many <font color=Blue>-- :: Parser s t a -> Parser s t [a]</font>+ <font color=Cyan>,</font> many1 <font color=Blue>-- :: Parser s t a -> Parser s t [a]</font>+ <font color=Cyan>,</font> sepBy <font color=Blue>-- :: Parser s t a -> Parser s t sep -> Parser s t [a]</font>+ <font color=Cyan>,</font> sepBy1 <font color=Blue>-- :: Parser s t a -> Parser s t sep -> Parser s t [a]</font>+ <font color=Cyan>,</font> bracketSep <font color=Blue>-- :: Parser s t bra -> Parser s t sep -> Parser s t ket</font>+ <font color=Blue>-- -> Parser s t a -> Parser s t [a]</font>+ <font color=Cyan>,</font> bracket <font color=Blue>-- :: Parser s t bra -> Parser s t ket -> Parser s t a</font>+ <font color=Blue>-- -> Parser s t a</font>+ <font color=Cyan>,</font> manyFinally <font color=Blue>-- :: Parser s t a -> Parser s t z -> Parser s t [a]</font>+ <font color=Blue>-- ** State-handling</font>+ <font color=Cyan>,</font> stUpdate <font color=Blue>-- :: (s->s) -> Parser s t ()</font>+ <font color=Cyan>,</font> stQuery <font color=Blue>-- :: (s->a) -> Parser s t a</font>+ <font color=Cyan>,</font> stGet <font color=Blue>-- :: Parser s t s</font>+ <font color=Blue>-- ** Re-parsing</font>+ <font color=Cyan>,</font> reparse <font color=Blue>-- :: [t] -> Parser s t ()</font>+ <font color=Cyan>)</font> <font color=Green><u>where</u></font>++<font color=Cyan>#</font><font color=Green><u>if</u></font> <b><font color=Magenta>__GLASGOW_HASKELL__</font></b>+<font color=Green><u>import</u></font> Control<font color=Cyan>.</font>Exception hiding <font color=Cyan>(</font>bracket<font color=Cyan>)</font>+throwE <font color=Red>::</font> String <font color=Red>-></font> a+<a name="throwE"></a>throwE msg <font color=Red>=</font> throw <font color=Cyan>(</font>ErrorCall msg<font color=Cyan>)</font>+<font color=Cyan>#</font><font color=Green><u>else</u></font>+throwE <font color=Red>::</font> String <font color=Red>-></font> a+throwE msg <font color=Red>=</font> error msg+<font color=Cyan>#</font>endif++<font color=Blue>-- $parser</font>+<font color=Blue>-- Parsers do not return explicit failure. An exception is raised</font>+<font color=Blue>-- instead. This allows partial results to be returned before a</font>+<font color=Blue>-- full parse is complete.</font>++<font color=Blue>-- | The @Parser@ datatype is a fairly generic parsing monad with error</font>+<font color=Blue>-- reporting and a running state. It can be used for arbitrary token</font>+<font color=Blue>-- types, not just String input.</font>+<font color=Green><u>newtype</u></font> Parser s t a <font color=Red>=</font> P <font color=Cyan>(</font>s <font color=Red>-></font> <font color=Red>[</font>t<font color=Red>]</font> <font color=Red>-></font> <font color=Cyan>(</font>Either String a<font color=Cyan>,</font> s<font color=Cyan>,</font> <font color=Red>[</font>t<font color=Red>]</font><font color=Cyan>)</font><font color=Cyan>)</font>++<font color=Blue>-- | A return type like Either, that distinguishes not only between</font>+<font color=Blue>-- right and wrong answers, but also had gradations of wrongness.</font>+<font color=Blue>-- Not used in this library. !!!!!!!!!!!!!!!!!!!!!!!!!!</font>+<a name="EitherE"></a><font color=Green><u>type</u></font> EitherE a b <font color=Red>=</font> Either <font color=Cyan>(</font>Bool<font color=Cyan>,</font>a<font color=Cyan>)</font> b++<font color=Blue>-- | Apply a parser to an initial state and input token sequence.</font>+<font color=Blue>-- The parser cannot return an error value explicitly, so errors</font>+<font color=Blue>-- raise an exception. Thus, results can be partial (lazily constructed,</font>+<font color=Blue>-- but containing undefined).</font>+runParser <font color=Red>::</font> Parser s t a <font color=Red>-></font> s <font color=Red>-></font> <font color=Red>[</font>t<font color=Red>]</font> <font color=Red>-></font> <font color=Cyan>(</font>a<font color=Cyan>,</font> s<font color=Cyan>,</font> <font color=Red>[</font>t<font color=Red>]</font><font color=Cyan>)</font>+<a name="runParser"></a>runParser <font color=Cyan>(</font>P p<font color=Cyan>)</font> s <font color=Red>=</font>+ <font color=Cyan>(</font><font color=Red>\</font> <font color=Cyan>(</font>e<font color=Cyan>,</font>s<font color=Cyan>,</font>ts<font color=Cyan>)</font><font color=Red>-></font> <font color=Cyan>(</font><font color=Green><u>case</u></font> e <font color=Green><u>of</u></font> <font color=Cyan>{</font>Left m<font color=Red>-></font>throwE m<font color=Cyan>;</font> Right x<font color=Red>-></font>x<font color=Cyan>}</font><font color=Cyan>,</font> s<font color=Cyan>,</font> ts<font color=Cyan>)</font><font color=Cyan>)</font>+ <font color=Cyan>.</font> p s++<font color=Green><u>instance</u></font> Functor <font color=Cyan>(</font>Parser s t<font color=Cyan>)</font> <font color=Green><u>where</u></font>+ fmap f <font color=Cyan>(</font>P p<font color=Cyan>)</font> <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>s ts<font color=Red>-></font> <font color=Green><u>case</u></font> p s ts <font color=Green><u>of</u></font>+ <font color=Cyan>(</font>Left msg<font color=Cyan>,</font> s'<font color=Cyan>,</font> ts'<font color=Cyan>)</font> <font color=Red>-></font> <font color=Cyan>(</font>Left msg<font color=Cyan>,</font> s'<font color=Cyan>,</font> ts'<font color=Cyan>)</font>+ <font color=Cyan>(</font>Right x<font color=Cyan>,</font> s'<font color=Cyan>,</font> ts'<font color=Cyan>)</font> <font color=Red>-></font> <font color=Cyan>(</font>Right <font color=Cyan>(</font>f x<font color=Cyan>)</font><font color=Cyan>,</font> s'<font color=Cyan>,</font> ts'<font color=Cyan>)</font><font color=Cyan>)</font>+<font color=Green><u>instance</u></font> Monad <font color=Cyan>(</font>Parser s t<font color=Cyan>)</font> <font color=Green><u>where</u></font>+ return x <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>s ts<font color=Red>-></font> <font color=Cyan>(</font>Right x<font color=Cyan>,</font> s<font color=Cyan>,</font> ts<font color=Cyan>)</font><font color=Cyan>)</font>+ <font color=Cyan>(</font>P f<font color=Cyan>)</font> <font color=Cyan>>>=</font> g <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>s ts<font color=Red>-></font> <font color=Green><u>case</u></font> f s ts <font color=Green><u>of</u></font>+ <font color=Cyan>(</font>Left msg<font color=Cyan>,</font> s'<font color=Cyan>,</font> ts'<font color=Cyan>)</font> <font color=Red>-></font> <font color=Cyan>(</font>Left msg<font color=Cyan>,</font> s'<font color=Cyan>,</font> ts'<font color=Cyan>)</font>+ <font color=Cyan>(</font>Right x<font color=Cyan>,</font> s'<font color=Cyan>,</font> ts'<font color=Cyan>)</font> <font color=Red>-></font> <font color=Green><u>let</u></font> <font color=Cyan>(</font>P g'<font color=Cyan>)</font> <font color=Red>=</font> g x+ <font color=Green><u>in</u></font> g' s' ts'<font color=Cyan>)</font>+ fail msg <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>s ts<font color=Red>-></font> <font color=Cyan>(</font>Left msg<font color=Cyan>,</font> s<font color=Cyan>,</font> ts<font color=Cyan>)</font><font color=Cyan>)</font>++<font color=Blue>-- | Simple failure can be corrected, but when a simple fail is not strong</font>+<font color=Blue>-- enough, use failBad for emphasis. It guarantees parsing will terminate</font>+<font color=Blue>-- with an exception.</font>+failBad <font color=Red>::</font> String <font color=Red>-></font> Parser s t a+<a name="failBad"></a>failBad msg <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>s ts<font color=Red>-></font> <font color=Cyan>(</font>throwE msg<font color=Cyan>,</font> s<font color=Cyan>,</font> ts<font color=Cyan>)</font><font color=Cyan>)</font>++<font color=Blue>-- | Commit is a way of raising the severity of any errors found within</font>+<font color=Blue>-- its argument. Used in the middle of a parser definition, it means that</font>+<font color=Blue>-- any operations prior to commitment fail softly, but after commitment,</font>+<font color=Blue>-- they fail hard.</font>+commit <font color=Red>::</font> Parser s t a <font color=Red>-></font> Parser s t a+<a name="commit"></a>commit <font color=Cyan>(</font>P p<font color=Cyan>)</font> <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>s ts<font color=Red>-></font> <font color=Green><u>case</u></font> p s ts <font color=Green><u>of</u></font>+ <font color=Cyan>(</font>Left e<font color=Cyan>,</font> s'<font color=Cyan>,</font> ts'<font color=Cyan>)</font> <font color=Red>-></font> <font color=Cyan>(</font>throwE e<font color=Cyan>,</font> s'<font color=Cyan>,</font> ts'<font color=Cyan>)</font>+ right <font color=Red>-></font> right <font color=Cyan>)</font>++<font color=Blue>-- Combinators</font>++<font color=Blue>-- | One token</font>+next <font color=Red>::</font> Parser s t t+<a name="next"></a>next <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>s ts<font color=Red>-></font> <font color=Green><u>case</u></font> ts <font color=Green><u>of</u></font>+ <font color=Red>[</font><font color=Red>]</font> <font color=Red>-></font> <font color=Cyan>(</font>Left <font color=Magenta>"Ran out of input (EOF)"</font><font color=Cyan>,</font> s<font color=Cyan>,</font> <font color=Red>[</font><font color=Red>]</font><font color=Cyan>)</font>+ <font color=Cyan>(</font>t<font color=Red><b>:</b></font>ts'<font color=Cyan>)</font> <font color=Red>-></font> <font color=Cyan>(</font>Right t<font color=Cyan>,</font> s<font color=Cyan>,</font> ts'<font color=Cyan>)</font> <font color=Cyan>)</font>++<font color=Blue>-- | One token satifying a predicate</font>+satisfy <font color=Red>::</font> <font color=Cyan>(</font>t<font color=Red>-></font>Bool<font color=Cyan>)</font> <font color=Red>-></font> Parser s t t+<a name="satisfy"></a>satisfy p <font color=Red>=</font> <font color=Green><u>do</u></font><font color=Cyan>{</font> x <font color=Red><-</font> next+ <font color=Cyan>;</font> <font color=Green><u>if</u></font> p x <font color=Green><u>then</u></font> return x <font color=Green><u>else</u></font> fail <font color=Magenta>"Parse.satisfy: failed"</font>+ <font color=Cyan>}</font>++<font color=Green><u>infixl</u></font> <font color=Magenta>3</font> <font color=Cyan>`apply`</font>+<font color=Blue>-- | Apply a parsed function to a parsed value</font>+apply <font color=Red>::</font> Parser s t <font color=Cyan>(</font>a<font color=Red>-></font>b<font color=Cyan>)</font> <font color=Red>-></font> Parser s t a <font color=Red>-></font> Parser s t b+<font color=Blue>--pf `apply` px = do { f <- pf; x <- px; return (f x) }</font>+<font color=Blue>-- Needs to be lazier! Must not force the argument value too early.</font>+<a name="apply"></a><font color=Cyan>(</font>P pf<font color=Cyan>)</font> <font color=Cyan>`apply`</font> <font color=Cyan>(</font>P px<font color=Cyan>)</font> <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>s ts<font color=Red>-></font>+ <font color=Green><u>case</u></font> pf s ts <font color=Green><u>of</u></font>+ <font color=Cyan>(</font>Left msg<font color=Cyan>,</font> s'<font color=Cyan>,</font> ts'<font color=Cyan>)</font> <font color=Red>-></font> <font color=Cyan>(</font>Left msg<font color=Cyan>,</font> s'<font color=Cyan>,</font> ts'<font color=Cyan>)</font>+ <font color=Cyan>(</font>Right f<font color=Cyan>,</font> s'<font color=Cyan>,</font> ts'<font color=Cyan>)</font> <font color=Red>-></font> <font color=Green><u>let</u></font> <font color=Cyan>(</font>x'<font color=Cyan>,</font>s''<font color=Cyan>,</font>ts''<font color=Cyan>)</font> <font color=Red>=</font> px s' ts'+ x <font color=Red>=</font> <font color=Green><u>case</u></font> x' <font color=Green><u>of</u></font>+ Right x <font color=Red>-></font> x+ Left e <font color=Red>-></font> throwE e+ <font color=Green><u>in</u></font> <font color=Cyan>(</font>Right <font color=Cyan>(</font>f x<font color=Cyan>)</font><font color=Cyan>,</font> s''<font color=Cyan>,</font> ts''<font color=Cyan>)</font><font color=Cyan>)</font>++<font color=Green><u>infixl</u></font> <font color=Magenta>3</font> <font color=Cyan>`discard`</font>+<font color=Blue>-- | @x `discard` y@ parses both x and y, but discards the result of y</font>+discard <font color=Red>::</font> Parser s t a <font color=Red>-></font> Parser s t b <font color=Red>-></font> Parser s t a+<a name="discard"></a>px <font color=Cyan>`discard`</font> py <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font> x <font color=Red><-</font> px<font color=Cyan>;</font> <font color=Green><u>_</u></font> <font color=Red><-</font> py<font color=Cyan>;</font> return x <font color=Cyan>}</font>++<font color=Blue>-- | @p `adjustErr` f@ applies the transformation @f@ to any error message</font>+<font color=Blue>-- generated in @p@, having no effect if @p@ succeeds.</font>+adjustErr <font color=Red>::</font> Parser s t a <font color=Red>-></font> <font color=Cyan>(</font>String<font color=Red>-></font>String<font color=Cyan>)</font> <font color=Red>-></font> Parser s t a+<a name="adjustErr"></a><font color=Cyan>(</font>P p<font color=Cyan>)</font> <font color=Cyan>`adjustErr`</font> f <font color=Red>=</font>+ P <font color=Cyan>(</font><font color=Red>\</font>s ts<font color=Red>-></font> <font color=Green><u>case</u></font> p s ts <font color=Green><u>of</u></font>+ <font color=Cyan>(</font>Left msg<font color=Cyan>,</font> s'<font color=Cyan>,</font> ts'<font color=Cyan>)</font> <font color=Red>-></font> <font color=Cyan>(</font>Left <font color=Cyan>(</font>f msg<font color=Cyan>)</font><font color=Cyan>,</font> s<font color=Cyan>,</font> ts'<font color=Cyan>)</font>+ right <font color=Red>-></font> right <font color=Cyan>)</font>++<font color=Blue>-- | @adjustErrBad@ is just like @adjustErr@ except it also raises the</font>+<font color=Blue>-- severity of the error.</font>+adjustErrBad <font color=Red>::</font> Parser s t a <font color=Red>-></font> <font color=Cyan>(</font>String<font color=Red>-></font>String<font color=Cyan>)</font> <font color=Red>-></font> Parser s t a+<font color=Blue>-- p `adjustErrBad` f = commit (p `adjustErr` f)</font>+<a name="adjustErrBad"></a><font color=Cyan>(</font>P p<font color=Cyan>)</font> <font color=Cyan>`adjustErrBad`</font> f <font color=Red>=</font>+ P <font color=Cyan>(</font><font color=Red>\</font>s ts<font color=Red>-></font> <font color=Green><u>case</u></font> p s ts <font color=Green><u>of</u></font>+ <font color=Cyan>(</font>Left msg<font color=Cyan>,</font> s'<font color=Cyan>,</font> ts'<font color=Cyan>)</font> <font color=Red>-></font> <font color=Cyan>(</font>throwE <font color=Cyan>(</font>f msg<font color=Cyan>)</font><font color=Cyan>,</font> s<font color=Cyan>,</font> ts'<font color=Cyan>)</font>+ right <font color=Red>-></font> right <font color=Cyan>)</font>++<font color=Green><u>infixl</u></font> <font color=Magenta>6</font> <font color=Cyan>`onFail`</font> <font color=Blue>-- not sure about precedence 6?</font>+<font color=Blue>-- | @p `onFail` q@ means parse p unless p fails in which case parse q instead.</font>+<font color=Blue>-- Can be chained together to give multiple attempts to parse something.</font>+<font color=Blue>-- (Note that q could itself be a failing parser, e.g. to change the error</font>+<font color=Blue>-- message from that defined in p to something different.)</font>+<font color=Blue>-- However, a *severe* failure in p cannot be ignored.</font>+onFail <font color=Red>::</font> Parser s t a <font color=Red>-></font> Parser s t a <font color=Red>-></font> Parser s t a+<a name="onFail"></a><font color=Cyan>(</font>P p<font color=Cyan>)</font> <font color=Cyan>`onFail`</font> <font color=Cyan>(</font>P q<font color=Cyan>)</font> <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>s ts<font color=Red>-></font> <font color=Green><u>case</u></font> p s ts <font color=Green><u>of</u></font>+ <font color=Cyan>(</font>Left <font color=Green><u>_</u></font><font color=Cyan>,</font> <font color=Green><u>_</u></font><font color=Cyan>,</font> <font color=Green><u>_</u></font><font color=Cyan>)</font> <font color=Red>-></font> q s ts+ right <font color=Red>-></font> right <font color=Cyan>)</font>++<font color=Blue>-- | Parse the first alternative in the list that succeeds.</font>+oneOf <font color=Red>::</font> <font color=Red>[</font>Parser s t a<font color=Red>]</font> <font color=Red>-></font> Parser s t a+<a name="oneOf"></a>oneOf <font color=Red>[</font><font color=Red>]</font> <font color=Red>=</font> fail <font color=Cyan>(</font><font color=Magenta>"Failed to parse any of the possible choices"</font><font color=Cyan>)</font>+oneOf <font color=Cyan>(</font>p<font color=Red><b>:</b></font>ps<font color=Cyan>)</font> <font color=Red>=</font> p <font color=Cyan>`onFail`</font> oneOf ps++<font color=Blue>-- | Parse the first alternative that succeeds, but if none succeed,</font>+<font color=Blue>-- report only the severe errors, and if none of those, then report</font>+<font color=Blue>-- all the soft errors.</font>+oneOf' <font color=Red>::</font> <font color=Red>[</font><font color=Cyan>(</font>String<font color=Cyan>,</font> Parser s t a<font color=Cyan>)</font><font color=Red>]</font> <font color=Red>-></font> Parser s t a+<a name="oneOf'"></a>oneOf' ps <font color=Red>=</font> accum <font color=Red>[</font><font color=Red>]</font> ps+ <font color=Green><u>where</u></font> accum errs <font color=Red>[</font><font color=Red>]</font> <font color=Red>=</font>+ <font color=Green><u>case</u></font> errs <font color=Green><u>of</u></font>+ <font color=Red>[</font><font color=Red>]</font> <font color=Red>-></font> failBad <font color=Cyan>(</font><font color=Magenta>"internal failure in parser (oneOf'):\n"</font>+ <font color=Cyan>++</font>indent <font color=Magenta>2</font> <font color=Cyan>(</font>show <font color=Cyan>(</font>map fst ps<font color=Cyan>)</font><font color=Cyan>)</font><font color=Cyan>)</font>+ <font color=Red>[</font><font color=Cyan>(</font><font color=Green><u>_</u></font><font color=Cyan>,</font>e<font color=Cyan>)</font><font color=Red>]</font> <font color=Red>-></font> fail e+ es <font color=Red>-></font> fail <font color=Cyan>(</font><font color=Magenta>"one of the following failures occurred:\n"</font>+ <font color=Cyan>++</font>indent <font color=Magenta>2</font> <font color=Cyan>(</font>concatMap showErr <font color=Cyan>(</font>reverse es<font color=Cyan>)</font><font color=Cyan>)</font><font color=Cyan>)</font>+ accum errs <font color=Cyan>(</font><font color=Cyan>(</font>e<font color=Cyan>,</font>P p<font color=Cyan>)</font><font color=Red><b>:</b></font>ps<font color=Cyan>)</font> <font color=Red>=</font>+ P <font color=Cyan>(</font><font color=Red>\</font>u ts<font color=Red>-></font> <font color=Green><u>case</u></font> p u ts <font color=Green><u>of</u></font>+ <font color=Cyan>(</font>Left err<font color=Cyan>,</font><font color=Green><u>_</u></font><font color=Cyan>,</font><font color=Green><u>_</u></font><font color=Cyan>)</font> <font color=Red>-></font> <font color=Green><u>let</u></font> <font color=Cyan>(</font>P p<font color=Cyan>)</font> <font color=Red>=</font> accum <font color=Cyan>(</font><font color=Cyan>(</font>e<font color=Cyan>,</font>err<font color=Cyan>)</font><font color=Red><b>:</b></font>errs<font color=Cyan>)</font> ps+ <font color=Green><u>in</u></font> p u ts+ right <font color=Red>-></font> right <font color=Cyan>)</font>+ showErr <font color=Cyan>(</font>name<font color=Cyan>,</font>err<font color=Cyan>)</font> <font color=Red>=</font> name<font color=Cyan>++</font><font color=Magenta>":\n"</font><font color=Cyan>++</font>indent <font color=Magenta>2</font> err++<font color=Blue>-- | Helper for formatting error messages: indents all lines by a fixed amount.</font>+indent <font color=Red>::</font> Int <font color=Red>-></font> String <font color=Red>-></font> String+<a name="indent"></a>indent n <font color=Red>=</font> unlines <font color=Cyan>.</font> map <font color=Cyan>(</font>replicate n <font color=Magenta>' '</font> <font color=Cyan>++</font><font color=Cyan>)</font> <font color=Cyan>.</font> lines++<font color=Blue>-- | 'optional' indicates whether the parser succeeded through the Maybe type.</font>+optional <font color=Red>::</font> Parser s t a <font color=Red>-></font> Parser s t <font color=Cyan>(</font>Maybe a<font color=Cyan>)</font>+<a name="optional"></a>optional p <font color=Red>=</font> fmap Just p <font color=Cyan>`onFail`</font> return Nothing++<font color=Blue>-- | 'many p' parses a list of elements with individual parser p.</font>+<font color=Blue>-- Cannot fail, since an empty list is a valid return value.</font>+many <font color=Red>::</font> Parser s t a <font color=Red>-></font> Parser s t <font color=Red>[</font>a<font color=Red>]</font>+<a name="many"></a>many p <font color=Red>=</font> many1 p <font color=Cyan>`onFail`</font> return <font color=Red>[</font><font color=Red>]</font>++<font color=Blue>-- | Parse a non-empty list of items.</font>+many1 <font color=Red>::</font> Parser s t a <font color=Red>-></font> Parser s t <font color=Red>[</font>a<font color=Red>]</font>+<a name="many1"></a>many1 p <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font> x <font color=Red><-</font> p <font color=Cyan>`adjustErr`</font> <font color=Cyan>(</font><font color=Cyan>(</font><font color=Magenta>"In a sequence:\n"</font><font color=Cyan>++</font><font color=Cyan>)</font><font color=Cyan>.</font> indent <font color=Magenta>2</font><font color=Cyan>)</font>+ <font color=Cyan>;</font> xs <font color=Red><-</font> many p+ <font color=Cyan>;</font> return <font color=Cyan>(</font>x<font color=Red><b>:</b></font>xs<font color=Cyan>)</font>+ <font color=Cyan>}</font>+<font color=Blue>-- `adjustErr` ("When looking for a non-empty sequence:\n"++)</font>++<font color=Blue>-- | Parse a list of items separated by discarded junk.</font>+sepBy <font color=Red>::</font> Parser s t a <font color=Red>-></font> Parser s t sep <font color=Red>-></font> Parser s t <font color=Red>[</font>a<font color=Red>]</font>+<a name="sepBy"></a>sepBy p sep <font color=Red>=</font> <font color=Green><u>do</u></font> sepBy1 p sep <font color=Cyan>`onFail`</font> return <font color=Red>[</font><font color=Red>]</font>++<font color=Blue>-- | Parse a non-empty list of items separated by discarded junk.</font>+sepBy1 <font color=Red>::</font> Parser s t a <font color=Red>-></font> Parser s t sep <font color=Red>-></font> Parser s t <font color=Red>[</font>a<font color=Red>]</font>+<a name="sepBy1"></a>sepBy1 p sep <font color=Red>=</font> <font color=Green><u>do</u></font> <font color=Cyan>{</font> x <font color=Red><-</font> p+ <font color=Cyan>;</font> xs <font color=Red><-</font> many <font color=Cyan>(</font><font color=Green><u>do</u></font> <font color=Cyan>{</font>sep<font color=Cyan>;</font> p<font color=Cyan>}</font><font color=Cyan>)</font>+ <font color=Cyan>;</font> return <font color=Cyan>(</font>x<font color=Red><b>:</b></font>xs<font color=Cyan>)</font>+ <font color=Cyan>}</font>+ <font color=Cyan>`adjustErr`</font> <font color=Cyan>(</font><font color=Magenta>"When looking for a non-empty sequence with separators:\n"</font><font color=Cyan>++</font><font color=Cyan>)</font>+ +<font color=Blue>-- | Parse a list of items, discarding the start, end, and separator</font>+<font color=Blue>-- items.</font>+bracketSep <font color=Red>::</font> Parser s t bra <font color=Red>-></font> Parser s t sep <font color=Red>-></font> Parser s t ket+ <font color=Red>-></font> Parser s t a <font color=Red>-></font> Parser s t <font color=Red>[</font>a<font color=Red>]</font>+<a name="bracketSep"></a>bracketSep open sep close p <font color=Red>=</font>+ <font color=Green><u>do</u></font> <font color=Cyan>{</font> open<font color=Cyan>;</font> close<font color=Cyan>;</font> return <font color=Red>[</font><font color=Red>]</font> <font color=Cyan>}</font>+ <font color=Cyan>`onFail`</font>+ <font color=Green><u>do</u></font> <font color=Cyan>{</font> open <font color=Cyan>`adjustErr`</font> <font color=Cyan>(</font><font color=Magenta>"Missing opening bracket:\n"</font><font color=Cyan>++</font><font color=Cyan>)</font>+ <font color=Cyan>;</font> x <font color=Red><-</font> p <font color=Cyan>`adjustErr`</font> <font color=Cyan>(</font><font color=Magenta>"After first bracket in a group:\n"</font><font color=Cyan>++</font><font color=Cyan>)</font>+ <font color=Cyan>;</font> xs <font color=Red><-</font> many <font color=Cyan>(</font><font color=Green><u>do</u></font> <font color=Cyan>{</font>sep<font color=Cyan>;</font> p<font color=Cyan>}</font><font color=Cyan>)</font>+ <font color=Cyan>;</font> close <font color=Cyan>`adjustErrBad`</font> <font color=Cyan>(</font><font color=Magenta>"When looking for closing bracket:\n"</font><font color=Cyan>++</font><font color=Cyan>)</font>+ <font color=Cyan>;</font> return <font color=Cyan>(</font>x<font color=Red><b>:</b></font>xs<font color=Cyan>)</font>+ <font color=Cyan>}</font>++<font color=Blue>-- | Parse a bracketed item, discarding the brackets.</font>+bracket <font color=Red>::</font> Parser s t bra <font color=Red>-></font> Parser s t ket <font color=Red>-></font> Parser s t a <font color=Red>-></font> Parser s t a+<a name="bracket"></a>bracket open close p <font color=Red>=</font> <font color=Green><u>do</u></font>+ <font color=Green><u>do</u></font> <font color=Cyan>{</font> open <font color=Cyan>`adjustErr`</font> <font color=Cyan>(</font><font color=Magenta>"Missing opening bracket:\n"</font><font color=Cyan>++</font><font color=Cyan>)</font>+ <font color=Cyan>;</font> x <font color=Red><-</font> p+ <font color=Cyan>;</font> close <font color=Cyan>`adjustErrBad`</font> <font color=Cyan>(</font><font color=Magenta>"Missing closing bracket:\n"</font><font color=Cyan>++</font><font color=Cyan>)</font>+ <font color=Cyan>;</font> return x+ <font color=Cyan>}</font>++<font color=Blue>-- | 'manyFinally e t' parses a possibly-empty sequence of e's,</font>+<font color=Blue>-- terminated by a t. Any parse failures could be due either to</font>+<font color=Blue>-- a badly-formed terminator or a badly-formed element, so raise</font>+<font color=Blue>-- both possible errors.</font>+manyFinally <font color=Red>::</font> Parser s t a <font color=Red>-></font> Parser s t z <font color=Red>-></font> Parser s t <font color=Red>[</font>a<font color=Red>]</font>+<a name="manyFinally"></a>manyFinally pp<font color=Red>@</font><font color=Cyan>(</font>P p<font color=Cyan>)</font> pt<font color=Red>@</font><font color=Cyan>(</font>P t<font color=Cyan>)</font> <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>s ts <font color=Red>-></font>+ <font color=Green><u>case</u></font> p s ts <font color=Green><u>of</u></font>+ <font color=Cyan>(</font>Left e<font color=Cyan>,</font> <font color=Green><u>_</u></font><font color=Cyan>,</font> <font color=Green><u>_</u></font><font color=Cyan>)</font> <font color=Red>-></font>+ <font color=Green><u>case</u></font> t s ts <font color=Green><u>of</u></font>+ <font color=Cyan>(</font>Right <font color=Green><u>_</u></font><font color=Cyan>,</font> s'<font color=Cyan>,</font> ts'<font color=Cyan>)</font> <font color=Red>-></font> <font color=Cyan>(</font>Right <font color=Red>[</font><font color=Red>]</font><font color=Cyan>,</font> s'<font color=Cyan>,</font> ts'<font color=Cyan>)</font>+ <font color=Cyan>(</font>Left e<font color=Cyan>,</font> s'<font color=Cyan>,</font> ts'<font color=Cyan>)</font> <font color=Red>-></font> <font color=Cyan>(</font>Left e<font color=Cyan>,</font> s'<font color=Cyan>,</font> ts'<font color=Cyan>)</font>+ <font color=Cyan>(</font>Right x<font color=Cyan>,</font> s'<font color=Cyan>,</font> ts'<font color=Cyan>)</font> <font color=Red>-></font>+ <font color=Green><u>let</u></font> <font color=Cyan>(</font>tail<font color=Cyan>,</font>s''<font color=Cyan>,</font>ts''<font color=Cyan>)</font> <font color=Red>=</font> runParser <font color=Cyan>(</font>manyFinally pp pt<font color=Cyan>)</font> s' ts'+ <font color=Green><u>in</u></font> <font color=Cyan>(</font>Right <font color=Cyan>(</font>x<font color=Red><b>:</b></font>tail<font color=Cyan>)</font><font color=Cyan>,</font> s''<font color=Cyan>,</font> ts''<font color=Cyan>)</font> <font color=Cyan>)</font>++<font color=Blue>------------------------------------------------------------------------</font>+<font color=Blue>-- State handling</font>++<font color=Blue>-- | Update the internal state.</font>+stUpdate <font color=Red>::</font> <font color=Cyan>(</font>s<font color=Red>-></font>s<font color=Cyan>)</font> <font color=Red>-></font> Parser s t <font color=Cyan>(</font><font color=Cyan>)</font>+<a name="stUpdate"></a>stUpdate f <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>s ts<font color=Red>-></font> <font color=Cyan>(</font>Right <font color=Cyan>(</font><font color=Cyan>)</font><font color=Cyan>,</font> f s<font color=Cyan>,</font> ts<font color=Cyan>)</font><font color=Cyan>)</font>++<font color=Blue>-- | Query the internal state.</font>+stQuery <font color=Red>::</font> <font color=Cyan>(</font>s<font color=Red>-></font>a<font color=Cyan>)</font> <font color=Red>-></font> Parser s t a+<a name="stQuery"></a>stQuery f <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>s ts<font color=Red>-></font> <font color=Cyan>(</font>Right <font color=Cyan>(</font>f s<font color=Cyan>)</font><font color=Cyan>,</font> s<font color=Cyan>,</font> ts<font color=Cyan>)</font><font color=Cyan>)</font>++<font color=Blue>-- | Deliver the entire internal state.</font>+stGet <font color=Red>::</font> Parser s t s+<a name="stGet"></a>stGet <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>s ts<font color=Red>-></font> <font color=Cyan>(</font>Right s<font color=Cyan>,</font> s<font color=Cyan>,</font> ts<font color=Cyan>)</font><font color=Cyan>)</font>++<font color=Blue>------------------------------------------------------------------------</font>+<font color=Blue>-- | Push some tokens back onto the front of the input stream and reparse.</font>+<font color=Blue>-- This is useful e.g. for recursively expanding macros. When the</font>+<font color=Blue>-- user-parser recognises a macro use, it can lookup the macro</font>+<font color=Blue>-- expansion from the parse state, lex it, and then stuff the</font>+<font color=Blue>-- lexed expansion back down into the parser.</font>+reparse <font color=Red>::</font> <font color=Red>[</font>t<font color=Red>]</font> <font color=Red>-></font> Parser s t <font color=Cyan>(</font><font color=Cyan>)</font>+<a name="reparse"></a>reparse ts <font color=Red>=</font> P <font color=Cyan>(</font><font color=Red>\</font>s inp<font color=Red>-></font> <font color=Cyan>(</font>Right <font color=Cyan>(</font><font color=Cyan>)</font><font color=Cyan>,</font> s<font color=Cyan>,</font> ts<font color=Cyan>++</font>inp<font color=Cyan>)</font><font color=Cyan>)</font>++<font color=Blue>------------------------------------------------------------------------</font>+</pre>
+ docs/index.html view
@@ -0,0 +1,242 @@+<!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.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.+<li> <b>Text.ParserCombinators.Poly</b>+ 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. 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.PolyState</b> is just like Poly, except it+ adds an arbitrary running state parameter.+<li> <b>Text.ParserCombinators.PolyLazy</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.PolyStateLazy</b> combines PolyState and+ PolyLazy.+<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>)+</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>+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>+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>Released version:</b><br>+polyparse-1.0, release date 2007.01.26<br>+By HTTP:+<a href="http://www.cs.york.ac.uk/fp/polyparse-1.0.tar.gz">.tar.gz</a>,+<a href="http://www.cs.york.ac.uk/fp/polyparse-1.0.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>+++<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>+ 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.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 and Text.XML.HaXml.XmlContent are two 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 Hutton and Meijer in 1994, 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>Niklas Rojemo's combinators.+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>Daan Leijen's parsec.+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>Doaitse Swierstra's UU_Parse.+An all-singing, all-dancing parsing library. Deeply sophisticated.++<li>Koen Claessen's ReadP.+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
@@ -0,0 +1,29 @@+name: polyparse+version: 1.0+ghc-options: -DVERSION="1.0"+cc-options: -DVERSION="1.0"+license: LGPL+license-file: COPYRIGHT+author: Malcolm Wallace <Malcolm.Wallace@cs.york.ac.uk>+maintainer: author+homepage: http://www.cs.york.ac.uk/fp/polyparse/+category: Text, Parsing+synopsis: A variety of alternative parser combinator libraries.+description:+ A variety of alternative parser combinator libraries, including+ the original HuttonMeijer set. The Poly sets have features like+ good error reporting, arbitrary token type, running state, lazy+ parsing, and so on. Finally, Text.Parse is a proposed+ replacement for the standard Read class, for better+ deserialisation of Haskell values from Strings.+exposed-modules:+ Text.ParserCombinators.HuttonMeijer,+ Text.ParserCombinators.HuttonMeijerWallace,+ Text.ParserCombinators.Poly,+ Text.ParserCombinators.PolyState,+ Text.ParserCombinators.PolyLazy,+ Text.ParserCombinators.PolyStateLazy,+ Text.Parse+hs-source-dirs: src+build-depends: base, haskell98+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,84 @@+SOFTWARE = polyparse+VERSION = 1.0++LIBSRCS = \+ Text/ParserCombinators/HuttonMeijer.hs \+ Text/ParserCombinators/HuttonMeijerWallace.hs \+ Text/ParserCombinators/Poly.hs \+ Text/ParserCombinators/PolyState.hs \+ Text/ParserCombinators/PolyLazy.hs \+ Text/ParserCombinators/PolyStateLazy.hs \+ Text/Parse.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
@@ -0,0 +1,178 @@+module Text.Parse+ ( -- * The Parse class is a replacement for the standard Read class. + -- $parser+ TextParser -- synonym for Parser Char, i.e. string input, no state+ , Parse(..) -- instances: (), (a,b), (a,b,c), Maybe a, Either a, [a],+ -- Int, Integer, Float, Double, Char, Bool+ , parseByRead -- :: Read a => String -> TextParser a+ -- ** Combinators specific to string input, lexed haskell-style+ , word -- :: TextParser String+ , isWord -- :: String -> TextParser ()+ , optionalParens -- :: TextParser a -> TextParser a+ , field -- :: Parse a => String -> TextParser a+ , constructors-- :: [(String,TextParser a)] -> TextParser a+ , enumeration -- :: Show a => String -> [a] -> TextParser a+ -- ** Re-export all the more general combinators from Poly too+ , module Text.ParserCombinators.Poly+ ) where++import Char (isSpace)+import List (intersperse)+import Text.ParserCombinators.Poly++------------------------------------------------------------------------+-- $parser+-- 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 !-}++-- | A synonym for Parser Char, i.e. string input (no state)+type TextParser a = Parser Char a++-- | The class @Parse@ is a replacement for @Read@, operating over String input.+-- Essentially, it permits better error messages for why something failed to+-- parse. It is rather important that @parse@ can read back exactly what+-- is generated by the corresponding instance of @show@. To apply a parser+-- to some text, use @runParser@.+class Parse a where+ parse :: TextParser a+ parseList :: TextParser [a] -- only to distinguish [] and ""+ parseList = do { isWord "[]"; return [] }+ `onFail`+ do { isWord "["; isWord "]"; return [] }+ `onFail`+ bracketSep (isWord "[") (isWord ",") (isWord "]") parse+ `adjustErr` ("Expected a list, but\n"++)++-- | If there already exists a Read instance for a type, then we can make+-- a Parser for it, but with only poor error-reporting.+parseByRead :: Read a => String -> TextParser a+parseByRead name =+ P (\s-> case reads s of+ [] -> (Left (False,"no parse, expected a "++name), s)+ [(a,s')] -> (Right a, s')+ _ -> (Left (False,"ambiguous parse, expected a "++name), s)+ )++-- | One lexical chunk (Haskell-style lexing).+word :: TextParser String+word = P (\s-> case lex s of+ [] -> (Left (False,"no input? (impossible)"), s)+ [("",s')] -> (Left (False,"no input?"), s')+ ((x,s'):_) -> (Right x, s') )++-- | Ensure that the next input word is the given string. (Note the input+-- is lexed as haskell, so wordbreaks at spaces, symbols, etc.)+isWord :: String -> TextParser String+isWord w = do { w' <- word+ ; if w'==w then return w else fail ("expected "++w++" got "++w')+ }++-- | Allow true string parens around an item.+optionalParens :: TextParser a -> TextParser a+optionalParens p = bracket (isWord "(") (isWord ")") p `onFail` p++-- | Deal with named field syntax. The string argument is the field name,+-- and the parser returns the value of the field.+field :: Parse a => String -> TextParser a+field name = do { isWord name; commit $ do { isWord "="; parse } }++-- | 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.+constructors :: [(String,TextParser a)] -> TextParser a+constructors cs = oneOf' (map cons cs)+ where cons (name,p) =+ ( name+ , do { isWord name+ ; p `adjustErrBad` (("got constructor, but within "+ ++name++",\n")++)+ }+ )++-- | 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.+enumeration :: (Show a) => String -> [a] -> TextParser a+enumeration typ cs = oneOf (map (\c-> do { isWord (show c); return c }) cs)+ `adjustErr`+ (++("\n expected "++typ++" value ("++e++")"))+ where e = concat (intersperse ", " (map show (init cs)))+ ++ ", or " ++ show (last cs)++------------------------------------------------------------------------+-- Instances for all the Standard Prelude types.++-- Basic types+instance Parse Int where+ parse = parseByRead "Int"+instance Parse Integer where+ parse = parseByRead "Integer"+instance Parse Float where+ parse = parseByRead "Float"+instance Parse Double where+ parse = parseByRead "Double"+instance Parse Char where+ parse = parseByRead "Char"+ -- parseList = bracket (isWord "\"") (satisfy (=='"'))+ -- (many (satisfy (/='"')))+ -- not totally correct for strings...+ parseList = do { w <- word; if head w == '"' then return (init (tail w))+ else fail "not a string" }++instance Parse Bool where+ parse = enumeration "Bool" [False,True]++instance Parse Ordering where+ parse = enumeration "Ordering" [LT,EQ,GT]++-- Structural types+instance Parse () where+ parse = P p+ where p [] = (Left (False,"no input: expected a ()"), [])+ p ('(':cs) = case dropWhile isSpace cs of+ (')':s) -> (Right (), s)+ _ -> (Left (False,"Expected ) after ("), cs)+ p (c:cs) | isSpace c = p cs+ | otherwise = ( Left (False,"Expected a (), got "++show c)+ , (c:cs))++instance (Parse a, Parse b) => Parse (a,b) where+ parse = do{ isWord "(" `adjustErr` ("Opening a 2-tuple\n"++)+ ; x <- parse `adjustErr` ("In 1st item of a 2-tuple\n"++)+ ; isWord "," `adjustErr` ("Separating a 2-tuple\n"++)+ ; y <- parse `adjustErr` ("In 2nd item of a 2-tuple\n"++)+ ; isWord ")" `adjustErr` ("Closing a 2-tuple\n"++)+ ; return (x,y) }++instance (Parse a, Parse b, Parse c) => Parse (a,b,c) where+ parse = do{ isWord "(" `adjustErr` ("Opening a 3-tuple\n"++)+ ; x <- parse `adjustErr` ("In 1st item of a 3-tuple\n"++)+ ; isWord "," `adjustErr` ("Separating(1) a 3-tuple\n"++)+ ; y <- parse `adjustErr` ("In 2nd item of a 3-tuple\n"++)+ ; isWord "," `adjustErr` ("Separating(2) a 3-tuple\n"++)+ ; z <- parse `adjustErr` ("In 3rd item of a 3-tuple\n"++)+ ; isWord ")" `adjustErr` ("Closing a 3-tuple\n"++)+ ; return (x,y,z) }++instance Parse a => Parse (Maybe a) where+ parse = do { isWord "Nothing"; return Nothing }+ `onFail`+ do { isWord "Just"+ ; fmap Just $ optionalParens parse+ `adjustErrBad` ("but within Just, "++)+ }+ `adjustErr` (("expected a Maybe (Just or Nothing)\n"++).indent 2)++instance (Parse a, Parse b) => Parse (Either a b) where+ parse = constructors [ ("Left", do { fmap Left $ optionalParens parse } )+ , ("Right", do { fmap Right $ optionalParens parse } )+ ]++instance Parse a => Parse [a] where+ parse = parseList++------------------------------------------------------------------------
+ src/Text/ParserCombinators/HuttonMeijer.hs view
@@ -0,0 +1,218 @@+-----------------------------------------------------------------------------+-- |+-- Module : Text.ParserCombinators.HuttonMeijer+-- Copyright : Graham Hutton (University of Nottingham), Erik Meijer (University of Utrecht)+-- Licence : BSD+-- +-- Maintainer : Malcolm Wallace <Malcolm.Wallace@cs.york.ac.uk>+-- Stability : Stable+-- Portability : All+--+-- A LIBRARY OF MONADIC PARSER COMBINATORS+-- +-- 29th July 1996+-- +-- Graham Hutton Erik Meijer+-- University of Nottingham University of Utrecht+-- +-- This Haskell script defines a library of parser combinators, and is+-- taken from sections 1-6 of our article "Monadic Parser Combinators".+-- Some changes to the library have been made in the move from Gofer+-- to Haskell:+-- +-- * Do notation is used in place of monad comprehension notation;+-- +-- * The parser datatype is defined using "newtype", to avoid the overhead+-- of tagging and untagging parsers with the P constructor.+-----------------------------------------------------------------------------+++module Text.ParserCombinators.HuttonMeijer+ (Parser(..), item, first, papply, (+++), sat, {-tok,-} many, many1,+ sepby, sepby1, chainl,+ chainl1, chainr, chainr1, ops, bracket, char, digit, lower, upper,+ letter, alphanum, string, ident, nat, int, spaces, comment, junk,+ skip, token, natural, integer, symbol, identifier) where++import Char+import Monad++infixr 5 +++++type Token = Char++---------------------------------------------------------+-- | The parser monad++newtype Parser a = P ([Token] -> [(a,[Token])])++instance Functor Parser where+ -- map :: (a -> b) -> (Parser a -> Parser b)+ fmap f (P p) = P (\inp -> [(f v, out) | (v,out) <- p inp])++instance Monad Parser where+ -- return :: a -> Parser a+ return v = P (\inp -> [(v,inp)])++ -- >>= :: Parser a -> (a -> Parser b) -> Parser b+ (P p) >>= f = P (\inp -> concat [papply (f v) out | (v,out) <- p inp])++ -- fail :: String -> Parser a+ fail _ = P (\_ -> [])++instance MonadPlus Parser where+ -- mzero :: Parser a+ mzero = P (\_ -> [])++ -- mplus :: Parser a -> Parser a -> Parser a+ (P p) `mplus` (P q) = P (\inp -> (p inp ++ q inp))++-- ------------------------------------------------------------+-- * Other primitive parser combinators+-- ------------------------------------------------------------++item :: Parser Token+item = P (\inp -> case inp of+ [] -> []+ (x:xs) -> [(x,xs)])++first :: Parser a -> Parser a+first (P p) = P (\inp -> case p inp of+ [] -> []+ (x:_) -> [x])++papply :: Parser a -> [Token] -> [(a,[Token])]+papply (P p) inp = p inp++-- ------------------------------------------------------------+-- * Derived combinators+-- ------------------------------------------------------------++(+++) :: Parser a -> Parser a -> Parser a+p +++ q = first (p `mplus` q)++sat :: (Token -> Bool) -> Parser Token+sat p = do {x <- item; if p x then return x else mzero}++--tok :: Token -> Parser Token+--tok t = do {x <- item; if t==snd x then return t else mzero}++many :: Parser a -> Parser [a]+many p = many1 p +++ return []+--many p = force (many1 p +++ return [])++many1 :: Parser a -> Parser [a]+many1 p = do {x <- p; xs <- many p; return (x:xs)}++sepby :: Parser a -> Parser b -> Parser [a]+p `sepby` sep = (p `sepby1` sep) +++ return []++sepby1 :: Parser a -> Parser b -> Parser [a]+p `sepby1` sep = do {x <- p; xs <- many (do {sep; p}); return (x:xs)}++chainl :: Parser a -> Parser (a -> a -> a) -> a -> Parser a+chainl p op v = (p `chainl1` op) +++ return v++chainl1 :: Parser a -> Parser (a -> a -> a) -> Parser a+p `chainl1` op = do {x <- p; rest x}+ where+ rest x = do {f <- op; y <- p; rest (f x y)}+ +++ return x++chainr :: Parser a -> Parser (a -> a -> a) -> a -> Parser a+chainr p op v = (p `chainr1` op) +++ return v++chainr1 :: Parser a -> Parser (a -> a -> a) -> Parser a+p `chainr1` op = do {x <- p; rest x}+ where+ rest x = do {f <- op; y <- p `chainr1` op; return (f x y)}+ +++ return x++ops :: [(Parser a, b)] -> Parser b+ops xs = foldr1 (+++) [do {p; return op} | (p,op) <- xs]++bracket :: Parser a -> Parser b -> Parser c -> Parser b+bracket open p close = do {open; x <- p; close; return x}++-- ------------------------------------------------------------+-- * Useful parsers+-- ------------------------------------------------------------++char :: Char -> Parser Char+char x = sat (\y -> x == y)++digit :: Parser Char+digit = sat isDigit++lower :: Parser Char+lower = sat isLower++upper :: Parser Char+upper = sat isUpper++letter :: Parser Char+letter = sat isAlpha++alphanum :: Parser Char+alphanum = sat isAlphaNum +++ char '_'++string :: String -> Parser String+string "" = return ""+string (x:xs) = do {char x; string xs; return (x:xs)}++ident :: Parser String+ident = do {x <- lower; xs <- many alphanum; return (x:xs)}++nat :: Parser Int+nat = do {x <- digit; return (fromEnum x - fromEnum '0')} `chainl1` return op+ where+ m `op` n = 10*m + n++int :: Parser Int+int = do {char '-'; n <- nat; return (-n)} +++ nat++-- ------------------------------------------------------------+-- * Lexical combinators+-- ------------------------------------------------------------++spaces :: Parser ()+spaces = do {many1 (sat isSpace); return ()}++comment :: Parser ()+--comment = do {string "--"; many (sat (\x -> x /= '\n')); return ()}+--comment = do +-- _ <- string "--"+-- _ <- many (sat (\x -> x /= '\n'))+-- return ()+comment = do+ bracket (string "/*") (many item) (string "*/")+ return ()++junk :: Parser ()+junk = do {many (spaces +++ comment); return ()}++skip :: Parser a -> Parser a+skip p = do {junk; p}++token :: Parser a -> Parser a+token p = do {v <- p; junk; return v}++-- ------------------------------------------------------------+-- * Token parsers+-- ------------------------------------------------------------++natural :: Parser Int+natural = token nat++integer :: Parser Int+integer = token int++symbol :: String -> Parser String+symbol xs = token (string xs)++identifier :: [String] -> Parser String+identifier ks = token (do {x <- ident;+ if not (elem x ks) then return x+ else return mzero})++------------------------------------------------------------------------------
+ src/Text/ParserCombinators/HuttonMeijerWallace.hs view
@@ -0,0 +1,297 @@+{-----------------------------------------------------------------------------++ A LIBRARY OF MONADIC PARSER COMBINATORS++ 29th July 1996++ Graham Hutton Erik Meijer+ University of Nottingham University of Utrecht++This Haskell 1.3 script defines a library of parser combinators, and is taken+from sections 1-6 of our article "Monadic Parser Combinators". Some changes+to the library have been made in the move from Gofer to Haskell:++ * Do notation is used in place of monad comprehension notation;++ * The parser datatype is defined using "newtype", to avoid the overhead+ of tagging and untagging parsers with the P constructor.++------------------------------------------------------------------------------+** Extended to allow a symbol table/state to be threaded through the monad.+** Extended to allow a parameterised token type, rather than just strings.+** Extended to allow error-reporting.++(Extensions: 1998-2000 Malcolm.Wallace@cs.york.ac.uk)+(More extensions: 2004 gk-haskell@ninebynine.org)++------------------------------------------------------------------------------}++-- | This library of monadic parser combinators is based on the ones+-- defined by Graham Hutton and Erik Meijer. It has been extended by+-- Malcolm Wallace to use an abstract token type (no longer just a+-- string) as input, and to incorporate a State Transformer monad, useful+-- for symbol tables, macros, and so on. Basic facilities for error+-- reporting have also been added, and later extended by Graham Klyne+-- to return the errors through an @Either@ type, rather than just+-- calling @error@.++module Text.ParserCombinators.HuttonMeijerWallace+ (+ -- * The parser monad+ Parser(..)+ -- * Primitive parser combinators+ , item, eof, papply, papply'+ -- * Derived combinators+ , (+++), {-sat,-} tok, nottok, many, many1+ , sepby, sepby1, chainl, chainl1, chainr, chainr1, ops, bracket+ , toEOF+ -- * Error handling+ , elserror+ -- * State handling+ , stupd, stquery, stget+ -- * Re-parsing+ , reparse+ ) where++import Char+import Monad++infixr 5 +++++--- The parser monad ---------------------------------------------------------++type ParseResult s t e a = Either e [(a,s,[Either e t])]++newtype Parser s t e a = P ( s -> [Either e t] -> ParseResult s t e a )+ -- ^ The parser type is parametrised on the types of the state @s@,+ -- the input tokens @t@, error-type @e@, and the result value @a@.+ -- The state and remaining input are threaded through the monad.++instance Functor (Parser s t e) where+ -- fmap :: (a -> b) -> (Parser s t e a -> Parser s t e b)+ fmap f (P p) = P (\st inp -> case p st inp of+ Right res -> Right [(f v, s, out) | (v,s,out) <- res]+ Left err -> Left err+ )++instance Monad (Parser s t e) where+ -- return :: a -> Parser s t e a+ return v = P (\st inp -> Right [(v,st,inp)])+ -- >>= :: Parser s t e a -> (a -> Parser s t e b) -> Parser s t e b+ (P p) >>= f = P (\st inp -> case p st inp of+ Right res -> foldr joinresults (Right [])+ [ papply' (f v) s out | (v,s,out) <- res ]+ Left err -> Left err+ )+ -- fail :: String -> Parser s t e a+ fail err = P (\st inp -> Right [])+ -- I know it's counterintuitive, but we want no-parse, not an error.++instance MonadPlus (Parser s t e) where+ -- mzero :: Parser s t e a+ mzero = P (\st inp -> Right [])+ -- mplus :: Parser s t e a -> Parser s t e a -> Parser s t e a+ (P p) `mplus` (P q) = P (\st inp -> joinresults (p st inp) (q st inp))++-- joinresults ensures that explicitly raised errors are dominant,+-- provided no parse has yet been found. The commented out code is+-- a slightly stricter specification of the real code.+joinresults :: ParseResult s t e a -> ParseResult s t e a -> ParseResult s t e a+{-+joinresults (Left p) (Left q) = Left p+joinresults (Left p) (Right _) = Left p+joinresults (Right []) (Left q) = Left q+joinresults (Right p) (Left q) = Right p+joinresults (Right p) (Right q) = Right (p++q)+-}+joinresults (Left p) q = Left p+joinresults (Right []) q = q+joinresults (Right p) q = Right (p++ case q of Left _ -> []+ Right r -> r)+++--- Primitive parser combinators ---------------------------------------------++-- | Deliver the first remaining token.+item :: Parser s t e t+item = P (\st inp -> case inp of+ [] -> Right []+ (Left e: _) -> Left e+ (Right x: xs) -> Right [(x,st,xs)]+ )++-- | Fail if end of input is not reached+eof :: Show p => Parser s (p,t) String ()+eof = P (\st inp -> case inp of+ [] -> Right [((),st,[])]+ (Left e:_) -> Left e+ (Right (p,_):_) -> Left ("End of input expected at "+ ++show p++"\n but found text")+ )++{-+-- | Ensure the value delivered by the parser is evaluated to WHNF.+force :: Parser s t e a -> Parser s t e a+force (P p) = P (\st inp -> let Right xs = p st inp+ h = head xs in+ h `seq` Right (h: tail xs)+ )+-- [[[GK]]] ^^^^^^+-- WHNF = Weak Head Normal Form, meaning that it has no top-level redex.+-- In this case, I think that means that the first element of the list+-- is fully evaluated.+--+-- NOTE: the original form of this function fails if there is no parse+-- result for p st inp (head xs fails if xs is null), so the modified+-- form can assume a Right value only.+--+-- Why is this needed?+-- It's not exported, and the only use of this I see is commented out.+---------------------------------------+-}+++-- | Deliver the first parse result only, eliminating any backtracking.+first :: Parser s t e a -> Parser s t e a+first (P p) = P (\st inp -> case p st inp of+ Right (x:xs) -> Right [x]+ otherwise -> otherwise+ )++-- | Apply the parser to some real input, given an initial state value.+-- If the parser fails, raise 'error' to halt the program.+-- (This is the original exported behaviour - to allow the caller to+-- deal with the error differently, see @papply'@.)+papply :: Parser s t String a -> s -> [Either String t]+ -> [(a,s,[Either String t])]+papply (P p) st inp = either error id (p st inp)++-- | Apply the parser to some real input, given an initial state value.+-- If the parser fails, return a diagnostic message to the caller.+papply' :: Parser s t e a -> s -> [Either e t]+ -> Either e [(a,s,[Either e t])]+papply' (P p) st inp = p st inp++--- Derived combinators ------------------------------------------------------++-- | A choice between parsers. Keep only the first success.+(+++) :: Parser s t e a -> Parser s t e a -> Parser s t e a+p +++ q = first (p `mplus` q)++-- | Deliver the first token if it satisfies a predicate.+sat :: (t -> Bool) -> Parser s (p,t) e t+sat p = do {(_,x) <- item; if p x then return x else mzero}++-- | Deliver the first token if it equals the argument.+tok :: Eq t => t -> Parser s (p,t) e t+tok t = do {(_,x) <- item; if x==t then return t else mzero}++-- | Deliver the first token if it does not equal the argument.+nottok :: Eq t => [t] -> Parser s (p,t) e t+nottok ts = do {(_,x) <- item; if x `notElem` ts then return x+ else mzero}++-- | Deliver zero or more values of @a@.+many :: Parser s t e a -> Parser s t e [a]+many p = many1 p +++ return []+--many p = force (many1 p +++ return [])++-- | Deliver one or more values of @a@.+many1 :: Parser s t e a -> Parser s t e [a]+many1 p = do {x <- p; xs <- many p; return (x:xs)}++-- | Deliver zero or more values of @a@ separated by @b@'s.+sepby :: Parser s t e a -> Parser s t e b -> Parser s t e [a]+p `sepby` sep = (p `sepby1` sep) +++ return []++-- | Deliver one or more values of @a@ separated by @b@'s.+sepby1 :: Parser s t e a -> Parser s t e b -> Parser s t e [a]+p `sepby1` sep = do {x <- p; xs <- many (do {sep; p}); return (x:xs)}++chainl :: Parser s t e a -> Parser s t e (a->a->a) -> a+ -> Parser s t e a+chainl p op v = (p `chainl1` op) +++ return v++chainl1 :: Parser s t e a -> Parser s t e (a->a->a) -> Parser s t e a+p `chainl1` op = do {x <- p; rest x}+ where+ rest x = do {f <- op; y <- p; rest (f x y)}+ +++ return x++chainr :: Parser s t e a -> Parser s t e (a->a->a) -> a+ -> Parser s t e a+chainr p op v = (p `chainr1` op) +++ return v++chainr1 :: Parser s t e a -> Parser s t e (a->a->a) -> Parser s t e a+p `chainr1` op = do {x <- p; rest x}+ where+ rest x = do { f <- op+ ; y <- p `chainr1` op+ ; return (f x y)+ }+ +++ return x++ops :: [(Parser s t e a, b)] -> Parser s t e b+ops xs = foldr1 (+++) [do {p; return op} | (p,op) <- xs]++bracket :: (Show p,Show t) =>+ Parser s (p,t) e a -> Parser s (p,t) e b ->+ Parser s (p,t) e c -> Parser s (p,t) e b+bracket open p close = do { open+ ; x <- p+ ; close -- `elserror` "improperly matched construct";+ ; return x+ }++-- | Accept a complete parse of the input only, no partial parses.+toEOF :: Show p =>+ Parser s (p,t) String a -> Parser s (p,t) String a+toEOF p = do { x <- p; eof; return x }+++--- Error handling -----------------------------------------------------------++-- | Return an error using the supplied diagnostic string, and a token type+-- which includes position information.+parseerror :: (Show p,Show t) => String -> Parser s (p,t) String a+parseerror err = P (\st inp ->+ case inp of+ [] -> Left "Parse error: unexpected EOF\n"+ (Left e:_) -> Left ("Lexical error: "++e)+ (Right (p,t):_) ->+ Left ("Parse error: in "++show p++"\n "+ ++err++"\n "++"Found "++show t)+ )+++-- | If the parser fails, generate an error message.+elserror :: (Show p,Show t) => Parser s (p,t) String a -> String+ -> Parser s (p,t) String a+p `elserror` s = p +++ parseerror s++--- State handling -----------------------------------------------------------++-- | Update the internal state.+stupd :: (s->s) -> Parser s t e ()+stupd f = P (\st inp-> {-let newst = f st in newst `seq`-}+ Right [((), f st, inp)])++-- | Query the internal state.+stquery :: (s->a) -> Parser s t e a+stquery f = P (\st inp-> Right [(f st, st, inp)])++-- | Deliver the entire internal state.+stget :: Parser s t e s+stget = P (\st inp-> Right [(st, st, inp)])+++--- Push some tokens back onto the input stream and reparse ------------------++-- | 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.+reparse :: [Either e t] -> Parser s t e ()+reparse ts = P (\st inp-> Right [((), st, ts++inp)])++------------------------------------------------------------------------------
+ src/Text/ParserCombinators/Poly.hs view
@@ -0,0 +1,238 @@+module Text.ParserCombinators.Poly+ ( -- * The Parser datatype+ Parser(P) -- datatype, instance of: Functor, Monad+ , runParser -- :: Parser t a -> [t] -> (Either String a, [t])+ , failBad -- :: String -> Parser t a+ , commit -- :: Parser t a -> Parser t a++ -- * Combinators:+ -- ** Primitives+ , next -- :: Parser t t+ , satisfy -- :: (t->Bool) -> Parser t t+ , apply -- :: Parser t (a->b) -> Parser t a -> Parser t b+ , discard -- :: Parser t a -> Parser t b -> Parser t a+ -- ** Error-handling+ , adjustErr -- :: Parser t a -> (String->String) -> Parser t a+ , adjustErrBad-- :: Parser t a -> (String->String) -> Parser t a+ , indent -- :: Int -> String -> String+ -- ** Choices+ , onFail -- :: Parser t a -> Parser t a -> Parser t a+ , oneOf -- :: Show t => [Parser t a] -> Parser t a+ , oneOf' -- :: [(String,Parser t a)] -> Parser t a+ , optional -- :: Parser t a -> Parser t (Maybe a)+ -- ** Sequences+ , many -- :: Parser t a -> Parser t [a]+ , many1 -- :: Parser t a -> Parser t [a]+ , sepBy -- :: Parser t a -> Parser t sep -> Parser t [a]+ , sepBy1 -- :: Parser t a -> Parser t sep -> Parser t [a]+ , bracketSep -- :: Parser t bra -> Parser t sep -> Parser t ket+ -- -> Parser t a -> Parser t [a]+ , bracket -- :: Parser t bra -> Parser t ket -> Parser t a+ -- -> Parser t a+ , manyFinally -- :: Parser t a -> Parser t z -> Parser t [a]+ -- ** re-parsing+ , reparse -- :: [t] -> Parser t ()+ ) where+++-- | The @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)+newtype Parser t a = P ([t] -> (EitherE String a, [t]))++-- A return type like Either, that distinguishes not only between+-- right and wrong answers, but also had gradations of wrongness.+type EitherE a b = Either (Bool,a) b++-- | Apply a parser to an input token sequence.+runParser :: Parser t a -> [t] -> (Either String a, [t])+runParser (P p) =+ (\ (e,ts)-> (case e of {Left (_,m)->Left m; Right m->Right m}, ts) )+ . p++instance Functor (Parser t) where+ fmap f (P p) = P (\ts-> case p ts of+ (Left msg, ts') -> (Left msg, ts')+ (Right x, ts') -> (Right (f x), ts'))+instance Monad (Parser t) where+ return x = P (\ts-> (Right x, ts))+ (P f) >>= g = P (\ts-> case f ts of+ (Left msg, ts') -> (Left msg, ts')+ (Right x, ts') -> let (P g') = g x in g' ts')+ fail e = P (\ts-> (Left (False,e), ts))++-- | When a simple fail is not strong enough, use failBad for emphasis.+-- An emphasised (severe) error can propagate out through choice operators.+failBad :: String -> Parser t a+failBad msg = P (\ts-> (Left (True,msg), ts))++-- | 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.+commit :: Parser t a -> Parser t a+commit (P p) = P (\ts-> case p ts of+ (Left (_,e), ts') -> (Left (True,e), ts')+ right -> right )+++-- Combinators++-- | One token+next :: Parser t t+next = P (\ts-> case ts of+ [] -> (Left (False,"Ran out of input (EOF)"), [])+ (t:ts') -> (Right t, ts') )++-- | One token satifying a predicate+satisfy :: (t->Bool) -> Parser t t+satisfy p = do{ x <- next+ ; if p x then return x else fail "Parse.satisfy: failed"+ }++infixl 3 `apply`+-- | Apply a parsed function to a parsed value+apply :: Parser t (a->b) -> Parser t a -> Parser t b+pf `apply` px = do { f <- pf; x <- px; return (f x) }++infixl 3 `discard`+-- | @x `discard` y@ parses both x and y, but discards the result of y+discard :: Parser t a -> Parser t b -> Parser t a+px `discard` py = do { x <- px; _ <- py; return x }++-- | @p `adjustErr` f@ applies the transformation @f@ to any error message+-- generated in @p@, having no effect if @p@ succeeds.+adjustErr :: Parser t a -> (String->String) -> Parser t a+(P p) `adjustErr` f = P (\ts-> case p ts of+ (Left (b,msg), ts') -> (Left (b,(f msg)), ts')+ right -> right )++-- | @adjustErrBad@ is just like @adjustErr@ except it also raises the+-- severity of the error.+adjustErrBad :: Parser t a -> (String->String) -> Parser t a+p `adjustErrBad` f = commit (p `adjustErr` f)++infixl 6 `onFail` -- not sure about precedence 6?+-- | @p `onFail` q@ 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.+onFail :: Parser t a -> Parser t a -> Parser t a+(P p) `onFail` (P q) = P (\ts-> case p ts of+ r@(Left (True,_), _) -> r+ (Left _, _) -> q ts+ right -> right )++-- | Parse the first alternative in the list that succeeds.+oneOf :: [Parser t a] -> Parser t a+oneOf [] = do { n <- next+ ; fail ("failed to parse any of the possible choices")+ }+--oneOf :: Show t => [Parser t a] -> Parser t a+--oneOf [] = do { n <- next+-- ; fail ("failed to parse any of the possible choices"+-- ++"\n next token is "++show n)+-- }+oneOf (p:ps) = p `onFail` oneOf ps++-- | 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.+oneOf' :: [(String, Parser t a)] -> Parser t a+oneOf' = accum []+ where accum errs [] =+ case filter isBad errs of+ [] -> fail ("failed to parse any of the possible choices:\n"+ ++indent 2 (concatMap showErr (reverse errs)))+ [(_,(_,e))] -> failBad e+ es -> failBad ("one of the following failures occurred:\n"+ ++indent 2 (concatMap showErr (reverse es)))+ accum errs ((e,P p):ps) =+ P (\ts-> case p ts of+ (Left err,_) -> let (P p) = accum ((e,err):errs) ps+ in p ts+ right -> right )+ showErr (name,(_,err)) = name++":\n"++indent 2 err+ isBad (_,(b,_)) = b++-- | Helper for formatting error messages: indents all lines by a fixed amount.+indent :: Int -> String -> String+indent n = unlines . map (replicate n ' ' ++) . lines++-- | 'optional' indicates whether the parser succeeded through the Maybe type.+optional :: Parser t a -> Parser t (Maybe a)+optional p = fmap Just p `onFail` return Nothing++-- | 'many p' parses a list of elements with individual parser p.+-- Cannot fail, since an empty list is a valid return value.+many :: Parser t a -> Parser t [a]+many p = many1 p `onFail` return []++-- | Parse a non-empty list of items.+many1 :: Parser t a -> Parser t [a]+many1 p = do { x <- p `adjustErr` (("In a sequence:\n"++). indent 2)+ ; xs <- many p+ ; return (x:xs)+ }+-- `adjustErr` ("When looking for a non-empty sequence:\n\t"++)++-- | Parse a list of items separated by discarded junk.+sepBy :: Parser t a -> Parser t sep -> Parser t [a]+sepBy p sep = do sepBy1 p sep `onFail` return []++-- | Parse a non-empty list of items separated by discarded junk.+sepBy1 :: Parser t a -> Parser t sep -> Parser t [a]+sepBy1 p sep = do { x <- p+ ; xs <- many (do {sep; p})+ ; return (x:xs)+ }+ `adjustErr` ("When looking for a non-empty sequence with separators:\n\t"++)+ +-- | Parse a list of items, discarding the start, end, and separator+-- items.+bracketSep :: Parser t bra -> Parser t sep -> Parser t ket+ -> Parser t a -> Parser t [a]+bracketSep open sep close p =+ do { open; close; return [] }+ `onFail`+ do { open `adjustErr` ("Missing opening bracket:\n\t"++)+ ; x <- p `adjustErr` ("After first bracket in a group:\n\t"++)+ ; xs <- many (do {sep; p})+ ; close `adjustErrBad` ("When looking for closing bracket:\n\t"++)+ ; return (x:xs)+ }++-- | Parse a bracketed item, discarding the brackets.+bracket :: Parser t bra -> Parser t ket -> Parser t a -> Parser t a+bracket open close p = do+ do { open `adjustErr` ("Missing opening bracket:\n\t"++)+ ; x <- p+ ; close `adjustErrBad` ("Missing closing bracket:\n\t"++)+ ; return x+ }++-- | 'manyFinally e t' parses a possibly-empty sequence of e's,+-- terminated by a t. Any parse failures could be due either to+-- a badly-formed terminator or a badly-formed element, so raise+-- both possible errors.+manyFinally :: Parser t a -> Parser t z -> Parser t [a]+manyFinally p t =+ do { xs <- many p+ ; oneOf' [ ("sequence terminator", do { t; return () } )+ , ("item in a sequence", do { p; return () } )+ ]+ ; return xs+ }++------------------------------------------------------------------------+-- | 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.+reparse :: [t] -> Parser t ()+reparse ts = P (\inp-> (Right (), ts++inp))++------------------------------------------------------------------------
+ src/Text/ParserCombinators/PolyLazy.hs view
@@ -0,0 +1,267 @@+module Text.ParserCombinators.PolyLazy+ ( -- * The Parser datatype.+ -- $parser+ Parser(P) -- datatype, instance of: Functor, Monad+ , runParser -- :: Parser t a -> [t] -> (a, [t])+ , failBad -- :: String -> Parser t a+ , commit -- :: Parser t a -> Parser t a+ -- * Combinators:+ -- ** Primitives+ , next -- :: Parser t t+ , satisfy -- :: (t->Bool) -> Parser t t+ , apply -- :: Parser t (a->b) -> Parser t a -> Parser t b+ , discard -- :: Parser t a -> Parser t b -> Parser t a+ -- ** Error-handling+ , adjustErr -- :: Parser t a -> (String->String) -> Parser t a+ , adjustErrBad-- :: Parser t a -> (String->String) -> Parser t a+ , indent -- :: Int -> String -> String+ -- ** Choices+ , onFail -- :: Parser t a -> Parser t a -> Parser t a+ , oneOf -- :: Show t => [Parser t a] -> Parser t a+ , oneOf' -- :: [(String,Parser t a)] -> Parser t a+ , optional -- :: Parser t a -> Parser t (Maybe a)+ -- ** Sequences+ , many -- :: Parser t a -> Parser t [a]+ , many1 -- :: Parser t a -> Parser t [a]+ , sepBy -- :: Parser t a -> Parser t sep -> Parser t [a]+ , sepBy1 -- :: Parser t a -> Parser t sep -> Parser t [a]+ , bracketSep -- :: Parser t bra -> Parser t sep -> Parser t ket+ -- -> Parser t a -> Parser t [a]+ , bracket -- :: Parser t bra -> Parser t ket -> Parser t a+ -- -> Parser t a+ , manyFinally -- :: Parser t a -> Parser t z -> Parser t [a]+ -- ** Re-parsing+ , reparse -- :: [t] -> Parser t ()+ ) where++#if __GLASGOW_HASKELL__+import Control.Exception hiding (bracket)+throwE :: String -> a+throwE msg = throw (ErrorCall msg)+#else+throwE :: String -> a+throwE msg = error msg+#endif++-- $parser+-- When applied, these parsers do not return explicit failure.+-- An exception is+-- raised instead. This allows partial results to be returned+-- before a full parse is complete.+-- One of the key ways to ensure that your parser is properly lazy,+-- is to parse the initial portion of text returning a function, then+-- use the @apply@ combinator to build the final value.++-- | The @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 PolyStateLazy+-- instead.)+newtype Parser t a = P ([t] -> (Either String a, [t]))++-- A return type like Either, that distinguishes not only between+-- right and wrong answers, but also had gradations of wrongness.+-- Not used in this library. !!!!!!!!!!!!!!!!!!!!!!!!!!!+type EitherE a b = Either (Bool,a) b++-- | Apply a parser to an input token sequence. The parser cannot return+-- an error value explicitly, so errors raise an exception. Thus, results+-- can be partial (lazily constructed, but containing undefined).+runParser :: Parser t a -> [t] -> (a, [t])+runParser (P p) =+ (\ (e,ts)-> (case e of {Left m->throwE m; Right x->x}, ts) )+ . p++instance Functor (Parser t) where+ fmap f (P p) = P (\ts-> case p ts of+ (Left msg, ts') -> (Left msg, ts')+ (Right x, ts') -> (Right (f x), ts'))+instance Monad (Parser t) where+ return x = P (\ts-> (Right x, ts))+ (P f) >>= g = P (\ts-> case f ts of+ (Left msg, ts') -> (Left msg, ts')+ (Right x, ts') -> let (P g') = g x in g' ts')+ fail e = P (\ts-> (Left e, ts))++-- | Simple failure can be corrected, but when a simple fail is not strong+-- enough, use failBad for emphasis. It guarantees parsing will+-- terminate with an exception.++failBad :: String -> Parser t a+failBad msg = P (\ts-> (throwE msg, ts))++-- | 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.+commit :: Parser t a -> Parser t a+commit (P p) = P (\ts-> case p ts of+ (Left e, ts') -> (throwE e, ts')+ right -> right )+++-- Combinators++-- | One token+next :: Parser t t+next = P (\ts-> case ts of+ [] -> (Left "Ran out of input (EOF)", [])+ (t:ts') -> (Right t, ts') )++-- | One token satifying a predicate+satisfy :: (t->Bool) -> Parser t t+satisfy p = do{ x <- next+ ; if p x then return x else fail "Parse.satisfy: failed"+ }++infixl 3 `apply`+-- | Apply a parsed function to a parsed value+apply :: Parser t (a->b) -> Parser t a -> Parser t b+--pf `apply` px = do { f <- pf; x <- px; return (f x) }+-- Needs to be lazier! Must not force the argument value too early. +(P pf) `apply` (P px) = P (\ts->+ case pf ts of+ (Left msg, ts') -> (Left msg, ts')+ (Right f, ts') -> let (x',ts'') = px ts'+ x = case x' of { Right x -> x; Left e -> throwE e }+ in (Right (f x), ts'') )++infixl 3 `discard`+-- | @x `discard` y@ parses both x and y, but discards the result of y+discard :: Parser t a -> Parser t b -> Parser t a+px `discard` py = do { x <- px; _ <- py; return x }++-- | @p `adjustErr` f@ applies the transformation @f@ to any error message+-- generated in @p@, having no effect if @p@ succeeds.+adjustErr :: Parser t a -> (String->String) -> Parser t a+(P p) `adjustErr` f = P (\ts-> case p ts of+ (Left msg, ts') -> (Left (f msg), ts')+ right -> right )++-- | @adjustErrBad@ is just like @adjustErr@ except it also raises the+-- severity of the error.+adjustErrBad :: Parser t a -> (String->String) -> Parser t a+p `adjustErrBad` f = commit (p `adjustErr` f)++infixl 6 `onFail` -- not sure about precedence 6?+-- | @p `onFail` q@ 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.+onFail :: Parser t a -> Parser t a -> Parser t a+(P p) `onFail` (P q) = P (\ts-> case p ts of+ (Left _, _) -> q ts+ right -> right )++-- | Parse the first alternative in the list that succeeds.+oneOf :: [Parser t a] -> Parser t a+oneOf [] = do { n <- next+ ; fail ("failed to parse any of the possible choices")+ }+--oneOf :: Show t => [Parser t a] -> Parser t a+--oneOf [] = do { n <- next+-- ; fail ("failed to parse any of the possible choices"+-- ++"\n next token is "++show n)+-- }+oneOf (p:ps) = p `onFail` oneOf ps++-- | 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.+oneOf' :: [(String, Parser t a)] -> Parser t a+oneOf' ps = accum [] ps+ where accum errs [] =+ case errs of+ [] -> failBad ("internal failure in parser (oneOf'):\n"+ ++indent 2 (show (map fst ps)))+ [(_,e)] -> fail e+ es -> fail ("one of the following failures occurred:\n"+ ++indent 2 (concatMap showErr (reverse es)))+ accum errs ((e,P p):ps) =+ P (\ts-> case p ts of+ (Left err,_) -> let (P p) = accum ((e,err):errs) ps+ in p ts+ right -> right )+ showErr (name,err) = name++":\n"++indent 2 err++-- | Helper for formatting error messages: indents all lines by a fixed amount.+indent :: Int -> String -> String+indent n = unlines . map (replicate n ' ' ++) . lines++-- | 'optional' indicates whether the parser succeeded through the Maybe type.+optional :: Parser t a -> Parser t (Maybe a)+optional p = fmap Just p `onFail` return Nothing++-- | 'many p' parses a list of elements with individual parser p.+-- Cannot fail, since an empty list is a valid return value.+many :: Parser t a -> Parser t [a]+many p = many1 p `onFail` return []++-- | Parse a non-empty list of items.+many1 :: Parser t a -> Parser t [a]+many1 p = do { x <- p `adjustErr` (("In a sequence:\n"++). indent 2)+ ; xs <- many p+ ; return (x:xs)+ }+-- `adjustErr` ("When looking for a non-empty sequence:\n\t"++)++-- | Parse a list of items separated by discarded junk.+sepBy :: Parser t a -> Parser t sep -> Parser t [a]+sepBy p sep = do sepBy1 p sep `onFail` return []++-- | Parse a non-empty list of items separated by discarded junk.+sepBy1 :: Parser t a -> Parser t sep -> Parser t [a]+sepBy1 p sep = do { x <- p+ ; xs <- many (do {sep; p})+ ; return (x:xs)+ }+ `adjustErr` ("When looking for a non-empty sequence with separators:\n\t"++)+ +-- | Parse a list of items, discarding the start, end, and separator+-- items.+bracketSep :: Parser t bra -> Parser t sep -> Parser t ket+ -> Parser t a -> Parser t [a]+bracketSep open sep close p =+ do { open; close; return [] }+ `onFail`+ do { open `adjustErr` ("Missing opening bracket:\n\t"++)+ ; x <- p `adjustErr` ("After first bracket in a group:\n\t"++)+ ; xs <- many (do {sep; p})+ ; close `adjustErrBad` ("When looking for closing bracket:\n\t"++)+ ; return (x:xs)+ }++-- | Parse a bracketed item, discarding the brackets.+bracket :: Parser t bra -> Parser t ket -> Parser t a -> Parser t a+bracket open close p = do+ do { open `adjustErr` ("Missing opening bracket:\n\t"++)+ ; x <- p+ ; close `adjustErrBad` ("Missing closing bracket:\n\t"++)+ ; return x+ }++-- | 'manyFinally e t' parses a possibly-empty sequence of e's,+-- terminated by a t. Any parse failures could be due either to+-- a badly-formed terminator or a badly-formed element, so raise+-- both possible errors.+manyFinally :: Parser t a -> Parser t z -> Parser t [a]+manyFinally pp@(P p) pt@(P t) = P (\ts ->+ case p ts of+ (Left e, _) ->+ case t ts of+ (Right _, ts') -> (Right [], ts')+ (Left e, ts') -> (Left e, ts')+ (Right x, ts') ->+ let (tail,ts'') = runParser (manyFinally pp pt) ts'+ in (Right (x:tail), ts'') )++------------------------------------------------------------------------+-- | 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.+reparse :: [t] -> Parser t ()+reparse ts = P (\inp-> (Right (), ts++inp))++------------------------------------------------------------------------
+ src/Text/ParserCombinators/PolyState.hs view
@@ -0,0 +1,248 @@+module Text.ParserCombinators.PolyState+ ( -- * The Parser datatype+ Parser(P) -- datatype, instance of: Functor, Monad+ , runParser -- :: Parser s t a -> s -> [t] -> (Either String a, s, [t])+ , failBad -- :: String -> Parser s t a+ , commit -- :: Parser s t a -> Parser s t a+ -- * Combinators:+ -- ** Primitives+ , next -- :: Parser s t t+ , satisfy -- :: (t->Bool) -> Parser s t t+ , apply -- :: Parser t (a->b) -> Parser s t a -> Parser s t b+ , discard -- :: Parser s t a -> Parser s t b -> Parser s t a+ -- ** Error-handling+ , adjustErr -- :: Parser s t a -> (String->String) -> Parser s t a+ , adjustErrBad-- :: Parser s t a -> (String->String) -> Parser s t a+ , indent -- :: Int -> String -> String+ -- ** Choices+ , onFail -- :: Parser s t a -> Parser s t a -> Parser s t a+ , oneOf -- :: [Parser s t a] -> Parser s t a+ , oneOf' -- :: [(String, Parser s t a)] -> Parser s t a+ -- ** Sequences+ , many -- :: Parser s t a -> Parser s t [a]+ , many1 -- :: Parser s t a -> Parser s t [a]+ , sepBy -- :: Parser s t a -> Parser s t sep -> Parser s t [a]+ , sepBy1 -- :: Parser s t a -> Parser s t sep -> Parser s t [a]+ , bracketSep -- :: Parser s t bra -> Parser s t sep -> Parser s t ket+ -- -> Parser s t a -> Parser s t [a]+ , bracket -- :: Parser s t bra -> Parser s t ket -> Parser s t a+ -- -> Parser s t a+ , manyFinally -- :: Parser s t a -> Parser s t z -> Parser s t [a]+ -- ** State-handling+ , stUpdate -- :: (s->s) -> Parser s t ()+ , stQuery -- :: (s->a) -> Parser s t a+ , stGet -- :: Parser s t s+ -- ** Re-parsing+ , reparse -- :: [t] -> Parser s t ()+ ) where++-- | The @Parser@ datatype is a fairly generic parsing monad with error+-- reporting and a running state. It can be used for arbitrary token+-- types, not just String input.+newtype Parser s t a = P (s -> [t] -> (EitherE String a, s, [t]))++-- | A return type like Either, that distinguishes not only between+-- right and wrong answers, but also had gradations of wrongness.+type EitherE a b = Either (Bool,a) b++-- | Apply a parser to an initial state and input token sequence.+runParser :: Parser s t a -> s -> [t] -> (Either String a, s, [t])+runParser (P p) s =+ (\ (e,s,ts)-> (case e of Left (_,m)->Left m; Right m->Right m+ ,s,ts))+ . p s++instance Functor (Parser s t) where+ fmap f (P p) = P (\s ts-> case p s ts of+ (Left msg, s', ts') -> (Left msg, s', ts')+ (Right x, s', ts') -> (Right (f x), s', ts'))+instance Monad (Parser s t) where+ return x = P (\s ts-> (Right x, s, ts))+ (P f) >>= g = P (\s ts-> case f s ts of+ (Left msg, s', ts') -> (Left msg, s', ts')+ (Right x, s', ts') -> let (P g') = g x+ in g' s' ts')+ fail msg = P (\s ts-> (Left (False,msg), s, ts))++-- | When a simple fail is not strong enough, use failBad for emphasis.+-- An emphasised (severe) error can propagate out through choice operators.+failBad :: String -> Parser s t a+failBad msg = P (\s ts-> (Left (True,msg), s, ts))++-- | 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.+commit :: Parser s t a -> Parser s t a+commit (P p) = P (\s ts-> case p s ts of+ (Left (_,e), s', ts') -> (Left (True,e), s', ts')+ right -> right )++-- Combinators++-- | One token+next :: Parser s t t+next = P (\s ts-> case ts of+ [] -> (Left (False,"Ran out of input (EOF)"), s, [])+ (t:ts') -> (Right t, s, ts') )++-- | One token satifying a predicate+satisfy :: (t->Bool) -> Parser s t t+satisfy p = do{ x <- next+ ; if p x then return x else fail "Parse.satisfy: failed"+ }++infixl 3 `apply`+-- | Apply a parsed function to a parsed value+apply :: Parser s t (a->b) -> Parser s t a -> Parser s t b+pf `apply` px = do { f <- pf; x <- px; return (f x) }++infixl 3 `discard`+-- | @x `discard` y@ parses both x and y, but discards the result of y+discard :: Parser s t a -> Parser s t b -> Parser s t a+px `discard` py = do { x <- px; _ <- py; return x }++-- | @p `adjustErr` f@ applies the transformation @f@ to any error message+-- generated in @p@, having no effect if @p@ succeeds.+adjustErr :: Parser s t a -> (String->String) -> Parser s t a+(P p) `adjustErr` f =+ P (\s ts-> case p s ts of+ (Left (b,msg), s', ts') -> (Left (b,(f msg)), s, ts')+ right -> right )++-- | @adjustErrBad@ is just like @adjustErr@ except it also raises the+-- severity of the error.+adjustErrBad :: Parser s t a -> (String->String) -> Parser s t a+-- p `adjustErrBad` f = commit (p `adjustErr` f)+(P p) `adjustErrBad` f =+ P (\s ts-> case p s ts of+ (Left (_,msg), s', ts') -> (Left (True,(f msg)), s, ts')+ right -> right )++infixl 6 `onFail` -- not sure about precedence 6?+-- | @p `onFail` q@ 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.+onFail :: Parser s t a -> Parser s t a -> Parser s t a+(P p) `onFail` (P q) = P (\s ts-> case p s ts of+ r@(Left (True,_), _, _) -> r+ (Left _, _, _) -> q s ts+ right -> right )++-- | Parse the first alternative in the list that succeeds.+oneOf :: [Parser s t a] -> Parser s t a+oneOf [] = fail ("Failed to parse any of the possible choices")+oneOf (p:ps) = p `onFail` oneOf ps++-- | 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.+oneOf' :: [(String, Parser s t a)] -> Parser s t a+oneOf' = accum []+ where accum errs [] =+ case filter isBad errs of+ [] -> fail ("failed to parse any of the possible choices:\n"+ ++indent 2 (concatMap showErr (reverse errs)))+ [(_,(_,e))] -> failBad e+ es -> failBad ("one of the following failures occurred:\n"+ ++indent 2 (concatMap showErr (reverse es)))+ accum errs ((e,P p):ps) =+ P (\u ts-> case p u ts of+ (Left err,_,_) -> let (P p) = accum ((e,err):errs) ps+ in p u ts+ right -> right )+ showErr (name,(_,err)) = name++":\n"++indent 2 err+ isBad (_,(b,_)) = b++-- | Helper for formatting error messages: indents all lines by a fixed amount.+indent :: Int -> String -> String+indent n = unlines . map (replicate n ' ' ++) . lines++-- | 'many p' parses a list of elements with individual parser p.+-- Cannot fail, since an empty list is a valid return value.+many :: Parser s t a -> Parser s t [a]+many p = many1 p `onFail` return []++-- | Parse a non-empty list of items.+many1 :: Parser s t a -> Parser s t [a]+many1 p = do { x <- p `adjustErr` (("In a sequence:\n"++). indent 2)+ ; xs <- many p+ ; return (x:xs)+ }+-- `adjustErr` ("When looking for a non-empty sequence:\n"++)++-- | Parse a list of items separated by discarded junk.+sepBy :: Parser s t a -> Parser s t sep -> Parser s t [a]+sepBy p sep = do sepBy1 p sep `onFail` return []++-- | Parse a non-empty list of items separated by discarded junk.+sepBy1 :: Parser s t a -> Parser s t sep -> Parser s t [a]+sepBy1 p sep = do { x <- p+ ; xs <- many (do {sep; p})+ ; return (x:xs)+ }+ `adjustErr` ("When looking for a non-empty sequence with separators:\n"++)+ +-- | Parse a list of items, discarding the start, end, and separator+-- items.+bracketSep :: Parser s t bra -> Parser s t sep -> Parser s t ket+ -> Parser s t a -> Parser s t [a]+bracketSep open sep close p =+ do { open; close; return [] }+ `onFail`+ do { open `adjustErr` ("Missing opening bracket:\n"++)+ ; x <- p `adjustErr` ("After first bracket in a group:\n"++)+ ; xs <- many (do {sep; p})+ ; close `adjustErrBad` ("When looking for closing bracket:\n"++)+ ; return (x:xs)+ }++-- | Parse a bracketed item, discarding the brackets.+bracket :: Parser s t bra -> Parser s t ket -> Parser s t a -> Parser s t a+bracket open close p = do+ do { open `adjustErr` ("Missing opening bracket:\n"++)+ ; x <- p+ ; close `adjustErrBad` ("Missing closing bracket:\n"++)+ ; return x+ }++-- | 'manyFinally e t' parses a possibly-empty sequence of e's,+-- terminated by a t. Any parse failures could be due either to+-- a badly-formed terminator or a badly-formed element, so raise+-- both possible errors.+manyFinally :: Parser s t a -> Parser s t z -> Parser s t [a]+manyFinally p t =+ do { xs <- many p+ ; oneOf' [ ("sequence terminator", do { t; return () } )+ , ("item in a sequence", do { p; return () } )+ ]+ ; return xs+ }++------------------------------------------------------------------------+-- State handling++-- | Update the internal state.+stUpdate :: (s->s) -> Parser s t ()+stUpdate f = P (\s ts-> (Right (), f s, ts))++-- | Query the internal state.+stQuery :: (s->a) -> Parser s t a+stQuery f = P (\s ts-> (Right (f s), s, ts))++-- | Deliver the entire internal state.+stGet :: Parser s t s+stGet = P (\s ts-> (Right s, s, ts))++------------------------------------------------------------------------+-- | 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.+reparse :: [t] -> Parser s t ()+reparse ts = P (\s inp-> (Right (), s, ts++inp))++------------------------------------------------------------------------
+ src/Text/ParserCombinators/PolyStateLazy.hs view
@@ -0,0 +1,281 @@+module Text.ParserCombinators.PolyStateLazy+ ( -- * The Parser datatype.+ -- $parser+ Parser(P) -- datatype, instance of: Functor, Monad+ , runParser -- :: Parser s t a -> s -> [t] -> (a, s, [t])+ , failBad -- :: String -> Parser s t a+ , commit -- :: Parser s t a -> Parser s t a+ -- * Combinators:+ -- ** Primitives+ , next -- :: Parser s t t+ , satisfy -- :: (t->Bool) -> Parser s t t+ , apply -- :: Parser t (a->b) -> Parser s t a -> Parser s t b+ , discard -- :: Parser s t a -> Parser s t b -> Parser s t a+ -- ** Error-handling+ , adjustErr -- :: Parser s t a -> (String->String) -> Parser s t a+ , adjustErrBad-- :: Parser s t a -> (String->String) -> Parser s t a+ , indent -- :: Int -> String -> String+ -- ** Choices+ , onFail -- :: Parser s t a -> Parser s t a -> Parser s t a+ , oneOf -- :: [Parser s t a] -> Parser s t a+ , oneOf' -- :: [(String, Parser s t a)] -> Parser s t a+ , optional -- :: Parser s t a -> Parser s t (Maybe a)+ -- ** Sequences+ , many -- :: Parser s t a -> Parser s t [a]+ , many1 -- :: Parser s t a -> Parser s t [a]+ , sepBy -- :: Parser s t a -> Parser s t sep -> Parser s t [a]+ , sepBy1 -- :: Parser s t a -> Parser s t sep -> Parser s t [a]+ , bracketSep -- :: Parser s t bra -> Parser s t sep -> Parser s t ket+ -- -> Parser s t a -> Parser s t [a]+ , bracket -- :: Parser s t bra -> Parser s t ket -> Parser s t a+ -- -> Parser s t a+ , manyFinally -- :: Parser s t a -> Parser s t z -> Parser s t [a]+ -- ** State-handling+ , stUpdate -- :: (s->s) -> Parser s t ()+ , stQuery -- :: (s->a) -> Parser s t a+ , stGet -- :: Parser s t s+ -- ** Re-parsing+ , reparse -- :: [t] -> Parser s t ()+ ) where++#if __GLASGOW_HASKELL__+import Control.Exception hiding (bracket)+throwE :: String -> a+throwE msg = throw (ErrorCall msg)+#else+throwE :: String -> a+throwE msg = error msg+#endif++-- $parser+-- Parsers do not return explicit failure. An exception is raised+-- instead. This allows partial results to be returned before a+-- full parse is complete.++-- | The @Parser@ datatype is a fairly generic parsing monad with error+-- reporting and a running state. It can be used for arbitrary token+-- types, not just String input.+newtype Parser s t a = P (s -> [t] -> (Either String a, s, [t]))++-- | A return type like Either, that distinguishes not only between+-- right and wrong answers, but also had gradations of wrongness.+-- Not used in this library. !!!!!!!!!!!!!!!!!!!!!!!!!!+type EitherE a b = Either (Bool,a) b++-- | Apply a parser to an initial state and input token sequence.+-- The parser cannot return an error value explicitly, so errors+-- raise an exception. Thus, results can be partial (lazily constructed,+-- but containing undefined).+runParser :: Parser s t a -> s -> [t] -> (a, s, [t])+runParser (P p) s =+ (\ (e,s,ts)-> (case e of {Left m->throwE m; Right x->x}, s, ts))+ . p s++instance Functor (Parser s t) where+ fmap f (P p) = P (\s ts-> case p s ts of+ (Left msg, s', ts') -> (Left msg, s', ts')+ (Right x, s', ts') -> (Right (f x), s', ts'))+instance Monad (Parser s t) where+ return x = P (\s ts-> (Right x, s, ts))+ (P f) >>= g = P (\s ts-> case f s ts of+ (Left msg, s', ts') -> (Left msg, s', ts')+ (Right x, s', ts') -> let (P g') = g x+ in g' s' ts')+ fail msg = P (\s ts-> (Left msg, s, ts))++-- | Simple failure can be corrected, but when a simple fail is not strong+-- enough, use failBad for emphasis. It guarantees parsing will terminate+-- with an exception.+failBad :: String -> Parser s t a+failBad msg = P (\s ts-> (throwE msg, s, ts))++-- | 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.+commit :: Parser s t a -> Parser s t a+commit (P p) = P (\s ts-> case p s ts of+ (Left e, s', ts') -> (throwE e, s', ts')+ right -> right )++-- Combinators++-- | One token+next :: Parser s t t+next = P (\s ts-> case ts of+ [] -> (Left "Ran out of input (EOF)", s, [])+ (t:ts') -> (Right t, s, ts') )++-- | One token satifying a predicate+satisfy :: (t->Bool) -> Parser s t t+satisfy p = do{ x <- next+ ; if p x then return x else fail "Parse.satisfy: failed"+ }++infixl 3 `apply`+-- | Apply a parsed function to a parsed value+apply :: Parser s t (a->b) -> Parser s t a -> Parser s t b+--pf `apply` px = do { f <- pf; x <- px; return (f x) }+-- Needs to be lazier! Must not force the argument value too early.+(P pf) `apply` (P px) = P (\s ts->+ case pf s ts of+ (Left msg, s', ts') -> (Left msg, s', ts')+ (Right f, s', ts') -> let (x',s'',ts'') = px s' ts'+ x = case x' of+ Right x -> x+ Left e -> throwE e+ in (Right (f x), s'', ts''))++infixl 3 `discard`+-- | @x `discard` y@ parses both x and y, but discards the result of y+discard :: Parser s t a -> Parser s t b -> Parser s t a+px `discard` py = do { x <- px; _ <- py; return x }++-- | @p `adjustErr` f@ applies the transformation @f@ to any error message+-- generated in @p@, having no effect if @p@ succeeds.+adjustErr :: Parser s t a -> (String->String) -> Parser s t a+(P p) `adjustErr` f =+ P (\s ts-> case p s ts of+ (Left msg, s', ts') -> (Left (f msg), s, ts')+ right -> right )++-- | @adjustErrBad@ is just like @adjustErr@ except it also raises the+-- severity of the error.+adjustErrBad :: Parser s t a -> (String->String) -> Parser s t a+-- p `adjustErrBad` f = commit (p `adjustErr` f)+(P p) `adjustErrBad` f =+ P (\s ts-> case p s ts of+ (Left msg, s', ts') -> (throwE (f msg), s, ts')+ right -> right )++infixl 6 `onFail` -- not sure about precedence 6?+-- | @p `onFail` q@ 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.+onFail :: Parser s t a -> Parser s t a -> Parser s t a+(P p) `onFail` (P q) = P (\s ts-> case p s ts of+ (Left _, _, _) -> q s ts+ right -> right )++-- | Parse the first alternative in the list that succeeds.+oneOf :: [Parser s t a] -> Parser s t a+oneOf [] = fail ("Failed to parse any of the possible choices")+oneOf (p:ps) = p `onFail` oneOf ps++-- | 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.+oneOf' :: [(String, Parser s t a)] -> Parser s t a+oneOf' ps = accum [] ps+ where accum errs [] =+ case errs of+ [] -> failBad ("internal failure in parser (oneOf'):\n"+ ++indent 2 (show (map fst ps)))+ [(_,e)] -> fail e+ es -> fail ("one of the following failures occurred:\n"+ ++indent 2 (concatMap showErr (reverse es)))+ accum errs ((e,P p):ps) =+ P (\u ts-> case p u ts of+ (Left err,_,_) -> let (P p) = accum ((e,err):errs) ps+ in p u ts+ right -> right )+ showErr (name,err) = name++":\n"++indent 2 err++-- | Helper for formatting error messages: indents all lines by a fixed amount.+indent :: Int -> String -> String+indent n = unlines . map (replicate n ' ' ++) . lines++-- | 'optional' indicates whether the parser succeeded through the Maybe type.+optional :: Parser s t a -> Parser s t (Maybe a)+optional p = fmap Just p `onFail` return Nothing++-- | 'many p' parses a list of elements with individual parser p.+-- Cannot fail, since an empty list is a valid return value.+many :: Parser s t a -> Parser s t [a]+many p = many1 p `onFail` return []++-- | Parse a non-empty list of items.+many1 :: Parser s t a -> Parser s t [a]+many1 p = do { x <- p `adjustErr` (("In a sequence:\n"++). indent 2)+ ; xs <- many p+ ; return (x:xs)+ }+-- `adjustErr` ("When looking for a non-empty sequence:\n"++)++-- | Parse a list of items separated by discarded junk.+sepBy :: Parser s t a -> Parser s t sep -> Parser s t [a]+sepBy p sep = do sepBy1 p sep `onFail` return []++-- | Parse a non-empty list of items separated by discarded junk.+sepBy1 :: Parser s t a -> Parser s t sep -> Parser s t [a]+sepBy1 p sep = do { x <- p+ ; xs <- many (do {sep; p})+ ; return (x:xs)+ }+ `adjustErr` ("When looking for a non-empty sequence with separators:\n"++)+ +-- | Parse a list of items, discarding the start, end, and separator+-- items.+bracketSep :: Parser s t bra -> Parser s t sep -> Parser s t ket+ -> Parser s t a -> Parser s t [a]+bracketSep open sep close p =+ do { open; close; return [] }+ `onFail`+ do { open `adjustErr` ("Missing opening bracket:\n"++)+ ; x <- p `adjustErr` ("After first bracket in a group:\n"++)+ ; xs <- many (do {sep; p})+ ; close `adjustErrBad` ("When looking for closing bracket:\n"++)+ ; return (x:xs)+ }++-- | Parse a bracketed item, discarding the brackets.+bracket :: Parser s t bra -> Parser s t ket -> Parser s t a -> Parser s t a+bracket open close p = do+ do { open `adjustErr` ("Missing opening bracket:\n"++)+ ; x <- p+ ; close `adjustErrBad` ("Missing closing bracket:\n"++)+ ; return x+ }++-- | 'manyFinally e t' parses a possibly-empty sequence of e's,+-- terminated by a t. Any parse failures could be due either to+-- a badly-formed terminator or a badly-formed element, so raise+-- both possible errors.+manyFinally :: Parser s t a -> Parser s t z -> Parser s t [a]+manyFinally pp@(P p) pt@(P t) = P (\s ts ->+ case p s ts of+ (Left e, _, _) ->+ case t s ts of+ (Right _, s', ts') -> (Right [], s', ts')+ (Left e, s', ts') -> (Left e, s', ts')+ (Right x, s', ts') ->+ let (tail,s'',ts'') = runParser (manyFinally pp pt) s' ts'+ in (Right (x:tail), s'', ts'') )++------------------------------------------------------------------------+-- State handling++-- | Update the internal state.+stUpdate :: (s->s) -> Parser s t ()+stUpdate f = P (\s ts-> (Right (), f s, ts))++-- | Query the internal state.+stQuery :: (s->a) -> Parser s t a+stQuery f = P (\s ts-> (Right (f s), s, ts))++-- | Deliver the entire internal state.+stGet :: Parser s t s+stGet = P (\s ts-> (Right s, s, ts))++------------------------------------------------------------------------+-- | 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.+reparse :: [t] -> Parser s t ()+reparse ts = P (\s inp-> (Right (), s, ts++inp))++------------------------------------------------------------------------
+ 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 = []+ }+