HOOG $1 ""..XX<>?a%"%%((2269;;=AEEIIKPTTVZ]eggmmqrttvb -.LMllrrwwc (44AAFGYY^^ffmnz|d##&&(*,.77??AEOOTTacffllnne !&((+57GJOQV[accflpswf ,,//67??CCHHOOaacceeklpp~~g))227=BBJJNO[`ggnnh  >BTTi$$()11::<<AJSSZZ`ciinnuw~~jKKk 1199>@TTVVhhool $$((67>ADDFGIIKUZZ\\deiilmrsvv~~m&((+,22AAFFRRVcfgww{{~~n  #'-.117:<<CJNOSSVZ``blppuxo! '**/36699<<FGIITV[\^^acehjw}~p!"+,358<IIVV\\^^jjqq__r$ %%035589;;CGJJQQUV[\^^``beghqtxs !"%&1389;@EGIIKKMMVV]afgjjttxt% #%''),44669=@@BEIKQQVVZZ`adflnqw||u&'1177::FGNOYYdehhvKKw11UUgjllx 45ABHHRRy +.@@KKPPWZ\\aallwwzPP|fԗ-Z0)r()(->(All(Anyh(ArithException[(ArrayExceptionN(AsyncExceptionA(Bool( BufferMode' BufferState' ByteString'CCharT'CClock"'CDev&CDouble&CFloat>&CIno%CInt%CIntMaxf%CIntPtr%CLDouble$CLLong}$CLong5$CMode#COff#CPid]#CPtrdiff#CSChar"CShort" CSigAtomic="CSize!CSsize!CTime{!CUChar3!CUInt CUIntMax CUIntPtr[ CULLong CULongCUShortCWchar;Chan0CharComplex ConsoleEventConstr ConstrRepConsumedDataRepDataTypeDouble-DynamicE12E6Errno ExceptionExitCodeFDTypeFdFixityFloat-GeneralCategory Handle HandlePosn HandleTypeHashDataIOIOError IOErrorType IOExceptionIOModefIdQIdentity9Inserts5IntInt16Int32BInt64Int8IntPtrXIntegerLexeme ListTMaybeMessageOrderingtPc ParseError]QSemSQSemNIReadP0ReadPrecSTMSeekMode SourcePos StableNameStringTVarThreadIdTimeoutTyConTypeRepUnique~VersioncWeakXWordWord16Word32eWord64Word8WordPtr{ZipListf[::]W[] TraversableFoldableMonadFix Applicative Alternative MonadPlusFunctorMonadFunctorMonadFunctor Applicative ReadShowTypeableBitsIntegralBoundedRealStorableEnumNumOrdEq PrintfArgStorableDataShowNumRealEnumIntegralBoundedIxReadBitsOrdEq PrintfArgStorableDataEqOrdNumEnumIntegralBitsShowRealBoundedIxRead PrintfArgStorableDataNumEnumIntegralBitsShowRealBoundedIxReadOrdEq PrintfArgStorableDataShowNumRealEnumIntegralBoundedIxReadBitsOrdEq PrintfArgStorableDataShowNumRealEnumIntegralBoundedIxReadBitsOrdEq Typeable1EqOrdShowReadTypeableOrdEqDataDataEqTypeableDataShowEqOrdTypeable Typeable1Error Typeable1ShowOrdEqShowReadEnumIxOrdEq Typeable1FunctorMonadFunctorMonad MonadPlusFunctorMonad MonadPlusTypeableTypeableShowMonad MonadPlus MonoidDataReadShowBoundedEnumIxOrdEqEnumEqOrd TraversableFoldableMonadFix Applicative AlternativeFunctorMonad MonadPlus MonadTransShowEqRead PrintfArgBitsDataReadEqOrdNumEnumShowIxRealIntegral ReadShowTypeableBitsIntegralBoundedRealStorableEnumNumOrdEq PrintfArgStorableDataShowNumRealEnumIntegralBoundedIxReadBitsOrdEq PrintfArgStorableDataEqOrdShowNumEnumIntegralReadBitsRealBoundedIx PrintfArgStorableDataShowNumEnumIntegralReadBitsRealBoundedIxOrdEq PrintfArgStorableDataShowNumRealEnumIntegralBoundedIxReadBitsOrdEq PrintfArgBitsStorableDataReadShowNumBoundedEnumIxRealIntegralEqOrdEqFunctorMonadMonadFixFunctor ApplicativeShowReadEnumIxOrdEqEqShowEqShowError MonadErrorMonadFix ApplicativeFunctorMonad MonadPlus MonadErrorMonadIOShowEqShowEqShowDataEqShowIxBoundedShowReadEnumOrdEq PrintfArgStorableDataEqOrdNumReal FractionalRealFracFloating RealFloatShowEnumReadShowEq ReadShowTypeableBitsIntegralBoundedRealStorableEnumNumOrdEqEqShowReadOrdEqShowEqEq HasResolution HasResolutionTypeableShow PrintfArgStorableDataEqOrdNumReal FractionalFloatingRealFrac RealFloatShowEnumReadTypeableDataShowShowEqFunctorShowEqShowEqReadShowEnumOrdEqTypeable Typeable1 PrintfArgIsCharStorableDataReadShowBoundedEnumIxEqOrd Typeable1 ReadShowTypeableBitsIntegralBoundedRealStorableEnumNumOrdEq ReadShowTypeableBitsIntegralBoundedRealStorableEnumNumOrdEq ReadShowTypeableBitsIntegralBoundedRealStorableEnumNumOrdEq ReadShowTypeableBitsIntegralBoundedRealStorableEnumNumOrdEq ReadShowTypeableBitsIntegralBoundedRealStorableEnumNumOrdEq ReadShowTypeableBitsIntegralBoundedRealStorableEnumNumOrdEq ReadShowTypeableBitsIntegralBoundedRealStorableEnumNumOrdEq ReadShowTypeableBitsIntegralBoundedRealStorableEnumNumOrdEq ReadShowTypeableRealStorableEnumNumOrdEq ReadShowTypeableBitsIntegralBoundedRealStorableEnumNumOrdEq ReadShowTypeableBitsIntegralBoundedRealStorableEnumNumOrdEq ReadShowTypeableBitsIntegralBoundedRealStorableEnumNumOrdEq ReadShowTypeableBitsIntegralBoundedRealStorableEnumNumOrdEq ReadShowTypeableBitsIntegralBoundedRealStorableEnumNumOrdEq ReadShowTypeableBitsIntegralBoundedRealStorableEnumNumOrdEq ReadShowTypeableBitsIntegralBoundedRealStorableEnumNumOrdEq ReadShowTypeableBitsIntegralBoundedRealStorableEnumNumOrdEq ReadShowTypeableBitsIntegralBoundedRealStorableEnumNumOrdEq ReadShowTypeableBitsIntegralBoundedRealStorableEnumNumOrdEq ReadShowTypeableBitsIntegralBoundedRealStorableEnumNumOrdEq ReadShowTypeable RealFloatRealFracFloating FractionalRealStorableEnumNumOrdEq ReadShowTypeableBitsIntegralBoundedRealStorableEnumNumOrdEq ReadShowTypeableBitsIntegralBoundedRealStorableEnumNumOrdEq ReadShowTypeableBitsIntegralBoundedRealStorableEnumNumOrdEq ReadShowTypeableBitsIntegralBoundedRealStorableEnumNumOrdEq ReadShowTypeable RealFloatRealFracFloating FractionalRealStorableEnumNumOrdEq ReadShowTypeable RealFloatRealFracFloating FractionalRealStorableEnumNumOrdEq ReadShowTypeableRealStorableEnumNumOrdEq ReadShowTypeableRealStorableEnumNumOrdEq ReadShowTypeableBitsIntegralBoundedRealStorableEnumNumOrdEqIsStringDataReadShowTypeableEqOrdMonoidIsStringShowReadDataTypeableEqOrdMonoidEqShowReadOrdEq StorableDataReadShowBoundedEnumIxOrdEqShowOrdEqShowOrdEqShowOrdEqMonoidBoundedShowReadOrdEqMonoidBoundedShowReadOrdEqArrow ArrowChoice ArrowApply ArrowLoop MonoidDataReadShowBoundedEnumIxEqOrd)? ByteCountR0CDirM0CDirentH0CFLockC0CGroup>0CLconv90CPasswd40 CSigaction/0CSigset*0CStat%0CString0 CStringLen/CTermios/CTm/CTms/CUtimbuf/CUtsname/CWString/ CWStringLen/ CharParser/ ClockTick/Column~/ConIndexx/DeviceIDq/ EpochTimei/FDb/FileID[/FileModeS/ FileOffsetL/FilePath?/FinalizerEnvPtr / FinalizerPtr. GenParser.Generic.GenericB.GenericM.GenericQ.GenericR.GenericTz.HandlePositionp.IOErrorb.IPrP. LanguageDef .Limit.Line.Micro. OperatorTable-Parsec-Parser- PermParser_-PicoP-PrecJ-ProcessGroupIDC- ProcessID<-Rational)- RawBuffer-ReadS,STRep, SampleVar,ShowSq, SourceNamed,StringW, TokenParser',stGenTokenParser[]CharstIdentity[]Char[]Char[]Char[]CharaMVar(,)IntMVarasaState#s(#,#)State#saa[]Char[](,)a[]CharMutableByteArray# RealWorldRatioIntegerCPidCPidIntFixedE12tokstaStreamPermParser[]CharstaParsecT[]Char()IdentitysuParsecTsuIdentitytoksta[][]OperatortokstaFixedE6IntCLongstGenLanguageDef[]CharstIdentity(,)IntInt IOExceptionIntegeraammararmamaacacatokstParsecT[]tokstIdentityaFunPtrPtraIO()envaFunPtrPtrenvPtraIO()[]CharCOffCModeCInoCIntCTimeCDevIntIntCClockstParsecT[]CharstIdentity(,)PtrCWcharIntPtrCWchar()()()()()(,)PtrCCharIntPtrCChar()()()()()()()()()CSize(:[abicwd7seofigfhRdiv]jD]k ]lYm UnRo=Np-IqHr3BsB;t7u4v4w.1z0|0|i0p1l1i1s1t1ZipList#41p43V46<48*4e3o(3rX1a62id1tk1er1b2h1m1r1Writert1WriterTo1d1e1IOModea1n1d1l1e1 HandleTypeu 2f2f2e2r%2 BufferStatep=2a2m2pN2eU2d\2a2mh2oo2nv2a}2d2 WrappedMonadr2r2o2w2 WrappedArrowo2n2a2d2 WrappedMonadr3r3o3w3 WrappedArrowr/3d63Word#313336383pb3ti3rp3WordPtrWord843Word64#3Word64#23Word3263Word16Word#a4k4Weak#4Weak##14Word84C4#J4Word642]4#d4Word326w4#~4Word16Worde4r4s4i4o4n4Versionn5p"5s4e4r4e4r4r5o 5r5 IOErrorTypep)5e05r75c>5aE5sL5eS5lZ5ea5th5to5ev5r}5GeneralCategoryd,7e6i6s5a56u5p5p5o5r5t5e5d5o5p5e5r6a6t6i6o6n$6 IOErrorTypet<6iC6sJ6fQ6iX6e_6df6cm6ot6n{6s6t6r6a6i6n6t6s6 IOErrorTypeq6t6Unitu6e6Uniquex7p 7e7c7t7Messagee37fo7r?7fF7lM7oT7w[7ArithExceptioniv7n}7e7d7e7l7e7m7e7n7t7ArrayExceptionh:i9o9r69v9y7c8p7e8a.8r8e8p8TypeRepb58l<8eC8Typeable1828384858687x8 Typeable7 Typeable6 Typeable5 Typeable4 Typeable3 Typeable2 Typeable1o9n 9TyCona!9r(9TVaraS9uB9eI9BoolvZ9ea9rh9so9av9b}9l9e9 Traversablek9e9n9p9a9r9s9e9r9 TokenParsermi:t:l:e:c:a:s#:e*:l1:e8:t?:tF:eM:rT:GeneralCategoryep:ew:x~:p:i:r:e:d: IOErrorTyper:e:a:d:i;k:i:l:l:e:d:AsyncExceptiond;ThreadId#/; ThreadId# #&BaAe@h@o@pp?t<u*<yq;m <s};t;u;n;e;x;p;e;c;t;Messagee;m;e;r;r;o;r; IOErrorTypeb<o<l<Lexememu<r6<r=<oD<gK<aR<tY<e`<GeneralCategorySumSTa$>m>o=r<e#=i<n<g<Stringc<r<e<p<DataRepo<n<s=t =r= ConstrRepaf=fW=pH=t9=STretSTRepSTRefmm=FDTypeStreamp=e=r=m=p=a=r=s=e=r=StreamPermParserr=a=b=l=e>StorableSTMb>c>rz>t:>eA>State#j>tZ>StateTState#r>a>y>STArrayk>o>v>e>r>f>l>o>w>AsyncExceptionl>e?nG?p ?t?r? StablePtr#3? StablePtr#aN?mU?e\? StableNameaw?c~?e@i?n?g?c?o?m?b?i?n?i?n?g?m?a?r?k?GeneralCategoryGeneralCategoryu$@r+@c2@e9@nf@pE@oL@sS@ SourcePosam@mt@e{@ SourceNameo@u@t@d@o@w@n@ ConsoleEventw@Shows@ShowSepAmAi AcAlAo!As(Ae/Ad6Ah=AaDAnKAdRAlYAe`A HandleTypekwAfAmAoAdAeASeekModerAoAmAeAnAdASeekModemApAlAeAvBa BrB SampleVarIntegera-HeBipBwIBsPBRWStbBRWSTgwBh~BtBEitheraEcEgDlDpbDqCsCtBuBrBnBiBnBoBrBdBeBrCArgOrderoCuCr$Cc+Ce2CbCeCvCCaJCnQCiXCs_ChfCemCdtC IOErrorTypexChCaCuCsCtCeCdC IOErrorTypeuCsCyC IOErrorTypeaFDuDiDrDeDoDr#Dd*De1Dr8DArgOrderrMDgTDArgDescrliDypDReplyaDtDiDvDeDsDeDeDkDSeekModeuDlDaDrDfDiDlDeEFDTypecEsaEu!Ep(Ed/Ee6Er=ErDEoKErRE ExceptionehEloEevEr}ErEoErE ExceptionoEnEeErErEoErE ExceptiondFlERealf4FwFo FrFlFd!F RealWorldl`Fr@FaGFcNFRealFracogFanFtuF RealFloatReadbGeGhGmxGpDGs5GwFrFiFtFeFhGmFoFdFeFIOModea GnGdGlGe%G HandleTypeReadSReadPrXGe_GcfGReadPrecoGdGeGIOModeaGnGdGlGeG HandleTyperGReadertGReaderTuHfHfHeHrH BufferStatetHw9HbtHdEHeLHvSHiZHcaHehHFDTypeu{HfHfHeHrH RawBufferLexemeiHoHRationHaHlHRationalsHeIm IQSemnIQSemNaLeKiKoKrIsItqIuWIn^IceILexemerxIPtr ByteStringeYKiJoIc-JdJtIoIcIoIlIeIrIrIoIrI IOErrorTypeuJcJtJProducte4Js;JsBJghJiNJdUJ ProcessIDroJovJu}JpJiJdJProcessGroupIDnJvJaJtJeJuJsJeJGeneralCategorytJfKa8KtKyKpKe$K PrintfTyper?KgFK PrintfArgcKfeKilKxsKOperatorPrecoKsKtKfKiKxKOperatorlKPoolcKoKPicorKmLihLp1LuLtLe#LArgOrdera8Lr?LsFLeMLrTL PermParsersoLsvLi}LoLnLdLeLnLiLeLdL IOErrorTyperOiEOoLOnSOGeneralCategoryuoOmvOb}OeOrOGeneralCategoryeOtOtOeOrOGeneralCategoryrOrOoOrO IOErrorTyped POrdePr%Pi,Pn3Pg:POrderingaQePt]PaPdPinPouPn|POptDescrePsPcPrPOptDescrrPgPArgDescrnFQrPaPtPoPrPOperatortQaQb!Ql(Qe/Q OperatorTablepMQuTQn[QcbQtiQupQawQt~QiQoQnQGeneralCategoryqQuQeQOpaqueReplyjQeQcQtQObjecteTo)RuRmRNuma}Tb5TmSn$Sr SsRtNRazRhZRiaRnhRgoRMaybesRsRiRgRnReRdRGeneralCategoryuRcRhRtRhRiRnRgR IOErrorTypeeSpSDataRepsSt0Se7Sr>SmESiLSnSSaZStaSihSooSnvS ExceptionpSaScSiSnSgSmSaSrSkSGeneralCategoryeStShSoSdTe TrTrToTr&T ExceptionuWeEW MonadStatee~WweWslWMonadRWSaWdWeWrW MonadReaderlWuWsW MonadPlusoWMonadIOiWxWMonadFixrXrXo$Xr+X MonadErroroFXnMXtTX MonadContinXfuXi|XeXrXlXsXyXmXbXoXlXGeneralCategoryeXtXtXeXrXGeneralCategoryc YrYoYMicros1Ys8Ya?YgFYeMYMessagetYyjYbqYexYMaybehYsYyYmYbYoYlYGeneralCategorya\e[iZoYtYOrderinggZspZwZeZrZcZa#Zs*Ze1Zl8Ze?ZtFZtMZeTZr[ZGeneralCategoryswZo~ZfZpZrZeZcZiZsZiZoZnZArithExceptionoZfZfZ ConsoleEventm[n-[s[t[t[ListTe4[Lineb[sL[eS[pZ[aa[rh[ao[tv[o}[r[GeneralCategoryu[f[f[e[r[i[n[g[ BufferModei[t[Limitf\t4\x\e\m\e$\Lexemet;\eB\rI\nP\uW\m^\be\el\rs\GeneralCategoryt\Eithern\s\t\Lastg\u\a\g\e\d\e\f\ LanguageDefl]e]i]s%]l,]i3]Kleisli#i]uP]sW]t^]MaybeInteger #Id10d3d6c8cdcg~cl cnu_o?^p+^s]x]Ixc^s]t]r]i]n]g]IsStringh ^a^r^IsCharr2^IPrIOaH_e^m|^r_^ef^fm^IORefo^d^e^IOModer^x^c^e^p^t^i^o^n^ IOExceptionr^o_r_IOErrort_y%_p,_e3_ IOErrorTyperO_rV_a]_yd_IOArrayabd)bf bialarat`v_a_l_i_d_a_r_g_u_m_e_n_t_ IOErrorTypeInt #a1a3ma6Ba84acaew`pY`r>`eE`pL`DataRept``rg`IntPtrg`r`r`u`p`t`e`d` IOErrorTypee`r`a`l`Integralr`Integero anasatar%a ConstrRepInt84IaInt64#]aInt64#2taInt326aInt16Int#:+::+:taiaaalaqauaoataeaGeneralCategoryibxbOperatore0bx7bo>buEbtLboSbfZbbabohbuobnvbd}bsbArrayExceptionpbpbrbobpbrbibabtbebtbybpbeb IOErrorTypelcecg ca'cl.co5cpdInt16Intaeedpcdrjdiqdnxdtdfdtdydpded HPrintfTypeadpdodvdedrdfdldodwdAsyncExceptionnfres"eher.ee5esnlEneLnHandleenfnginepnnwne~nrnincnFFFormatinonrnmnantnFFFormatxnendnFFFormatxop ooonoe!on(ot/oFFFormatFDFdtUoy\opcoejoFDTypelosoeoBoolFloat 1#s6sirmrn2rorpqqqrCqxocqi ppoeocotoMessagetpcpepf`ps(pu/pc6pc=peDpsKpsRpExitCodeagpinplupu|prpepExitCodexpcpeppptpipopnp ExceptionopdpepExitCodee qpqtqi"qo)qn0q ExceptionrJqnqoVqr]qReplyErrorcqt|qErrorTaqlqlq ExceptionoqErrnoOrderingEqoqcqhqtqiqmre r EpochTimef&rLexemecmrdXruCrmJrEnumo_rEndoltro{rsrirnrgrmrarrrkrGeneralCategoryprtryrConsumedtrhresrsEitherE62*sE12#wave_uitotuty\sncsasesitso{sesrsrsosrs IOErrorTypexscsespstsisosns Exceptionmsitc tDynamicastp(tl/te6tx=thDtaKtnRtdYtl`tegtHandlelztDualutbtltetDouble#tDouble#r)uvtitdtetbtytzueuruouArithExceptione0uc7ut>uoEurLuySuFDTypeajvcvfunuvzuiucueuiuduDeviceIDourumuauluArithExceptionauuulutvHandlerivmva$vl+vn2vu9vm@vbGveNvrUvGeneralCategorydqvlxvovcvkv ExceptionswtvavDataDatarvtvyvpvevDataTypeevpwDataRephwp$wu+wn2wc9wt@wuGwaNwtUwi\wocwnjwGeneralCategoryDouble#_a=cdcfׂgh ij^lmo }p|sztczupxwwcKxswtwrwixn xgxCWStringl(xe/xn6x CWStringLenhRxaYxr`xCWcharc>ziylyr%ysxtxixsxnxaxmxexCUtsnamemxbxuxfxCUtimbufhxoyr ytyCUShortr,ye3yn:ycAyyHysOyyVym]ybdyokylryGeneralCategorylyoynygyCULongoynygyCULLongnytyCUIntmzpytzr zCUIntPtra%zx,zCUIntMaxhEzaLzrSzCUCharezizmtzCTmszCTmsmzezCTimerzmzizozszCTermioscs|hN|i{sp{t{aZ{r {i{n{g"{CStringl8{e?{nF{ CStringLenta{CStatiw{z~{e{CSsizeg{z{e{CSizea{s{e{t{CSigsetc|t{o{m{i|c | CSigAtomict%|i,|o3|n:| CSigactionoU|r\|tc|CShorthz|a|r|CSChara|i|t|r|d|i|f|f|CPtrdiffd|CPids|s}w}d}CPasswdf{lVm)n6}i~nv~s}tL}Contrs}td}ContToz}l}GeneralCategoryc} ConsoleEvento/~t}u}m}e}d}ConsumedConstr}Constrr~e~p~ ConstrRepl6~e=~eD~vK~eR~nY~t`~ ConsoleEvente}~c~t~o~r~p~u~n~c~t~u~a~t~i~o~n~GeneralCategorynd exConIndexp0l7e>xEComplexu]mdnkColumnfCOffodeCModec9dl߀ocnse ConsoleEventdYpun ctu!a(t/i6o=nDGeneralCategoryh`agnndul|e HandleTypegCLongkticŀk̀ ClockTickongCLLongo ubl e'CLDoubleo@nGvNCLconvmeplbsuzfCJmpBufnotCIntm܁ptārˁCIntPtraxCIntMaxCInoa3unk# ByteStringnr?Char#pWa^reslesrz CharParserChar#ChanroupǂCGroupiFlposCFposo a/ckCFLockt6CFloatlMeTCFileeڃiotu{bleCDoublerCDirenƒtɃCDirentvCDevh loc kCClocka'r.CChartDcKhRHandlerCharilņowrPuEyteac߄strinĄg˄ ByteStringount ByteCountrra#y*#1 ByteArray#fLfSeZraBufferlڅmstate BufferStateodeƅ BufferModeist BufferListc+n il BufferListo2n9s@ BufferListeWa^ke ConsoleEventoundedBoundedlBoolŏcӆkچbediGondeadm#v*a1r8 ExceptionnNdUe\fcijnqixtely ExceptionufferƇi͇nԇgۇ BufferModetsBitsb^d:lnp?rs,sy8n?cFeMxTc[ebpitpiwo~nAsyncExceptione5ocAssoclnrΈiՈg܈htAssocone Assocef#t*Assocr<tCiJoQnXf_afimlte{d Exceptiong׋irraowArrowaŠclbm2p zero ArrowZerolus ArrowPluso9n@aGdN ArrowMonadoioppw ArrowLoophoice ArrowChoicepɊpЊl׊yފ ArrowApplyyArray#bexc e'p.t5i<oCnJArrayExceptionArray#tyhexceptionArithExceptiondorderArgOrderesc&r-ArgDescrpFelRiYc`agtniuv|e ApplicativendhӌmodenjIOModeaڌndle HandleTypey Anyglԍr}t0e7r>nEaLtSiZvaeh AlternativeeadyexistsÍ IOErrorTypeAllcrepDataReponst$r+ ConstrRepdArH#OAddr#seollsuzteseekSeekMode:ʎ][]:ю]؎[::]*+::+:: :*:)!()1 p T  Assoc BoolVOInt_^MessageIOrderingP ParseErrorcbWRQ9 SourcePos a`]\[XJH:s;u< ()musParsecT vmhY4'CharmusParsecTpLCDoublemusParsecTIntegermusParsecT SourcePosmusParsecTamusOperator65amusParsecTukfeED@830/-,)( bmusParsecTt2smusParsecTtmusParsecT umusParsecT DoubleIntegerEithermusParsecTusStatemusParsecTn7Char[]musParsecTBaMaybemusParsecT%a[]musParsecTqM+*&t[]musParsecToastsParsec=asttok GenParserAasttokOperatorausParseclausReplygTSKbstsStreamPermParsersr?>musGenLanguageDefG musGenTokenParser$* a ParseErrorEither#!usStatej()IO"Char[]ZNFMessage[]UaConsumedda ParseErrorEitherIO a ParseErrorEitherm1IdentitystChar[]GenLanguageDefIdentitystChar[]GenTokenParserChar[][]st(,)MaybemiausReplymConsumedm.ؗ7 : :jtQŝtϚ{_7͙ SourcePosst SourcePosuBoolCharpbatsruuvbmusParsecTa2 SourcePost[] SourcePosoa[]a[]aqChar[]tuaMaybetuusStateusStatenChar[]t[]o Assoc6BoolG GChar]LInta`MHHMessageRQPPOON ParseError gcXWWVUTSQ SourcePoslkkjcba`_^]\[ZYRKagfed-skjih1#"!sttlllkkkumj1#uust SourcePosMaybeuaaasttok GenParseraasttok GenParserbastsStreamPermParser?>aaamusParsecT6-,aamusParsecT5 ()musParsecT$$$CharmusParsecTGGGG$DoublemusParsecT$ IntegermusParsecT$$ $ $ $amus OperatorTable amusParsecT'tqfM3210/.-,+*))('&%$($&$$$"$$$$$$$$$$$$ closemusParsecT3endmusParsecT*openmusParsecT3sepmusParsecT+tmusParsecT4DoubleIntegerEithermusParsecT$ Char[]musParsecT$!$ $$$$$$a[]musParsecT$)$'$%$#a()sParsec"!astsParsecs?astsStreamPermParser=asttok GenParserAausParsec#ausReplyTmusGenLanguageDef musGenTokenParser usStateg<;:987.astsParseca(,)r>Char[]lk\[KJIHGGGFFFFFEDCB10$$$#! Message[]FaMaybelkt[]otok[]amusParsecT[]@Char[][]G G/asttokOperator[][]AausReplymConsumedm8aIdentity()Char[]ParsecT vyb9ȴV? ڳ}K,! sDбrS0аz_>̯zT(î|m^O7ͭ|b:$ iH2'ѫ«cA+yj[H'ߩЩw\IըaFMonadmStreammStreamsStreamtStringMonadm&Streams'StreamsStreammStreamsStreammStreamsEqtStreammStreamsStreamtStringMonadmMonadmStreamsStreamtStringStreammStreamsStreamtStringStreammStreamsStreamtMonadm~StreammStreamsMonadmKPoopNLinemnMColumn"Line!ColumnString  SourceName$ SourceNameMonadmXY7bV5W6Un, efgStringL-StreammStreams>StreammStreamsStringrP SourceNameZ8dStringqColumnLine SourceNameyVX StringStringStreammStreamsStringMonadmStringrvStreammStreamsStreammStreamsString OperatorTable@!StreammStreams+ Streams* StreamsStreamsMonadmqsShowtStreammStreamsStreamt5StreammStreamsMonadmStreammStreams SourceName(uSMonadmStringvTMonadmString:<StreammStreams;=StreammStreams RS23StreammStreamsaStreammStreams)Monadm~\StreammStreamsStreammStreams_`StreammStreamsStreammStreams*StringStreams SourceNameShowaStreamsStreams SourceName8StreammStreamsStringString .67{ ZEF%& Mhs.FQjt[9?ADOj"$0HxStringkO SourceName9lm GHI'()*+,StringString klIJKLz{|}^StreammStreamsParserString234dBMonadm0ShowtStreammStreamsStreamta?MonadmMonadmcAMonadm-/Niz /GY]puStreammStreamsT4StreammStreamsb@MonadmeCh TokenParser Qfgt1DERi LanguageDefoW) sQ-yK/kO5i?uU; mQ9uI#sS/u[7gS7y_A!g=[-eE5y]=yMsS1sWA+ sS1mQ1oI]=wM3׼qE׻oFкfBƹrX4&|,| whitespaceC whiteSpaceupperbupper updatestate updateStateupdateposstringupdatePosString updateposcharع updatePosCharupdateparserstateupdateParserState unknownerror/ unknownError unexpectedQ unexpectedunexpectsUnExpectunconsunconstrytrytokenstokens tokenprimex tokenPrimEx tokenprim tokenPrim tokenparser( TokenParsertokenPTokentokentabwtabsysunexpecterrorsysUnExpectError sysunexpect SysUnExpectsymbolsymbol stringliteral stringLiteralstring(StringstringstreampermparserZStreamPermParser stateuser stateUserstateposstatePos stateinput¼ stateInputstateStatesquaressquaresspaces"spacesspace=space sourcepos[ SourcePos% sourcename SourceName# sourceName$ sourcelineν sourceLine" sourcecolumn sourceColumn! skipmany1) skipMany1skipmanyJskipManyshowerrormessagessshowErrorMessagessetstatesetState setsourcename setSourceName  setsourceline setSourceLinesetsourcecolumn'setSourceColumn setpositionY setPositionsetparserstatesetParserStatesetinputsetInput seterrorpos˿ setErrorPosseterrormessagesetErrorMessage sependby1 sepEndBy1sependby>sepEndBysepby1\sepBy1sepbywsepBysemisep1semiSep1semisepsemiSepsemisemisatisfysatisfyrunptrunPT runparsert  runParserT runparser? runParser runparsectb runParsecTrunp|runPreservedopnamesreservedOpNames reservedop reservedOp reservednames reservedNamesreservedreservedreply5ReplypzeroKpzeroputstatedputStateprim|PrimprefixPrefixpostfixPostfixposPospermutepermute permparser PermParserperm"Perm parsetest? parseTest parserzerob parserZero parserreturn parserReturn parserplus parserPlus parserfail parserFail parserbind parserBindparserParser parsefromfile- parseFromFile parseerror\ ParseErrorparsectParsecT parsecmap parsecMapparsecParsec parsecparseparseparensparens optionmaybe' optionMaybeoptionalJoptionaloptionhoption~opstartopStart|}opletteropLetterz{ operatortable OperatorTableyoperatorOperatorwoperatorxoneof%oneOfvok<OkoctdigitRoctDigituoctalooctalt notfollowedby notFollowedBysnoneofnoneOfrnewposnewPosqnewlinenewlinepnewerrorunknownnewErrorUnknownonewerrormessageAnewErrorMessagennestedcommentsnnestedCommentslmnaturalorfloatnaturalOrFloatknaturalnaturalj mondriandef mondrianDefimondrianmondrianh modifystate+ modifyState messagestringO messageStringg messageequ messageEqfmessagecomparemessageCompareemessageMessagecdmergeerrorreplymergeErrorReply mergeerror  mergeErrorbmanytill.manyTilla manyaccumO manyAccummany1imany1`manymany_maketokenparsermakeTokenParser^lowerlower] lookahead lookAhead~\lineLine|}[lexeme&lexeme{ZletterBletterzYlazy\Lazy languagedefw LanguageDefwxyUVWXlanguageLanguage labelslabelsvTlabellabeluS javastyle javaStyletRinteger%integersQ initialposF initialPosrPinfixeInfixqO incsourceline incSourceLineopNincsourcecolumnincSourceColumnmnM identstart identStartlKL identletter identLetterkIJ identifier> identifierjHhexdigit`hexDigitiG hexadecimal hexadecimalhF haskellstyle haskellStylegE haskelldef haskellDeffDhaskellhaskelleCgetstategetStatedB getposition3 getPositioncAgetparserstate\getParserStateb@getinputgetInputa?gentokenparserGenTokenParser`> genparser GenParser^_<=genlanguagedefGenLanguageDef\]:;float)float[9exprBExprexpect\ExpectZ8errorposzerrorPosXY7 errormessages errorMessagesW6errorisunknownerrorIsUnknownV5errorErrorUeofeofT4endby1*endBy1S3endbyEendByR2emptydefbemptyDefQ1emptyEmptyPdotdotO0digitdigitN/decimaldecimalM.countcountL-consumedConsumedJK commentstart$ commentStartI+, commentlineO commentLineH)* commentendx commentEndG'( commasep1 commaSep1F&commasepcommaSepE%commacommaD$ combinator CombinatorcolumnColumnBC#colon?colonA"choiceZchoice@! charparserz CharParser  charliteral charLiteral?charCharchar>chainr1chainr1=chainrchainr<chainl1chainl1;chainl:chainl: casesensitive] caseSensitive9 bytestring ByteStringbuildexpressionparserbuildExpressionParser8bracketsbrackets7bracesbraces6betweenbetween5 assocright< AssocRight4 assocnone_ AssocNone3 assocleft AssocLeft2assocAssoc1anytokenanyToken0anycharanyChar/anglesangles. alphanumalphaNum- adderrormessage=addErrorMessage, <||>`<||>+ <|?>x<|?>* <|><|>)(<$?><$?>'<$$><$$>&b C(&be2<ldn6h>4NNgc7OFobH9ɯD̫ʪƩ'أ}&eןPR  fE|rȑygى_DŽ3Ёmb~1{zzyxt)sqpnmlh$hgeged/cSa`_s_^]<\1Y X*WV#U%T#RPcOLN[LJdI/HE>EyDCB7A?G=::T:k987n7643S100^/*/-,L+*)(%"!e `zA?m>>V j  H J  R@S~Sbw~1v-\4]I=2pJ0uۺ۷öGyU_VɨrV;ÚaX@a<>R1hՁ^р}~}{ezJy8x&w_vutsrp5ppo omljicf/f6eRd``^:]pZYU)UTTSSxRPN(N\MLHLKJIFDCBZBX@?q><;:8]75410 .+[++) )h&%m%#$#o" # l$9\,U   1 3 ;a&R9zKz whiteSpace whiteSpace :: GenTokenParser s u m -> ParsecT s u m ()lGenTokenParsersumParsecTsum()#Parses any white space. White space consists of zero or more occurrences of a space, a line comment or a block (multi line) comment. Block comments may be nested. How comments are started and ended is defined in the LanguageDef that is passed to makeTokenParser. upperupper :: Stream s m Char => ParsecT s u m CharJStreamsmCharParsecTsumChar]Parses an upper case letter (a character between 'A' and 'Z'). Returns the parsed character.  updateState updateState ::  Monad m => (u -> u) -> ParsecT s u m ()@MonadmuuParsecTsum()6An alias for modifyState for backwards compatibility. updatePosStringupdatePosString ::  SourcePos -> String ->  SourcePos  SourcePosString SourcePosThe expression updatePosString pos s updates the source position pos by calling updatePosChar on every character in s, ie. foldl updatePosChar pos string.  updatePosChar updatePosChar ::  SourcePos -> Char ->  SourcePos\= SourcePosChar SourcePosQUpdate a source position given a character. If the character is a newline ('\n') or carriage return ('\r') the line number is incremented by 1. If the character is a tab ('t') the column number is incremented to the nearest 8'th column, ie. column + 8 - ((column-1) `mod` 8). In all other cases, the column is incremented by 1.  unexpected unexpected :: Stream s m t => String -> ParsecT s u m aLStreamsmtStringParsecTsumaThe parser unexpected msg always fails with an unexpected error message msg without consuming any input. The parsers fail, (<?>) and unexpected are the three parsers used to generate error messages. Of these, only (<?>) is commonly used. For an example of the use of unexpected, see the definition of Text.Parsec.Combinator.notFollowedBy. UnExpectUnExpect :: String -> MessageG3StringMessagetrytry :: GenParser tok st a -> GenParser tok st a GenParsertoksta GenParsertokstatokens tokens :: (Stream s m t, Eq t) => ([t] -> String) -> (SourcePos -> [t] -> SourcePos) -> [t] -> ParsecT s u m [t]StreamsmtEqt[]tString SourcePos[]t SourcePos[]tParsecTsum[]t tokenPrimEx  tokenPrimEx :: Stream s m t =>  (t -> String) -> "(SourcePos -> t -> s -> SourcePos) -> %Maybe (SourcePos -> t -> s -> u -> u) -> (t -> Maybe a) -> ParsecT s u m avStreamsmttString SourcePosts SourcePosMaybe SourcePostsuutMaybeaParsecTsuma tokenPrim tokenPrim :: Stream s m t => t -> String ->  SourcePos -> t -> s ->  SourcePos -> t -> Maybe a -> ParsecT s u m aOStreamsmt tString SourcePosts SourcePostMaybeaParsecTsumaThe parser token showTok nextPos testTok accepts a token t with result x when the function testTok t returns Just x. The token can be shown using showTok t. The position of the next token should be returned when nextPos is called with the current source position pos, the current token t and the rest of the tokens toks, nextPos pos t toks. This is the most primitive combinator for accepting tokens. For example, the Text.Parsec.Char.char parser could be implemented as:
char c
  = tokenPrim showChar nextPos testChar
  where
    showChar x        = "'" ++ x ++ "'"
    testChar x        = if x == c then Just x else Nothing
    nextPos pos x xs  = updatePosChar pos x
 TokenParserX TokenParser :: ParsecT s u m String -> String -> ParsecT s u m () -> ParsecT s u m String -> String -> ParsecT s u m () -> ParsecT s u m Char -> ParsecT s u m String -> ParsecT s u m Integer ->  ParsecT s u m Integer ->  ParsecT s u m Double ->  %ParsecT s u m (Either Integer Double) ->  ParsecT s u m Integer ->  ParsecT s u m Integer -> ParsecT s u m Integer -> String -> ParsecT s u m String -> ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m () -> ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m String -> ParsecT s u m String ->  ParsecT s u m String -> !ParsecT s u m String -> "ParsecT s u m a -> #ParsecT s u m [a] -> $ParsecT s u m a -> %ParsecT s u m [a] -> &ParsecT s u m a -> 'ParsecT s u m [a] -> (ParsecT s u m a -> )ParsecT s u m [a] -> GenTokenParser s u m+ParsecTsumStringStringParsecTsum()ParsecTsumStringStringParsecTsum()ParsecTsumCharParsecTsumStringParsecTsumIntegerParsecTsumIntegerParsecTsumDoubleParsecTsumEitherIntegerDoubleParsecTsumIntegerParsecTsumIntegerParsecTsumIntegerStringParsecTsumStringParsecTsumaParsecTsumaParsecTsum()ParsecTsumaParsecTsumaParsecTsumaParsecTsumaParsecTsumaParsecTsumaParsecTsumaParsecTsumaParsecTsumaParsecTsumaParsecTsumStringParsecTsumStringParsecTsumStringParsecTsumStringParsecTsumaParsecTsum[]aParsecTsumaParsecTsum[]aParsecTsumaParsecTsum[]aParsecTsumaParsecTsum[]aGenTokenParsersum TokenParsertype  TokenParser st$ = GenTokenParser String st Identity|tokentoken :: Stream s Identity t => t -> String -> t ->  SourcePos -> t -> Maybe a ->  Parsec s u a/StreamsIdentityttStringt SourcePostMaybeaParsecsuaThe parser token showTok posFromTok testTok accepts a token t with result x when the function testTok t returns Just x. The source position of the t should be returned by posFromTok t and the token can be shown using showTok t. This combinator is expressed in terms of tokenPrim. It is used to accept user defined token streams. For example, suppose that we have a stream of basic tokens tupled with source positions. We can than define a parser that accepts single tokens as:
mytoken x
  = token showTok posFromTok testTok
  where
    showTok (pos,t)     = show t
    posFromTok (pos,t)  = pos
    testTok (pos,t)     = if x == t then Just t else Nothing
tabtab :: Stream s m Char => ParsecT s u m CharStreamsmCharParsecTsumChar8Parses a tab character ('\t'). Returns a tab character.  SysUnExpect SysUnExpect :: String -> MessageStringMessagesymbolsymbol :: GenTokenParser s u m -> String -> ParsecT s u m StringVGenTokenParsersumStringParsecTsumString`Lexeme parser symbol s parses string s and skips trailing white space.  stringLiteral stringLiteral :: GenTokenParser s u m -> ParsecT s u m Stringc)GenTokenParsersumParsecTsumStringThis lexeme parser parses a literal string. Returns the literal string value. This parsers deals correctly with escape sequences and gaps. The literal string is parsed according to the grammar rules defined in the Haskell report (which matches most programming languages quite closely). stringstring :: Stream s m Char => String -> ParsecT s u m String)StreamsmCharStringParsecTsumStringstring s parses a sequence of characters given by s. Returns the parsed string (i.e. s).
divOrMod    =   string "div" 
            <|> string "mod"
 stateUser stateUser ::  State s u -> uN9StatesuustatePosstatePos ::  State s u ->  SourcePosStatesu SourcePos stateInput stateInput ::  State s u -> s" StatesusState State :: s ->  SourcePos -> u ->  State s us SourcePosuStatesuStatedata State s usquaressquares :: GenTokenParser s u m -> ParsecT s u m a -> ParsecT s u m a[GenTokenParsersumParsecTsumaParsecTsuma!DEPRECATED: Use brackets. spacesspaces :: Stream s m Char => ParsecT s u m ()KStreamsmCharParsecTsum()LSkips zero or more white space characters. See also skipMany. spacespace :: Stream s m Char => ParsecT s u m CharStreamsmCharParsecTsumCharlParses a white space character (any character which satisfies isSpace) Returns the parsed character.  SourcePosdata  SourcePosThe abstract data type SourcePos represents source positions. It contains the name of the source (i.e. file name), a line number and a column number. SourcePos is an instance of the Show, Eq and Ord class.  sourceName sourceName ::  SourcePos ->  SourceName%  SourcePos SourceName8Extracts the name of the source from a source position.  SourceNametype  SourceName = String sourceLine sourceLine ::  SourcePos -> Line SourcePosLine1Extracts the line number from a source position.  sourceColumn sourceColumn ::  SourcePos -> Column SourcePosColumn3Extracts the column number from a source position.  skipMany1 skipMany1 :: Stream s m t => ParsecT s u m a -> ParsecT s u m ()JStreamsmtParsecTsumaParsecTsum()bskipMany1 p applies the parser p one or more times, skipping its result. skipManyskipMany :: Stream s m t => ParsecT s u m a -> ParsecT s u m () a StreamsmtParsecTsumaParsecTsum()skipMany p applies the parser p zero or more times, skipping its result.
spaces  = skipMany space
showErrorMessagesshowErrorMessages :: String -> String -> String -> String -> String ->  [Message] -> String-  StringStringStringStringString[]MessageStringsetStatesetState ::  Monad m => u -> ParsecT s u m ()  MonadmuParsecTsum()3An alias for putState for backwards compatibility.  setSourceName setSourceName ::  SourcePos ->  SourceName ->  SourcePos Z  SourcePos SourceName SourcePosSet the name of the source.  setSourceLine setSourceLine ::  SourcePos -> Line ->  SourcePos'   SourcePosLine SourcePos*Set the line number of a source position. setSourceColumnsetSourceColumn ::  SourcePos -> Column ->  SourcePos   SourcePosColumn SourcePos,Set the column number of a source position.  setPosition setPosition ::  Monad m =>  SourcePos -> ParsecT s u m ()|Monadm SourcePosParsecTsum()KsetPosition pos sets the current source position to pos. setParserStatesetParserState ::  Monad m =>  State s u -> ParsecT s u m (State s u)sMonadmStatesuParsecTsumStatesuEsetParserState st set the full parser state to st. setInputsetInput ::  Monad m => s -> ParsecT s u m ()VMonadmsParsecTsum()setInput input continues parsing with input. The getInput and setInput functions can for example be used to deal with #include files.  setErrorPos setErrorPos ::  SourcePos ->  ParseError ->  ParseError SourcePos ParseError ParseErrorsetErrorMessagesetErrorMessage :: Message ->  ParseError ->  ParseErrorX4Message ParseError ParseError sepEndBy1 sepEndBy1 :: Stream s m t => ParsecT s u m a -> ParsecT s u m sep -> ParsecT s u m [a]KStreamsmtParsecTsumaParsecTsumsepParsecTsum[]asepEndBy1 p sep parses one or more occurrences of p, separated and optionally ended by sep. Returns a list of values returned by p. sepEndBysepEndBy :: Stream s m t => ParsecT s u m a -> ParsecT s u m sep -> ParsecT s u m [a]StreamsmtParsecTsumaParsecTsumsepParsecTsum[]asepEndBy p sep parses zero or more occurrences of p, separated and optionally ended by sep, ie. haskell style statements. Returns a list of values returned by p.
haskellStatements  = haskellStatement `sepEndBy` semi
sepBy1sepBy1 :: Stream s m t => ParsecT s u m a -> ParsecT s u m sep -> ParsecT s u m [a]StreamsmtParsecTsumaParsecTsumsepParsecTsum[]asepBy1 p sep parses one or more occurrences of p, separated by sep. Returns a list of values returned by p. sepBysepBy :: Stream s m t => ParsecT s u m a -> ParsecT s u m sep -> ParsecT s u m [a]kStreamsmtParsecTsumaParsecTsumsepParsecTsum[]asepBy p sep parses zero or more occurrences of p, separated by sep. Returns a list of values returned by p.
commaSep p  = p `sepBy` (symbol ",")
semiSep1semiSep1 :: GenTokenParser s u m -> ParsecT s u m a -> ParsecT s u m [a]GenTokenParsersumParsecTsumaParsecTsum[]aLexeme parser semiSep1 p parses one or more occurrences of p separated by semi. Returns a list of values returned by p. semiSepsemiSep :: GenTokenParser s u m -> ParsecT s u m a -> ParsecT s u m [a]z(GenTokenParsersumParsecTsumaParsecTsum[]aLexeme parser semiSep p parses zero or more occurrences of p separated by semi. Returns a list of values returned by p. semisemi :: GenTokenParser s u m -> ParsecT s u m String|GenTokenParsersumParsecTsumStringjLexeme parser |semi| parses the character ';' and skips any trailing white space. Returns the string ";". satisfysatisfy :: Stream s m Char => (Char -> Bool) -> ParsecT s u m CharStreamsmCharCharBoolParsecTsumCharThe parser satisfy f succeeds for any character for which the supplied function f returns True. Returns the character that is actually parsed.  runParser  runParser :: GenParser tok st a -> st ->  SourceName -> [tok] -> Either ParseError ah GenParsertokstast SourceName[]tokEither ParseErrorareservedOpNamesreservedOpNames :: GenLanguageDef s u m -> [String]GenLanguageDefsum[]String The list of reserved operators. reservedOpNamesreservedOpNames :: GenLanguageDef s u m -> [String]  GenLanguageDefsum[]String The list of reserved operators.  reservedOp reservedOp :: GenTokenParser s u m -> String -> ParsecT s u m ()!Q!GenTokenParsersumStringParsecTsum()The lexeme parser reservedOp name parses symbol name, but it also checks that the name is not a prefix of a valid operator. A reservedOp is treated as a single token using try.  reservedNames reservedNames :: GenLanguageDef s u m -> [String]""GenLanguageDefsum[]String"The list of reserved identifiers.  reservedNames reservedNames :: GenLanguageDef s u m -> [String]##GenLanguageDefsum[]String"The list of reserved identifiers. reservedreserved :: GenTokenParser s u m -> String -> ParsecT s u m ()$L$GenTokenParsersumStringParsecTsum()The lexeme parser reserved name parses symbol name, but it also checks that the name is not a prefix of a valid identifier. A reserved word is treated as a single token using try. pzeropzero :: GenParser tok st a%% GenParsertokstaPrefixPrefix :: GenParser tok st (a -> a) -> Operator tok st ad&+& GenParsertokstaaOperatortokstapermutepermute :: Stream s Identity tok => StreamPermParser s st a ->  Parsec s st a1'&StreamsIdentitytokStreamPermParsersstaParsecsstaThe parser permute perm parses a permutation of parser described by perm. For example, suppose we want to parse a permutation of: an optional string of a's, the character b and an optional c. This can be described by:
test  = permute (tuple <$?> ("",many1 (char 'a'))
                       <||> char 'b' 
                       <|?> ('_',char 'c'))
      where
        tuple a b c  = (a,b,c)
 PermParsertype  PermParser tok st a = StreamPermParser String st ai)?Provided for backwards compatibility. The tok type is ignored.  parseTest parseTest :: !(Stream s Identity t, Show a) =>  Parsec s () a -> s -> IO ()t*+*StreamsIdentitytShowaParsecs()asIO()The expression parseTest p input applies a parser p against input input and prints the result to stdout. Used for testing parsers. Parsertype Parser = Parsec String ()W+Parsertype Parser = Parsec ByteString ()+ parseFromFile parseFromFile :: Parser a -> String -> IO (Either ParseError a)T,,ParseraStringIOEither ParseErroraparseFromFile p filePath runs a string parser p on the input read from filePath using readFile. Returns either a ParseError (Left) or a value of type a (Right).
main    = do{ result <- parseFromFile numbers "digits.txt"
            ; case result of
                Left err  -> print err
                Right xs  -> print (sum xs)
            }
 parseFromFile parseFromFile :: Parser a -> String -> IO (Either ParseError a)..ParseraStringIOEither ParseErroraparseFromFile p filePath runs a lazy bytestring parser p on the input read from filePath using ByteString.Lazy.Char8.readFile. Returns either a ParseError (Left) or a value of type a (Right).
main    = do{ result <- parseFromFile numbers "digits.txt"
            ; case result of
                Left err  -> print err
                Right xs  -> print (sum xs)
            }
 ParseErrordata  ParseError0>The abstract data type ParseError represents parse errors. It provides the source position (SourcePos) of the error and a list of error messages (Message). A ParseError can be returned by the function Text.Parsec.Prim.parse. ParseError is an instance of the Show class. parse parse :: Stream s Identity t =>  Parsec s () a ->  SourceName -> s -> Either ParseError a22StreamsIdentitytParsecs()a SourceNamesEither ParseErroraparse p filePath input runs a parser p over Identity without user state. The filePath is only used in error messages and may be the empty string. Returns either a ParseError (Left) or a value of type a (Right).
main    = case (parse numbers "" "11, 2, 43") of
           Left err  -> print err
           Right xs  -> print (sum xs)

numbers = commaSep integer
parensparens :: GenTokenParser s u m -> ParsecT s u m a -> ParsecT s u m ac55GenTokenParsersumParsecTsumaParsecTsumanLexeme parser parens p parses p enclosed in parenthesis, returning the value of p.  optionMaybe optionMaybe :: Stream s m t => ParsecT s u m a -> ParsecT s u m (Maybe a)6N6StreamsmtParsecTsumaParsecTsumMaybeaoption p tries to apply parser p. If p fails without consuming input, it return Nothing, otherwise it returns Just the value returned by p. optionaloptional :: Stream s m t => ParsecT s u m a -> ParsecT s u m ()87StreamsmtParsecTsumaParsecTsum()optional p tries to apply parser p. It will parse p or nothing. It only fails if p fails after consuming input. It discards the result of p. optionoption :: Stream s m t => a -> ParsecT s u m a -> ParsecT s u m a9@9StreamsmtaParsecTsumaParsecTsuma2option x p tries to apply parser p. If p fails without consuming input, it returns the value x, otherwise the value returned by p.
priority  = option 0 (do{ d <- digit
                        ; return (digitToInt d) 
                        })
opStartopStart :: GenLanguageDef s u m -> ParsecT s u m CharV;;GenLanguageDefsumParsecTsumCharzThis parser should accept any start characters of operators. For example oneOf ":!#$%&*+./<=>?@\\^|-~" opStartopStart :: GenLanguageDef s u m -> ParsecT s u m Charm<5<GenLanguageDefsumParsecTsumCharzThis parser should accept any start characters of operators. For example oneOf ":!#$%&*+./<=>?@\\^|-~" opLetteropLetter :: GenLanguageDef s u m -> ParsecT s u m Char=N=GenLanguageDefsumParsecTsumCharThis parser should accept any legal tail characters of operators. Note that this parser should even be defined if the language doesn't support user-defined operators, or otherwise the reservedOp parser won't work correctly. opLetteropLetter :: GenLanguageDef s u m -> ParsecT s u m Char ?>GenLanguageDefsumParsecTsumCharThis parser should accept any legal tail characters of operators. Note that this parser should even be defined if the language doesn't support user-defined operators, or otherwise the reservedOp parser won't work correctly.  OperatorTabletype  OperatorTable tok st a = [[Operator tok st a]]T@operatoroperator :: GenTokenParser s u m -> ParsecT s u m String@@GenTokenParsersumParsecTsumString_This lexeme parser parses a legal operator. Returns the name of the operator. This parser will fail on any operators that are reserved operators. Legal operator (start) characters and reserved operators are defined in the LanguageDef that is passed to makeTokenParser. An operator is treated as a single token using try. Operatordata Operator tok st aBoneOfoneOf :: Stream s m Char => [Char] -> ParsecT s u m Char8CBStreamsmChar[]CharParsecTsumCharoneOf cs succeeds if the current character is in the supplied list of characters cs. Returns the parsed character. See also satisfy.
vowel  = oneOf "aeiou"
octDigitoctDigit :: Stream s m Char => ParsecT s u m CharDUDStreamsmCharParsecTsumCharWParses an octal digit (a character between '0' and '7'). Returns the parsed character. octaloctal :: GenTokenParser s u m -> ParsecT s u m Integer|EAEGenTokenParsersumParsecTsumIntegerParses a positive whole number in the octal system. The number should be prefixed with "0o" or "0O". Returns the value of the number.  notFollowedBy notFollowedBy :: (Stream s m t, Show t) => ParsecT s u m t -> ParsecT s u m ()FFStreamsmtShowtParsecTsumtParsecTsum()7notFollowedBy p only succeeds when parser p fails. This parser does not consume any input. This parser can be used to implement the 'longest match' rule. For example, when recognizing keywords (for example let), we want to make sure that a keyword is not followed by a legal identifier character, in which case the keyword is actually an identifier (for example lets). We can program this behaviour as follows:
keywordLet  = try (do{ string "let"
                     ; notFollowedBy alphaNum
                     })
noneOfnoneOf :: Stream s m Char => [Char] -> ParsecT s u m CharIuIStreamsmChar[]CharParsecTsumCharAs the dual of oneOf, noneOf cs succeeds if the current character not in the supplied list of characters cs. Returns the parsed character.
consonant = noneOf "aeiou"
newPos newPos ::  SourceName -> Line -> Column ->  SourcePos"KJ SourceNameLineColumn SourcePosYCreate a new SourcePos with the given source name, line number and column number. newlinenewline :: Stream s m Char => ParsecT s u m CharLKStreamsmCharParsecTsumChar@Parses a newline character ('\n'). Returns a newline character. newErrorUnknownnewErrorUnknown ::  SourcePos ->  ParseErrorLL SourcePos ParseErrornewErrorMessagenewErrorMessage :: Message ->  SourcePos ->  ParseErrorXM5MMessage SourcePos ParseErrornestedCommentsnestedComments :: GenLanguageDef s u m -> BoolMMGenLanguageDefsumBoolCSet to True if the language supports nested block comments. nestedCommentsnestedComments :: GenLanguageDef s u m -> BoolNNGenLanguageDefsumBoolCSet to True if the language supports nested block comments. naturalOrFloatnaturalOrFloat :: GenTokenParser s u m -> %ParsecT s u m (Either Integer Double)OvOGenTokenParsersumParsecTsumEitherIntegerDouble This lexeme parser parses either natural or a float. Returns the value of the number. This parsers deals with any overlap in the grammar rules for naturals and floats. The number is parsed according to the grammar rules defined in the Haskell report. naturalnatural :: GenTokenParser s u m -> ParsecT s u m IntegeroQ4QGenTokenParsersumParsecTsumIntegerThis lexeme parser parses a natural number (a positive whole number). Returns the value of the number. The number can be specified in decimal, hexadecimal or octal. The number is parsed according to the grammar rules in the Haskell report.  mondrianDef mondrianDef :: LanguageDef stRR LanguageDefst3The language definition for the language Mondrian. mondrianmondrian :: TokenParser st[SGS TokenParserst#A lexer for the mondrian language.  messageString messageString :: Message -> StringSSMessageString1Extract the message string from an error message  messageEq messageEq :: Message -> Message -> BoolT|TMessageMessageBoolmessageComparemessageCompare :: Message -> Message -> Ordering%UUMessageMessageOrderingMessageMessage :: String -> MessageUqUStringMessageMessagedata MessageUThis abstract data type represents parse error messages. There are four kinds of messages:
data Message = SysUnExpect String
             | UnExpect String
             | Expect String
             | Message String
The fine distinction between different kinds of parse errors allows the system to generate quite good error messages for the user. It also allows error messages that are formatted in different languages. Each kind of message is generated by different combinators:
  • A SysUnExpect message is automatically generated by the Text.Parsec.Combinator.satisfy combinator. The argument is the unexpected input.
  • A UnExpect message is generated by the Text.Parsec.Prim.unexpected combinator. The argument describes the unexpected item.
  • A Expect message is generated by the Text.Parsec.Prim.<?> combinator. The argument describes the expected item.
  • A Message message is generated by the fail combinator. The argument is some general parser message.
 mergeError mergeError ::  ParseError ->  ParseError ->  ParseErrorlZEZ ParseError ParseError ParseErrormanyTillmanyTill :: Stream s m t => ParsecT s u m a -> ParsecT s u m end -> ParsecT s u m [a]][ZStreamsmtParsecTsumaParsecTsumendParsecTsum[]amanyTill p end applies parser p zero or more times until parser end succeeds. Returns the list of values returned by p. This parser can be used to scan comments:
simpleComment   = do{ string "<!--"
                    ; manyTill anyChar (try (string "-->"))
                    }
Note the overlapping parsers anyChar and string "<!--", and therefore the use of the try combinator. many1many1 :: Stream s m t => ParsecT s u m a -> ParsecT s u m [a]]]StreamsmtParsecTsumaParsecTsum[]amany p applies the parser p one or more times. Returns a list of the returned values of p.
word  = many1 letter
manymany :: Stream s m t => ParsecT s u m a -> ParsecT s u m [a]>_^StreamsmtParsecTsumaParsecTsum[]amany p applies the parser p zero or more times. Returns a list of the returned values of p.
identifier  = do{ c  <- letter
                ; cs <- many (alphaNum <|> char '_')
                ; return (c:cs)
                }
makeTokenParsermakeTokenParser :: Stream s m Char => GenLanguageDef s u m -> GenTokenParser s u m5a`StreamsmCharGenLanguageDefsumGenTokenParsersumThe expression makeTokenParser language creates a GenTokenParser record that contains lexical parsers that are defined using the definitions in the language record. The use of this function is quite stylized - one imports the appropiate language definition and selects the lexical parsers that are needed from the resulting GenTokenParser.
module Main where

import Text.Parsec
import qualified Text.Parsec.Token as P
import Text.Parsec.Language (haskellDef)

-- The parser
...

expr  =   parens expr
      <|> identifier
      <|> ...
     

-- The lexer
lexer       = P.makeTokenParser haskellDef    
    
parens      = P.parens lexer
braces      = P.braces lexer
identifier  = P.identifier lexer
reserved    = P.reserved lexer
...
lowerlower :: Stream s m Char => ParsecT s u m CharddStreamsmCharParsecTsumChar_Parses a lower case character (a character between 'a' and 'z'). Returns the parsed character.  lookAhead lookAhead :: Stream s m t => ParsecT s u m a -> ParsecT s u m aeeStreamsmtParsecTsumaParsecTsumaDlookAhead p parses p without consuming any input. Linetype Line = Int_flexemelexeme :: GenTokenParser s u m -> ParsecT s u m a -> ParsecT s u m a&gfGenTokenParsersumParsecTsumaParsecTsumalexeme p first applies parser p and than the whiteSpace parser, returning the value of p. Every lexical token (lexeme) is defined using lexeme, this way every parse starts at a point without white space. Parsers that use lexeme are called lexeme parsers in this document. The only point where the whiteSpace parser should be called explicitly is the start of the main parser in order to skip any leading white space.
mainParser  = do{ whiteSpace
                 ; ds <- many (lexeme digit)
                 ; eof
                 ; return (sum ds)
                 }
letterletter :: Stream s m Char => ParsecT s u m Char9jjStreamsmCharParsecTsumCharWParses a letter (an upper case or lower case character). Returns the parsed character.  LanguageDef LanguageDef :: String -> String -> String -> Bool -> ParsecT s u m Char -> ParsecT s u m Char -> ParsecT s u m Char -> ParsecT s u m Char -> [String] ->  [String] ->  Bool -> GenLanguageDef s u mlk StringStringStringBoolParsecTsumCharParsecTsumCharParsecTsumCharParsecTsumChar[]String[]StringBoolGenLanguageDefsum LanguageDeftype  LanguageDef st$ = GenLanguageDef String st Identityl LanguageDef LanguageDef :: String -> String -> String -> Bool -> ParsecT s u m Char -> ParsecT s u m Char -> ParsecT s u m Char -> ParsecT s u m Char -> [String] ->  [String] ->  Bool -> GenLanguageDef s u m oCn StringStringStringBoolParsecTsumCharParsecTsumCharParsecTsumCharParsecTsumChar[]String[]StringBoolGenLanguageDefsum LanguageDeftype  LanguageDef st$ = GenLanguageDef String st Identitylolabelslabels ::  Monad m => ParsecT s u m a -> [String] -> ParsecT s u m a1poMonadmParsecTsuma[]StringParsecTsumalabellabel ::  Monad m => ParsecT s u m a -> String -> ParsecT s u m appMonadmParsecTsumaStringParsecTsuma javaStyle javaStyle :: LanguageDef stEq1q LanguageDefstThis is a minimal token definition for Java style languages. It defines the style of comments, valid identifiers and case sensitivity. It does not define any reserved words or operators. integerinteger :: GenTokenParser s u m -> ParsecT s u m IntegerrhrGenTokenParsersumParsecTsumIntegerUThis lexeme parser parses an integer (a whole number). This parser is like natural except that it can be prefixed with sign (i.e. '-' or '+'). Returns the value of the number. The number can be specified in decimal, hexadecimal or octal. The number is parsed according to the grammar rules in the Haskell report.  initialPos initialPos ::  SourceName ->  SourcePosjtPt SourceName SourcePosvCreate a new SourcePos with the given source name, and line number and column number set to 1, the upper left. InfixInfix :: GenParser tok st (a -> a -> a) -> Assoc -> Operator tok st au[u GenParsertokstaaaAssocOperatortoksta incSourceLine incSourceLine ::  SourcePos -> Line ->  SourcePos*v v SourcePosLine SourcePos1Increments the line number of a source position. incSourceColumnincSourceColumn ::  SourcePos -> Column ->  SourcePosvv SourcePosColumn SourcePos3Increments the column number of a source position.  identStart identStart :: GenLanguageDef s u m -> ParsecT s u m CharwwGenLanguageDefsumParsecTsumCharoThis parser should accept any start characters of identifiers. For example letter <|> char "_".  identStart identStart :: GenLanguageDef s u m -> ParsecT s u m CharxxGenLanguageDefsumParsecTsumCharoThis parser should accept any start characters of identifiers. For example letter <|> char "_".  identLetter identLetter :: GenLanguageDef s u m -> ParsecT s u m CharyyGenLanguageDefsumParsecTsumCharvThis parser should accept any legal tail characters of identifiers. For example alphaNum <|> char "_".  identLetter identLetter :: GenLanguageDef s u m -> ParsecT s u m Char{zGenLanguageDefsumParsecTsumCharvThis parser should accept any legal tail characters of identifiers. For example alphaNum <|> char "_".  identifier identifier :: GenTokenParser s u m -> ParsecT s u m String#|{GenTokenParsersumParsecTsumStringXThis lexeme parser parses a legal identifier. Returns the identifier string. This parser will fail on identifiers that are reserved words. Legal identifier (start) characters and reserved words are defined in the LanguageDef that is passed to makeTokenParser. An identifier is treated as a single token using try. hexDigithexDigit :: Stream s m Char => ParsecT s u m Char~}StreamsmCharParsecTsumCharsParses a hexadecimal digit (a digit or a letter between 'a' and 'f' or 'A' and 'F'). Returns the parsed character.  hexadecimal hexadecimal :: GenTokenParser s u m -> ParsecT s u m Integer$~GenTokenParsersumParsecTsumIntegerParses a positive whole number in the hexadecimal system. The number should be prefixed with "0x" or "0X". Returns the value of the number.  haskellStyle haskellStyle :: LanguageDef st LanguageDefstThis is a minimal token definition for Haskell style languages. It defines the style of comments, valid identifiers and case sensitivity. It does not define any reserved words or operators.  haskellDef haskellDef :: LanguageDef st( LanguageDefst2The language definition for the Haskell language. haskellhaskell :: TokenParser st TokenParserst"A lexer for the haskell language. getStategetState ::  Monad m => ParsecT s u m uD MonadmParsecTsumu Returns the current user state.  getPosition getPosition ::  Monad m => ParsecT s u m SourcePosMonadmParsecTsum SourcePos@Returns the current source position. See also SourcePos. getParserStategetParserState ::  Monad m => ParsecT s u m (State s u)ƒMonadmParsecTsumStatesu8Returns the full parser state as a State record. getInputgetInput ::  Monad m => ParsecT s u m smIMonadmParsecTsumsReturns the current input GenTokenParserdata GenTokenParser s u m̈́The type of the record that holds lexical parsers that work on s streams with state u over a monad m.  GenParsertype  GenParser tok st = Parsec [tok] st GenParsertype  GenParser t st = Parsec ByteString stGenLanguageDefdata GenLanguageDef s u m9The GenLanguageDef type is a record that contains all parameterizable features of the Text.Parsec.Token module. The module Text.Parsec.Language contains some default definitions. GenLanguageDefdata GenLanguageDef s u m;The GenLanguageDef type is a record that contains all parameterizable features of the Text.Parsec.Token module. The module Text.Parsec.Language contains some default definitions. floatfloat :: GenTokenParser s u m -> ParsecT s u m DoubleZGenTokenParsersumParsecTsumDoubleThis lexeme parser parses a floating point value. Returns the value of the number. The number is parsed according to the grammar rules defined in the Haskell report. ExpectExpect :: String -> MessageStringMessageerrorPoserrorPos ::  ParseError ->  SourcePos ParseError SourcePos2Extracts the source position from the parse error  errorMessages errorMessages ::  ParseError ->  [Message] ParseError[]Message9Extracts the list of error messages from the parse error errorIsUnknownerrorIsUnknown ::  ParseError -> Bool]H ParseErrorBooleofeof :: (Stream s m t, Show t) => ParsecT s u m ()StreamsmtShowtParsecTsum()This parser only succeeds at the end of the input. This is not a primitive parser but it is defined using notFollowedBy.
eof  = notFollowedBy anyToken <?> "end of input"
endBy1endBy1 :: Stream s m t => ParsecT s u m a -> ParsecT s u m sep -> ParsecT s u m [a]8StreamsmtParsecTsumaParsecTsumsepParsecTsum[]aendBy1 p sep parses one or more occurrences of p, seperated and ended by sep. Returns a list of values returned by p. endByendBy :: Stream s m t => ParsecT s u m a -> ParsecT s u m sep -> ParsecT s u m [a]'ĎStreamsmtParsecTsumaParsecTsumsepParsecTsum[]aendBy p sep parses zero or more occurrences of p, seperated and ended by sep. Returns a list of values returned by p.
cStatements  = cStatement `endBy` semi
emptyDefemptyDef :: LanguageDef stT@ LanguageDefstdotdot :: GenTokenParser s u m -> ParsecT s u m StringGenTokenParsersumParsecTsumStringpLexeme parser dot parses the character '.' and skips any trailing white space. Returns the string ".". digitdigit :: Stream s m Char => ParsecT s u m CharStreamsmCharParsecTsumChar.Parses a digit. Returns the parsed character. decimaldecimal :: GenTokenParser s u m -> ParsecT s u m IntegerxGenTokenParsersumParsecTsumIntegerWParses a positive whole number in the decimal system. Returns the value of the number. countcount :: Stream s m t => Int -> ParsecT s u m a -> ParsecT s u m [a]ӓStreamsmtIntParsecTsumaParsecTsum[]acount n p parses n occurrences of p. If n is smaller or equal to zero, the parser equals to return []. Returns a list of n values returned by p.  commentStart commentStart :: GenLanguageDef s u m -> String,GenLanguageDefsumStringDescribes the start of a block comment. Use the empty string if the language doesn't support block comments. For example "/*".  commentStart commentStart :: GenLanguageDef s u m -> String4GenLanguageDefsumStringDescribes the start of a block comment. Use the empty string if the language doesn't support block comments. For example "/*".  commentLine commentLine :: GenLanguageDef s u m -> String:GenLanguageDefsumString}Describes the start of a line comment. Use the empty string if the language doesn't support line comments. For example "//".  commentLine commentLine :: GenLanguageDef s u m -> String>GenLanguageDefsumString}Describes the start of a line comment. Use the empty string if the language doesn't support line comments. For example "//".  commentEnd commentEnd :: GenLanguageDef s u m -> String@GenLanguageDefsumString}Describes the end of a block comment. Use the empty string if the language doesn't support block comments. For example "*/".  commentEnd commentEnd :: GenLanguageDef s u m -> StringBGenLanguageDefsumString}Describes the end of a block comment. Use the empty string if the language doesn't support block comments. For example "*/".  commaSep1 commaSep1 :: GenTokenParser s u m -> ParsecT s u m a -> ParsecT s u m [a]BGenTokenParsersumParsecTsumaParsecTsum[]aLexeme parser commaSep1 p parses one or more occurrences of p separated by comma. Returns a list of values returned by p. commaSepcommaSep :: GenTokenParser s u m -> ParsecT s u m a -> ParsecT s u m [a] GenTokenParsersumParsecTsumaParsecTsum[]aLexeme parser commaSep p parses zero or more occurrences of p separated by comma. Returns a list of values returned by p. commacomma :: GenTokenParser s u m -> ParsecT s u m StringJGenTokenParsersumParsecTsumStringrLexeme parser comma parses the character ',' and skips any trailing white space. Returns the string ",". Columntype Column = Intcoloncolon :: GenTokenParser s u m -> ParsecT s u m StringWGenTokenParsersumParsecTsumStringrLexeme parser colon parses the character ':' and skips any trailing white space. Returns the string ":". choicechoice :: Stream s m t => [ParsecT s u m a] -> ParsecT s u m apStreamsmt[]ParsecTsumaParsecTsumachoice ps tries to apply the parsers in the list ps in order, until one of them succeeds. Returns the value of the succeeding parser.  CharParsertype  CharParser st = GenParser Char st charLiteral charLiteral :: GenTokenParser s u m -> ParsecT s u m CharHGenTokenParsersumParsecTsumChar&This lexeme parser parses a single literal character. Returns the literal character value. This parsers deals correctly with escape sequences. The literal character is parsed according to the grammar rules defined in the Haskell report (which matches most programming languages quite closely). charchar :: Stream s m Char => Char -> ParsecT s u m Char УStreamsmCharCharParsecTsumCharchar c parses a single character c. Returns the parsed character (i.e. c).
semiColon  = char ';'
chainr1chainr1 :: Stream s m t => ParsecT s u m a -> ParsecT s u m (a -> a -> a) -> ParsecT s u m a'StreamsmtParsecTsumaParsecTsumaaaParsecTsumachainr1 p op x parser one or more occurrences of |p|, separated by op Returns a value obtained by a right associative application of all functions returned by op to the values returned by p. chainr chainr :: Stream s m t => ParsecT s u m a -> ParsecT s u m (a -> a -> a) -> a -> ParsecT s u m aStreamsmtParsecTsumaParsecTsumaaaaParsecTsumaEchainr p op x parser zero or more occurrences of p, separated by op Returns a value obtained by a right associative application of all functions returned by op to the values returned by p. If there are no occurrences of p, the value x is returned. chainl1chainl1 :: Stream s m t => ParsecT s u m a -> ParsecT s u m (a -> a -> a) -> ParsecT s u m aYStreamsmtParsecTsumaParsecTsumaaaParsecTsumachainl1 p op x parser one or more occurrences of p, separated by op Returns a value obtained by a left associative application of all functions returned by op to the values returned by p. . This parser can for example be used to eliminate left recursion which typically occurs in expression grammars.
expr    = term   `chainl1` mulop
term    = factor `chainl1` addop
factor  = parens expr <|> integer

mulop   =   do{ symbol "*"; return (*)   }
        <|> do{ symbol "/"; return (div) }

addop   =   do{ symbol "+"; return (+) }
        <|> do{ symbol "-"; return (-) }
chainl chainl :: Stream s m t => ParsecT s u m a -> ParsecT s u m (a -> a -> a) -> a -> ParsecT s u m aWStreamsmtParsecTsumaParsecTsumaaaaParsecTsumaGchainl p op x parser zero or more occurrences of p, separated by op. Returns a value obtained by a left associative application of all functions returned by op to the values returned by p. If there are zero occurrences of p, the value x is returned.  caseSensitive caseSensitive :: GenLanguageDef s u m -> Bool%GenLanguageDefsumBool6Set to True if the language is case sensitive.  caseSensitive caseSensitive :: GenLanguageDef s u m -> BoolGenLanguageDefsumBool6Set to True if the language is case sensitive. buildExpressionParserbuildExpressionParser :: OperatorTable tok st a -> GenParser tok st a -> GenParser tok st a  OperatorTabletoksta GenParsertoksta GenParsertokstabracketsbrackets :: GenTokenParser s u m -> ParsecT s u m a -> ParsecT s u m aֱGenTokenParsersumParsecTsumaParsecTsuma{Lexeme parser brackets p parses p enclosed in brackets ('[' and ']'), returning the value of p. bracesbraces :: GenTokenParser s u m -> ParsecT s u m a -> ParsecT s u m a̲GenTokenParsersumParsecTsumaParsecTsumawLexeme parser braces p parses p enclosed in braces ('{' and '}'), returning the value of p. between between :: Stream s m t => ParsecT s u m open -> ParsecT s u m close -> ParsecT s u m a -> ParsecT s u m a9StreamsmtParsecTsumopenParsecTsumcloseParsecTsumaParsecTsumabetween open close p parses open, followed by p and close. Returns the value returned by p.
braces  = between (symbol "{") (symbol "}")
 AssocRight AssocRight :: AssocAssoc AssocNone AssocNone :: AssocAssoc AssocLeft AssocLeft :: AssocC;AssocAssocdata AssocqNThis data type specifies the associativity of operators: left, right or none. anyTokenanyToken :: (Stream s m t, Show t) => ParsecT s u m tSStreamsmtShowtParsecTsumtThe parser anyToken accepts any kind of token. It is for example used to implement eof. Returns the accepted token. anyCharanyChar :: Stream s m Char => ParsecT s u m Char`/StreamsmCharParsecTsumCharFThis parser succeeds for any character. Returns the parsed character. anglesangles :: GenTokenParser s u m -> ParsecT s u m a -> ParsecT s u m am!GenTokenParsersumParsecTsumaParsecTsumaLexeme parser angles p parses p enclosed in angle brackets ('<' and '>'), returning the value of p. alphaNumalphaNum :: Stream s m Char => ParsecT s u m Char}LStreamsmCharParsecTsumCharZParses a letter or digit (a character between '0' and '9'). Returns the parsed character. addErrorMessageaddErrorMessage :: Message ->  ParseError ->  ParseErrorqMMessage ParseError ParseError<||> (<||>) :: Stream s Identity tok => StreamPermParser s st (a -> b) ->  Parsec s st a -> StreamPermParser s st bStreamsIdentitytokStreamPermParsersstabParsecsstaStreamPermParsersstbThe expression perm <||> p adds parser p to the permutation parser perm. The parser p is not allowed to accept empty input - use the optional combinator (<|?>) instead. Returns a new permutation parser that includes p. <|?> (<|?>) :: Stream s Identity tok => StreamPermParser s st (a -> b) -> (a, Parsec s st a) -> StreamPermParser s st bϾQStreamsIdentitytokStreamPermParsersstab(,)aParsecsstaStreamPermParsersstb.The expression perm <||> (x,p) adds parser p to the permutation parser perm. The parser p is optional - if it can not be applied, the default value x will be used instead. Returns a new permutation parser that includes the optional parser p. <|> (<|>) ::  Monad m => ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a~MonadmParsecTsumaParsecTsumaParsecTsumaThis combinator implements choice. The parser p <|> q first applies p. If it succeeds, the value of p is returned. If p fails without consuming any input, parser q is tried. This combinator is defined equal to the mplus member of the MonadPlus class and the (Control.Applicative.<|>) member of Control.Applicative.Alternative. The parser is called predictive since q is only tried when parser p didn't consume any input (i.e.. the look ahead is 1). This non-backtracking behaviour allows for both an efficient implementation of the parser combinators and the generation of good error messages.  () ::  Monad m => ParsecT s u m a -> String -> ParsecT s u m aIMonadmParsecTsumaStringParsecTsumaThe parser p ? msg behaves as parser p, but whenever the parser p fails without consuming any input, it replaces expect error messages with the expect error message msg. This is normally used at the end of a set alternatives where we want to return an error message in terms of a higher level construct rather than returning all possible characters. For example, if the expr parser from the try example would fail, the error message is: '...: expecting expression'. Without the (<?>) combinator, the message would be like '...: expecting "let" or letter', which is less friendly. <$?> (<$?>) :: Stream s Identity tok => (a -> b) -> (a, Parsec s st a) -> StreamPermParser s st btStreamsIdentitytokab(,)aParsecsstaStreamPermParsersstbUThe expression f <$?> (x,p) creates a fresh permutation parser consisting of parser p. The the final result of the permutation parser is the function f applied to the return value of p. The parser p is optional - if it can not be applied, the default value x will be used instead. <$$> (<$$>) :: Stream s Identity tok => (a -> b) ->  Parsec s st a -> StreamPermParser s st bStreamsIdentitytokabParsecsstaStreamPermParsersstb1The expression f <$$> p creates a fresh permutation parser consisting of parser p. The the final result of the permutation parser is the function f applied to the return value of p. The parser p is not allowed to accept empty input - use the optional combinator (<$?>) instead. If the function f takes more than one parameter, the type variable b is instantiated to a functional type which combines nicely with the adds parser p to the (<||>) combinator. This results in stylized code where a permutation parser starts with a combining function f followed by the parsers. The function f gets its parameters in the order in which the parsers are specified, but actual input can be in any order. |class  Monad m => | (Stream s m t) (s -> t)An instance of Stream has stream type s, underlying monad m and token type t determined by the stream Some rough guidelines for a "correct" instance of Stream:
  • unfoldM uncons gives the [t] corresponding to the stream
  • A Stream instance is responsible for maintaining the "position within the stream" in the stream state s. This is trivial unless you are using the monad in a non-trivial way.
 whiteSpace whiteSpace :: GenTokenParser s u m -> ParsecT s u m () GenTokenParsersumParsecTsum()#Parses any white space. White space consists of zero or more occurrences of a space, a line comment or a block (multi line) comment. Block comments may be nested. How comments are started and ended is defined in the LanguageDef that is passed to makeTokenParser. upperupper :: Stream s m Char => ParsecT s u m CharStreamsmCharParsecTsumChar]Parses an upper case letter (a character between 'A' and 'Z'). Returns the parsed character.  updateState updateState ::  Monad m => (u -> u) -> ParsecT s u m ()zMonadmuuParsecTsum()6An alias for modifyState for backwards compatibility. updatePosStringupdatePosString ::  SourcePos -> String ->  SourcePossR SourcePosString SourcePosThe expression updatePosString pos s updates the source position pos by calling updatePosChar on every character in s, ie. foldl updatePosChar pos string.  updatePosChar updatePosChar ::  SourcePos -> Char ->  SourcePos SourcePosChar SourcePosQUpdate a source position given a character. If the character is a newline ('\n') or carriage return ('\r') the line number is incremented by 1. If the character is a tab ('t') the column number is incremented to the nearest 8'th column, ie. column + 8 - ((column-1) `mod` 8). In all other cases, the column is incremented by 1. updateParserStateupdateParserState ::  Monad m => (State s u -> State s u) -> ParsecT s u m (State s u)MonadmStatesuStatesuParsecTsumStatesuNupdateParserState f applies function f to the parser state.  unknownError unknownError ::  State s u ->  ParseErrorStatesu ParseError unexpected unexpected :: Stream s m t => String -> ParsecT s u m a^)StreamsmtStringParsecTsumaThe parser unexpected msg always fails with an unexpected error message msg without consuming any input. The parsers fail, (<?>) and unexpected are the three parsers used to generate error messages. Of these, only (<?>) is commonly used. For an example of the use of unexpected, see the definition of Text.Parsec.Combinator.notFollowedBy. UnExpectUnExpect :: String -> MessageYEStringMessageunconsuncons :: Stream s m t => s -> m (Maybe (t, s))StreamsmtsmMaybe(,)tstrytry :: Stream s m t => ParsecT s u m a -> ParsecT s u m aPStreamsmtParsecTsumaParsecTsumaThe parser try p behaves like parser p, except that it pretends that it hasn't consumed any input when an error occurs. This combinator is used whenever arbitrary look ahead is needed. Since it pretends that it hasn't consumed any input when p fails, the (<|>) combinator will try its second alternative even when the first parser failed while consuming input. The try combinator can for example be used to distinguish identifiers and reserved words. Both reserved words and identifiers are a sequence of letters. Whenever we expect a certain reserved word where we can also expect an identifier we have to use the try combinator. Suppose we write:
expr        = letExpr <|> identifier <?> "expression"

letExpr     = do{ string "let"; ... }
identifier  = many1 letter
If the user writes "lexical", the parser fails with: unexpected 'x', expecting 't' in "let". Indeed, since the (<|>) combinator only tries alternatives when the first alternative hasn't consumed input, the identifier parser is never tried (because the prefix "le" of the string "let" parser is already consumed). The right behaviour can be obtained by adding the try combinator:
expr        = letExpr <|> identifier <?> "expression"

letExpr     = do{ try (string "let"); ... }
identifier  = many1 letter
tokens tokens :: (Stream s m t, Eq t) => ([t] -> String) -> (SourcePos -> [t] -> SourcePos) -> [t] -> ParsecT s u m [t]XStreamsmtEqt[]tString SourcePos[]t SourcePos[]tParsecTsum[]t tokenPrimEx  tokenPrimEx :: Stream s m t =>  (t -> String) -> "(SourcePos -> t -> s -> SourcePos) -> %Maybe (SourcePos -> t -> s -> u -> u) -> (t -> Maybe a) -> ParsecT s u m aDStreamsmttString SourcePosts SourcePosMaybe SourcePostsuutMaybeaParsecTsuma tokenPrim tokenPrim :: Stream s m t => t -> String ->  SourcePos -> t -> s ->  SourcePos -> t -> Maybe a -> ParsecT s u m a Streamsmt tString SourcePosts SourcePostMaybeaParsecTsumaThe parser token showTok nextPos testTok accepts a token t with result x when the function testTok t returns Just x. The token can be shown using showTok t. The position of the next token should be returned when nextPos is called with the current source position pos, the current token t and the rest of the tokens toks, nextPos pos t toks. This is the most primitive combinator for accepting tokens. For example, the Text.Parsec.Char.char parser could be implemented as:
char c
  = tokenPrim showChar nextPos testChar
  where
    showChar x        = "'" ++ x ++ "'"
    testChar x        = if x == c then Just x else Nothing
    nextPos pos x xs  = updatePosChar pos x
 TokenParserX TokenParser :: ParsecT s u m String -> String -> ParsecT s u m () -> ParsecT s u m String -> String -> ParsecT s u m () -> ParsecT s u m Char -> ParsecT s u m String -> ParsecT s u m Integer ->  ParsecT s u m Integer ->  ParsecT s u m Double ->  %ParsecT s u m (Either Integer Double) ->  ParsecT s u m Integer ->  ParsecT s u m Integer -> ParsecT s u m Integer -> String -> ParsecT s u m String -> ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m () -> ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m String -> ParsecT s u m String ->  ParsecT s u m String -> !ParsecT s u m String -> "ParsecT s u m a -> #ParsecT s u m [a] -> $ParsecT s u m a -> %ParsecT s u m [a] -> &ParsecT s u m a -> 'ParsecT s u m [a] -> (ParsecT s u m a -> )ParsecT s u m [a] -> GenTokenParser s u mr:+ParsecTsumStringStringParsecTsum()ParsecTsumStringStringParsecTsum()ParsecTsumCharParsecTsumStringParsecTsumIntegerParsecTsumIntegerParsecTsumDoubleParsecTsumEitherIntegerDoubleParsecTsumIntegerParsecTsumIntegerParsecTsumIntegerStringParsecTsumStringParsecTsumaParsecTsumaParsecTsum()ParsecTsumaParsecTsumaParsecTsumaParsecTsumaParsecTsumaParsecTsumaParsecTsumaParsecTsumaParsecTsumaParsecTsumaParsecTsumStringParsecTsumStringParsecTsumStringParsecTsumStringParsecTsumaParsecTsum[]aParsecTsumaParsecTsum[]aParsecTsumaParsecTsum[]aParsecTsumaParsecTsum[]aGenTokenParsersum TokenParsertype  TokenParser st$ = GenTokenParser String st Identitytokentoken :: Stream s Identity t => t -> String -> t ->  SourcePos -> t -> Maybe a ->  Parsec s u aStreamsIdentityttStringt SourcePostMaybeaParsecsuaThe parser token showTok posFromTok testTok accepts a token t with result x when the function testTok t returns Just x. The source position of the t should be returned by posFromTok t and the token can be shown using showTok t. This combinator is expressed in terms of tokenPrim. It is used to accept user defined token streams. For example, suppose that we have a stream of basic tokens tupled with source positions. We can than define a parser that accepts single tokens as:
mytoken x
  = token showTok posFromTok testTok
  where
    showTok (pos,t)     = show t
    posFromTok (pos,t)  = pos
    testTok (pos,t)     = if x == t then Just t else Nothing
tabtab :: Stream s m Char => ParsecT s u m CharV%StreamsmCharParsecTsumChar8Parses a tab character ('\t'). Returns a tab character. sysUnExpectErrorsysUnExpectError :: String ->  SourcePos ->  Reply s u a-String SourcePosReplysua SysUnExpect SysUnExpect :: String -> MessageStringMessage symbolsymbol :: GenTokenParser s u m -> String -> ParsecT s u m StringN GenTokenParsersumStringParsecTsumString`Lexeme parser symbol s parses string s and skips trailing white space.  stringLiteral stringLiteral :: GenTokenParser s u m -> ParsecT s u m String[!GenTokenParsersumParsecTsumStringThis lexeme parser parses a literal string. Returns the literal string value. This parsers deals correctly with escape sequences and gaps. The literal string is parsed according to the grammar rules defined in the Haskell report (which matches most programming languages quite closely). stringstring :: Stream s m Char => String -> ParsecT s u m String!StreamsmCharStringParsecTsumStringstring s parses a sequence of characters given by s. Returns the parsed string (i.e. s).
divOrMod    =   string "div" 
            <|> string "mod"
 StreamPermParserdata StreamPermParser s st a/The type StreamPermParser s st a denotes a permutation parser that, when converted by the permute function, parses s streams with user state st and returns a value of type a on success. Normally, a permutation parser is first build with special operators like (<||>) and than transformed into a normal parser using permute.  stateUser stateUser ::  State s u -> uStatesuustatePosstatePos ::  State s u ->  SourcePoshStatesu SourcePos stateInput stateInput ::  State s u -> sStatesusState State :: s ->  SourcePos -> u ->  State s usPs SourcePosuStatesuStatedata State s u squaressquares :: GenTokenParser s u m -> ParsecT s u m a -> ParsecT s u m an"GenTokenParsersumParsecTsumaParsecTsuma!DEPRECATED: Use brackets. spacesspaces :: Stream s m Char => ParsecT s u m ()StreamsmCharParsecTsum()LSkips zero or more white space characters. See also skipMany. spacespace :: Stream s m Char => ParsecT s u m CharStreamsmCharParsecTsumCharlParses a white space character (any character which satisfies isSpace) Returns the parsed character.  SourcePosdata  SourcePosThe abstract data type SourcePos represents source positions. It contains the name of the source (i.e. file name), a line number and a column number. SourcePos is an instance of the Show, Eq and Ord class.  SourcePosdata  SourcePosThe abstract data type SourcePos represents source positions. It contains the name of the source (i.e. file name), a line number and a column number. SourcePos is an instance of the Show, Eq and Ord class.  sourceName sourceName ::  SourcePos ->  SourceName SourcePos SourceName8Extracts the name of the source from a source position.  sourceName sourceName ::  SourcePos ->  SourceName SourcePos SourceName8Extracts the name of the source from a source position.  SourceNametype  SourceName = String< SourceNametype  SourceName = String sourceLine sourceLine ::  SourcePos -> Line SourcePosLine1Extracts the line number from a source position.  sourceLine sourceLine ::  SourcePos -> Line|h SourcePosLine1Extracts the line number from a source position.  sourceColumn sourceColumn ::  SourcePos -> Column SourcePosColumn3Extracts the column number from a source position.  sourceColumn sourceColumn ::  SourcePos -> Column SourcePosColumn3Extracts the column number from a source position.  skipMany1 skipMany1 :: Stream s m t => ParsecT s u m a -> ParsecT s u m () a StreamsmtParsecTsumaParsecTsum()bskipMany1 p applies the parser p one or more times, skipping its result. skipManyskipMany :: Stream s m t => ParsecT s u m a -> ParsecT s u m () x StreamsmtParsecTsumaParsecTsum()skipMany p applies the parser p zero or more times, skipping its result.
spaces  = skipMany space
showErrorMessagesshowErrorMessages :: String -> String -> String -> String -> String ->  [Message] -> StringD  StringStringStringStringString[]MessageStringsetStatesetState ::  Monad m => u -> ParsecT s u m ()  MonadmuParsecTsum()3An alias for putState for backwards compatibility.  setSourceName setSourceName ::  SourcePos ->  SourceName ->  SourcePos q  SourcePos SourceName SourcePosSet the name of the source.  setSourceName setSourceName ::  SourcePos ->  SourceName ->  SourcePosJ% SourcePos SourceName SourcePosSet the name of the source.  setSourceLine setSourceLine ::  SourcePos -> Line ->  SourcePos SourcePosLine SourcePos*Set the line number of a source position.  setSourceLine setSourceLine ::  SourcePos -> Line ->  SourcePos SourcePosLine SourcePos*Set the line number of a source position.  setSourceColumnsetSourceColumn ::  SourcePos -> Column ->  SourcePosfE SourcePosColumn SourcePos,Set the column number of a source position. setSourceColumnsetSourceColumn ::  SourcePos -> Column ->  SourcePos& SourcePosColumn SourcePos,Set the column number of a source position.  setPosition setPosition ::  Monad m =>  SourcePos -> ParsecT s u m ()Monadm SourcePosParsecTsum()KsetPosition pos sets the current source position to pos. setParserStatesetParserState ::  Monad m =>  State s u -> ParsecT s u m (State s u)MonadmStatesuParsecTsumStatesuEsetParserState st set the full parser state to st. setInputsetInput ::  Monad m => s -> ParsecT s u m ()MonadmsParsecTsum()setInput input continues parsing with input. The getInput and setInput functions can for example be used to deal with #include files.  setErrorPos setErrorPos ::  SourcePos ->  ParseError ->  ParseError SourcePos ParseError ParseErrorsetErrorMessagesetErrorMessage :: Message ->  ParseError ->  ParseErroruMessage ParseError ParseError sepEndBy1 sepEndBy1 :: Stream s m t => ParsecT s u m a -> ParsecT s u m sep -> ParsecT s u m [a])StreamsmtParsecTsumaParsecTsumsepParsecTsum[]asepEndBy1 p sep parses one or more occurrences of p, separated and optionally ended by sep. Returns a list of values returned by p. sepEndBysepEndBy :: Stream s m t => ParsecT s u m a -> ParsecT s u m sep -> ParsecT s u m [a],StreamsmtParsecTsumaParsecTsumsepParsecTsum[]asepEndBy p sep parses zero or more occurrences of p, separated and optionally ended by sep, ie. haskell style statements. Returns a list of values returned by p.
haskellStatements  = haskellStatement `sepEndBy` semi
sepBy1sepBy1 :: Stream s m t => ParsecT s u m a -> ParsecT s u m sep -> ParsecT s u m [a]*StreamsmtParsecTsumaParsecTsumsepParsecTsum[]asepBy1 p sep parses one or more occurrences of p, separated by sep. Returns a list of values returned by p. sepBysepBy :: Stream s m t => ParsecT s u m a -> ParsecT s u m sep -> ParsecT s u m [a]IStreamsmtParsecTsumaParsecTsumsepParsecTsum[]asepBy p sep parses zero or more occurrences of p, separated by sep. Returns a list of values returned by p.
commaSep p  = p `sepBy` (symbol ",")
 semiSep1semiSep1 :: GenTokenParser s u m -> ParsecT s u m a -> ParsecT s u m [a]IGenTokenParsersumParsecTsumaParsecTsum[]aLexeme parser semiSep1 p parses one or more occurrences of p separated by semi. Returns a list of values returned by p.  semiSepsemiSep :: GenTokenParser s u m -> ParsecT s u m a -> ParsecT s u m [a]iGenTokenParsersumParsecTsumaParsecTsum[]aLexeme parser semiSep p parses zero or more occurrences of p separated by semi. Returns a list of values returned by p.  semisemi :: GenTokenParser s u m -> ParsecT s u m StringGenTokenParsersumParsecTsumStringjLexeme parser |semi| parses the character ';' and skips any trailing white space. Returns the string ";". satisfysatisfy :: Stream s m Char => (Char -> Bool) -> ParsecT s u m Char! StreamsmCharCharBoolParsecTsumCharThe parser satisfy f succeeds for any character for which the supplied function f returns True. Returns the character that is actually parsed. runPT runPT :: Stream s m t => ParsecT s u m a -> u ->  SourceName -> s -> m (Either ParseError a)"]"StreamsmtParsecTsumau SourceNamesmEither ParseErrora runParserT  runParserT :: Stream s m t => ParsecT s u m a -> u ->  SourceName -> s -> m (Either ParseError a)#e#StreamsmtParsecTsumau SourceNamesmEither ParseErroraThe most general way to run a parser. runParserT p state filePath input runs parser p on the input list of tokens input, obtained from source filePath with the initial user state st. The filePath is only used in error messages and may be the empty string. Returns a computation in the underlying monad m that return either a ParseError (Left) or a value of type a (Right).  runParser  runParser :: Stream s Identity t =>  Parsec s u a -> u ->  SourceName -> s -> Either ParseError a&=&StreamsIdentitytParsecsuau SourceNamesEither ParseErrora'The most general way to run a parser over the Identity monad. runParser p state filePath input runs parser p on the input list of tokens input, obtained from source filePath with the initial user state st. The filePath is only used in error messages and may be the empty string. Returns either a ParseError (Left) or a value of type a (Right).
parseFromFile p fname
  = do{ input <- readFile fname
      ; return (runParser p () fname input)
      }
 runParsecT runParsecT :: ParsecT s u m a ->  State s u -> m (Consumed (m (Reply s u a))))F)ParsecTsumaStatesumConsumedmReplysuarunP runP :: Stream s Identity t =>  Parsec s u a -> u ->  SourceName -> s -> Either ParseError a*6*StreamsIdentitytParsecsuau SourceNamesEither ParseErrora reservedOpNamesreservedOpNames :: GenLanguageDef s u m -> [String](+*GenLanguageDefsum[]String The list of reserved operators.  reservedOp reservedOp :: GenTokenParser s u m -> String -> ParsecT s u m (),+GenTokenParsersumStringParsecTsum()The lexeme parser reservedOp name parses symbol name, but it also checks that the name is not a prefix of a valid operator. A reservedOp is treated as a single token using try.  reservedNames reservedNames :: GenLanguageDef s u m -> [String]p-D-GenLanguageDefsum[]String"The list of reserved identifiers.  reservedreserved :: GenTokenParser s u m -> String -> ParsecT s u m ()G. .GenTokenParsersumStringParsecTsum()The lexeme parser reserved name parses symbol name, but it also checks that the name is not a prefix of a valid identifier. A reserved word is treated as a single token using try. Replydata Reply s u aZ/putStateputState ::  Monad m => u -> ParsecT s u m ()//MonadmuParsecTsum()8putState st set the user state to st.  PrefixPrefix :: ParsecT s u m (a -> a) -> Operator s u m a0|0ParsecTsumaaOperatorsuma PostfixPostfix :: ParsecT s u m (a -> a) -> Operator s u m aO11ParsecTsumaaOperatorsuma permutepermute :: Stream s Identity tok => StreamPermParser s st a ->  Parsec s st a21StreamsIdentitytokStreamPermParsersstaParsecsstaThe parser permute perm parses a permutation of parser described by perm. For example, suppose we want to parse a permutation of: an optional string of a's, the character b and an optional c. This can be described by:
test  = permute (tuple <$?> ("",many1 (char 'a'))
                       <||> char 'b' 
                       <|?> ('_',char 'c'))
      where
        tuple a b c  = (a,b,c)
 PermParsertype  PermParser tok st a = StreamPermParser String st aT4?Provided for backwards compatibility. The tok type is ignored.  parseTest parseTest :: !(Stream s Identity t, Show a) =>  Parsec s () a -> s -> IO ()_55StreamsIdentitytShowaParsecs()asIO()The expression parseTest p input applies a parser p against input input and prints the result to stdout. Used for testing parsers.  parserZero parserZero ::  Monad m => ParsecT s u m at6P6MonadmParsecTsumaparserZero always fails without consuming any input. parserZero is defined equal to the mzero member of the MonadPlus class and to the Control.Applicative.empty member of the Control.Applicative.Applicative class.  parserReturn parserReturn ::  Monad m => a -> ParsecT s u m a77MonadmaParsecTsuma parserPlus parserPlus ::  Monad m => ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a88MonadmParsecTsumaParsecTsumaParsecTsuma parserFail parserFail ::  Monad m => String -> ParsecT s u m ag999MonadmStringParsecTsuma parserBind parserBind ::  Monad m => ParsecT s u m a -> (a -> ParsecT s u m b) -> ParsecT s u m bP:9MonadmParsecTsumaaParsecTsumbParsecTsumbParsertype Parser = Parsec String ():Parsertype Parser = Parsec ByteString (): parseFromFile parseFromFile :: Parser a -> String -> IO (Either ParseError a);[;ParseraStringIOEither ParseErroraparseFromFile p filePath runs a string parser p on the input read from filePath using readFile. Returns either a ParseError (Left) or a value of type a (Right).
main    = do{ result <- parseFromFile numbers "digits.txt"
            ; case result of
                Left err  -> print err
                Right xs  -> print (sum xs)
            }
 parseFromFile parseFromFile :: Parser a -> String -> IO (Either ParseError a)==ParseraStringIOEither ParseErroraparseFromFile p filePath runs a strict bytestring parser p on the input read from filePath using ByteString.Char8.readFile. Returns either a ParseError (Left) or a value of type a (Right).
main    = do{ result <- parseFromFile numbers "digits.txt"
            ; case result of
                Left err  -> print err
                Right xs  -> print (sum xs)
            }
 ParseErrordata  ParseError?>The abstract data type ParseError represents parse errors. It provides the source position (SourcePos) of the error and a list of error messages (Message). A ParseError can be returned by the function Text.Parsec.Prim.parse. ParseError is an instance of the Show class.  ParseErrordata  ParseErrorkA>The abstract data type ParseError represents parse errors. It provides the source position (SourcePos) of the error and a list of error messages (Message). A ParseError can be returned by the function Text.Parsec.Prim.parse. ParseError is an instance of the Show class. ParsecTParsecT ::  State s u -> m (Consumed (m (Reply s u a))) -> ParsecT s u m a{C*CStatesumConsumedmReplysuaParsecTsumaParsecTdata ParsecT s u m aCParserT monad transformer and Parser type ParsecT s u m a is a parser with stream type s, user state type u, underlying monad m and return type a  parsecMap parsecMap ::  Monad m => (a -> b) -> ParsecT s u m a -> ParsecT s u m b:EDMonadmabParsecTsumaParsecTsumbParsectype Parsec s u = ParsecT s u IdentityEparse parse :: Stream s Identity t =>  Parsec s () a ->  SourceName -> s -> Either ParseError auFFStreamsIdentitytParsecs()a SourceNamesEither ParseErroraparse p filePath input runs a parser p over Identity without user state. The filePath is only used in error messages and may be the empty string. Returns either a ParseError (Left) or a value of type a (Right).
main    = case (parse numbers "" "11, 2, 43") of
           Left err  -> print err
           Right xs  -> print (sum xs)

numbers = commaSep integer
 parensparens :: GenTokenParser s u m -> ParsecT s u m a -> ParsecT s u m aHHGenTokenParsersumParsecTsumaParsecTsumanLexeme parser parens p parses p enclosed in parenthesis, returning the value of p.  optionMaybe optionMaybe :: Stream s m t => ParsecT s u m a -> ParsecT s u m (Maybe a)*JIStreamsmtParsecTsumaParsecTsumMaybeaoption p tries to apply parser p. If p fails without consuming input, it return Nothing, otherwise it returns Just the value returned by p. optionaloptional :: Stream s m t => ParsecT s u m a -> ParsecT s u m ()KXKStreamsmtParsecTsumaParsecTsum()optional p tries to apply parser p. It will parse p or nothing. It only fails if p fails after consuming input. It discards the result of p. optionoption :: Stream s m t => a -> ParsecT s u m a -> ParsecT s u m aMLStreamsmtaParsecTsumaParsecTsuma2option x p tries to apply parser p. If p fails without consuming input, it returns the value x, otherwise the value returned by p.
priority  = option 0 (do{ d <- digit
                        ; return (digitToInt d) 
                        })
 opStartopStart :: GenLanguageDef s u m -> ParsecT s u m CharNNGenLanguageDefsumParsecTsumCharzThis parser should accept any start characters of operators. For example oneOf ":!#$%&*+./<=>?@\\^|-~"  opLetteropLetter :: GenLanguageDef s u m -> ParsecT s u m CharOOGenLanguageDefsumParsecTsumCharThis parser should accept any legal tail characters of operators. Note that this parser should even be defined if the language doesn't support user-defined operators, or otherwise the reservedOp parser won't work correctly.  OperatorTabletype  OperatorTable s u m a = [[Operator s u m a]]DQAn OperatorTable s u m a is a list of Operator s u m a lists. The list is ordered in descending precedence. All operators in one list have the same precedence (but may have a different associativity).  operatoroperator :: GenTokenParser s u m -> ParsecT s u m StringRRGenTokenParsersumParsecTsumString_This lexeme parser parses a legal operator. Returns the name of the operator. This parser will fail on any operators that are reserved operators. Legal operator (start) characters and reserved operators are defined in the LanguageDef that is passed to makeTokenParser. An operator is treated as a single token using try.  Operatordata Operator s u m a]TThis data type specifies operators that work on values of type a. An operator is either binary infix or unary prefix or postfix. A binary operator has also an associated associativity. oneOfoneOf :: Stream s m Char => [Char] -> ParsecT s u m CharUUStreamsmChar[]CharParsecTsumCharoneOf cs succeeds if the current character is in the supplied list of characters cs. Returns the parsed character. See also satisfy.
vowel  = oneOf "aeiou"
Ok Ok :: a ->  State s u ->  ParseError ->  Reply s u a&WVaStatesu ParseErrorReplysuaoctDigitoctDigit :: Stream s m Char => ParsecT s u m CharWWStreamsmCharParsecTsumCharWParses an octal digit (a character between '0' and '7'). Returns the parsed character.  octaloctal :: GenTokenParser s u m -> ParsecT s u m IntegerXlXGenTokenParsersumParsecTsumIntegerParses a positive whole number in the octal system. The number should be prefixed with "0o" or "0O". Returns the value of the number.  notFollowedBy notFollowedBy :: (Stream s m t, Show t) => ParsecT s u m t -> ParsecT s u m ()ZYStreamsmtShowtParsecTsumtParsecTsum()7notFollowedBy p only succeeds when parser p fails. This parser does not consume any input. This parser can be used to implement the 'longest match' rule. For example, when recognizing keywords (for example let), we want to make sure that a keyword is not followed by a legal identifier character, in which case the keyword is actually an identifier (for example lets). We can program this behaviour as follows:
keywordLet  = try (do{ string "let"
                     ; notFollowedBy alphaNum
                     })
noneOfnoneOf :: Stream s m Char => [Char] -> ParsecT s u m Char\\StreamsmChar[]CharParsecTsumCharAs the dual of oneOf, noneOf cs succeeds if the current character not in the supplied list of characters cs. Returns the parsed character.
consonant = noneOf "aeiou"
newPos newPos ::  SourceName -> Line -> Column ->  SourcePosM^%^ SourceNameLineColumn SourcePosYCreate a new SourcePos with the given source name, line number and column number. newlinenewline :: Stream s m Char => ParsecT s u m Char/_^StreamsmCharParsecTsumChar@Parses a newline character ('\n'). Returns a newline character. newErrorUnknownnewErrorUnknown ::  SourcePos ->  ParseError__ SourcePos ParseErrornewErrorMessagenewErrorMessage :: Message ->  SourcePos ->  ParseError```Message SourcePos ParseError nestedCommentsnestedComments :: GenLanguageDef s u m -> Bool a`GenLanguageDefsumBoolCSet to True if the language supports nested block comments.  naturalOrFloatnaturalOrFloat :: GenTokenParser s u m -> %ParsecT s u m (Either Integer Double)"baGenTokenParsersumParsecTsumEitherIntegerDouble This lexeme parser parses either natural or a float. Returns the value of the number. This parsers deals with any overlap in the grammar rules for naturals and floats. The number is parsed according to the grammar rules defined in the Haskell report.  naturalnatural :: GenTokenParser s u m -> ParsecT s u m IntegerccGenTokenParsersumParsecTsumIntegerThis lexeme parser parses a natural number (a positive whole number). Returns the value of the number. The number can be specified in decimal, hexadecimal or octal. The number is parsed according to the grammar rules in the Haskell report.  mondrianDef mondrianDef :: LanguageDef st0ee LanguageDefst3The language definition for the language Mondrian.  mondrianmondrian :: TokenParser stee TokenParserst#A lexer for the mondrian language.  modifyState modifyState ::  Monad m => (u -> u) -> ParsecT s u m ()vfGfMonadmuuParsecTsum() updateState f applies function f to the user state. Suppose that we want to count identifiers in a source, we could use the user state as:
expr  = do{ x <- identifier
          ; updateState (+1)
          ; return (Id x)
          }
 messageString messageString :: Message -> StringggMessageString1Extract the message string from an error message MessageMessage :: String -> MessagehlhStringMessageMessagedata MessagehThis abstract data type represents parse error messages. There are four kinds of messages:
data Message = SysUnExpect String
             | UnExpect String
             | Expect String
             | Message String
The fine distinction between different kinds of parse errors allows the system to generate quite good error messages for the user. It also allows error messages that are formatted in different languages. Each kind of message is generated by different combinators:
  • A SysUnExpect message is automatically generated by the Text.Parsec.Combinator.satisfy combinator. The argument is the unexpected input.
  • A UnExpect message is generated by the Text.Parsec.Prim.unexpected combinator. The argument describes the unexpected item.
  • A Expect message is generated by the Text.Parsec.Prim.<?> combinator. The argument describes the expected item.
  • A Message message is generated by the fail combinator. The argument is some general parser message.
mergeErrorReplymergeErrorReply ::  ParseError ->  Reply s u a ->  Reply s u amLm ParseErrorReplysuaReplysua mergeError mergeError ::  ParseError ->  ParseError ->  ParseErrornm ParseError ParseError ParseErrormanyTillmanyTill :: Stream s m t => ParsecT s u m a -> ParsecT s u m end -> ParsecT s u m [a]onStreamsmtParsecTsumaParsecTsumendParsecTsum[]amanyTill p end applies parser p zero or more times until parser end succeeds. Returns the list of values returned by p. This parser can be used to scan comments:
simpleComment   = do{ string "<!--"
                    ; manyTill anyChar (try (string "-->"))
                    }
Note the overlapping parsers anyChar and string "<!--", and therefore the use of the try combinator.  manyAccum manyAccum :: Stream s m t => (a -> [a] -> [a]) -> ParsecT s u m a -> ParsecT s u m [a]qoqStreamsmta[]a[]aParsecTsumaParsecTsum[]amany1many1 :: Stream s m t => ParsecT s u m a -> ParsecT s u m [a]r;rStreamsmtParsecTsumaParsecTsum[]amany p applies the parser p one or more times. Returns a list of the returned values of p.
word  = many1 letter
manymany :: Stream s m t => ParsecT s u m a -> ParsecT s u m [a]ssStreamsmtParsecTsumaParsecTsum[]amany p applies the parser p zero or more times. Returns a list of the returned values of p.
identifier  = do{ c  <- letter
                ; cs <- many (alphaNum <|> char '_')
                ; return (c:cs)
                }
 makeTokenParsermakeTokenParser :: Stream s m Char => GenLanguageDef s u m -> GenTokenParser s u muuStreamsmCharGenLanguageDefsumGenTokenParsersumThe expression makeTokenParser language creates a GenTokenParser record that contains lexical parsers that are defined using the definitions in the language record. The use of this function is quite stylized - one imports the appropiate language definition and selects the lexical parsers that are needed from the resulting GenTokenParser.
module Main where

import Text.Parsec
import qualified Text.Parsec.Token as P
import Text.Parsec.Language (haskellDef)

-- The parser
...

expr  =   parens expr
      <|> identifier
      <|> ...
     

-- The lexer
lexer       = P.makeTokenParser haskellDef    
    
parens      = P.parens lexer
braces      = P.braces lexer
identifier  = P.identifier lexer
reserved    = P.reserved lexer
...
lowerlower :: Stream s m Char => ParsecT s u m Charmy ParsecT s u m a -> ParsecT s u m az=zStreamsmtParsecTsumaParsecTsumaDlookAhead p parses p without consuming any input.  Linetype Line = IntzLinetype Line = Int-{ lexemelexeme :: GenTokenParser s u m -> ParsecT s u m a -> ParsecT s u m a{{GenTokenParsersumParsecTsumaParsecTsumalexeme p first applies parser p and than the whiteSpace parser, returning the value of p. Every lexical token (lexeme) is defined using lexeme, this way every parse starts at a point without white space. Parsers that use lexeme are called lexeme parsers in this document. The only point where the whiteSpace parser should be called explicitly is the start of the main parser in order to skip any leading white space.
mainParser  = do{ whiteSpace
                 ; ds <- many (lexeme digit)
                 ; eof
                 ; return (sum ds)
                 }
letterletter :: Stream s m Char => ParsecT s u m Char~StreamsmCharParsecTsumCharWParses a letter (an upper case or lower case character). Returns the parsed character.  LanguageDef LanguageDef :: String -> String -> String -> Bool -> ParsecT s u m Char -> ParsecT s u m Char -> ParsecT s u m Char -> ParsecT s u m Char -> [String] ->  [String] ->  Bool -> GenLanguageDef s u mi StringStringStringBoolParsecTsumCharParsecTsumCharParsecTsumCharParsecTsumChar[]String[]StringBoolGenLanguageDefsum LanguageDeftype  LanguageDef st$ = GenLanguageDef String st Identitý LanguageDeftype  LanguageDef st$ = GenLanguageDef String st Identity/labelslabels ::  Monad m => ParsecT s u m a -> [String] -> ParsecT s u m aMonadmParsecTsuma[]StringParsecTsumalabellabel ::  Monad m => ParsecT s u m a -> String -> ParsecT s u m ajMonadmParsecTsumaStringParsecTsuma javaStyle javaStyle :: LanguageDef st LanguageDefstThis is a minimal token definition for Java style languages. It defines the style of comments, valid identifiers and case sensitivity. It does not define any reserved words or operators.  integerinteger :: GenTokenParser s u m -> ParsecT s u m Integerf+GenTokenParsersumParsecTsumIntegerUThis lexeme parser parses an integer (a whole number). This parser is like natural except that it can be prefixed with sign (i.e. '-' or '+'). Returns the value of the number. The number can be specified in decimal, hexadecimal or octal. The number is parsed according to the grammar rules in the Haskell report.  initialPos initialPos ::  SourceName ->  SourcePos- SourceName SourcePosvCreate a new SourcePos with the given source name, and line number and column number set to 1, the upper left.  InfixInfix :: ParsecT s u m (a -> a -> a) -> Assoc -> Operator s u m a[ParsecTsumaaaAssocOperatorsuma incSourceLine incSourceLine ::  SourcePos -> Line ->  SourcePosȈ SourcePosLine SourcePos1Increments the line number of a source position.  incSourceLine incSourceLine ::  SourcePos -> Line ->  SourcePos SourcePosLine SourcePos1Increments the line number of a source position.  incSourceColumnincSourceColumn ::  SourcePos -> Column ->  SourcePosiH SourcePosColumn SourcePos3Increments the column number of a source position. incSourceColumnincSourceColumn ::  SourcePos -> Column ->  SourcePos0 SourcePosColumn SourcePos3Increments the column number of a source position.  identStart identStart :: GenLanguageDef s u m -> ParsecT s u m Char΋GenLanguageDefsumParsecTsumCharoThis parser should accept any start characters of identifiers. For example letter <|> char "_".  identLetter identLetter :: GenLanguageDef s u m -> ParsecT s u m CharGenLanguageDefsumParsecTsumCharvThis parser should accept any legal tail characters of identifiers. For example alphaNum <|> char "_".  identifier identifier :: GenTokenParser s u m -> ParsecT s u m String7GenTokenParsersumParsecTsumStringXThis lexeme parser parses a legal identifier. Returns the identifier string. This parser will fail on identifiers that are reserved words. Legal identifier (start) characters and reserved words are defined in the LanguageDef that is passed to makeTokenParser. An identifier is treated as a single token using try. hexDigithexDigit :: Stream s m Char => ParsecT s u m CharStreamsmCharParsecTsumCharsParses a hexadecimal digit (a digit or a letter between 'a' and 'f' or 'A' and 'F'). Returns the parsed character.  hexadecimal hexadecimal :: GenTokenParser s u m -> ParsecT s u m Integer8GenTokenParsersumParsecTsumIntegerParses a positive whole number in the hexadecimal system. The number should be prefixed with "0x" or "0X". Returns the value of the number.  haskellStyle haskellStyle :: LanguageDef st# LanguageDefstThis is a minimal token definition for Haskell style languages. It defines the style of comments, valid identifiers and case sensitivity. It does not define any reserved words or operators.  haskellDef haskellDef :: LanguageDef st<( LanguageDefst2The language definition for the Haskell language.  haskellhaskell :: TokenParser stÓ TokenParserst"A lexer for the haskell language. getStategetState ::  Monad m => ParsecT s u m uX4MonadmParsecTsumu Returns the current user state.  getPosition getPosition ::  Monad m => ParsecT s u m SourcePosՔMonadmParsecTsum SourcePos@Returns the current source position. See also SourcePos. getParserStategetParserState ::  Monad m => ParsecT s u m (State s u)֕MonadmParsecTsumStatesu8Returns the full parser state as a State record. getInputgetInput ::  Monad m => ParsecT s u m s]MonadmParsecTsumsReturns the current input  GenTokenParserdata GenTokenParser s u mThe type of the record that holds lexical parsers that work on s streams with state u over a monad m.  GenParsertype  GenParser tok st = Parsec [tok] st GenParsertype  GenParser t st = Parsec ByteString st GenLanguageDefdata GenLanguageDef s u mMThe GenLanguageDef type is a record that contains all parameterizable features of the Text.Parsec.Token module. The module Text.Parsec.Language contains some default definitions.  GenLanguageDefdata GenLanguageDef s u mOThe GenLanguageDef type is a record that contains all parameterizable features of the Text.Parsec.Token module. The module Text.Parsec.Language contains some default definitions.  floatfloat :: GenTokenParser s u m -> ParsecT s u m DoublenGenTokenParsersumParsecTsumDoubleThis lexeme parser parses a floating point value. Returns the value of the number. The number is parsed according to the grammar rules defined in the Haskell report. ExpectExpect :: String -> MessageStringMessage errorPoserrorPos ::  ParseError ->  SourcePos ParseError SourcePos2Extracts the source position from the parse error errorPoserrorPos ::  ParseError ->  SourcePos ParseError SourcePos2Extracts the source position from the parse error  errorMessages errorMessages ::  ParseError ->  [Message]hJ ParseError[]Message9Extracts the list of error messages from the parse error errorIsUnknownerrorIsUnknown ::  ParseError -> Bool ParseErrorBoolErrorError ::  ParseError ->  Reply s u aa ParseErrorReplysuaeofeof :: (Stream s m t, Show t) => ParsecT s u m ()מStreamsmtShowtParsecTsum()This parser only succeeds at the end of the input. This is not a primitive parser but it is defined using notFollowedBy.
eof  = notFollowedBy anyToken <?> "end of input"
endBy1endBy1 :: Stream s m t => ParsecT s u m a -> ParsecT s u m sep -> ParsecT s u m [a]]StreamsmtParsecTsumaParsecTsumsepParsecTsum[]aendBy1 p sep parses one or more occurrences of p, seperated and ended by sep. Returns a list of values returned by p. endByendBy :: Stream s m t => ParsecT s u m a -> ParsecT s u m sep -> ParsecT s u m [a]LStreamsmtParsecTsumaParsecTsumsepParsecTsum[]aendBy p sep parses zero or more occurrences of p, seperated and ended by sep. Returns a list of values returned by p.
cStatements  = cStatement `endBy` semi
 emptyDefemptyDef :: LanguageDef stye LanguageDefstEmptyEmpty :: a ->  Consumed aԣaConsumeda dotdot :: GenTokenParser s u m -> ParsecT s u m Stringm3GenTokenParsersumParsecTsumStringpLexeme parser dot parses the character '.' and skips any trailing white space. Returns the string ".". digitdigit :: Stream s m Char => ParsecT s u m Charb1StreamsmCharParsecTsumChar.Parses a digit. Returns the parsed character.  decimaldecimal :: GenTokenParser s u m -> ParsecT s u m Integer3GenTokenParsersumParsecTsumIntegerWParses a positive whole number in the decimal system. Returns the value of the number. countcount :: Stream s m t => Int -> ParsecT s u m a -> ParsecT s u m [a]SStreamsmtIntParsecTsumaParsecTsum[]acount n p parses n occurrences of p. If n is smaller or equal to zero, the parser equals to return []. Returns a list of n values returned by p. ConsumedConsumed :: a ->  Consumed aoaConsumedaConsumeddata Consumed a commentStart commentStart :: GenLanguageDef s u m -> StringCGenLanguageDefsumStringDescribes the start of a block comment. Use the empty string if the language doesn't support block comments. For example "/*".  commentLine commentLine :: GenLanguageDef s u m -> StringI#GenLanguageDefsumString}Describes the start of a line comment. Use the empty string if the language doesn't support line comments. For example "//".  commentEnd commentEnd :: GenLanguageDef s u m -> StringK%GenLanguageDefsumString}Describes the end of a block comment. Use the empty string if the language doesn't support block comments. For example "*/".  commaSep1 commaSep1 :: GenTokenParser s u m -> ParsecT s u m a -> ParsecT s u m [a]KGenTokenParsersumParsecTsumaParsecTsum[]aLexeme parser commaSep1 p parses one or more occurrences of p separated by comma. Returns a list of values returned by p.  commaSepcommaSep :: GenTokenParser s u m -> ParsecT s u m a -> ParsecT s u m [a]GenTokenParsersumParsecTsumaParsecTsum[]aLexeme parser commaSep p parses zero or more occurrences of p separated by comma. Returns a list of values returned by p.  commacomma :: GenTokenParser s u m -> ParsecT s u m StringSGenTokenParsersumParsecTsumStringrLexeme parser comma parses the character ',' and skips any trailing white space. Returns the string ",".  Columntype Column = IntColumntype Column = Int5 coloncolon :: GenTokenParser s u m -> ParsecT s u m StringҰGenTokenParsersumParsecTsumStringrLexeme parser colon parses the character ':' and skips any trailing white space. Returns the string ":". choicechoice :: Stream s m t => [ParsecT s u m a] -> ParsecT s u m aStreamsmt[]ParsecTsumaParsecTsumachoice ps tries to apply the parsers in the list ps in order, until one of them succeeds. Returns the value of the succeeding parser.  charLiteral charLiteral :: GenTokenParser s u m -> ParsecT s u m Char8GenTokenParsersumParsecTsumChar&This lexeme parser parses a single literal character. Returns the literal character value. This parsers deals correctly with escape sequences. The literal character is parsed according to the grammar rules defined in the Haskell report (which matches most programming languages quite closely). charchar :: Stream s m Char => Char -> ParsecT s u m CharStreamsmCharCharParsecTsumCharchar c parses a single character c. Returns the parsed character (i.e. c).
semiColon  = char ';'
chainr1chainr1 :: Stream s m t => ParsecT s u m a -> ParsecT s u m (a -> a -> a) -> ParsecT s u m azStreamsmtParsecTsumaParsecTsumaaaParsecTsumachainr1 p op x parser one or more occurrences of |p|, separated by op Returns a value obtained by a right associative application of all functions returned by op to the values returned by p. chainr chainr :: Stream s m t => ParsecT s u m a -> ParsecT s u m (a -> a -> a) -> a -> ParsecT s u m ap StreamsmtParsecTsumaParsecTsumaaaaParsecTsumaEchainr p op x parser zero or more occurrences of p, separated by op Returns a value obtained by a right associative application of all functions returned by op to the values returned by p. If there are no occurrences of p, the value x is returned. chainl1chainl1 :: Stream s m t => ParsecT s u m a -> ParsecT s u m (a -> a -> a) -> ParsecT s u m aIStreamsmtParsecTsumaParsecTsumaaaParsecTsumachainl1 p op x parser one or more occurrences of p, separated by op Returns a value obtained by a left associative application of all functions returned by op to the values returned by p. . This parser can for example be used to eliminate left recursion which typically occurs in expression grammars.
expr    = term   `chainl1` mulop
term    = factor `chainl1` addop
factor  = parens expr <|> integer

mulop   =   do{ symbol "*"; return (*)   }
        <|> do{ symbol "/"; return (div) }

addop   =   do{ symbol "+"; return (+) }
        <|> do{ symbol "-"; return (-) }
chainl chainl :: Stream s m t => ParsecT s u m a -> ParsecT s u m (a -> a -> a) -> a -> ParsecT s u m aGStreamsmtParsecTsumaParsecTsumaaaaParsecTsumaGchainl p op x parser zero or more occurrences of p, separated by op. Returns a value obtained by a left associative application of all functions returned by op to the values returned by p. If there are zero occurrences of p, the value x is returned.  caseSensitive caseSensitive :: GenLanguageDef s u m -> BoolGenLanguageDefsumBool6Set to True if the language is case sensitive.  buildExpressionParserbuildExpressionParser :: Stream s m t => OperatorTable s u m a -> ParsecT s u m a -> ParsecT s u m aVStreamsmt OperatorTablesumaParsecTsumaParsecTsumaYbuildExpressionParser table term builds an expression parser for terms term with operators from table, taking the associativity and precedence specified in table into account. Prefix and postfix operators of the same precedence can only occur once (i.e. --2 is not allowed if - is prefix negate). Prefix and postfix operators of the same precedence associate to the left (i.e. if ++ is postfix increment, than -2++ equals -1, not -3). The buildExpressionParser takes care of all the complexity involved in building expression parser. Here is an example of an expression parser that handles prefix signs, postfix increment and basic arithmetic.
expr    = buildExpressionParser table term
        <?> "expression"

term    =  parens expr 
        <|> natural
        <?> "simple expression"

table   = [ [prefix "-" negate, prefix "+" id ]
          , [postfix "++" (+1)]
          , [binary "*" (*) AssocLeft, binary "/" (div) AssocLeft ]
          , [binary "+" (+) AssocLeft, binary "-" (-)   AssocLeft ]
          ]
        
binary  name fun assoc = Infix (do{ reservedOp name; return fun }) assoc
prefix  name fun       = Prefix (do{ reservedOp name; return fun })
postfix name fun       = Postfix (do{ reservedOp name; return fun })
 bracketsbrackets :: GenTokenParser s u m -> ParsecT s u m a -> ParsecT s u m az.GenTokenParsersumParsecTsumaParsecTsuma{Lexeme parser brackets p parses p enclosed in brackets ('[' and ']'), returning the value of p.  bracesbraces :: GenTokenParser s u m -> ParsecT s u m a -> ParsecT s u m apGenTokenParsersumParsecTsumaParsecTsumawLexeme parser braces p parses p enclosed in braces ('{' and '}'), returning the value of p. between between :: Stream s m t => ParsecT s u m open -> ParsecT s u m close -> ParsecT s u m a -> ParsecT s u m aVStreamsmtParsecTsumopenParsecTsumcloseParsecTsumaParsecTsumabetween open close p parses open, followed by p and close. Returns the value returned by p.
braces  = between (symbol "{") (symbol "}")
 AssocRight AssocRight :: Assoc_WAssoc AssocNone AssocNone :: AssocAssoc AssocLeft AssocLeft :: AssocAssoc Assocdata AssocNThis data type specifies the associativity of operators: left, right or none. anyTokenanyToken :: (Stream s m t, Show t) => ParsecT s u m tStreamsmtShowtParsecTsumtThe parser anyToken accepts any kind of token. It is for example used to implement eof. Returns the accepted token. anyCharanyChar :: Stream s m Char => ParsecT s u m CharStreamsmCharParsecTsumCharFThis parser succeeds for any character. Returns the parsed character.  anglesangles :: GenTokenParser s u m -> ParsecT s u m a -> ParsecT s u m aGenTokenParsersumParsecTsumaParsecTsumaLexeme parser angles p parses p enclosed in angle brackets ('<' and '>'), returning the value of p. alphaNumalphaNum :: Stream s m Char => ParsecT s u m Char!StreamsmCharParsecTsumCharZParses a letter or digit (a character between '0' and '9'). Returns the parsed character. addErrorMessageaddErrorMessage :: Message ->  ParseError ->  ParseErrorMessage ParseError ParseError <||> (<||>) :: Stream s Identity tok => StreamPermParser s st (a -> b) ->  Parsec s st a -> StreamPermParser s st b/StreamsIdentitytokStreamPermParsersstabParsecsstaStreamPermParsersstbThe expression perm <||> p adds parser p to the permutation parser perm. The parser p is not allowed to accept empty input - use the optional combinator (<|?>) instead. Returns a new permutation parser that includes p.  <|?> (<|?>) :: Stream s Identity tok => StreamPermParser s st (a -> b) -> (a, Parsec s st a) -> StreamPermParser s st bsStreamsIdentitytokStreamPermParsersstab(,)aParsecsstaStreamPermParsersstb.The expression perm <||> (x,p) adds parser p to the permutation parser perm. The parser p is optional - if it can not be applied, the default value x will be used instead. Returns a new permutation parser that includes the optional parser p. <|> (<|>) ::  Monad m => ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m av"MonadmParsecTsumaParsecTsumaParsecTsumaThis combinator implements choice. The parser p <|> q first applies p. If it succeeds, the value of p is returned. If p fails without consuming any input, parser q is tried. This combinator is defined equal to the mplus member of the MonadPlus class and the (Control.Applicative.<|>) member of Control.Applicative.Alternative. The parser is called predictive since q is only tried when parser p didn't consume any input (i.e.. the look ahead is 1). This non-backtracking behaviour allows for both an efficient implementation of the parser combinators and the generation of good error messages.  () ::  Monad m => ParsecT s u m a -> String -> ParsecT s u m aMonadmParsecTsumaStringParsecTsumaThe parser p ? msg behaves as parser p, but whenever the parser p fails without consuming any input, it replaces expect error messages with the expect error message msg. This is normally used at the end of a set alternatives where we want to return an error message in terms of a higher level construct rather than returning all possible characters. For example, if the expr parser from the try example would fail, the error message is: '...: expecting expression'. Without the (<?>) combinator, the message would be like '...: expecting "let" or letter', which is less friendly.  <$?> (<$?>) :: Stream s Identity tok => (a -> b) -> (a, Parsec s st a) -> StreamPermParser s st b{StreamsIdentitytokab(,)aParsecsstaStreamPermParsersstbUThe expression f <$?> (x,p) creates a fresh permutation parser consisting of parser p. The the final result of the permutation parser is the function f applied to the return value of p. The parser p is optional - if it can not be applied, the default value x will be used instead.  <$$> (<$$>) :: Stream s Identity tok => (a -> b) ->  Parsec s st a -> StreamPermParser s st b`StreamsIdentitytokabParsecsstaStreamPermParsersstb1The expression f <$$> p creates a fresh permutation parser consisting of parser p. The the final result of the permutation parser is the function f applied to the return value of p. The parser p is not allowed to accept empty input - use the optional combinator (<$?>) instead. If the function f takes more than one parameter, the type variable b is instantiated to a functional type which combines nicely with the adds parser p to the (<||>) combinator. This results in stylized code where a permutation parser starts with a combining function f followed by the parsers. The function f gets its parameters in the order in which the parsers are specified, but actual input can be in any order.  SourcePosdata  SourcePos The abstract data type SourcePos represents source positions. It contains the name of the source (i.e. file name), a line number and a column number. SourcePos is an instance of the Show, Eq and Ord class.  sourceName sourceName ::  SourcePos ->  SourceNamem SourcePos SourceName8Extracts the name of the source from a source position.  SourceNametype  SourceName = String sourceLine sourceLine ::  SourcePos -> LinehT SourcePosLine1Extracts the line number from a source position.  sourceColumn sourceColumn ::  SourcePos -> Column SourcePosColumn3Extracts the column number from a source position.  setSourceName setSourceName ::  SourcePos ->  SourceName ->  SourcePos SourcePos SourceName SourcePosSet the name of the source.  setSourceLine setSourceLine ::  SourcePos -> Line ->  SourcePosz[ SourcePosLine SourcePos*Set the line number of a source position. setSourceColumnsetSourceColumn ::  SourcePos -> Column ->  SourcePos8 SourcePosColumn SourcePos,Set the column number of a source position.  ParseErrordata  ParseError>The abstract data type ParseError represents parse errors. It provides the source position (SourcePos) of the error and a list of error messages (Message). A ParseError can be returned by the function Text.Parsec.Prim.parse. ParseError is an instance of the Show class. Linetype Line = Int incSourceLine incSourceLine ::  SourcePos -> Line ->  SourcePos{ SourcePosLine SourcePos1Increments the line number of a source position. incSourceColumnincSourceColumn ::  SourcePos -> Column ->  SourcePos_> SourcePosColumn SourcePos3Increments the column number of a source position. errorPoserrorPos ::  ParseError ->  SourcePos ParseError SourcePos2Extracts the source position from the parse error Columntype Column = IntjTokenmodule Text.ParserCombinators.Parsec.TokenParsec compatibility module  Tokenmodule Text.Parsec.TokensA helper module to parse lexical elements (tokens). See makeTokenParser for a description of how to use it. Stringmodule Text.Parsec.StringGMake Strings an instance of Stream with Char token type. Primmodule Text.ParserCombinators.Parsec.PrimDParsec compatibility module Primmodule Text.Parsec.Prim"The primitive parser combinators. Posmodule Text.ParserCombinators.Parsec.PosParsec compatibility module Posmodule Text.Parsec.PosNTextual source positions. Permmodule Text.ParserCombinators.Parsec.PermParsec compatibility module  Permmodule Text.Parsec.Perm6This module implements permutation parsers. The algorithm used is fairly complex since we push the type system to its limits :-) The algorithm is described in: Parsing Permutation Phrases, by Arthur Baars, Andres Loh and Doaitse Swierstra. Published as a functional pearl at the Haskell Workshop 2001. parsecpackage parseccjMonadic parser combinators Parsec is designed from scratch as an industrial-strength parser library. It is simple, safe, well documented (on the package homepage), has extensive libraries and good error messages, and is also fast. It is defined as a monad transformer that can be stacked on arbitrary monads, and it is also parametric in the input stream type.  Parsecmodule Text.ParserCombinators.ParsecParsec compatibility module Parsecmodule Text.ParsecaLazymodule Text.Parsec.ByteString.LazyPMake lazy ByteStrings an instance of Stream with Char token type. Languagemodule Text.ParserCombinators.Parsec.LanguageBParsec compatibility module  Languagemodule Text.Parsec.LanguageA helper module that defines some language definitions that can be used to instantiate a token parser (see Text.Parsec.Token). Exprmodule Text.ParserCombinators.Parsec.ExprjParsec compatibility module  Exprmodule Text.Parsec.ExprhA helper module to parse "expressions". Builds a parser given a table of operators and associativities. Errormodule Text.ParserCombinators.Parsec.ErrornParsec compatibility module Errormodule Text.Parsec.Error Parse errors  Combinatormodule Text.ParserCombinators.Parsec. Combinator#Parsec compatibility module  Combinatormodule Text.Parsec. Combinator"Commonly used generic combinators Charmodule Text.ParserCombinators.Parsec.CharParsec compatibility module Charmodule Text.Parsec.Char=!Commonly used character parsers.  ByteStringmodule Text.Parsec. ByteStringRMake strict ByteStrings an instance of Stream with Char token type. ~jR5$W3{VTextParserCombinatorsParsecTokenTextParserCombinatorsParsecPermTextParserCombinatorsParsecLanguageTextParserCombinatorsParsecExprTextParserCombinatorsParsecPosTextParserCombinatorsParsecErrorTextParserCombinatorsParsecCharTextParserCombinatorsParsec CombinatorTextParserCombinatorsParsecPrimTextParserCombinatorsParsecTextParsecPermTextParsecLanguageTextParsecExprTextParsecTokenTextParsecErrorTextParsecPosTextParsec ByteStringLazyTextParsec ByteStringTextParsecStringTextParsec CombinatorTextParsecCharTextParsecPrimTextParsecparsec3.0.0Bhttp://hackage.haskell.org/packages/archive/parsec/3.0.0/doc/html/Ahttp://hackage.haskell.org/cgi-bin/hackage-scripts/package/parsec