HOOGTmg'..0033551/045uuww2 8QR_ aaa >>JLNNQRTVY]aagjnrtwyy|}b+,==BBYYaac %%**1167::@@BBJKQRYY[\^agirrtwyzd!#%(6>>FFRRnp}}e !')*88:;>BFFIMPRTTWY^bddffiinsxy}}f '9IIOPSSaaffnng+,88:=?BWWYYffhippxxh!!1167>EQQWW^^yyi !!#%',89;;ABFTXY]]ccffhjnprrxy~k 1167BBgiyyl !%''-6;;ABEEIIKLUY[[dfiimnrrtuxy~m "&78IIYdyyn #%(,116;@BEOWYcfhjmmoptz|}o  !-:<=@@BBIIOPRSYYaaddffjjxxz{p  !&&88<=CEIIMMPRZ\_afmqr|r  !''+,28<=DEINPRTTYY\\^^aaffhjlsvw{{s %%*,11679:@@DEHHMMOSUUXYbbhikmst! &'+,88:;?EGHJNTUWWYYabddffhjlmorxx{{~u +,116799<=CESS[]cceflmyyvNNssw !!RRx #$))FFOPSS]]y &&==VVYY`az VVyy3DtMl%a"c()J"->"All!Any! BlockReason!Bool! ByteStringY!CChar!CClock CDev CDoubleT CFloatCInoCIntkCIntMax#CIntPtrCLDoubleCLLong:CLongCModeCOffbCPidCPtrdiffCSCharCShortB CSigAtomicCSizeCSsizejCTime8CUCharCUIntCUIntMax`CUIntPtrCULLongCULongCUShort@CWcharChanCharComplex ConsoleEventConstr ConstrRepDataRepDataType~DoubleeDynamicLE12=E6.Either#Errno ExceptionFdFixityFloatGeneralCategorywHashDatanIOXIdCInserts?IntInt16Int32Int64Int8IntPtrrIntegerZLexemeQMaybeNestedAtomically NoMethodErrorNonTerminationOrderingPPatternMatchFail}QSemsQSemNiReadPPReadPrec7 RecConError RecSelError RecUpdErrorSTM StableNameTVarThreadId ThreadStatusTimeout~UniquevVersion[WordBWord16)Word32Word64Word8WordPtrZipList[::]r[]1 TraversableFoldable Applicative AlternativeMonadFix MonadPlusFunctorMonadFunctor Applicative ReadShowTypeableBitsIntegralBoundedRealStorableEnumNumOrdEq PrintfArgDataStorable PrintfArgDataStorable PrintfArgDataStorable PrintfArgDataStorable PrintfArgDataStorableEqOrdShowReadTypeableOrdEqTypeableShow ExceptionEqShowOrdEqShowEqOrdTypeable Typeable1 Typeable1 Typeable1FunctorMonadTypeableShow ExceptionTypeableShow ExceptionTypeableShow ExceptionFunctorMonad MonadPlusFunctorMonad MonadPlusTypeableTypeableTypeableShow ExceptionMonad MonadPlusMonoidDataIxTypeableShow ExceptionTypeableShow ExceptionTypeableShow Exception TraversableFoldable Applicative AlternativeMonadFix MonadPlusFunctorMonadShowEq PrintfArgDataBitsIx ReadShowTypeableBitsIntegralBoundedRealStorableEnumNumOrdEq PrintfArgDataStorable PrintfArgDataStorable PrintfArgDataStorable PrintfArgDataStorable PrintfArgDataStorableBitsIxEqFunctor Applicative ApplicativeMonadFixShowEqIxBoundedShowReadEnumOrdEq PrintfArgDataStorableShowEq ReadShowTypeableBitsIntegralBoundedRealStorableEnumNumOrdEqTypeable ExceptionShowEqEq Typeable2 HasResolution HasResolution ExceptionTypeableShow PrintfArgDataStorableShowShowEqShowEqShowEqReadShowEnumOrdEqTypeable Typeable1 PrintfArgIsCharDataStorableIx 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 ReadShowTypeableBitsIntegralBoundedRealStorableEnumNumOrdEqIsStringEqOrdMonoidIsStringEqOrdMonoidDataReadShowTypeableShowReadDataTypeableDataStorableIxShowOrdEqMonoidBoundedShowReadOrdEqMonoidBoundedShowReadOrdEqArrow ArrowChoice ArrowApply ArrowLoopCategoryMonoidDataEqOrdIxe" ByteCount%CString% CStringLeny%CWStringi% CWStringLenM% ClockTickD%ConIndex>%DeviceID7% EpochTime/%FileID(%FileMode % FileOffset%FilePath %FinalizerEnvPtr$ FinalizerPtr$IOError$IPr$Limit$Micro$Picoq$Preck$ProcessGroupIDd$ ProcessID]$RationalJ$ReadS$ SampleVar#ShowS#String#[]Char[]Char[]CharaMVar(,)IntMVaraa[]Char[](,)a[]CharRatioIntegerCPidCPidIntFixedE12FixedE6CLong(,)IntInt IOExceptionaFunPtrPtraIO()envaFunPtrPtrenvPtraIO()[]CharCOffCModeCInoCTimeCDevIntCClock(,)PtrCWcharIntPtrCWchar(,)PtrCCharIntPtrCCharCSize(:l[lavfbbc-XdTehQf`MgLhKiFjFkFlCm@n)>ot;p8q7r3s.t*u(v(wj&z/&i6&p=&lD&iK&sR&tY&ZipList#(ep(o'r&a&i&t&e&m&o&d&e&IOModep&a'mX'p&e&d&a&'m&o&n'a 'd' WrappedMonadr-'r4'o;'wB' WrappedArrowo_'nf'am'dt' WrappedMonadr'r'o'w' WrappedArrowr'd'Word#a(1J(33(6(8 (p't'r'WordPtrWord84#(Word642:(Word326Q(Word16Word#aw(k~(WeakWorde(r(s(i(o(n(Versionn)pC)s(e(r(i(n(t)e )r)r)u!)p()t/)AsyncExceptionpJ)eQ)rX)c_)af)sm)et)l{)e)t)t)e)r)GeneralCategoryd)i)q)u)e)Uniquee)f'*r)f)l*o *w*ArithExceptioni.*n5*e<*dC*eJ*lQ*eX*m_*ef*nm*tt*ArrayExceptionh,iQ,r+v+y*c+p*e*a*r*e*p*TypeRepb*l*e*Typeable1+2+3w+4d+5Q+6>+7++ Typeable7 Typeable6 Typeable5 Typeable4 Typeable3 Typeable2 Typeable1o+n+TyCona+r+TVar#+TVar#a,v ,e,r,s ,a',b.,l5,e<, TraversabletX,l_,ef,cm,at,s{,e,l,e,t,t,e,r,GeneralCategoryr,e,a,d,bI.d".f-i-kw-r;-s-t -a-t-u-s%- ThreadStatusuB-nI-nP-iW-n^-ge- ThreadStatusi~-l-l-e-d-AsyncExceptiond-ThreadId#- ThreadId#i-n-i-s-h.e .d. ThreadStatusi).e0.d7. ThreadStatuslP.oW.c^.ke.el.ds. ThreadStatusaA3e2h^2o1pM1t//u.y.m.b.o.l.Lexemem"/r.r.o.g.a.t/e /GeneralCategorySumSTa<0m/0o/rO/e/i[/nb/gi/Stringc/r/e/p/DataRepo/n/s/t/r/ ConstrRepf/p/STRepSTRefr0a0b0l0e0StorableSTMb0c0rp0tR0eY0#`0State#rw0a~0y0STArrayk0o0v0e0r0f0l0o0w0AsyncExceptionl0e0n$1p1t 1r1 StablePtra+1m21e91 StableNameaT1c[1e1ig1nn1gu1c|1o1m1b1i1n1i1n1g1m1a1r1k1GeneralCategoryGeneralCategorym2e2e2x2c2e$2p+2t22i92o@2nG2 SomeExceptiono2uj2tq2dx2o2w2n2 ConsoleEventw2Shows2ShowSe2k2f 3m2o2d2e2SeekModer3o3m3e%3n,3d33SeekModemH3pO3lV3e]3vd3ak3rr3 SampleVara57e3i3g3h3t3Eithera5c4l4q&4t3u3r3n3i3n3o3r4d 4e4r4ArgOrderax4u24i94r@4eG4oN4rU4d\4ec4rj4ArgOrderr4g4ArgDescra4t4i4v4e4s4e4e4k4SeekModec~5s85u4p4d5e5r5r5o5r#5 RecUpdErrore?5lF5eM5rT5r[5ob5ri5 RecSelErroro5n5e5r5r5o5r5 RecConErrordk6l5Realf6w5o5r5l5d6 RealWorldlC6r#6a*6c16RealFracoJ6aQ6tX6 RealFloatReadm7p6s6w6r6i6t6e6m6o6d6e6IOModeReadSReadPr6e6c7ReadPreco7d"7e)7IOModet~7wA7bH7uO7fV7f]7ed7rk7 RawBufferLexemei7o7Ration7a7l7Rationals7e7m7QSemn7QSemNau:eD:i(:o :ri8sY8tE8u+8n28c98LexemerL8Ptr ByteStringe9i)9oz8c8d8u8c8t8Producte8s8s8g8i8d8 ProcessIDr8o8u8p9i 9d9ProcessGroupIDnt9v59a<9tC9eJ9uQ9sX9e_9GeneralCategoryt{9f9a9t9y9p9e9 PrintfTyper9g9 PrintfArgc9f9i9x9FixityPreco:l:Poolc/:o6:PicorK:mR:uY:t`:eg:ArgOrderr:t:t:e:r:n:m:a:t:c:h:f:a:i:l:PatternMatchFaila:g;r ;a;p;h ;s';e.;p5;a<;rC;aJ;tQ;oX;r_;GeneralCategoryp==r<t;v;e;r;f;l;o;w;ArithExceptionh;e;r;l<n<p+<s;y;m<b<o<l<GeneralCategoryu2<n9<c@<tG<uN<aU<t\<ic<oj<nq<GeneralCategoryu<m<b<e<r<GeneralCategorye<t<t<e<r<GeneralCategoryd<Orde=r=i=n$=g+=Orderinge=tI=a=dv=iZ=oa=nh=OptDescre}=s=c=r=OptDescrr=g=ArgDescrn=p=u=n=c=t=u=a=t=i>o >n>GeneralCategorye@oN>u:>mA>Numae@b@m?n>r>tn>a>hz>i>n>g>Maybes>s>i>g>n>e>d>GeneralCategorye>p>DataRepse?t?e?r?m?i#?n*?a1?t8?i??oF?nM?NonTerminationpl?as?cz?i?n?g?m?a?r?k?GeneralCategorye?t?h?o?d?e?r?r?o?r@ NoMethodErroru$@f+@f2@e9@r@@iG@nN@gU@ BufferModerl@gs@ArgDescrs@t@e@d@a@t@o@m@i@c@a@l@l@y@NestedAtomicallyalCiHCo BuHAvAaAr&AMVar#9AMVar#tOAaVAb]AldAekAaAbwAy~AtAeAaArArAaAyA#AMutableByteArray#rArAaAyA#A MutableArray#dBnBaABo#Bi*Bd1BMonoiddHBMonadfBpaBlhBuoBsvB MonadPlusiBxBMonadFixiBfBiBeBrBlCsByBmBbBoBlBGeneralCategoryeCtCt%Ce,Cr3CGeneralCategorycOCrVCo]CMicrotCyxCbCeCMaybehCsCyCmCbCoClCGeneralCategoryahFeEiDoCgDskDwDe DrDcDaDs%De,Dl3De:DtADtHDeODrVDGeneralCategorysrDoyDfDpDrDeDcDiDsDiDoDnDArithExceptionoDfDfD ConsoleEventmEnEe EbfEsEe Ep'Ea.Er5EaSErrnoEqo`ScgShnStuSi|SmSeS EpochTimefSLexemecSdSuSmSEnumoSEndolSoSsTiTnTgTmTa#Tr*Tk1TGeneralCategorypMTtTTy[T ByteStringtrThyTeTrTEitherE62TE12aSWeViUosUuWUyTnTa1UeTxTcTeTpUt UiUoUn"U Exceptionm8Ui?UcFUDynamica^UleUDualuUwUnUDownbUlUeUDoublevUiUdUeUbUyUzUeUrUoUArithExceptionaWcVfVncVv.Vi5VccBoundedlVcBoolokccrckycbfecrcecacscocnc BlockReasondcieocncb_edeedfsdmMdo dsdtdmd BlockReasont'dh.de5dr*Int[]oaA-Int64Maybe~m_?Int64[]pbBWord8 ForeignPtrWord8IOWord8MaybeWord8[]&aIO;:a[]z ByteStringChar(,)Maybe ByteStringInt(,)Maybe  ByteStringInteger(,)Maybe! ByteStringWord8(,)Maybe"CharChar(,)[]+Word8Word8(,)[],a ByteString(,)IOQIntIntWord8 ForeignPtr(,,)()PtrIOWord8PtrIOa ForeignPtrIOKHt рxxxBxwvXvt BoolCharCharvBoolWord8Word8CharCharCharyxwWord8Word8Word8a ByteStringaaCharCharzaCharaaWord8Word8aWord8aaa ByteStringiaaChar{aaWord8Characc(,)CharaccWord8acc(,)Word8accBoolChar rqponmlkjBoolWord8 ~}| ByteString ByteStringh ByteStringChars ByteStringWord8CharCharutWord8Word8aChar(,)MaybeaUaWord8(,)MaybeaV()IOWord8PtrSRIntIOWord8PtrTaIOCCharPtr;aIntInt(,,)IOWord8PtrQaIOIntCCharPtr(,): Addr#L ByteString~}|{zzyxwvtsrqponmlkjifedcba`_^]XWNMIFEDCBA@?>;:9876543210//..--,,++**))('&%$#"!^CIntCSize  CULong  CharyuYOGFEDCBA@?>=<1HandleJIHIntVUTSRQPONMLKJ43Int64ZYXW76 RawBufferWord8gfedcba`_^]\[ZP9 a {iVUacc  ()IO ByteString[]$CCharPtr Char[]Word8 ForeignPtrWord8Ptr      Word8[]aIOaPtrCharChar(,)[]Word8Word8(,)[]IntCCharPtr(,)zoP5"ˍ}rgXMB3͌Œqf[0!pU؊Ɋa:+݉j_L=2# ۈЈňpI>3$ه·Ç|qfSH9. ׆̆uf[PA6+ׅ̅xiV/$ ΄whE2#ЃDE$%stwe43()mTSU&'*+TV/Cb, oq!^$  MZ[wxSuvy~a+ionpUVr#qpvxYz;M=H\ W *h"f59Qa):E]!?14 56723}ebcjlkiFKCStringjGL CStringLenX 0AFG<8=B rsW]^ >?@#lRQ"y9RY_%&D\dfIg87<.:`'(-N}d2  1 NO;.>J ktuOPXFilePathStringP  FilePath 6H`{c/0hJIA~CStringK@CCStringLB CStringLen_gmn,-|I+ۧ{OۦkM/ѥf<Z@ʣX*٢a7 š{Y7٠kS%O/ٞsS1ߝcE#ӜiI5˛Y3[;͙oK#ݘqK) חeM-ǖ}[;͕Y9ߔsS1ϓa-ӒM/eG!zipwith-zipWithmSTzipOziplQR writefiles writeFilekOPwordswordsNw2cw2cMuseascstringlenϑuseAsCStringLenjL useascstring useAsCStringiKunzipunziphIJunwords;unwordsHunsafeuseascstringlengunsafeUseAsCStringLenGunsafeuseascstringunsafeUseAsCStringF unsafetake’ unsafeTakeE unsafetail unsafeTailDunsafepackmalloccstringunsafePackMallocCStringCunsafepackcstringlenFunsafePackCStringLenBunsafepackcstringfinalizerunsafePackCStringFinalizerAunsafepackcstringunsafePackCString@unsafepackaddresslenunsafePackAddressLen?unsafepackaddressunsafePackAddress> unsafeindexA unsafeIndex= unsafeheadb unsafeHead<unsafefinalizeunsafeFinalize; unsafedrop unsafeDrop: unsafecreate̔ unsafeCreate9unsafeUnsafeunpackunpackg78unlines'unlines6unfoldrnFunfoldrNf5unfoldreunfoldre34unconsunconsd12 transpose transposec/0 toforeignptrޕ toForeignPtr.tochunkstoChunks- takewhile takeWhileb+,takeDtakea)*tailsetails`'(tailtail_%& splitwith splitWith^#$splitatӖsplitAt]!"splitsplit\ spanendspanEnd[span6spanZsortVsortYsnocnsnocXsmallchunksizesmallChunkSize singleton singletonWscanr1scanr1VscanrscanrUscanl1scanl1Tscanl3scanlSreverseWreverseR replicate replicateQrepeatrepeat  readintegerǘ readInteger readintreadInt readfilereadFileP  putstrln0putStrLnOputstrVputStrNpsvPS partition partitionMpackcstringlenpackCStringLenL packcstringݙ packCStringKpackpackJnullforeignptr&nullForeignPtrnullDnullInotelemgnotElemHminimumminimumGmemsetmemsetmemcpy_ptr_baoffԚmemcpy_ptr_baoffmemcpymemcpymemcmpmemcmpmemchr&memchrmaximum?maximumF mapaccumrg mapAccumRE mapaccuml mapAccumLDmapmapCmallocbytestringmallocByteStringlineslineslengthlengthBlazy>LazylastRlastAiterateuiterate issuffixof isSuffixOf@ isspaceword8 isSpaceWord8 isspacechar8 isSpaceChar8 isprefixof isPrefixOf? isinfixof1 isInfixOf> invariantS invariant intersperses intersperse=internalInternal intercalate intercalate<interactinteract;inlineperformioinlinePerformIOinits;inits:init\init9index}index8 hputstrln hPutStrLn7hputstrÞhPutStr6hputhPut5hgetnonblocking hGetNonBlocking4hgetline<hGetLine3 hgetcontents` hGetContents2hgethGet1headhead0groupby˟groupBy/~groupgroup.}getlinegetLine- getcontents5 getContents,|fusion^Fusionfromforeignptr~fromForeignPtr fromchunks fromChunks{ foldrchunksǠ foldrChunkszfoldr1'foldr1'+foldr1foldr1*yfoldr'&foldr')foldrAfoldr(x foldlchunksi foldlChunkswfoldl1'foldl1''vfoldl1foldl1&ufoldl'Сfoldl'%tfoldlfoldl$sfindsubstringsfindSubstrings# findsubstringI findSubstring" findindicesq findIndices!r findindex findIndex qfind¢findpfilterfilteroemptyEmptymemptyn elemindices: elemIndicesl elemindexendi elemIndexEnd elemindex elemIndexkelemelemj dropwhileأ dropWhileidropdrophdefaultchunksize)defaultChunkSizegcycleJcyclefcreateandtrim'mcreateAndTrim' createandtrim createAndTrimcreatecreatecountʤcountecopycopydcons' cons'ccons%consb concatmapJ concatMapaconcatqconcat` chunkoverhead chunkOverhead_chunkChunk]chunk^checkinvariantcheckInvariant\char8Char8c_strlen c_strlen c_reverse= c_reverse c_minimum[ c_minimum c_maximumy c_maximum c_intersperse c_interspersec_free_finalizerĦc_free_finalizerc_countc_count~c2wc2w} bytestring ByteStringz{|Z[ bytestringbreaksubstringbbreakSubstringybreakendbreakEndx breakbyte breakBytebreakçbreak vwY appendfile appendFile tuXappendappend rsWany3any pqVallQall noUXٮCѡIԙVj}xi˃HZ~}/|{yxywvuEusr&qndlkji8izhgfeodca`_]\ \ZXVUTTShRPhOM,MLJJIsHFYEqDyCBBqA/@c>;:8775432/-,+e*(J(& %$"! , xn _S    6 (='Wp!E o@LGO;Bqmgpu[^@һRZշ  Oت̩8u@ ]@Nb^Ucgosϔtϒ.abrIYBd` Հ{ ~G}{zy4ywutsrrwqpoomlj]hedca_^^@]y\A[ZXhWVUTSS%RhODMJIVIH(GECBAA<9f7520.-F(<$s#V")!d6)hemu A m  < R  !@VkBi%d@!4c@+j[vj;_"^|",hDP޾ؼܹѶ?viGzipWith zipWith :: (Char -> Char -> a) ->  ByteString ->  ByteString -> [a]įCharChara ByteString ByteString[]azipWith generalises zip by zipping with the function given as the first argument, instead of a tupling function. For example, zipWith (+) is applied to two ByteStrings to produce the list of corresponding sums. zipzip ::  ByteString ->  ByteString -> [(Char, Char)]O ByteString ByteString[](,)CharChar4O(n) zip takes two ByteStrings and returns a list of corresponding pairs of Chars. If one input ByteString is short, excess elements of the longer ByteString are discarded. This is equivalent to a pair of unpack operations, and so space usage may be large for multi-megabyte ByteStrings  writeFile writeFile :: FilePath ->  ByteString -> IO ()@FilePath ByteStringIO()%Write a ByteString to a file. wordswords ::  ByteString ->  [ByteString]׳ ByteString[] ByteStringwords breaks a ByteString up into a list of words, which were delimited by Chars representing white space. And
tokens isSpace = words
unwordsunwords ::  [ByteString] ->  ByteStringǴ[] ByteString ByteStringSThe unwords function is analogous to the unlines function, on words. unpackunpack ::  ByteString -> [Char] ByteString[]Char=O(n) Converts a ByteString to a String. unlinesunlines ::  [ByteString] ->  ByteStringV5[] ByteString ByteStringwunlines is an inverse operation to lines. It joins lines, after appending a terminating newline to each. unfoldrunfoldr :: (a -> Maybe (Char, a)) -> a ->  ByteStringi9aMaybe(,)Charaa ByteStringO(n) The unfoldr function is analogous to the List 'unfoldr'. unfoldr builds a ByteString from a seed value. The function takes the element and returns Nothing if it is done producing the ByteString or returns Just (a,b), in which case, a is a prepending to the ByteString and b is used as the next element in a recursive call. unconsuncons ::  ByteString -> Maybe (Char, ByteString)N ByteStringMaybe(,)Char ByteStringYO(1) Extract the head and tail of a ByteString, returning Nothing if it is empty.  transpose transpose ::  [ByteString] ->  [ByteString]Z3[] ByteString[] ByteStringaThe transpose function transposes the rows and columns of its ByteString argument. toChunkstoChunks ::  ByteString ->  [ByteString]3 ByteString[] ByteStringUO(n) Convert a lazy ByteString into a list of strict ByteString  takeWhile takeWhile :: (Char -> Bool) ->  ByteString ->  ByteString"CharBool ByteString ByteStringtakeWhile, applied to a predicate p and a ByteString xs, returns the longest prefix (possibly empty) of xs of elements that satisfy p. taketake :: Int64 ->  ByteString ->  ByteStringT2Int64 ByteString ByteStringO(n\c)/ take n, applied to a ByteString xs, returns the prefix of xs of length n, or xs itself if n > length xs. tailstails ::  ByteString ->  [ByteString]d ByteString[] ByteStringUO(n) Return all final segments of the given ByteString, longest first. tailtail ::  ByteString ->  ByteStringB' ByteString ByteStringZO(1) Extract the elements after the head of a ByteString, which must be non-empty.  splitWith splitWith :: (Char -> Bool) ->  ByteString ->  [ByteString]>CharBool ByteString[] ByteStringKO(n) Splits a ByteString into components delimited by separators, where the predicate returns True for a separator element. The resulting components do not contain the separators. Two adjacent separators result in an empty component in the output. eg.
splitWith (=='a') "aabbaca" == ["","","bb","c",""]
splitAtsplitAt :: Int64 ->  ByteString -> (ByteString, ByteString)0Int64 ByteString(,) ByteString ByteStringlO(n\c)/ splitAt n xs is equivalent to (take n xs, drop n xs). splitsplit :: Char ->  ByteString ->  [ByteString]$Char ByteString[] ByteStringO(n) Break a ByteString into pieces separated by the byte argument, consuming the delimiter. I.e.
split '\n' "a\nb\nd\ne" == ["a","b","d","e"]
split 'a'  "aXaXaXa"    == ["","X","X","X"]
split 'x'  "x"          == ["",""]
and
intercalate [c] . split c == id
split == splitWith . (==)
As for all splitting functions in this library, this function does not copy the substrings, it just constructs new ByteStrings that are slices of the original. spanspan :: (Char -> Bool) ->  ByteString -> (ByteString, ByteString)CharBool ByteString(,) ByteString ByteStringspan p xs breaks the ByteString into two segments. It is equivalent to (takeWhile p xs, dropWhile p xs) snocsnoc ::  ByteString -> Char ->  ByteString ByteStringChar ByteStringvO(n) Append a Char to the end of a ByteString. Similar to cons, this function performs a memcpy. smallChunkSizesmallChunkSize :: IntInt9Currently set to 4k, less the memory management overhead  singleton singleton :: Char ->  ByteString)Char ByteString;O(1) Convert a Char into a ByteString scanl scanl :: (Char -> Char -> Char) -> Char ->  ByteString ->  ByteStringCharCharCharChar ByteString ByteStringscanl is similar to foldl, but returns a list of successive reduced values from the left. This function will fuse.
scanl f z [x1, x2, ...] == [z, z `f` x1, (z `f` x1) `f` x2, ...]
Note that
last (scanl f z xs) == foldl f z xs.
reversereverse ::  ByteString ->  ByteString{ ByteString ByteString]O(n) reverse xs returns the elements of xs in reverse order.  replicate replicate :: Int64 -> Char ->  ByteStringqUInt64Char ByteString{O(n) replicate n x is a ByteString of length n with x the value of every element. repeatrepeat :: Char ->  ByteStringL7Char ByteString`repeat x is an infinite ByteString, with x the value of every element.  readInteger readInteger ::  ByteString -> Maybe (Integer, ByteString)L ByteStringMaybe(,)Integer ByteStringreadInteger reads an Integer from the beginning of the ByteString. If there is no integer at the beginning of the string, it returns Nothing, otherwise it just returns the int read, and the rest of the string. readIntreadInt ::  ByteString -> Maybe (Int, ByteString)~ ByteStringMaybe(,)Int ByteStringreadInt reads an Int from the beginning of the ByteString. If there is no integer at the beginning of the string, it returns Nothing, otherwise it just returns the int read, and the rest of the string. readFilereadFile :: FilePath ->  IO ByteStringFilePathIO ByteStringmRead an entire file lazily into a ByteString. Use 'text mode' on Windows to interpret newlines putStrLnputStrLn ::  ByteString -> IO () ByteStringIO()7Write a ByteString to stdout, appending a newline byte putStrputStr ::  ByteString -> IO ()_F ByteStringIO()Write a ByteString to stdout packpack :: [Char] ->  ByteString[]Char ByteString>O(n) Convert a String into a ByteString. nullnull ::  ByteString -> Boolze ByteStringBool0O(1) Test whether a ByteString is empty. notElemnotElem :: Char ->  ByteString -> Bool"Char ByteStringBool9O(n) notElem is the inverse of elem minimumminimum ::  ByteString -> Char ByteStringCharBminimum returns the minimum value from a ByteString maximummaximum ::  ByteString -> CharaL ByteStringCharBmaximum returns the maximum value from a ByteString  mapAccumR  mapAccumR :: (acc -> Char -> (acc, Char)) -> acc ->  ByteString -> (acc, ByteString)8accChar(,)accCharacc ByteString(,)acc ByteStringThe mapAccumR function behaves like a combination of map and foldr; it applies a function to each element of a ByteString, passing an accumulating parameter from right to left, and returning a final value of this accumulator together with the new ByteString.  mapAccumL  mapAccumL :: (acc -> Char -> (acc, Char)) -> acc ->  ByteString -> (acc, ByteString){0accChar(,)accCharacc ByteString(,)acc ByteStringThe mapAccumL function behaves like a combination of map and foldl; it applies a function to each element of a ByteString, passing an accumulating parameter from left to right, and returning a final value of this accumulator together with the new ByteString. mapmap :: (Char -> Char) ->  ByteString ->  ByteString!CharChar ByteString ByteStringvO(n) map f xs is the ByteString obtained by applying f to each element of xs lineslines ::  ByteString ->  [ByteString]  ByteString[] ByteStringlines breaks a ByteString up into a list of ByteStrings at newline Chars. The resulting strings do not contain newlines. As of bytestring 0.9.0.3, this function is stricter than its list cousin. lengthlength ::  ByteString -> Int646  ByteStringInt64SO(n\c)/ length returns the length of a ByteString as an Int64 lastlast ::  ByteString -> Char ByteStringCharRO(1) Extract the last element of a packed string, which must be non-empty. iterateiterate :: (Char -> Char) -> Char ->  ByteStringCharCharChar ByteStringiterate f x returns an infinite ByteString of repeated applications of f to x:
iterate f x == [x, f x, f (f x), ...]
 isPrefixOf isPrefixOf ::  ByteString ->  ByteString -> Bool ByteString ByteStringBoolO(n) The isPrefixOf function takes two ByteStrings and returns True iff the first is a prefix of the second.  invariant invariant ::  ByteString -> Bool ByteStringBoolThe data type invariant: Every ByteString is either Empty or consists of non-null ByteStrings. All functions must preserve this, and the QC properties must check this.  intersperse intersperse :: Char ->  ByteString ->  ByteStringChar ByteString ByteStringO(n) The intersperse function takes a Char and a ByteString and `intersperses' that Char between the elements of the ByteString. It is analogous to the intersperse function on Lists.  intercalate intercalate ::  ByteString ->  [ByteString] ->  ByteString` ByteString[] ByteString ByteStringO(n) The intercalate function takes a ByteString and a list of ByteStrings and concatenates the list after interspersing the first argument between each element of the list. interactinteract :: (ByteString -> ByteString) -> IO () ByteString ByteStringIO()The interact function takes a function of type ByteString -> ByteString as its argument. The entire input from the standard input device is passed to this function as its argument, and the resulting string is output on the standard output device. initsinits ::  ByteString ->  [ByteString]S2 ByteString[] ByteStringXO(n) Return all initial segments of the given ByteString, shortest first. initinit ::  ByteString ->  ByteString ByteString ByteStringSO(n\c)/ Return all the elements of a ByteString except the last one. indexindex ::  ByteString -> Int64 -> Char ByteStringInt64CharKO(1) ByteString index (subscript) operator, starting from 0. hPuthPut :: Handle ->  ByteString -> IO ()Handle ByteStringIO()<Outputs a ByteString to the specified Handle. hGetNonBlockinghGetNonBlocking :: Handle -> Int ->  IO ByteStringqOHandleIntIO ByteStringhGetNonBlocking is similar to hGet, except that it will never block waiting for data to become available, instead it returns only whatever data is available.  hGetContents hGetContents :: Handle ->  IO ByteStringrHandleIO ByteStringRead entire handle contents lazily into a ByteString. Chunks are read on demand, using the default chunk size. Once EOF is encountered, the Handle is closed. hGethGet :: Handle -> Int ->  IO ByteStringHandleIntIO ByteString[Read n bytes into a ByteString, directly from the specified Handle. headhead ::  ByteString -> Charp[ ByteStringCharPO(1) Extract the first element of a ByteString, which must be non-empty. groupBygroupBy :: (Char -> Char -> Bool) ->  ByteString ->  [ByteString]l7CharCharBool ByteString[] ByteStringKThe groupBy function is the non-overloaded version of group. groupgroup ::  ByteString ->  [ByteString]) ByteString[] ByteStringThe group function takes a ByteString and returns a list of ByteStrings such that the concatenation of the result is equal to the argument. Moreover, each sublist in the result contains only equal elements. For example,
group "Mississippi" = ["M","i","ss","i","ss","i","pp","i"]
It is a special case of groupBy, which allows the programmer to supply their own equality test.  getContents getContents ::  IO ByteStringIO ByteStringGgetContents. Equivalent to hGetContents stdin. Will read lazily  fromChunks fromChunks ::  [ByteString] ->  ByteString[] ByteString ByteStringUO(c) Convert a list of strict ByteString into a lazy ByteString  foldrChunks  foldrChunks :: (ByteString -> a -> a) -> a ->  ByteString -> a ByteStringaaa ByteStringaCConsume the chunks of a lazy ByteString with a natural right fold. foldr1foldr1 :: (Char -> Char -> Char) ->  ByteString -> CharCharCharChar ByteStringCharfoldr1 is a variant of foldr that has no starting value argument, and thus must be applied to non-empty ByteStrings foldr foldr :: (Char -> a -> a) -> a ->  ByteString -> aCharaaa ByteStringafoldr, applied to a binary operator, a starting value (typically the right-identity of the operator), and a packed string, reduces the packed string using the binary operator, from right to left.  foldlChunks  foldlChunks :: (a -> ByteString -> a) -> a ->  ByteString -> aCa ByteStringaa ByteStringa_Consume the chunks of a lazy ByteString with a strict, tail-recursive, accumulating left fold. foldl1'foldl1' :: (Char -> Char -> Char) ->  ByteString -> Char:CharCharChar ByteStringCharA'foldl1\'' is like foldl1, but strict in the accumulator. foldl1foldl1 :: (Char -> Char -> Char) ->  ByteString -> CharCharCharChar ByteStringCharfoldl1 is a variant of foldl that has no starting value argument, and thus must be applied to non-empty ByteStrings. foldl' foldl' :: (a -> Char -> a) -> a ->  ByteString -> a(aCharaa ByteStringa8'foldl\'' is like foldl, but strict in the accumulator. foldl foldl :: (a -> Char -> a) -> a ->  ByteString -> aaCharaa ByteStringafoldl, applied to a binary operator, a starting value (typically the left-identity of the operator), and a ByteString, reduces the ByteString using the binary operator, from left to right.  findIndices findIndices :: (Char -> Bool) ->  ByteString -> [Int64]R(CharBool ByteString[]Int64The findIndices function extends findIndex, by returning the indices of all elements satisfying the predicate, in ascending order.  findIndex findIndex :: (Char -> Bool) ->  ByteString ->  Maybe Int64UCharBool ByteStringMaybeInt64The findIndex function takes a predicate and a ByteString and returns the index of the first element in the ByteString satisfying the predicate. findfind :: (Char -> Bool) ->  ByteString ->  Maybe CharCharBool ByteStringMaybeCharO(n) The find function takes a predicate and a ByteString, and returns the first element in matching the predicate, or Nothing if there is no such element. filterfilter :: (Char -> Bool) ->  ByteString ->  ByteStringCharBool ByteString ByteStringO(n) filter, applied to a predicate and a ByteString, returns a ByteString containing those characters that satisfy the predicate. emptyempty ::  ByteString ByteString(O(1) The empty ByteString EmptyEmpty ::  ByteString>1 ByteString elemIndices elemIndices :: Char ->  ByteString -> [Int64]Char ByteString[]Int64O(n) The elemIndices function extends elemIndex, by returning the indices of all elements equal to the query element, in ascending order.  elemIndex elemIndex :: Char ->  ByteString ->  Maybe Int64Char ByteStringMaybeInt64O(n) The elemIndex function returns the index of the first element in the given ByteString which is equal (by memchr) to the query element, or Nothing if there is no such element. elemelem :: Char ->  ByteString -> Bool6Char ByteStringBooltO(n) elem is the ByteString membership predicate. This implementation uses memchr(3).  dropWhile dropWhile :: (Char -> Bool) ->  ByteString ->  ByteStringDCharBool ByteString ByteStringbdropWhile p xs returns the suffix remaining after takeWhile p xs. dropdrop :: Int64 ->  ByteString ->  ByteString&Int64 ByteString ByteStringO(n\c)/ drop n xs returns the suffix of xs after the first n elements, or [] if n > length xs. defaultChunkSizedefaultChunkSize :: IntInt:Currently set to 32k, less the memory management overhead cyclecycle ::  ByteString ->  ByteString ByteString ByteStringcycle ties a finite ByteString into a circular one, or equivalently, the infinite repetition of the original ByteString. countcount :: Char ->  ByteString -> Int64Char ByteStringInt64count returns the number of times its argument appears in the ByteString
count      == length . elemIndices
count '\n' == length . lines
But more efficiently than using length on the intermediate list. copycopy ::  ByteString ->  ByteString ByteString ByteString*O(n) Make a copy of the ByteString with its own storage. This is mainly useful to allow the rest of the data pointed to by the ByteString to be garbage collected, for example if a large string has been read in, and only a small part of it is needed in the rest of the program. cons'cons' :: Char ->  ByteString ->  ByteString|Char ByteString ByteStringO(1) Unlike cons, 'cons\'' is strict in the ByteString that we are consing onto. More precisely, it forces the head and the first chunk. It does this because, for space efficiency, it may coalesce the new byte onto the first 'chunk' rather than starting a new 'chunk'. So that means you can't use a lazy recursive contruction like this:
let xs = cons\' c xs in xs
You can however use cons, as well as repeat and cycle, to build infinite lazy ByteStrings. conscons :: Char ->  ByteString ->  ByteString  Char ByteString ByteString9O(1) cons is analogous to '(:)' for lists.  concatMap concatMap :: (Char -> ByteString) ->  ByteString ->  ByteString  Char ByteString ByteString ByteStringDMap a function over a ByteString and concatenate the results concatconcat ::  [ByteString] ->  ByteString  [] ByteString ByteString/O(n) Concatenate a list of ByteStrings.  chunkOverhead chunkOverhead :: Int#  IntFThe memory management overhead. Currently this is tuned for GHC only. chunkchunk ::  ByteString ->  ByteString ->  ByteString   ByteString ByteString ByteStringHSmart constructor for Chunk. Guarantees the data type invariant. ChunkChunk ::  ByteString ->  ByteString ->  ByteString   ByteString ByteString ByteStringcheckInvariantcheckInvariant ::  ByteString ->  ByteStringE* ByteString ByteString,In a form that checks the invariant lazily.  ByteStringdata  ByteStringA space-efficient representation of a Word8 vector, supporting many efficient operations. A ByteString contains 8-bit characters only. Instances of Eq, Ord, Read, Show, Data, Typeable  ByteStringdata  ByteStringA space-efficient representation of a Word8 vector, supporting many efficient operations. A ByteString contains 8-bit characters only. Instances of Eq, Ord, Read, Show, Data, Typeable breakbreak :: (Char -> Bool) ->  ByteString -> (ByteString, ByteString)CharBool ByteString(,) ByteString ByteStringPbreak p is equivalent to span (not . p).  appendFile appendFile :: FilePath ->  ByteString -> IO ()FilePath ByteStringIO()&Append a ByteString to a file. appendappend ::  ByteString ->  ByteString ->  ByteString| ByteString ByteString ByteString&O(n\c)/ Append two ByteStrings anyany :: (Char -> Bool) ->  ByteString -> BoolK(CharBool ByteStringBoolApplied to a predicate and a ByteString, any determines if any element of the ByteString satisfies the predicate. allall :: (Char -> Bool) ->  ByteString -> BoolM*CharBool ByteStringBoolApplied to a predicate and a ByteString, all determines if all elements of the ByteString satisfy the predicate. zipWith zipWith :: (Word8 -> Word8 -> a) ->  ByteString ->  ByteString -> [a]VWord8Word8a ByteString ByteString[]azipWith generalises zip by zipping with the function given as the first argument, instead of a tupling function. For example, zipWith (+) is applied to two ByteStrings to produce the list of corresponding sums. zipWith zipWith :: (Char -> Char -> a) ->  ByteString ->  ByteString -> [a]4CharChara ByteString ByteString[]azipWith generalises zip by zipping with the function given as the first argument, instead of a tupling function. For example, zipWith (+) is applied to two ByteStrings to produce the list of corresponding sums. zipzip ::  ByteString ->  ByteString -> [(Word8, Word8)] ByteString ByteString[](,)Word8Word8O(n) zip takes two ByteStrings and returns a list of corresponding pairs of bytes. If one input ByteString is short, excess elements of the longer ByteString are discarded. This is equivalent to a pair of unpack operations. zipzip ::  ByteString ->  ByteString -> [(Char, Char)]P ByteString ByteString[](,)CharChar4O(n) zip takes two ByteStrings and returns a list of corresponding pairs of Chars. If one input ByteString is short, excess elements of the longer ByteString are discarded. This is equivalent to a pair of unpack operations, and so space usage may be large for multi-megabyte ByteStrings  writeFile writeFile :: FilePath ->  ByteString -> IO () FilePath ByteStringIO()%Write a ByteString to a file.  writeFile writeFile :: FilePath ->  ByteString -> IO ()FilePath ByteStringIO()%Write a ByteString to a file. wordswords ::  ByteString ->  [ByteString]R1 ByteString[] ByteStringrwords breaks a ByteString up into a list of words, which were delimited by Chars representing white space. w2cw2c :: Word8 -> CharWord8CharLConversion between Word8 and Char. Should compile to a no-op. useAsCStringLenuseAsCStringLen ::  ByteString -> (CStringLen -> IO a) -> IO a  ByteString CStringLenIOaIOaO(n) construction Use a ByteString with a function requiring a CStringLen. As for useAsCString this function makes a copy of the original ByteString.  useAsCString useAsCString ::  ByteString -> (CString -> IO a) -> IO am A  ByteStringCStringIOaIOaO(n) construction Use a ByteString with a function requiring a null-terminated CString. The CString will be freed automatically. This is a memcpy(3). unzipunzip :: [(Word8, Word8)] -> (ByteString, ByteString)!![](,)Word8Word8(,) ByteString ByteStringO(n) unzip transforms a list of pairs of bytes into a pair of ByteStrings. Note that this performs two pack operations. unzipunzip :: [(Char, Char)] -> (ByteString, ByteString)""[](,)CharChar(,) ByteString ByteStringunzip transforms a list of pairs of Chars into a pair of ByteStrings. Note that this performs two pack operations. unwordsunwords ::  [ByteString] ->  ByteString##[] ByteString ByteStringSThe unwords function is analogous to the unlines function, on words. unsafeUseAsCStringLenunsafeUseAsCStringLen ::  ByteString -> (CStringLen -> IO a) -> IO a$$ ByteString CStringLenIOaIOaRO(1) construction Use a ByteString with a function requiring a CStringLen. This function does zero copying, and merely unwraps a ByteString to appear as a CStringLen. It is unsafe:
  • After calling this function the CStringLen shares the underlying byte buffer with the original ByteString. Thus modifying the CStringLen, either in C, or using poke, will cause the contents of the ByteString to change, breaking referential transparency. Other ByteStrings created by sharing (such as those produced via take or drop) will also reflect these changes. Modifying the CStringLen will break referential transparency. To avoid this, use useAsCStringLen, which makes a copy of the original ByteString.
unsafeUseAsCStringunsafeUseAsCString ::  ByteString -> (CString -> IO a) -> IO a(( ByteStringCStringIOaIOaO(1) construction Use a ByteString with a function requiring a CString. This function does zero copying, and merely unwraps a ByteString to appear as a CString. It is unsafe in two ways:
  • After calling this function the CString shares the underlying byte buffer with the original ByteString. Thus modifying the CString, either in C, or using poke, will cause the contents of the ByteString to change, breaking referential transparency. Other ByteStrings created by sharing (such as those produced via take or drop) will also reflect these changes. Modifying the CString will break referential transparency. To avoid this, use useAsCString, which makes a copy of the original ByteString.
  • CStrings are often passed to functions that require them to be null-terminated. If the original ByteString wasn't null terminated, neither will the CString be. It is the programmers responsibility to guarantee that the ByteString is indeed null terminated. If in doubt, use useAsCString.
 unsafeTake unsafeTake :: Int ->  ByteString ->  ByteString.-Int ByteString ByteStringA variety of take which omits the checks on n so there is an obligation on the programmer to provide a proof that 0 <= n <= length xs.  unsafeTail unsafeTail ::  ByteString ->  ByteString9// ByteString ByteStringA variety of tail for non-empty ByteStrings. unsafeTail omits the check for the empty case. As with unsafeHead, the programmer must provide a separate proof that the ByteString is non-empty. unsafePackMallocCStringunsafePackMallocCString :: CString ->  IO ByteString00CStringIO ByteStringO(n) Build a ByteString from a malloced CString. This value will have a free(3) finalizer associated to it. This funtion is unsafe. If the original CString is later modified, this change will be reflected in the resulting ByteString, breaking referential transparency. This function is also unsafe if you call its finalizer twice, which will result in a double free error, or if you pass it a CString not allocated with malloc. unsafePackCStringLenunsafePackCStringLen ::  CStringLen ->  IO ByteString32 CStringLenIO ByteStringO(1) Build a ByteString from a CStringLen. This value will have no finalizer associated with it, and will not be garbage collected by Haskell. This operation has O(1) complexity as we already know the final size, so no strlen(3) is required. This funtion is unsafe. If the original CStringLen is later modified, this change will be reflected in the resulting ByteString, breaking referential transparency. unsafePackCStringFinalizer unsafePackCStringFinalizer ::  Ptr Word8 -> Int -> IO () ->  IO ByteString55PtrWord8IntIO()IO ByteStringO(1) Construct a ByteString given a Ptr Word8 to a buffer, a length, and an IO action representing a finalizer. This function is not available on Hugs. This function is unsafe, it is possible to break referential transparency by modifying the underlying buffer pointed to by the first argument. Any changes to the original buffer will be reflected in the resulting ByteString. unsafePackCStringunsafePackCString :: CString ->  IO ByteString77CStringIO ByteStringO(n) Build a ByteString from a CString. This value will have no finalizer associated to it, and will not be garbage collected by Haskell. The ByteString length is calculated using strlen(3), and thus the complexity is a O(n). This function is unsafe. If the CString is later modified, this change will be reflected in the resulting ByteString, breaking referential transparency. unsafePackAddressLenunsafePackAddressLen :: Int -> Addr# ->  IO ByteStringE:$:IntAddr#IO ByteStringO(1) unsafePackAddressLen provides constant-time construction of ByteStrings which is ideal for string literals. It packs a null-terminated sequence of bytes into a ByteString, given a raw 'Addr\#' to the string, and the length of the string. This function is unsafe in two ways:
  • the length argument is assumed to be correct. If the length argument is incorrect, it is possible to overstep the end of the byte array.
  • if the underying Addr# is later modified, this change will be reflected in resulting ByteString, breaking referential transparency.
If in doubt, don't use these functions. unsafePackAddressunsafePackAddress :: Addr# ->  IO ByteStringX=<=Addr#IO ByteStringO(n) Pack a null-terminated sequence of bytes, pointed to by an Addr# (an arbitrary machine address assumed to point outside the garbage-collected heap) into a ByteString. A much faster way to create an Addr# is with an unboxed string literal, than to pack a boxed string. A unboxed string literal is compiled to a static char [] by GHC. Establishing the length of the string requires a call to strlen(3), so the Addr# must point to a null-terminated buffer (as is the case with string# literals in GHC). Use unsafePackAddressLen if you know the length of the string statically. An example:
literalFS = unsafePackAddress "literal"#
This function is unsafe. If you modify the buffer pointed to by the original Addr# this modification will be reflected in the resulting ByteString, breaking referential transparency. Note this also won't work if you Add# has embedded '\0' characters in the string (strlen will fail).  unsafeIndex unsafeIndex ::  ByteString -> Int -> Word8AA ByteStringIntWord8Unsafe ByteString index (subscript) operator, starting from 0, returning a Word8 This omits the bounds check, which means there is an accompanying obligation on the programmer to ensure the bounds are checked in some other way.  unsafeHead unsafeHead ::  ByteString -> Word8CC ByteStringWord8A variety of head for non-empty ByteStrings. unsafeHead omits the check for the empty case, so there is an obligation on the programmer to provide a proof that the ByteString is non-empty. unsafeFinalizeunsafeFinalize ::  ByteString -> IO ()YD@D ByteStringIO()Explicitly run the finaliser associated with a ByteString. References to this value after finalisation may generate invalid memory references. This function is unsafe, as there may be other ByteStrings referring to the same underlying pages. If you use this, you need to have a proof of some kind that all ByteStrings ever generated from the underlying byte array are no longer live.  unsafeDrop unsafeDrop :: Int ->  ByteString ->  ByteStringwFWFInt ByteString ByteStringA variety of drop which omits the checks on n so there is an obligation on the programmer to provide a proof that 0 <= n <= length xs.  unsafeCreate unsafeCreate :: Int -> (Ptr Word8 -> IO ()) ->  ByteStringGGIntPtrWord8IO() ByteStringA way of creating ByteStrings outside the IO monad. The Int argument gives the final size of the ByteString. Unlike createAndTrim the ByteString is not reallocated if the final size is less than the estimated size. unpackunpack ::  ByteString -> [Word8]IH ByteString[]Word89O(n) Converts a ByteString to a '[Word8]'. unpackunpack ::  ByteString -> [Char]II ByteString[]Char=O(n) Converts a ByteString to a String. unlinesunlines ::  [ByteString] ->  ByteStringmJLJ[] ByteString ByteStringwunlines is an inverse operation to lines. It joins lines, after appending a terminating newline to each. unfoldrN unfoldrN :: Int -> (a -> Maybe (Char, a)) -> a -> (ByteString, Maybe a)KlKIntaMaybe(,)Charaa(,) ByteStringMaybeaO(n) Like unfoldr, unfoldrN builds a ByteString from a seed value. However, the length of the result is limited by the first argument to unfoldrN. This function is more efficient than unfoldr when the maximum length of the result is known. The following equation relates unfoldrN and unfoldr:
unfoldrN n f s == take n (unfoldr f s)
unfoldrunfoldr :: (a -> Maybe (Word8, a)) -> a ->  ByteStringMMaMaybe(,)Word8aa ByteStringO(n) The unfoldr function is analogous to the List 'unfoldr'. unfoldr builds a ByteString from a seed value. The function takes the element and returns Nothing if it is done producing the ByteString or returns Just (a,b), in which case, a is a prepending to the ByteString and b is used as the next element in a recursive call. unfoldrunfoldr :: (a -> Maybe (Char, a)) -> a ->  ByteStringPOaMaybe(,)Charaa ByteString!O(n), where n is the length of the result. The unfoldr function is analogous to the List 'unfoldr'. unfoldr builds a ByteString from a seed value. The function takes the element and returns Nothing if it is done producing the ByteString or returns Just (a,b), in which case, a is the next character in the string, and b is the seed value for further production. Examples:
unfoldr (\x -> if x <= '9' then Just (x, succ x) else Nothing) '0' == "0123456789"
unconsuncons ::  ByteString -> Maybe (Word8, ByteString)RR ByteStringMaybe(,)Word8 ByteStringYO(1) Extract the head and tail of a ByteString, returning Nothing if it is empty. unconsuncons ::  ByteString -> Maybe (Char, ByteString)SkS ByteStringMaybe(,)Char ByteStringYO(1) Extract the head and tail of a ByteString, returning Nothing if it is empty.  transpose transpose ::  [ByteString] ->  [ByteString]wTPT[] ByteString[] ByteStringaThe transpose function transposes the rows and columns of its ByteString argument.  transpose transpose ::  [ByteString] ->  [ByteString]ZU3U[] ByteString[] ByteStringaThe transpose function transposes the rows and columns of its ByteString argument.  toForeignPtr toForeignPtr ::  ByteString -> (ForeignPtr Word8, Int, Int)`V*V ByteString(,,) ForeignPtrWord8IntInt7O(1) Deconstruct a ForeignPtr from a ByteString toChunkstoChunks ::  ByteString ->  [ByteString]WV ByteString[] ByteStringUO(n) Convert a lazy ByteString into a list of strict ByteString  takeWhile takeWhile :: (Word8 -> Bool) ->  ByteString ->  ByteStringXWWord8Bool ByteString ByteStringtakeWhile, applied to a predicate p and a ByteString xs, returns the longest prefix (possibly empty) of xs of elements that satisfy p.  takeWhile takeWhile :: (Char -> Bool) ->  ByteString ->  ByteStringLY#YCharBool ByteString ByteStringtakeWhile, applied to a predicate p and a ByteString xs, returns the longest prefix (possibly empty) of xs of elements that satisfy p. taketake :: Int64 ->  ByteString ->  ByteString~Z\ZInt64 ByteString ByteStringO(n\c)/ take n, applied to a ByteString xs, returns the prefix of xs of length n, or xs itself if n > length xs. taketake :: Int ->  ByteString ->  ByteString[[Int ByteString ByteStringO(1) take n, applied to a ByteString xs, returns the prefix of xs of length n, or xs itself if n > length xs. tailstails ::  ByteString ->  [ByteString]\\ ByteString[] ByteStringUO(n) Return all final segments of the given ByteString, longest first. tailstails ::  ByteString ->  [ByteString]]] ByteString[] ByteStringUO(n) Return all final segments of the given ByteString, longest first. tailtail ::  ByteString ->  ByteStringk^P^ ByteString ByteStringZO(1) Extract the elements after the head of a ByteString, which must be non-empty. tailtail ::  ByteString ->  ByteString-__ ByteString ByteStringO(1) Extract the elements after the head of a ByteString, which must be non-empty. An exception will be thrown in the case of an empty ByteString.  splitWith splitWith :: (Word8 -> Bool) ->  ByteString ->  [ByteString]k`;`Word8Bool ByteString[] ByteStringmO(n) Splits a ByteString into components delimited by separators, where the predicate returns True for a separator element. The resulting components do not contain the separators. Two adjacent separators result in an empty component in the output. eg.
splitWith (=='a') "aabbaca" == ["","","bb","c",""]
splitWith (=='a') []        == []
 splitWith splitWith :: (Char -> Bool) ->  ByteString ->  [ByteString]zbKbCharBool ByteString[] ByteStringKO(n) Splits a ByteString into components delimited by separators, where the predicate returns True for a separator element. The resulting components do not contain the separators. Two adjacent separators result in an empty component in the output. eg.
splitWith (=='a') "aabbaca" == ["","","bb","c",""]
splitAtsplitAt :: Int64 ->  ByteString -> (ByteString, ByteString)ld7dInt64 ByteString(,) ByteString ByteStringlO(n\c)/ splitAt n xs is equivalent to (take n xs, drop n xs). splitAtsplitAt :: Int ->  ByteString -> (ByteString, ByteString){eHeInt ByteString(,) ByteString ByteStringiO(1) splitAt n xs is equivalent to (take n xs, drop n xs). splitsplit :: Word8 ->  ByteString ->  [ByteString]nfFfWord8 ByteString[] ByteStringO(n) Break a ByteString into pieces separated by the byte argument, consuming the delimiter. I.e.
split '\n' "a\nb\nd\ne" == ["a","b","d","e"]
split 'a'  "aXaXaXa"    == ["","X","X","X",""]
split 'x'  "x"          == ["",""]
and
intercalate [c] . split c == id
split == splitWith . (==)
As for all splitting functions in this library, this function does not copy the substrings, it just constructs new ByteStrings that are slices of the original. splitsplit :: Char ->  ByteString ->  [ByteString]hhChar ByteString[] ByteStringO(n) Break a ByteString into pieces separated by the byte argument, consuming the delimiter. I.e.
split '\n' "a\nb\nd\ne" == ["a","b","d","e"]
split 'a'  "aXaXaXa"    == ["","X","X","X",""]
split 'x'  "x"          == ["",""]
and
intercalate [c] . split c == id
split == splitWith . (==)
As for all splitting functions in this library, this function does not copy the substrings, it just constructs new ByteStrings that are slices of the original. spanEndspanEnd :: (Char -> Bool) ->  ByteString -> (ByteString, ByteString)kGkCharBool ByteString(,) ByteString ByteStringspanEnd behaves like span but from the end of the ByteString. We have
spanEnd (not.isSpace) "x y z" == ("x y ","z")
and
spanEnd (not . isSpace) ps
   == 
let (x,y) = span (not.isSpace) (reverse ps) in (reverse y, reverse x) 
spanspan :: (Word8 -> Bool) ->  ByteString -> (ByteString, ByteString)Im mWord8Bool ByteString(,) ByteString ByteStringspan p xs breaks the ByteString into two segments. It is equivalent to (takeWhile p xs, dropWhile p xs) spanspan :: (Char -> Bool) ->  ByteString -> (ByteString, ByteString)nMnCharBool ByteString(,) ByteString ByteStringspan p xs breaks the ByteString into two segments. It is equivalent to (takeWhile p xs, dropWhile p xs) sortsort ::  ByteString ->  ByteStringoeo ByteString ByteString@O(n) Sort a ByteString efficiently, using counting sort. snocsnoc ::  ByteString -> Word8 ->  ByteString@pp ByteStringWord8 ByteString?O(n\c)/ Append a byte to the end of a ByteString snocsnoc ::  ByteString -> Char ->  ByteStringpp ByteStringChar ByteStringvO(n) Append a Char to the end of a ByteString. Similar to cons, this function performs a memcpy.  singleton singleton :: Word8 ->  ByteStringqqWord8 ByteString<O(1) Convert a Word8 into a ByteString  singleton singleton :: Char ->  ByteString}rhrChar ByteString;O(1) Convert a Char into a ByteString scanr1scanr1 :: (Char -> Char -> Char) ->  ByteString ->  ByteStringZs+sCharCharChar ByteString ByteStringPscanr1 is a variant of scanr that has no starting value argument. scanr scanr :: (Char -> Char -> Char) -> Char ->  ByteString ->  ByteString`t+tCharCharCharChar ByteString ByteString*scanr is the right-to-left dual of scanl. scanl1scanl1 :: (Char -> Char -> Char) ->  ByteString ->  ByteString,utCharCharChar ByteString ByteStringscanl1 is a variant of scanl that has no starting value argument:
scanl1 f [x1, x2, ...] == [x1, x1 `f` x2, ...]
scanl scanl :: (Word8 -> Word8 -> Word8) -> Word8 ->  ByteString ->  ByteStringwv>vWord8Word8Word8Word8 ByteString ByteStringscanl is similar to foldl, but returns a list of successive reduced values from the left. This function will fuse.
scanl f z [x1, x2, ...] == [z, z `f` x1, (z `f` x1) `f` x2, ...]
Note that
last (scanl f z xs) == foldl f z xs.
scanl scanl :: (Char -> Char -> Char) -> Char ->  ByteString ->  ByteString;xxCharCharCharChar ByteString ByteStringscanl is similar to foldl, but returns a list of successive reduced values from the left:
scanl f z [x1, x2, ...] == [z, z `f` x1, (z `f` x1) `f` x2, ...]
Note that
last (scanl f z xs) == foldl f z xs.
reversereverse ::  ByteString ->  ByteStringyy ByteString ByteString]O(n) reverse xs returns the elements of xs in reverse order. reversereverse ::  ByteString ->  ByteStringizNz ByteString ByteStringiO(n) reverse xs efficiently returns the elements of xs in reverse order.  replicate replicate :: Int64 -> Word8 ->  ByteStringR{5{Int64Word8 ByteString{O(n) replicate n x is a ByteString of length n with x the value of every element.  replicate replicate :: Int -> Char ->  ByteStringG|-|IntChar ByteStringO(n) replicate n x is a ByteString of length n with x the value of every element. The following holds:
replicate w c = unfoldr w (\u -> Just (u,u)) c
This implemenation uses memset(3) repeatrepeat :: Word8 ->  ByteString}}Word8 ByteString`repeat x is an infinite ByteString, with x the value of every element.  readInteger readInteger ::  ByteString -> Maybe (Integer, ByteString)~q~ ByteStringMaybe(,)Integer ByteStringreadInteger reads an Integer from the beginning of the ByteString. If there is no integer at the beginning of the string, it returns Nothing, otherwise it just returns the int read, and the rest of the string. readIntreadInt ::  ByteString -> Maybe (Int, ByteString) ByteStringMaybe(,)Int ByteStringreadInt reads an Int from the beginning of the ByteString. If there is no integer at the beginning of the string, it returns Nothing, otherwise it just returns the int read, and the rest of the string. readFilereadFile :: FilePath ->  IO ByteStringF'FilePathIO ByteStringsRead an entire file lazily into a ByteString. The Handle will be held open until EOF is encountered. readFilereadFile :: FilePath ->  IO ByteString.FilePathIO ByteStringRead an entire file strictly into a ByteString. This is far more efficient than reading the characters into a String and then using pack. It also may be more efficient than opening the file and reading it using hGet. putStrLnputStrLn ::  ByteString -> IO ()l ByteStringIO()7Write a ByteString to stdout, appending a newline byte putStrLnputStrLn ::  ByteString -> IO ()%  ByteStringIO()7Write a ByteString to stdout, appending a newline byte putStrputStr ::  ByteString -> IO () ByteStringIO()Write a ByteString to stdout putStrputStr ::  ByteString -> IO ()C* ByteStringIO()Write a ByteString to stdout PS PS :: ForeignPtr Word8 -> Int -> Int ->  ByteStringͅ ForeignPtrWord8IntInt ByteString partition partition :: (Word8 -> Bool) ->  ByteString -> (ByteString, ByteString){Word8Bool ByteString(,) ByteString ByteStringO(n) The partition function takes a predicate a ByteString and returns the pair of ByteStrings with elements which do and do not satisfy the predicate, respectively; i.e.,
partition p bs == (filter p xs, filter (not . p) xs)
packCStringLenpackCStringLen ::  CStringLen ->  IO ByteString: CStringLenIO ByteStringO(n). Construct a new ByteString from a CStringLen. The resulting ByteString is an immutable copy of the original CStringLen. The ByteString is a normal Haskell value and will be managed on the Haskell heap.  packCString packCString :: CString ->  IO ByteStringCStringIO ByteStringO(n). Construct a new ByteString from a CString. The resulting ByteString is an immutable copy of the original CString, and is managed on the Haskell heap. The original CString must be null terminated. packpack :: [Word8] ->  ByteString[]Word8 ByteString:O(n) Convert a '[Word8]' into a ByteString. packpack :: String ->  ByteStringString ByteStringO(n) Convert a String into a ByteString For applications with large numbers of string literals, pack can be a bottleneck. nullForeignPtrnullForeignPtr :: ForeignPtr Word8 ForeignPtrWord86The 0 pointer. Used to indicate the empty Bytestring. nullnull ::  ByteString -> Bool>) ByteStringBool0O(1) Test whether a ByteString is empty. nullnull ::  ByteString -> Boolʍ ByteStringBool0O(1) Test whether a ByteString is empty. notElemnotElem :: Word8 ->  ByteString -> BooltXWord8 ByteStringBool9O(n) notElem is the inverse of elem notElemnotElem :: Char ->  ByteString -> Bool% Char ByteStringBool9O(n) notElem is the inverse of elem minimumminimum ::  ByteString -> Word8 ByteStringWord8NO(n) minimum returns the minimum value from a ByteString minimumminimum ::  ByteString -> Charr] ByteStringCharBminimum returns the minimum value from a ByteString memset memset ::  Ptr Word8 -> Word8 -> CSize -> IO (Ptr Word8)]*PtrWord8Word8CSizeIOPtrWord8memcpy_ptr_baoff memcpy_ptr_baoff :: Ptr a ->  RawBuffer -> CInt -> CSize ->  IO (Ptr ())*Ptra RawBufferCIntCSizeIOPtr()memcpy memcpy ::  Ptr Word8 ->  Ptr Word8 -> CSize -> IO ()˒PtrWord8PtrWord8CSizeIO()memcmp memcmp ::  Ptr Word8 ->  Ptr Word8 -> CSize -> IO CIntp>PtrWord8PtrWord8CSizeIOCIntmemchr memchr ::  Ptr Word8 -> Word8 -> CSize -> IO (Ptr Word8)PtrWord8Word8CSizeIOPtrWord8maximummaximum ::  ByteString -> Word8}g ByteStringWord8NO(n) maximum returns the maximum value from a ByteString maximummaximum ::  ByteString -> Char- ByteStringCharBmaximum returns the maximum value from a ByteString  mapAccumR  mapAccumR :: (acc -> Word8 -> (acc, Word8)) -> acc ->  ByteString -> (acc, ByteString)SaccWord8(,)accWord8acc ByteString(,)acc ByteStringThe mapAccumR function behaves like a combination of map and foldr; it applies a function to each element of a ByteString, passing an accumulating parameter from right to left, and returning a final value of this accumulator together with the new ByteString.  mapAccumR  mapAccumR :: (acc -> Char -> (acc, Char)) -> acc ->  ByteString -> (acc, ByteString)KaccChar(,)accCharacc ByteString(,)acc ByteStringThe mapAccumR function behaves like a combination of map and foldr; it applies a function to each element of a ByteString, passing an accumulating parameter from right to left, and returning a final value of this accumulator together with the new ByteString.  mapAccumL  mapAccumL :: (acc -> Word8 -> (acc, Word8)) -> acc ->  ByteString -> (acc, ByteString)GaccWord8(,)accWord8acc ByteString(,)acc ByteStringThe mapAccumL function behaves like a combination of map and foldl; it applies a function to each element of a ByteString, passing an accumulating parameter from left to right, and returning a final value of this accumulator together with the new ByteString.  mapAccumL  mapAccumL :: (acc -> Char -> (acc, Char)) -> acc ->  ByteString -> (acc, ByteString)?accChar(,)accCharacc ByteString(,)acc ByteStringThe mapAccumL function behaves like a combination of map and foldl; it applies a function to each element of a ByteString, passing an accumulating parameter from left to right, and returning a final value of this accumulator together with the new list. mapmap :: (Word8 -> Word8) ->  ByteString ->  ByteStringWord8Word8 ByteString ByteStringwO(n) map f xs is the ByteString obtained by applying f to each element of xs. mapmap :: (Char -> Char) ->  ByteString ->  ByteStringCharChar ByteString ByteStringvO(n) map f xs is the ByteString obtained by applying f to each element of xs mallocByteStringmallocByteString :: Int -> IO (ForeignPtr a)ßIntIO ForeignPtrahWrapper of mallocForeignPtrBytes with faster implementation for GHC 6.5 builds newer than 060606 lineslines ::  ByteString ->  [ByteString] ByteString[] ByteStringlines breaks a ByteString up into a list of ByteStrings at newline Chars. The resulting strings do not contain newlines. lengthlength ::  ByteString -> Int64 ByteStringInt64SO(n\c)/ length returns the length of a ByteString as an Int64 lengthlength ::  ByteString -> IntO; ByteStringIntOO(1) length returns the length of a ByteString as an Int. lastlast ::  ByteString -> Word8 ByteStringWord8]O(n\c)/ Extract the last element of a ByteString, which must be finite and non-empty. lastlast ::  ByteString -> Char ByteStringCharRO(1) Extract the last element of a packed string, which must be non-empty. iterateiterate :: (Word8 -> Word8) -> Word8 ->  ByteStringqWord8Word8Word8 ByteStringiterate f x returns an infinite ByteString of repeated applications of f to x:
iterate f x == [x, f x, f (f x), ...]
 isSuffixOf isSuffixOf ::  ByteString ->  ByteString -> Boolƥ ByteString ByteStringBoolO(n) The isSuffixOf function takes two ByteStrings and returns True iff the first is a suffix of the second. The following holds:
isSuffixOf x y == reverse x `isPrefixOf` reverse y
 isSuffixOf isSuffixOf ::  ByteString ->  ByteString -> Bool) ByteString ByteStringBoolHO(n) The isSuffixOf function takes two ByteStrings and returns True iff the first is a suffix of the second. The following holds:
isSuffixOf x y == reverse x `isPrefixOf` reverse y
However, the real implemenation uses memcmp to compare the end of the string only, with no reverse required..  isSpaceWord8 isSpaceWord8 :: Word8 -> BoolӨèWord8BoolaSelects words corresponding to white-space characters in the Latin-1 range ordered by frequency.  isSpaceChar8 isSpaceChar8 :: Char -> BoolCharBool4Selects white-space characters in the Latin-1 range  isPrefixOf isPrefixOf ::  ByteString ->  ByteString -> BoolR1 ByteString ByteStringBoolO(n) The isPrefixOf function takes two ByteStrings and returns True iff the first is a prefix of the second.  isPrefixOf isPrefixOf ::  ByteString ->  ByteString -> Bool^= ByteString ByteStringBoolO(n) The isPrefixOf function takes two ByteStrings and returns True iff the first is a prefix of the second.  isInfixOf isInfixOf ::  ByteString ->  ByteString -> BoolhG ByteString ByteStringBoolCheck whether one string is a substring of another. isInfixOf p s is equivalent to not (null (findSubstrings p s)).  intersperse intersperse :: Word8 ->  ByteString ->  ByteString|ZWord8 ByteString ByteStringThe intersperse function takes a Word8 and a ByteString and `intersperses' that byte between the elements of the ByteString. It is analogous to the intersperse function on Lists.  intersperse intersperse :: Char ->  ByteString ->  ByteString׮Char ByteString ByteStringO(n) The intersperse function takes a Char and a ByteString and `intersperses' that Char between the elements of the ByteString. It is analogous to the intersperse function on Lists.  intercalate intercalate ::  ByteString ->  [ByteString] ->  ByteStringJ ByteString[] ByteString ByteStringO(n) The intercalate function takes a ByteString and a list of ByteStrings and concatenates the list after interspersing the first argument between each element of the list.  intercalate intercalate ::  ByteString ->  [ByteString] ->  ByteString ByteString[] ByteString ByteStringO(n) The intercalate function takes a ByteString and a list of ByteStrings and concatenates the list after interspersing the first argument between each element of the list. interactinteract :: (ByteString -> ByteString) -> IO ()޲ ByteString ByteStringIO()The interact function takes a function of type ByteString -> ByteString as its argument. The entire input from the standard input device is passed to this function as its argument, and the resulting string is output on the standard output device. interactinteract :: (ByteString -> ByteString) -> IO ()h ByteString ByteStringIO()The interact function takes a function of type ByteString -> ByteString as its argument. The entire input from the standard input device is passed to this function as its argument, and the resulting string is output on the standard output device. inlinePerformIOinlinePerformIO :: IO a -> aIOaaJust like unsafePerformIO, but we inline it. Big performance gains as it exposes lots of things to further inlining. Very unsafe. In particular, you should do no memory allocation inside an inlinePerformIO block. On Hugs this is just unsafePerformIO. initsinits ::  ByteString ->  [ByteString]yX ByteString[] ByteStringXO(n) Return all initial segments of the given ByteString, shortest first. initsinits ::  ByteString ->  [ByteString]C" ByteString[] ByteStringXO(n) Return all initial segments of the given ByteString, shortest first. initinit ::  ByteString ->  ByteString ByteString ByteStringSO(n\c)/ Return all the elements of a ByteString except the last one. initinit ::  ByteString ->  ByteString ByteString ByteStringO(1) Return all the elements of a ByteString except the last one. An exception will be thrown in the case of an empty ByteString. indexindex ::  ByteString -> Int64 -> Word8ƺ ByteStringInt64Word8KO(c) ByteString index (subscript) operator, starting from 0. indexindex ::  ByteString -> Int -> Chari ByteStringIntCharKO(1) ByteString index (subscript) operator, starting from 0.  hPutStrLn hPutStrLn :: Handle ->  ByteString -> IO ()S2Handle ByteStringIO()9Write a ByteString to a handle, appending a newline byte hPutStrhPutStr :: Handle ->  ByteString -> IO () Handle ByteStringIO()/A synonym for hPut, for compatibility hPutStrhPutStr :: Handle ->  ByteString -> IO ()Handle ByteStringIO()/A synonym for hPut, for compatibility hPuthPut :: Handle ->  ByteString -> IO ()gFHandle ByteStringIO()<Outputs a ByteString to the specified Handle. hPuthPut :: Handle ->  ByteString -> IO ()Handle ByteStringIO()<Outputs a ByteString to the specified Handle. hGetNonBlockinghGetNonBlocking :: Handle -> Int ->  IO ByteString˿HandleIntIO ByteStringhGetNonBlocking is similar to hGet, except that it will never block waiting for data to become available, instead it returns only whatever data is available. hGetNonBlockinghGetNonBlocking :: Handle -> Int ->  IO ByteString%HandleIntIO ByteStringhGetNonBlocking is identical to hGet, except that it will never block waiting for data to become available, instead it returns only whatever data is available. hGetLinehGetLine :: Handle ->  IO ByteString= HandleIO ByteStringRead a line from a handle  hGetContents hGetContents :: Handle ->  IO ByteStringHandleIO ByteStringRead entire handle contents lazily into a ByteString. Chunks are read on demand, using the default chunk size. Once EOF is encountered, the Handle is closed.  hGetContents hGetContents :: Handle ->  IO ByteStringHandleIO ByteStringRead entire handle contents strictly into a ByteString. This function reads chunks at a time, doubling the chunksize on each read. The final buffer is then realloced to the appropriate size. For files > half of available memory, this may lead to memory exhaustion. Consider using readFile in this case. As with hGet, the string representation in the file is assumed to be ISO-8859-1. The Handle is closed once the contents have been read, or if an exception is thrown. hGethGet :: Handle -> Int ->  IO ByteStringcAHandleIntIO ByteString[Read n bytes into a ByteString, directly from the specified Handle. hGethGet :: Handle -> Int ->  IO ByteString;HandleIntIO ByteStringRead a ByteString directly from the specified Handle. This is far more efficient than reading the characters into a String and then using pack. First argument is the Handle to read from, and the second is the number of bytes to read. It returns the bytes read, up to n, or EOF. hGet is implemented in terms of hGetBuf. If the handle is a pipe or socket, and the writing end is closed, hGet will behave as if EOF was reached. headhead ::  ByteString -> Word8u_ ByteStringWord8PO(1) Extract the first element of a ByteString, which must be non-empty. headhead ::  ByteString -> Char!  ByteStringCharPO(1) Extract the first element of a ByteString, which must be non-empty. groupBygroupBy :: (Word8 -> Word8 -> Bool) ->  ByteString ->  [ByteString]!Word8Word8Bool ByteString[] ByteStringKThe groupBy function is the non-overloaded version of group. groupBygroupBy :: (Char -> Char -> Bool) ->  ByteString ->  [ByteString]CharCharBool ByteString[] ByteStringKThe groupBy function is the non-overloaded version of group. groupgroup ::  ByteString ->  [ByteString] ByteString[] ByteStringThe group function takes a ByteString and returns a list of ByteStrings such that the concatenation of the result is equal to the argument. Moreover, each sublist in the result contains only equal elements. For example,
group "Mississippi" = ["M","i","ss","i","ss","i","pp","i"]
It is a special case of groupBy, which allows the programmer to supply their own equality test. groupgroup ::  ByteString ->  [ByteString] ByteString[] ByteStringThe group function takes a ByteString and returns a list of ByteStrings such that the concatenation of the result is equal to the argument. Moreover, each sublist in the result contains only equal elements. For example,
group "Mississippi" = ["M","i","ss","i","ss","i","pp","i"]
It is a special case of groupBy, which allows the programmer to supply their own equality test. It is about 40% faster than groupBy (==) getLinegetLine ::  IO ByteStringIO ByteStringRead a line from stdin.  getContents getContents ::  IO ByteStringeRIO ByteStringGgetContents. Equivalent to hGetContents stdin. Will read lazily  getContents getContents ::  IO ByteStringIO ByteStringgetContents. Read stdin strictly. Equivalent to hGetContents stdin The Handle is closed after the contents have been read. fromForeignPtr fromForeignPtr :: ForeignPtr Word8 -> Int -> Int ->  ByteString< ForeignPtrWord8IntInt ByteString1O(1) Build a ByteString from a ForeignPtr  fromChunks fromChunks ::  [ByteString] ->  ByteString[] ByteString ByteStringUO(c) Convert a list of strict ByteString into a lazy ByteString foldr1'foldr1' :: (Char -> Char -> Char) ->  ByteString -> CharCharCharChar ByteStringCharA strict variant of foldr1 foldr1foldr1 :: (Word8 -> Word8 -> Word8) ->  ByteString -> Word8bWord8Word8Word8 ByteStringWord8foldr1 is a variant of foldr that has no starting value argument, and thus must be applied to non-empty ByteStrings foldr1foldr1 :: (Char -> Char -> Char) ->  ByteString -> CharCharCharChar ByteStringCharfoldr1 is a variant of foldr that has no starting value argument, and thus must be applied to non-empty ByteStrings foldr' foldr' :: (Char -> a -> a) -> a ->  ByteString -> aCharaaa ByteStringa''foldr\'' is a strict variant of foldr foldr foldr :: (Word8 -> a -> a) -> a ->  ByteString -> abWord8aaa ByteStringafoldr, applied to a binary operator, a starting value (typically the right-identity of the operator), and a ByteString, reduces the ByteString using the binary operator, from right to left. foldr foldr :: (Char -> a -> a) -> a ->  ByteString -> aCharaaa ByteStringafoldr, applied to a binary operator, a starting value (typically the right-identity of the operator), and a packed string, reduces the packed string using the binary operator, from right to left. foldl1'foldl1' :: (Word8 -> Word8 -> Word8) ->  ByteString -> Word8HWord8Word8Word8 ByteStringWord8A'foldl1\'' is like foldl1, but strict in the accumulator. foldl1'foldl1' :: (Char -> Char -> Char) ->  ByteString -> Char!CharCharChar ByteStringChar"A strict version of foldl1 foldl1foldl1 :: (Word8 -> Word8 -> Word8) ->  ByteString -> Word8Word8Word8Word8 ByteStringWord8foldl1 is a variant of foldl that has no starting value argument, and thus must be applied to non-empty ByteStrings. This function is subject to array fusion. foldl1foldl1 :: (Char -> Char -> Char) ->  ByteString -> Char$CharCharChar ByteStringCharfoldl1 is a variant of foldl that has no starting value argument, and thus must be applied to non-empty ByteStrings. foldl' foldl' :: (a -> Word8 -> a) -> a ->  ByteString -> a=aWord8aa ByteStringa?'foldl\'' is like foldl, but strict in the accumulator. foldl' foldl' :: (a -> Char -> a) -> a ->  ByteString -> aaCharaa ByteStringa8'foldl\'' is like foldl, but strict in the accumulator. foldl foldl :: (a -> Word8 -> a) -> a ->  ByteString -> aaWord8aa ByteStringafoldl, applied to a binary operator, a starting value (typically the left-identity of the operator), and a ByteString, reduces the ByteString using the binary operator, from left to right. foldl foldl :: (a -> Char -> a) -> a ->  ByteString -> a2aCharaa ByteStringafoldl, applied to a binary operator, a starting value (typically the left-identity of the operator), and a ByteString, reduces the ByteString using the binary operator, from left to right. findSubstringsfindSubstrings ::  ByteString ->  ByteString -> [Int]h ByteString ByteString[]IntVFind the indexes of all (possibly overlapping) occurances of a substring in a string.  findSubstring findSubstring ::  ByteString ->  ByteString ->  Maybe IntX ByteString ByteStringMaybeIntGet the first index of a substring in another string, or Nothing if the string is not found. findSubstring p s is equivalent to listToMaybe (findSubstrings p s).  findIndices findIndices :: (Word8 -> Bool) ->  ByteString -> [Int64]Word8Bool ByteString[]Int64The findIndices function extends findIndex, by returning the indices of all elements satisfying the predicate, in ascending order.  findIndices findIndices :: (Char -> Bool) ->  ByteString -> [Int]CharBool ByteString[]IntThe findIndices function extends findIndex, by returning the indices of all elements satisfying the predicate, in ascending order.  findIndex findIndex :: (Word8 -> Bool) ->  ByteString ->  Maybe Int645Word8Bool ByteStringMaybeInt64The findIndex function takes a predicate and a ByteString and returns the index of the first element in the ByteString satisfying the predicate.  findIndex findIndex :: (Char -> Bool) ->  ByteString ->  Maybe IntoDCharBool ByteStringMaybeIntThe findIndex function takes a predicate and a ByteString and returns the index of the first element in the ByteString satisfying the predicate. findfind :: (Word8 -> Bool) ->  ByteString ->  Maybe Word8wWord8Bool ByteStringMaybeWord8 O(n) The find function takes a predicate and a ByteString, and returns the first element in matching the predicate, or Nothing if there is no such element.
find f p = case findIndex f p of Just n -> Just (p ! n) ; _ -> Nothing
findfind :: (Char -> Bool) ->  ByteString ->  Maybe CharDCharBool ByteStringMaybeCharO(n) The find function takes a predicate and a ByteString, and returns the first element in matching the predicate, or Nothing if there is no such element. filterfilter :: (Word8 -> Bool) ->  ByteString ->  ByteStringaWord8Bool ByteString ByteStringO(n) filter, applied to a predicate and a ByteString, returns a ByteString containing those characters that satisfy the predicate. filterfilter :: (Char -> Bool) ->  ByteString ->  ByteStringCharBool ByteString ByteStringO(n) filter, applied to a predicate and a ByteString, returns a ByteString containing those characters that satisfy the predicate. emptyempty ::  ByteStringz ByteString(O(1) The empty ByteString emptyempty ::  ByteString ByteString(O(1) The empty ByteString  elemIndices elemIndices :: Word8 ->  ByteString -> [Int64]Word8 ByteString[]Int64O(n) The elemIndices function extends elemIndex, by returning the indices of all elements equal to the query element, in ascending order. This implementation uses memchr(3).  elemIndices elemIndices :: Char ->  ByteString -> [Int]Char ByteString[]IntO(n) The elemIndices function extends elemIndex, by returning the indices of all elements equal to the query element, in ascending order.  elemIndexEnd elemIndexEnd :: Char ->  ByteString ->  Maybe Int Char ByteStringMaybeInt3O(n) The elemIndexEnd function returns the last index of the element in the given ByteString which is equal to the query element, or Nothing if there is no such element. The following holds:
elemIndexEnd c xs == 
(-) (length xs - 1) `fmap` elemIndex c (reverse xs)
 elemIndex elemIndex :: Word8 ->  ByteString ->  Maybe Int64Word8 ByteStringMaybeInt64O(n) The elemIndex function returns the index of the first element in the given ByteString which is equal to the query element, or Nothing if there is no such element. This implementation uses memchr(3).  elemIndex elemIndex :: Char ->  ByteString ->  Maybe IntS0Char ByteStringMaybeIntO(n) The elemIndex function returns the index of the first element in the given ByteString which is equal (by memchr) to the query element, or Nothing if there is no such element. elemelem :: Word8 ->  ByteString -> Bool{Word8 ByteStringBoolGO(n) elem is the ByteString membership predicate. elemelem :: Char ->  ByteString -> BoolP5Char ByteStringBooltO(n) elem is the ByteString membership predicate. This implementation uses memchr(3).  dropWhile dropWhile :: (Word8 -> Bool) ->  ByteString ->  ByteString`6Word8Bool ByteString ByteStringbdropWhile p xs returns the suffix remaining after takeWhile p xs.  dropWhile dropWhile :: (Char -> Bool) ->  ByteString ->  ByteString\3CharBool ByteString ByteStringbdropWhile p xs returns the suffix remaining after takeWhile p xs. dropdrop :: Int64 ->  ByteString ->  ByteString>Int64 ByteString ByteStringO(n\c)/ drop n xs returns the suffix of xs after the first n elements, or [] if n > length xs. dropdrop :: Int ->  ByteString ->  ByteString^>Int ByteString ByteStringO(1) drop n xs returns the suffix of xs after the first n elements, or [] if n > length xs. cyclecycle ::  ByteString ->  ByteStringiN ByteString ByteStringcycle ties a finite ByteString into a circular one, or equivalently, the infinite repetition of the original ByteString. createAndTrim'createAndTrim' :: Int -> (Ptr Word8 -> IO (Int, Int, a)) -> IO (ByteString, a)vIntPtrWord8IO(,,)IntIntaIO(,) ByteStringa createAndTrim createAndTrim :: Int -> (Ptr Word8 -> IO Int) ->  IO ByteStringvAIntPtrWord8IOIntIO ByteStringGiven the maximum size needed and a function to make the contents of a ByteString, createAndTrim makes the ByteString. The generating function is required to return the actual final size (<= the maximum size), and the resulting byte array is realloced to this size. createAndTrim is the main mechanism for creating custom, efficient ByteString functions, using Haskell or C functions to fill the space. createcreate :: Int -> (Ptr Word8 -> IO ()) ->  IO ByteStringIntPtrWord8IO()IO ByteStringVCreate ByteString of size l and use action f to fill it's contents. countcount :: Word8 ->  ByteString -> Int64fWord8 ByteStringInt64count returns the number of times its argument appears in the ByteString
count = length . elemIndices
But more efficiently than using length on the intermediate list. countcount :: Char ->  ByteString -> IntChar ByteStringIntcount returns the number of times its argument appears in the ByteString
count = length . elemIndices
Also
count '\n' == length . lines
But more efficiently than using length on the intermediate list. copycopy ::  ByteString ->  ByteString ByteString ByteString*O(n) Make a copy of the ByteString with its own storage. This is mainly useful to allow the rest of the data pointed to by the ByteString to be garbage collected, for example if a large string has been read in, and only a small part of it is needed in the rest of the program. copycopy ::  ByteString ->  ByteStringq ByteString ByteString*O(n) Make a copy of the ByteString with its own storage. This is mainly useful to allow the rest of the data pointed to by the ByteString to be garbage collected, for example if a large string has been read in, and only a small part of it is needed in the rest of the program. cons'cons' :: Word8 ->  ByteString ->  ByteString8Word8 ByteString ByteStringO(1) Unlike cons, 'cons\'' is strict in the ByteString that we are consing onto. More precisely, it forces the head and the first chunk. It does this because, for space efficiency, it may coalesce the new byte onto the first 'chunk' rather than starting a new 'chunk'. So that means you can't use a lazy recursive contruction like this:
let xs = cons\' c xs in xs
You can however use cons, as well as repeat and cycle, to build infinite lazy ByteStrings. conscons :: Word8 ->  ByteString ->  ByteString  Word8 ByteString ByteString9O(1) cons is analogous to '(:)' for lists. conscons :: Char ->  ByteString ->  ByteStringi H Char ByteString ByteStringmO(n) cons is analogous to (:) for lists, but of different complexity, as it requires a memcpy.  concatMap concatMap :: (Word8 -> ByteString) ->  ByteString ->  ByteString~ N Word8 ByteString ByteString ByteStringDMap a function over a ByteString and concatenate the results  concatMap concatMap :: (Char -> ByteString) ->  ByteString ->  ByteStringh 9 Char ByteString ByteString ByteStringDMap a function over a ByteString and concatenate the results concatconcat ::  [ByteString] ->  ByteString  [] ByteString ByteString/O(n) Concatenate a list of ByteStrings. concatconcat ::  [ByteString] ->  ByteString[] ByteString ByteString/O(n) Concatenate a list of ByteStrings. c_strlenc_strlen :: CString -> IO CSize[BCStringIOCSize c_reverse  c_reverse ::  Ptr Word8 ->  Ptr Word8 -> CULong -> IO ()PtrWord8PtrWord8CULongIO() c_minimum c_minimum ::  Ptr Word8 -> CULong -> IO Word8jPtrWord8CULongIOWord8 c_maximum c_maximum ::  Ptr Word8 -> CULong -> IO Word8PtrWord8CULongIOWord8 c_intersperse  c_intersperse ::  Ptr Word8 ->  Ptr Word8 -> CULong -> Word8 -> IO ()PtrWord8PtrWord8CULongWord8IO()c_free_finalizerc_free_finalizer :: FunPtr (Ptr Word8 -> IO ())jEFunPtrPtrWord8IO()c_count c_count ::  Ptr Word8 -> CULong -> Word8 ->  IO CULong PtrWord8CULongWord8IOCULongc2wc2w :: Char -> Word8\LCharWord8Unsafe conversion between Char and Word8. This is a no-op and silently truncates to 8 bits Chars > '\255'. It is provided as convenience for ByteString construction.  ByteStringdata  ByteStringKA space-efficient representation of a Word8 vector, supporting many efficient operations. A ByteString contains 8-bit characters only. Instances of Eq, Ord, Read, Show, Data, Typeable  ByteStringdata  ByteStringCA space-efficient representation of a Word8 vector, supporting many efficient operations. A ByteString contains 8-bit characters only. Instances of Eq, Ord, Read, Show, Data, Typeable  ByteStringdata  ByteString;A space-efficient representation of a Word8 vector, supporting many efficient operations. A ByteString contains 8-bit characters only. Instances of Eq, Ord, Read, Show, Data, Typeable breakSubstringbreakSubstring ::  ByteString ->  ByteString -> (ByteString, ByteString) ByteString ByteString(,) ByteString ByteString$Break a string on a substring, returning a pair of the part of the string prior to the match, and the rest of the string. The following relationships hold:
break (== c) l == breakSubstring (singleton c) l
and:
findSubstring s l ==
   if null s then Just 0
             else case breakSubstring s l of
                      (x,y) | null y    -> Nothing
                            | otherwise -> Just (length x)
For example, to tokenise a string, dropping delimiters:
tokenise x y = h : if null t then [] else tokenise x (drop (length x) t)
    where (h,t) = breakSubstring x y
To skip to the first occurence of a string:
snd (breakSubstring x y) 
To take the parts of a string before a delimiter:
fst (breakSubstring x y) 
breakEndbreakEnd :: (Char -> Bool) ->  ByteString -> (ByteString, ByteString)[CharBool ByteString(,) ByteString ByteStringsbreakEnd behaves like break but from the end of the ByteString breakEnd p == spanEnd (not.p) breakbreak :: (Word8 -> Bool) ->  ByteString -> (ByteString, ByteString)Word8Bool ByteString(,) ByteString ByteStringPbreak p is equivalent to span (not . p). breakbreak :: (Char -> Bool) ->  ByteString -> (ByteString, ByteString)CharBool ByteString(,) ByteString ByteStringPbreak p is equivalent to span (not . p).  appendFile appendFile :: FilePath ->  ByteString -> IO ()zFilePath ByteStringIO()&Append a ByteString to a file.  appendFile appendFile :: FilePath ->  ByteString -> IO ()N+FilePath ByteStringIO()&Append a ByteString to a file. appendappend ::  ByteString ->  ByteString ->  ByteString  ByteString ByteString ByteString&O(n\c)/ Append two ByteStrings appendappend ::  ByteString ->  ByteString ->  ByteString   ByteString ByteString ByteString#O(n) Append two ByteStrings anyany :: (Word8 -> Bool) ->  ByteString -> Bool]!9!Word8Bool ByteStringBoolO(n) Applied to a predicate and a ByteString, any determines if any element of the ByteString satisfies the predicate. anyany :: (Char -> Bool) ->  ByteString -> Boolk"H"CharBool ByteStringBoolApplied to a predicate and a ByteString, any determines if any element of the ByteString satisfies the predicate. allall :: (Word8 -> Bool) ->  ByteString -> Boolo#K#Word8Bool ByteStringBoolO(n) Applied to a predicate and a ByteString, all determines if all elements of the ByteString satisfy the predicate. allall :: (Char -> Bool) ->  ByteString -> Bool$`$CharBool ByteStringBoolApplied to a predicate and a ByteString, all determines if all elements of the ByteString satisfy the predicate. zipWith zipWith :: (Word8 -> Word8 -> a) ->  ByteString ->  ByteString -> [a]%%Word8Word8a ByteString ByteString[]azipWith generalises zip by zipping with the function given as the first argument, instead of a tupling function. For example, zipWith (+) is applied to two ByteStrings to produce the list of corresponding sums. zipzip ::  ByteString ->  ByteString -> [(Word8, Word8)]Q'' ByteString ByteString[](,)Word8Word8O(n) zip takes two ByteStrings and returns a list of corresponding pairs of bytes. If one input ByteString is short, excess elements of the longer ByteString are discarded. This is equivalent to a pair of unpack operations.  writeFile writeFile :: FilePath ->  ByteString -> IO ()((FilePath ByteStringIO()%Write a ByteString to a file. useAsCStringLenuseAsCStringLen ::  ByteString -> (CStringLen -> IO a) -> IO a)q) ByteString CStringLenIOaIOaO(n) construction Use a ByteString with a function requiring a CStringLen. As for useAsCString this function makes a copy of the original ByteString.  useAsCString useAsCString ::  ByteString -> (CString -> IO a) -> IO a+* ByteStringCStringIOaIOaO(n) construction Use a ByteString with a function requiring a null-terminated CString. The CString will be freed automatically. This is a memcpy(3). unzipunzip :: [(Word8, Word8)] -> (ByteString, ByteString)Y,,[](,)Word8Word8(,) ByteString ByteStringO(n) unzip transforms a list of pairs of bytes into a pair of ByteStrings. Note that this performs two pack operations. unpackunpack ::  ByteString -> [Word8]P-4- ByteString[]Word89O(n) Converts a ByteString to a '[Word8]'. unfoldrN unfoldrN :: Int -> (a -> Maybe (Word8, a)) -> a -> (ByteString, Maybe a)[..IntaMaybe(,)Word8aa(,) ByteStringMaybeaO(n) Like unfoldr, unfoldrN builds a ByteString from a seed value. However, the length of the result is limited by the first argument to unfoldrN. This function is more efficient than unfoldr when the maximum length of the result is known. The following equation relates unfoldrN and unfoldr:
snd (unfoldrN n f s) == take n (unfoldr f s)
unfoldrunfoldr :: (a -> Maybe (Word8, a)) -> a ->  ByteString0Z0aMaybe(,)Word8aa ByteString%O(n), where n is the length of the result. The unfoldr function is analogous to the List 'unfoldr'. unfoldr builds a ByteString from a seed value. The function takes the element and returns Nothing if it is done producing the ByteString or returns Just (a,b), in which case, a is the next byte in the string, and b is the seed value for further production. Examples:
   unfoldr (\x -> if x <= 5 then Just (x, x + 1) else Nothing) 0
== pack [0, 1, 2, 3, 4, 5]
unconsuncons ::  ByteString -> Maybe (Word8, ByteString)B33 ByteStringMaybe(,)Word8 ByteStringYO(1) Extract the head and tail of a ByteString, returning Nothing if it is empty.  transpose transpose ::  [ByteString] ->  [ByteString]43[] ByteString[] ByteStringaThe transpose function transposes the rows and columns of its ByteString argument.  takeWhile takeWhile :: (Word8 -> Bool) ->  ByteString ->  ByteString54Word8Bool ByteString ByteStringtakeWhile, applied to a predicate p and a ByteString xs, returns the longest prefix (possibly empty) of xs of elements that satisfy p. taketake :: Int ->  ByteString ->  ByteStringH6(6Int ByteString ByteStringO(1) take n, applied to a ByteString xs, returns the prefix of xs of length n, or xs itself if n > length xs. tailstails ::  ByteString ->  [ByteString]v7U7 ByteString[] ByteStringUO(n) Return all final segments of the given ByteString, longest first. tailtail ::  ByteString ->  ByteString388 ByteString ByteStringO(1) Extract the elements after the head of a ByteString, which must be non-empty. An exception will be thrown in the case of an empty ByteString.  splitWith splitWith :: (Word8 -> Bool) ->  ByteString ->  [ByteString]q9A9Word8Bool ByteString[] ByteStringmO(n) Splits a ByteString into components delimited by separators, where the predicate returns True for a separator element. The resulting components do not contain the separators. Two adjacent separators result in an empty component in the output. eg.
splitWith (=='a') "aabbaca" == ["","","bb","c",""]
splitWith (=='a') []        == []
splitAtsplitAt :: Int ->  ByteString -> (ByteString, ByteString);N;Int ByteString(,) ByteString ByteStringiO(1) splitAt n xs is equivalent to (take n xs, drop n xs). splitsplit :: Word8 ->  ByteString ->  [ByteString]t<L<Word8 ByteString[] ByteStringO(n) Break a ByteString into pieces separated by the byte argument, consuming the delimiter. I.e.
split '\n' "a\nb\nd\ne" == ["a","b","d","e"]
split 'a'  "aXaXaXa"    == ["","X","X","X",""]
split 'x'  "x"          == ["",""]
and
intercalate [c] . split c == id
split == splitWith . (==)
As for all splitting functions in this library, this function does not copy the substrings, it just constructs new ByteStrings that are slices of the original. spanEndspanEnd :: (Word8 -> Bool) ->  ByteString -> (ByteString, ByteString)?>Word8Bool ByteString(,) ByteString ByteStringspanEnd behaves like span but from the end of the ByteString. We have
spanEnd (not.isSpace) "x y z" == ("x y ","z")
and
spanEnd (not . isSpace) ps
   == 
let (x,y) = span (not.isSpace) (reverse ps) in (reverse y, reverse x) 
spanspan :: (Word8 -> Bool) ->  ByteString -> (ByteString, ByteString)@@Word8Bool ByteString(,) ByteString ByteStringspan p xs breaks the ByteString into two segments. It is equivalent to (takeWhile p xs, dropWhile p xs) sortsort ::  ByteString ->  ByteStringAA ByteString ByteString@O(n) Sort a ByteString efficiently, using counting sort. snocsnoc ::  ByteString -> Word8 ->  ByteStringBsB ByteStringWord8 ByteString<O(n) Append a byte to the end of a ByteString  singleton singleton :: Word8 ->  ByteString9C#CWord8 ByteString<O(1) Convert a Word8 into a ByteString scanr1scanr1 :: (Word8 -> Word8 -> Word8) ->  ByteString ->  ByteStringDCWord8Word8Word8 ByteString ByteStringPscanr1 is a variant of scanr that has no starting value argument. scanr scanr :: (Word8 -> Word8 -> Word8) -> Word8 ->  ByteString ->  ByteString+EDWord8Word8Word8Word8 ByteString ByteString*scanr is the right-to-left dual of scanl. scanl1scanl1 :: (Word8 -> Word8 -> Word8) ->  ByteString ->  ByteStringEEWord8Word8Word8 ByteString ByteStringscanl1 is a variant of scanl that has no starting value argument. This function will fuse.
scanl1 f [x1, x2, ...] == [x1, x1 `f` x2, ...]
scanl scanl :: (Word8 -> Word8 -> Word8) -> Word8 ->  ByteString ->  ByteStringaG(GWord8Word8Word8Word8 ByteString ByteStringscanl is similar to foldl, but returns a list of successive reduced values from the left. This function will fuse.
scanl f z [x1, x2, ...] == [z, z `f` x1, (z `f` x1) `f` x2, ...]
Note that
last (scanl f z xs) == foldl f z xs.
reversereverse ::  ByteString ->  ByteStringHH ByteString ByteStringiO(n) reverse xs efficiently returns the elements of xs in reverse order.  replicate replicate :: Int -> Word8 ->  ByteStringIIIntWord8 ByteStringO(n) replicate n x is a ByteString of length n with x the value of every element. The following holds:
replicate w c = unfoldr w (\u -> Just (u,u)) c
This implemenation uses memset(3) readFilereadFile :: FilePath ->  IO ByteString3KKFilePathIO ByteStringURead an entire file strictly into a ByteString. This is far more efficient than reading the characters into a String and then using pack. It also may be more efficient than opening the file and reading it using hGet. Files are read using 'binary mode' on Windows, for 'text mode' use the Char8 version of this function. putStrLnputStrLn ::  ByteString -> IO ()LL ByteStringIO()7Write a ByteString to stdout, appending a newline byte putStrputStr ::  ByteString -> IO ()MtM ByteStringIO()Write a ByteString to stdout  partition partition :: (Word8 -> Bool) ->  ByteString -> (ByteString, ByteString)gN*NWord8Bool ByteString(,) ByteString ByteStringO(n) The partition function takes a predicate a ByteString and returns the pair of ByteStrings with elements which do and do not satisfy the predicate, respectively; i.e.,
partition p bs == (filter p xs, filter (not . p) xs)
packCStringLenpackCStringLen ::  CStringLen ->  IO ByteStringOO CStringLenIO ByteStringO(n). Construct a new ByteString from a CStringLen. The resulting ByteString is an immutable copy of the original CStringLen. The ByteString is a normal Haskell value and will be managed on the Haskell heap.  packCString packCString :: CString ->  IO ByteStringfQHQCStringIO ByteStringO(n). Construct a new ByteString from a CString. The resulting ByteString is an immutable copy of the original CString, and is managed on the Haskell heap. The original CString must be null terminated. packpack :: [Word8] ->  ByteStringRR[]Word8 ByteStringO(n) Convert a '[Word8]' into a ByteString. For applications with large numbers of string literals, pack can be a bottleneck. In such cases, consider using packAddress (GHC only). nullnull ::  ByteString -> BoolSS ByteStringBool0O(1) Test whether a ByteString is empty. notElemnotElem :: Word8 ->  ByteString -> BoolTwTWord8 ByteStringBool9O(n) notElem is the inverse of elem minimumminimum ::  ByteString -> Word80UU ByteStringWord8O(n) minimum returns the minimum value from a ByteString This function will fuse. An exception will be thrown in the case of an empty ByteString. maximummaximum ::  ByteString -> Word8;V%V ByteStringWord8O(n) maximum returns the maximum value from a ByteString This function will fuse. An exception will be thrown in the case of an empty ByteString.  mapAccumR  mapAccumR :: (acc -> Word8 -> (acc, Word8)) -> acc ->  ByteString -> (acc, ByteString)WyWaccWord8(,)accWord8acc ByteString(,)acc ByteStringThe mapAccumR function behaves like a combination of map and foldr; it applies a function to each element of a ByteString, passing an accumulating parameter from right to left, and returning a final value of this accumulator together with the new ByteString.  mapAccumL  mapAccumL :: (acc -> Word8 -> (acc, Word8)) -> acc ->  ByteString -> (acc, ByteString)YuYaccWord8(,)accWord8acc ByteString(,)acc ByteStringThe mapAccumL function behaves like a combination of map and foldl; it applies a function to each element of a ByteString, passing an accumulating parameter from left to right, and returning a final value of this accumulator together with the new list. mapmap :: (Word8 -> Word8) ->  ByteString ->  ByteStringf[;[Word8Word8 ByteString ByteStringO(n) map f xs is the ByteString obtained by applying f to each element of xs. This function is subject to array fusion. lengthlength ::  ByteString -> Inte\Q\ ByteStringIntOO(1) length returns the length of a ByteString as an Int. lastlast ::  ByteString -> Word8]\ ByteStringWord8O(1) Extract the last element of a ByteString, which must be finite and non-empty. An exception will be thrown in the case of an empty ByteString.  isSuffixOf isSuffixOf ::  ByteString ->  ByteString -> Bool6^^ ByteString ByteStringBoolHO(n) The isSuffixOf function takes two ByteStrings and returns True iff the first is a suffix of the second. The following holds:
isSuffixOf x y == reverse x `isPrefixOf` reverse y
However, the real implemenation uses memcmp to compare the end of the string only, with no reverse required..  isPrefixOf isPrefixOf ::  ByteString ->  ByteString -> Bool`_ ByteString ByteStringBoolO(n) The isPrefixOf function takes two ByteStrings and returns True iff the first is a prefix of the second.  isInfixOf isInfixOf ::  ByteString ->  ByteString -> Boola` ByteString ByteStringBoolCheck whether one string is a substring of another. isInfixOf p s is equivalent to not (null (findSubstrings p s)).  intersperse intersperse :: Word8 ->  ByteString ->  ByteString&bbWord8 ByteString ByteStringO(n) The intersperse function takes a Word8 and a ByteString and `intersperses' that byte between the elements of the ByteString. It is analogous to the intersperse function on Lists.  intercalate intercalate ::  ByteString ->  [ByteString] ->  ByteStringctc ByteString[] ByteString ByteStringO(n) The intercalate function takes a ByteString and a list of ByteStrings and concatenates the list after interspersing the first argument between each element of the list. interactinteract :: (ByteString -> ByteString) -> IO ()dd ByteString ByteStringIO()The interact function takes a function of type ByteString -> ByteString as its argument. The entire input from the standard input device is passed to this function as its argument, and the resulting string is output on the standard output device. initsinits ::  ByteString ->  [ByteString]gfFf ByteString[] ByteStringXO(n) Return all initial segments of the given ByteString, shortest first. initinit ::  ByteString ->  ByteString'g g ByteString ByteStringO(1) Return all the elements of a ByteString except the last one. An exception will be thrown in the case of an empty ByteString. indexindex ::  ByteString -> Int -> Word8+hh ByteStringIntWord8KO(1) ByteString index (subscript) operator, starting from 0.  hPutStrLn hPutStrLn :: Handle ->  ByteString -> IO ()hhHandle ByteStringIO()9Write a ByteString to a handle, appending a newline byte hPutStrhPutStr :: Handle ->  ByteString -> IO ()iiHandle ByteStringIO()/A synonym for hPut, for compatibility hPuthPut :: Handle ->  ByteString -> IO ()_j>jHandle ByteStringIO()<Outputs a ByteString to the specified Handle. hGetNonBlockinghGetNonBlocking :: Handle -> Int ->  IO ByteString.k kHandleIntIO ByteStringhGetNonBlocking is identical to hGet, except that it will never block waiting for data to become available, instead it returns only whatever data is available. hGetLinehGetLine :: Handle ->  IO ByteStringFl)lHandleIO ByteStringRead a line from a handle  hGetContents hGetContents :: Handle ->  IO ByteStringllHandleIO ByteStringRead entire handle contents strictly into a ByteString. This function reads chunks at a time, doubling the chunksize on each read. The final buffer is then realloced to the appropriate size. For files > half of available memory, this may lead to memory exhaustion. Consider using readFile in this case. As with hGet, the string representation in the file is assumed to be ISO-8859-1. The Handle is closed once the contents have been read, or if an exception is thrown. hGethGet :: Handle -> Int ->  IO ByteStringFo$oHandleIntIO ByteStringRead a ByteString directly from the specified Handle. This is far more efficient than reading the characters into a String and then using pack. First argument is the Handle to read from, and the second is the number of bytes to read. It returns the bytes read, up to n, or EOF. hGet is implemented in terms of hGetBuf. If the handle is a pipe or socket, and the writing end is closed, hGet will behave as if EOF was reached. headhead ::  ByteString -> Word8qjq ByteStringWord8O(1) Extract the first element of a ByteString, which must be non-empty. An exception will be thrown in the case of an empty ByteString. groupBygroupBy :: (Word8 -> Word8 -> Bool) ->  ByteString ->  [ByteString]rrWord8Word8Bool ByteString[] ByteStringKThe groupBy function is the non-overloaded version of group. groupgroup ::  ByteString ->  [ByteString]}s\s ByteString[] ByteStringThe group function takes a ByteString and returns a list of ByteStrings such that the concatenation of the result is equal to the argument. Moreover, each sublist in the result contains only equal elements. For example,
group "Mississippi" = ["M","i","ss","i","ss","i","pp","i"]
It is a special case of groupBy, which allows the programmer to supply their own equality test. It is about 40% faster than groupBy (==) getLinegetLine ::  IO ByteStringuuIO ByteStringRead a line from stdin.  getContents getContents ::  IO ByteStringvuIO ByteStringgetContents. Read stdin strictly. Equivalent to hGetContents stdin The Handle is closed after the contents have been read. foldr1'foldr1' :: (Word8 -> Word8 -> Word8) ->  ByteString -> Word8)wvWord8Word8Word8 ByteStringWord8L'foldr1\'' is a variant of foldr1, but is strict in the accumulator. foldr1foldr1 :: (Word8 -> Word8 -> Word8) ->  ByteString -> Word8xwWord8Word8Word8 ByteStringWord8foldr1 is a variant of foldr that has no starting value argument, and thus must be applied to non-empty ByteStrings An exception will be thrown in the case of an empty ByteString. foldr' foldr' :: (Word8 -> a -> a) -> a ->  ByteString -> aryNyWord8aaa ByteStringa?'foldr\'' is like foldr, but strict in the accumulator. foldr foldr :: (Word8 -> a -> a) -> a ->  ByteString -> aEz!zWord8aaa ByteStringafoldr, applied to a binary operator, a starting value (typically the right-identity of the operator), and a ByteString, reduces the ByteString using the binary operator, from right to left. foldl1'foldl1' :: (Word8 -> Word8 -> Word8) ->  ByteString -> Word8{}{Word8Word8Word8 ByteStringWord8'foldl1\'' is like foldl1, but strict in the accumulator. An exception will be thrown in the case of an empty ByteString. foldl1foldl1 :: (Word8 -> Word8 -> Word8) ->  ByteString -> Word8||Word8Word8Word8 ByteStringWord8foldl1 is a variant of foldl that has no starting value argument, and thus must be applied to non-empty ByteStrings. This function is subject to array fusion. An exception will be thrown in the case of an empty ByteString. foldl' foldl' :: (a -> Word8 -> a) -> a ->  ByteString -> aL~(~aWord8aa ByteStringa'foldl\'' is like foldl, but strict in the accumulator. However, for ByteStrings, all left folds are strict in the accumulator. foldl foldl :: (a -> Word8 -> a) -> a ->  ByteString -> agCaWord8aa ByteStringafoldl, applied to a binary operator, a starting value (typically the left-identity of the operator), and a ByteString, reduces the ByteString using the binary operator, from left to right. This function is subject to array fusion. findSubstringsfindSubstrings ::  ByteString ->  ByteString -> [Int]Ȁ ByteString ByteString[]IntVFind the indexes of all (possibly overlapping) occurances of a substring in a string.  findSubstring findSubstring ::  ByteString ->  ByteString ->  Maybe Int ByteString ByteStringMaybeIntGet the first index of a substring in another string, or Nothing if the string is not found. findSubstring p s is equivalent to listToMaybe (findSubstrings p s).  findIndices findIndices :: (Word8 -> Bool) ->  ByteString -> [Int]6 Word8Bool ByteString[]IntThe findIndices function extends findIndex, by returning the indices of all elements satisfying the predicate, in ascending order.  findIndex findIndex :: (Word8 -> Bool) ->  ByteString ->  Maybe Intd8Word8Bool ByteStringMaybeIntThe findIndex function takes a predicate and a ByteString and returns the index of the first element in the ByteString satisfying the predicate. findfind :: (Word8 -> Bool) ->  ByteString ->  Maybe Word8lWord8Bool ByteStringMaybeWord8 O(n) The find function takes a predicate and a ByteString, and returns the first element in matching the predicate, or Nothing if there is no such element.
find f p = case findIndex f p of Just n -> Just (p ! n) ; _ -> Nothing
filterfilter :: (Word8 -> Bool) ->  ByteString ->  ByteString<Word8Bool ByteString ByteStringO(n) filter, applied to a predicate and a ByteString, returns a ByteString containing those characters that satisfy the predicate. This function is subject to array fusion. emptyempty ::  ByteString=0 ByteString(O(1) The empty ByteString  elemIndices elemIndices :: Word8 ->  ByteString -> [Int]̈Word8 ByteString[]IntO(n) The elemIndices function extends elemIndex, by returning the indices of all elements equal to the query element, in ascending order. This implementation uses memchr(3).  elemIndexEnd elemIndexEnd :: Word8 ->  ByteString ->  Maybe IntAWord8 ByteStringMaybeInt3O(n) The elemIndexEnd function returns the last index of the element in the given ByteString which is equal to the query element, or Nothing if there is no such element. The following holds:
elemIndexEnd c xs == 
(-) (length xs - 1) `fmap` elemIndex c (reverse xs)
 elemIndex elemIndex :: Word8 ->  ByteString ->  Maybe IntۋWord8 ByteStringMaybeIntO(n) The elemIndex function returns the index of the first element in the given ByteString which is equal to the query element, or Nothing if there is no such element. This implementation uses memchr(3). elemelem :: Word8 ->  ByteString -> Bool[?Word8 ByteStringBoolGO(n) elem is the ByteString membership predicate.  dropWhile dropWhile :: (Word8 -> Bool) ->  ByteString ->  ByteString>Word8Bool ByteString ByteStringbdropWhile p xs returns the suffix remaining after takeWhile p xs. dropdrop :: Int ->  ByteString ->  ByteStringInt ByteString ByteStringO(1) drop n xs returns the suffix of xs after the first n elements, or [] if n > length xs. countcount :: Word8 ->  ByteString -> Int1Word8 ByteStringIntcount returns the number of times its argument appears in the ByteString
count = length . elemIndices
But more efficiently than using length on the intermediate list. copycopy ::  ByteString ->  ByteStringO4 ByteString ByteString*O(n) Make a copy of the ByteString with its own storage. This is mainly useful to allow the rest of the data pointed to by the ByteString to be garbage collected, for example if a large string has been read in, and only a small part of it is needed in the rest of the program. conscons :: Word8 ->  ByteString ->  ByteStringגWord8 ByteString ByteStringmO(n) cons is analogous to (:) for lists, but of different complexity, as it requires a memcpy.  concatMap concatMap :: (Word8 -> ByteString) ->  ByteString ->  ByteStringޓWord8 ByteString ByteString ByteStringDMap a function over a ByteString and concatenate the results concatconcat ::  [ByteString] ->  ByteStringƔ[] ByteString ByteString/O(n) Concatenate a list of ByteStrings.  ByteStringdata  ByteString-A space-efficient representation of a Word8 vector, supporting many efficient operations. A ByteString contains 8-bit characters only. Instances of Eq, Ord, Read, Show, Data, Typeable breakSubstringbreakSubstring ::  ByteString ->  ByteString -> (ByteString, ByteString)r ByteString ByteString(,) ByteString ByteString$Break a string on a substring, returning a pair of the part of the string prior to the match, and the rest of the string. The following relationships hold:
break (== c) l == breakSubstring (singleton c) l
and:
findSubstring s l ==
   if null s then Just 0
             else case breakSubstring s l of
                      (x,y) | null y    -> Nothing
                            | otherwise -> Just (length x)
For example, to tokenise a string, dropping delimiters:
tokenise x y = h : if null t then [] else tokenise x (drop (length x) t)
    where (h,t) = breakSubstring x y
To skip to the first occurence of a string:
snd (breakSubstring x y) 
To take the parts of a string before a delimiter:
fst (breakSubstring x y) 
breakEndbreakEnd :: (Word8 -> Bool) ->  ByteString -> (ByteString, ByteString)NWord8Bool ByteString(,) ByteString ByteStringsbreakEnd behaves like break but from the end of the ByteString breakEnd p == spanEnd (not.p)  breakByte breakByte :: Word8 ->  ByteString -> (ByteString, ByteString)tWord8 ByteString(,) ByteString ByteStringbreakByte breaks its ByteString argument at the first occurence of the specified byte. It is more efficient than break as it is implemented with memchr(3). I.e.
break (=='c') "abcd" == breakByte 'c' "abcd"
breakbreak :: (Word8 -> Bool) ->  ByteString -> (ByteString, ByteString)QWord8Bool ByteString(,) ByteString ByteStringbreak p is equivalent to span (not . p). Under GHC, a rewrite rule will transform break (==) into a call to the specialised breakByte:
break ((==) x) = breakByte x
break (==x) = breakByte x
 appendFile appendFile :: FilePath ->  ByteString -> IO ()ОFilePath ByteStringIO()&Append a ByteString to a file. appendappend ::  ByteString ->  ByteString ->  ByteString] ByteString ByteString ByteString#O(n) Append two ByteStrings anyany :: (Word8 -> Bool) ->  ByteString -> Bool+Word8Bool ByteStringBoolO(n) Applied to a predicate and a ByteString, any determines if any element of the ByteString satisfies the predicate. allall :: (Word8 -> Bool) ->  ByteString -> Bool;Word8Bool ByteStringBoolO(n) Applied to a predicate and a ByteString, all determines if all elements of the ByteString satisfy the predicate. Unsafemodule Data.ByteString.Unsafe 4A module containing unsafe ByteString operations. This exposes the ByteString representation and low level construction functions. Modules which extend the ByteString system will need to use this module while ideally most users will be able to make do with the public interface modules. Lazymodule Data.ByteString.LazyyA time and space-efficient implementation of lazy byte vectors using lists of packed Word8 arrays, suitable for high performance use, both in terms of large data quantities, or high speed requirements. Byte vectors are encoded as lazy lists of strict Word8 arrays of bytes. They provide a means to manipulate large byte vectors without requiring the entire vector be resident in memory. Some operations, such as concat, append, reverse and cons, have better complexity than their Data.ByteString equivalents, due to optimisations resulting from the list spine structure. And for other operations lazy ByteStrings are usually within a few percent of strict ones, but with better heap usage. For data larger than the available memory, or if you have tight memory constraints, this module will be the only option. The default chunk size is 64k, which should be good in most circumstances. For people with large L2 caches, you may want to increase this to fit your cache. This module is intended to be imported qualified, to avoid name clashes with Prelude functions. eg.
import qualified Data.ByteString.Lazy as B
Original GHC implementation by Bryan O'Sullivan. Rewritten to use Data.Array.Unboxed.UArray by Simon Marlow. Rewritten to support slices and use Foreign.ForeignPtr.ForeignPtr by David Roundy. Polished and extended by Don Stewart. Lazy variant by Duncan Coutts and Don Stewart. Internalmodule Data.ByteString.Lazy.Internalb8A module containing semi-public ByteString internals. This exposes the ByteString representation and low level construction functions. Modules which extend the ByteString system will need to use this module while ideally most users will be able to make do with the public interface modules. Internalmodule Data.ByteString.Internalܪ8A module containing semi-public ByteString internals. This exposes the ByteString representation and low level construction functions. Modules which extend the ByteString system will need to use this module while ideally most users will be able to make do with the public interface modules. Fusionmodule Data.ByteString.FusionRStream fusion for ByteStrings. See the paper Stream Fusion: From Lists to Streams to Nothing at All, Coutts, Leshchinskiy and Stewart, 2007. Char8module Data.ByteString.Lazy.Char8(Manipulate lazy ByteStrings using Char operations. All Chars will be truncated to 8 bits. It can be expected that these functions will run at identical speeds to their Data.Word.Word8 equivalents in Data.ByteString.Lazy. This module is intended to be imported qualified, to avoid name clashes with Prelude functions. eg.
import qualified Data.ByteString.Lazy.Char8 as C
Char8module Data.ByteString.Char8Manipulate ByteStrings using Char operations. All Chars will be truncated to 8 bits. It can be expected that these functions will run at identical speeds to their Word8 equivalents in Data.ByteString. More specifically these byte strings are taken to be in the subset of Unicode covered by code points 0-255. This covers Unicode Basic Latin, Latin-1 Supplement and C0+C1 Controls. See: This module is intended to be imported qualified, to avoid name clashes with Prelude functions. eg.
import qualified Data.ByteString.Char8 as B
The Char8 interface to bytestrings provides an instance of IsString for the ByteString type, enabling you to use string literals, and have them implicitly packed to ByteStrings. Use -XOverloadedStrings to enable this. bytestringpackage  bytestring!3Fast, packed, strict and lazy byte arrays with a list interface A time and space-efficient implementation of byte vectors using packed Word8 arrays, suitable for high performance use, both in terms of large data quantities, or high speed requirements. Byte vectors are encoded as strict Word8 arrays of bytes, and lazy lists of strict chunks, held in a ForeignPtr, and can be passed between C and Haskell with little effort. Test coverage data for this library is available at: http://code.haskell.org/~dons/tests/bytestring/hpc_index.html  ByteStringmodule Data. ByteStringA time and space-efficient implementation of byte vectors using packed Word8 arrays, suitable for high performance use, both in terms of large data quantities, or high speed requirements. Byte vectors are encoded as strict Word8 arrays of bytes, held in a ForeignPtr, and can be passed between C and Haskell with little effort. This module is intended to be imported qualified, to avoid name clashes with Prelude functions. eg.
import qualified Data.ByteString as B
Original GHC implementation by Bryan O'Sullivan. Rewritten to use Data.Array.Unboxed.UArray by Simon Marlow. Rewritten to support slices and use ForeignPtr by David Roundy. Polished and extended by Don Stewart. <"ڸøData ByteStringLazyChar8Data ByteStringLazyData ByteStringChar8Data ByteStringData ByteStringUnsafeData ByteStringLazyInternalData ByteStringInternalData ByteStringFusion\ bytestring0.9.1.4Hhttp://hackage.haskell.org/packages/archive/bytestring/0.9.1.4/doc/html/Ehttp://hackage.haskell.org/cgi-bin/hackage-scripts/package/bytestring