Îõ³h$•æ‘û«      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ¡¢£¤¥¦§¨©ªè(c) Don Stewart 2006 (c) Duncan Coutts 2006-2011 (c) Michael Thompson 2015 BSD-styleNone '(>ÀÁÂÇÔÙ^ streaming-bytestring4A space-efficient representation of a succession of «0 vectors, supporting many efficient operations. An effectful 8 contains 8-bit bytes, or by using the operations from Streaming.ByteString.Char87 it can be interpreted as containing 8-bit characters.streaming-bytestring$A type alias for back-compatibility.streaming-bytestring Synonym of ¬ for GHC prior to 9.0.streaming-bytestringLike bracket, but specialized for .streaming-bytestringSmart constructor for .streaming-bytestring"Yield-style smart constructor for . streaming-bytestringReconceive an effect that results in an effectful bytestring as an effectful bytestring. Compare Streaming.mwrap. The closest equivalent of2Streaming.wrap :: f (Stream f m r) -> Stream f m r is here  consChunk. mwrap+ is the smart constructor for the internal Go constructor. streaming-bytestringÃConstruct a succession of chunks from its Church encoding (compare GHC.Exts.build) streaming-bytestring…Resolve a succession of chunks into its Church encoding; this is not a safe operation; it is equivalent to exposing the constructors streaming-bytestringÖThe chunk size used for I/O. Currently set to 32k, less the memory management overhead streaming-bytestringÔThe recommended chunk size. Currently set to 4k, less the memory management overheadstreaming-bytestringÅThe memory management overhead. Currently this is tuned for GHC only.streaming-bytestringüPacking and unpacking from lists packBytes' :: Monad m => [Word8] -> ByteString m () packBytes' cs0 = packChunks 32 cs0 where packChunks n cs = case B.packUptoLenBytes n cs of (bs, []) -> Chunk bs (Empty ()) (bs, cs') -> Chunk bs (packChunks (min (n * 2) BI.smallChunkSize) cs') -- packUptoLenBytes :: Int -> [Word8] -> (ByteString, [Word8]) packUptoLenBytes len xs0 = accursedUnutterablePerformIO (createUptoN' len $ p -> go p len xs0) where go !_ !n [] = return (len-n, []) go !_ !0 xs = return (len, xs) go !p !n (x:xs) = poke p x >> go (p ­¾ 1) (n-1) xs createUptoN' :: Int -> (Ptr Word8 -> IO (Int, a)) -> IO (B.ByteString, a) createUptoN' l f = do fp <- B.mallocByteString l (l', res)  -withForeignPtr fp $ p -à f p assert (l' <= l) $ return (B.PS fp 0 l', res) {- INLINABLE packBytes' -} Convert a ® of pure « into a chunked .streaming-bytestringConvert a vanilla ®& of characters into a stream of bytes.Note: Each ¯ value is truncated to 8 bits.streaming-bytestringThe reverse of %. Given a stream of bytes, produce a ® individual bytes.streaming-bytestringËCopied from Data.ByteString.Unsafe for compatibility with older bytestring.streaming-bytestringËCopied from Data.ByteString.Unsafe for compatibility with older bytestring.streaming-bytestring#Consume the chunks of an effectful  with a natural right fold.streaming-bytestring#Consume the chunks of an effectful * with a left fold. Suitable for use with °.streaming-bytestringInstead of mapping over each « or ¯, map over each strict ± chunk in the stream.streaming-bytestringLike , but map effectfully.streaming-bytestringLike 3, but discard the result of each effectful mapping.streaming-bytestring chunkFold is preferable to  foldlChunks* since it is an appropriate argument for Control.Foldl.purelyÐ which permits many folds and sinks to be run simultaneously on one bytestream.streaming-bytestring is preferable to * since it is an appropriate argument for Ð which permits many folds and sinks to be run simultaneously on one bytestream.streaming-bytestringLike ., but fold effectfully. Suitable for use with °.streaming-bytestringÐConsume the chunks of an effectful ByteString with a natural right monadic fold.streaming-bytestringInternal utility for unfoldr.streaming-bytestring9Given some continual monadic action that produces strict ±$ chunks, produce a stream of bytes.streaming-bytestringLike , but feed through a final r return value. streaming-bytestring+Stream chunks from something that contains m (Maybe ByteString) until it returns ².   is of particular use rendering  io-streams5 input streams as byte streams in the present sense. ÷import qualified Data.ByteString as B import qualified System.IO.Streams as S Q.reread S.read :: S.InputStream B.ByteString -> Q.ByteStream IO () Q.reread (liftIO . S.read) :: MonadIO m => S.InputStream B.ByteString -> Q.ByteStream m ()The other direction here is ÒS.unfoldM Q.unconsChunk :: Q.ByteString IO r -> IO (S.InputStream B.ByteString)!streaming-bytestringÖMake the information in a bytestring available to more than one eliminating fold, e.g.3Q.count 'l' $ Q.count 'o' $ Q.copy $ "hello\nworld"3 :> (2 :> ())ÅQ.length $ Q.count 'l' $ Q.count 'o' $ Q.copy $ Q.copy "hello\nworld"11 :> (3 :> (2 :> ()))ÞrunResourceT $ Q.writeFile "hello2.txt" $ Q.writeFile "hello1.txt" $ Q.copy $ "hello\nworld\n":! cat hello2.txthelloworld:! cat hello1.txthelloworldÓThis sort of manipulation could as well be acheived by combining folds - using  Control.Foldl• for example. But any sort of manipulation can be involved in the fold. Here are a couple of trivial complications involving splitting by lines:?let doubleLines = Q.unlines . maps (<* Q.chunk "\n" ) . Q.lines ByteStream m r5streaming-bytestringO(1) The empty  -- i.e.  return () Note that ByteStream m w/ is generally a monoid for monoidal values of w, like ().6streaming-bytestringO(1) Yield a « as a minimal .7streaming-bytestringO(n)( Convert a monadic stream of individual «s into a packed byte stream.8streaming-bytestringO(n)Á Converts a packed byte stream into a stream of individual bytes.9streaming-bytestringO(c)/ Convert a monadic stream of individual strict  chunks into a byte stream.:streaming-bytestringO(c)ü Convert a byte stream into a stream of individual strict bytestrings. This of course exposes the internal chunk structure.;streaming-bytestringO(1) Yield a strict  chunk.<streaming-bytestringO(n), Convert a byte stream into a single strict .Note that this is an  expensive½ operation that forces the whole monadic ByteString into memory and then copies all the data. If possible, try to avoid converting back and forth between streaming and strict bytestrings.=streaming-bytestringO(n)4 Convert a monadic byte stream into a single strict Ô, retaining the return value of the original pair. This operation is for use with °. ×mapped R.toStrict :: Monad m => Stream (ByteStream m) m r -> Stream (Of ByteString) m rÇIt is subject to all the objections one makes to Data.ByteString.Lazy =; all of these are devastating.>streaming-bytestringO(c)Þ Transmute a pseudo-pure lazy bytestring to its representation as a monadic stream of chunks.Q.putStrLn $ Q.fromLazy "hi"hiQ.fromLazy "hi"ÏChunk "hi" (Empty (())) -- note: a 'show' instance works in the identity monad Stream (Of L.ByteString) m rQ.toLazy "hello" "hello" :> ()ÈS.toListM $ traverses Q.toLazy $ Q.lines "one\ntwo\nthree\nfour\nfive\n"9["one","two","three","four","five",""] -- [L.ByteString]Astreaming-bytestringTest whether a ý is empty, collecting its return value; to reach the return value, this operation must check the whole length of the string.%Q.null "one\ntwo\three\nfour\nfive\n" False :> () Q.null "" True :> ()4S.print $ mapped R.null $ Q.lines "yours,\nMeredith"FalseFalseSuitable for use with °: ÈS.mapped Q.null :: Streaming (ByteStream m) m r -> Stream (Of Bool) m r Bstreaming-bytestringO(1) Test whether a ? is empty. The value is of course in the monad of the effects.%Q.null "one\ntwo\three\nfour\nfive\n"FalseQ.null $ Q.take 0 Q.stdinTrue:t Q.null $ Q.take 0 Q.stdin0Q.null $ Q.take 0 Q.stdin :: MonadIO m => m BoolCstreaming-bytestring Similar to A", but yields the remainder of the , stream when an answer has been determined.Dstreaming-bytestring6Remove empty ByteStrings from a stream of bytestrings.Estreaming-bytestringO1ð Distinguish empty from non-empty lines, while maintaining streaming; the empty ByteStrings are on the rightÄnulls :: ByteStream m r -> m (Sum (ByteStream m) (ByteStream m) r)ÍThere are many (generally slower) ways to remove null bytestrings from a Stream (ByteStream m) m r (besides using denull). If we pass next toÁmapped nulls bs :: Stream (Sum (ByteStream m) (ByteStream m)) m rthen can then apply Streaming.separate to getÏseparate (mapped nulls bs) :: Stream (ByteStream m) (Stream (ByteStream m) m) rÎThe inner monad is now made of the empty bytestrings; we act on this with hoist , considering that:t Q.effects . Q.concatQ.effects . Q.concat2 :: Monad m => Stream (Q.ByteStream m) m r -> m rwe have8hoist (Q.effects . Q.concat) . separate . mapped Q.nullsË :: Monad n => Stream (Q.ByteStream n) n b -> Stream (Q.ByteStream n) n bFstreaming-bytestringLike G$, report the length in bytes of the Ë by running through its contents. Since the return value is in the effect m., this is one way to "get out" of the stream.Gstreaming-bytestringO(n/c) G+ returns the length of a byte stream as an ³à together with the return value. This makes various maps possible.'Q.length "one\ntwo\three\nfour\nfive\n"23 :> ()ÍS.print $ S.take 3 $ mapped Q.length $ Q.lines "one\ntwo\three\nfour\nfive\n"384Hstreaming-bytestringO(1) H is analogous to (:) for lists.Istreaming-bytestringO(1) Unlike Hþ, '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 xsYou can however use H , as well as [ and \", to build infinite byte streams.Jstreaming-bytestringO(n/c) Append a byte to the end of a .Kstreaming-bytestringO(1) Extract the first element of a , which must be non-empty.Lstreaming-bytestringO(c) Extract the first element of a *, if there is one. Suitable for use with °: ÐS.mapped Q.head :: Stream (Q.ByteStream m) m r -> Stream (Of (Maybe Word8)) m r Mstreaming-bytestringO(1) Extract the head and tail of a á, or its return value if it is empty. This is the 'natural' uncons for an effectful byte stream.Nstreaming-bytestring The same as M&, will be removed in the next version.Ostreaming-bytestringLike M, but yields the entire first ±ç chunk that the stream is holding onto. If there wasn't one, it tries to fetch it. Yields the final r return value when the  is empty.Pstreaming-bytestring The same as O&, will be removed in the next version.Qstreaming-bytestringO(n/c) Extract the last element of a &, which must be finite and non-empty.Rstreaming-bytestringExtract the last element of a &, if possible. Suitable for use with °: ÑS.mapped Q.last :: Streaming (ByteStream m) m r -> Stream (Of (Maybe Word8)) m r Sstreaming-bytestringO(n/c) Append two  s together.Tstreaming-bytestringO(n) T f xs( is the ByteStream obtained by applying f to each element of xs.Ustreaming-bytestringU xs f applies fÆ to each chunk in the stream, and concatenates the resulting streams.Vstreaming-bytestringThe V function takes a « and a ; and `intersperses' that byte between the elements of the :. It is analogous to the intersperse function on Streams.Wstreaming-bytestringWº, applied to a binary operator, a starting value (typically the right-identity of the operator), and a ByteStream, reduces the ByteStream using the binary operator, from right to left.Xstreaming-bytestringXï, applied to a binary operator, a starting value (typically the left-identity of the operator), and a ByteStream, reduces the ByteStream using the binary operator, from left to right. We use the style of the foldl library for left foldsYstreaming-bytestringYò keeps the return value of the left-folded bytestring. Useful for simultaneous folds over a segmented bytestream.Zstreaming-bytestringZ f x? returns an infinite ByteStream of repeated applications -- of f to x: %iterate f x == [x, f x, f (f x), ...](R.stdout $ R.take 50 $ R.iterate succ 392()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXY,Q.putStrLn $ Q.take 50 $ Q.iterate succ '\''2()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXY[streaming-bytestring[ x! is an infinite ByteStream, with x! the value of every element."R.stdout $ R.take 50 $ R.repeat 602<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<%Q.putStrLn $ Q.take 50 $ Q.repeat 'z'2zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\streaming-bytestring\œ ties a finite ByteStream into a circular one, or equivalently, the infinite repetition of the original ByteStream. For an empty bytestring (like  return 17)) it of course makes an unproductive loop&Q.putStrLn $ Q.take 7 $ Q.cycle "y\n"yyyy]streaming-bytestringO(n) The ]% function is analogous to the Stream unfoldr. ]Ô builds a ByteStream from a seed value. The function takes the element and returns ²4 if it is done producing the ByteStream or returns ´ (a,b), in which case, a( is a prepending to the ByteStream and b1 is used as the next element in a recursive call.^streaming-bytestringLike ], but yields a final r when the « generation is complete._streaming-bytestringO(n/c) _ n, applied to a ByteStream xs, returns the prefix of xs of length n, or xs itself if n > G xs.ÊNote that in the streaming context this drops the final return value; a> preserves this information, and is sometimes to be preferred.8Q.putStrLn $ Q.take 8 $ "Is there a God?" >> return TrueIs there-Q.putStrLn $ "Is there a God?" >> return TrueIs there a God?TrueÃrest <- Q.putStrLn $ Q.splitAt 8 $ "Is there a God?" >> return TrueIs thereQ.effects restTrue`streaming-bytestringO(n/c) ` n xs returns the suffix of xs after the first n elements, or [] if n > G xs.!Q.putStrLn $ Q.drop 6 "Wisconsin"sin"Q.putStrLn $ Q.drop 16 "Wisconsin"astreaming-bytestringO(n/c) a n xs is equivalent to (_ n xs, ` n xs).Ürest <- Q.putStrLn $ Q.splitAt 3 "therapist is a danger to good hyphenation, as Knuth notes"theQ.putStrLn $ Q.splitAt 19 restrapist is a dangerbstreaming-bytestringb, applied to a predicate p and a ByteStream xs2, returns the longest prefix (possibly empty) of xs of elements that satisfy p.cstreaming-bytestringc p xs$ returns the suffix remaining after b p xs.dstreaming-bytestringd p is equivalent to e (µ . p).estreaming-bytestringe p xs? breaks the ByteStream into two segments. It is equivalent to (b p xs, c p xs).fstreaming-bytestringO(n) Splits a æ 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') [] == []gstreaming-bytestringO(n) Break a Ë 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 9intercalate [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 #s that are slices of the original.hstreaming-bytestringThe hÔ function takes a ByteStream and returns a list of ByteStreams 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 iÁ, which allows the programmer to supply their own equality test.istreaming-bytestringThe i& function is a generalized version of h.jstreaming-bytestringO(n) The j function takes a  and a list of ås and concatenates the list after interspersing the first argument between each element of the list.kstreaming-bytestring8Returns the number of times its argument appears in the . count = length . elemIndiceslstreaming-bytestring8Returns the number of times its argument appears in the . Suitable for use with °: ÌS.mapped (Q.count 37) :: Stream (Q.ByteStream m) m r -> Stream (Of Int) m r mstreaming-bytestringO(n) mø, applied to a predicate and a ByteStream, returns a ByteStream containing those characters that satisfy the predicate.nstreaming-bytestringRead entire handle contents lazily into a ). Chunks are read on demand, in at most k6-sized chunks. It does not block waiting for a whole k-sized chunk, so if less than kÐ bytes are available then they will be returned immediately as a smaller chunk. Note: the ¶' should be placed in binary mode with  for n to work correctly.ostreaming-bytestringRead n bytes into a , directly from the specified ¶, in chunks of size k.pstreaming-bytestringhGetNonBlockingN is similar to nœ, except that it will never block waiting for data to become available, instead it returns only whatever data is available. Chunks are read on demand, in k-sized chunks.qstreaming-bytestringRead entire handle contents lazily into a ;. Chunks are read on demand, using the default chunk size. Note: the ¶' should be placed in binary mode with  for q to work correctly.rstreaming-bytestringPipes-style nomenclature for q.sstreaming-bytestringPipes-style nomenclature for y.tstreaming-bytestringRead n bytes into a , directly from the specified ¶.ustreaming-bytestringhGetNonBlocking is similar to t¨, except that it will never block waiting for data to become available, instead it returns only whatever data is available. If there is no data available to be read, u returns 5.ƒNote: on Windows and with Haskell implementation other than GHC, this function does not work correctly; it behaves identically to t.vstreaming-bytestringWrite a  to a file. Use  & to ensure that the handle is closed.:set -XOverloadedStringsÇrunResourceT $ Q.writeFile "hello.txt" "Hello world.\nGoodbye world.\n":! cat "hello.txt" Hello world.Goodbye world.ÀrunResourceT $ Q.writeFile "hello2.txt" $ Q.readFile "hello.txt":! cat hello2.txt Hello world.Goodbye world.wstreaming-bytestring#Read an entire file into a chunked  IO ()Ñ. The handle will be held open until EOF is encountered. The block governed by ·2 will end with the closing of any handles opened.:! cat hello.txt Hello world.Goodbye world.0runResourceT $ Q.stdout $ Q.readFile "hello.txt" Hello world.Goodbye world.xstreaming-bytestring Append a  to a file. Use  & to ensure that the handle is closed.ÇrunResourceT $ Q.writeFile "hello.txt" "Hello world.\nGoodbye world.\n"0runResourceT $ Q.stdout $ Q.readFile "hello.txt" Hello world.Goodbye world.ÄrunResourceT $ Q.appendFile "hello.txt" "sincerely yours,\nArthur\n"1runResourceT $ Q.stdout $ Q.readFile "hello.txt" Hello world.Goodbye world.sincerely yours,Arthurystreaming-bytestringEquivalent to hGetContents stdin . Will read lazily.zstreaming-bytestring Outputs a  to the specified ¶.{streaming-bytestringPipes nomenclature for z.|streaming-bytestringPipes-style nomenclature for putStr.}streaming-bytestringA synonym for hPut, for compatibility ByteStream IO r -> IO r hPutStr = hPutÜ- | Write a ByteStream to stdout putStr :: ByteStream IO r -> IO r putStr = hPut IO.stdout/The interact function takes a function of type ByteStream -> ByteStream² 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. %interact morph = stdout (morph stdin)~streaming-bytestring1Zip a list and a stream-of-byte-streams together.streaming-bytestring×Take a builder constructed otherwise and convert it to a genuine streaming bytestring.ÛQ.putStrLn $ Q.toStreamingByteString $ stringUtf8 "È©¯ËË¢”¸" <> stringUtf8 " " <> integerDec 98È©¯ËË¢”¸ 98 5https://gist.github.com/michaelt/6ea89ca95a77b0ef91f3This benchmark2 shows its performance is indistinguishable from toLazyByteString€streaming-bytestringçTake a builder and convert it to a genuine streaming bytestring, using a specific allocation strategy.streaming-bytestringÖConcatenate a stream of builders (not a streaming bytestring!) into a single builder.Úlet aa = yield (integerDec 10000) >> yield (string8 " is a number.") >> yield (char8 '\n'))hPutBuilder IO.stdout $ concatBuilders aa10000 is a number.‚streaming-bytestring*A simple construction of a builder from a .5let aaa = "10000 is a number\n" :: Q.ByteString IO ()'hPutBuilder IO.stdout $ toBuilder aaa10000 is a numberá  !123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~€‚á5678>@?9:;=<3!4 TUjVHIJSmMNd`chieaf_bg1D€‚[Z\]^ WYXLKRQGFABEClkys|}wvxr{tqnoupzOP 2~è(c) Don Stewart 2006 (c) Duncan Coutts 2006-2011 (c) Michael Thompson 2015 BSD-styleNone &ÔÙáY(ƒstreaming-bytestring+Given a stream of bytes, produce a vanilla ® of characters.„streaming-bytestringO(n)à Convert a stream of separate characters into a packed byte stream.…streaming-bytestringO(1) Cons a ¯ onto a byte stream.†streaming-bytestringO(1) Yield a ¯ as a minimal ‡streaming-bytestringO(1) Unlike …ÿ, '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 xsYou can however use … , as well as • and \&, to build infinite lazy ByteStreams.ˆstreaming-bytestringO(n/c) Append a byte to the end of a ‰streaming-bytestringO(1)Ä Extract the first element of a ByteStream, which must be non-empty.Šstreaming-bytestringO(1)Ð Extract the first element of a ByteStream, if possible. Suitable for use with °: ÏS.mapped Q.head :: Stream (Q.ByteStream m) m r -> Stream (Of (Maybe Char)) m r ‹streaming-bytestringO(n/c)Ï Extract the last element of a ByteStream, which must be finite and non-empty.Œstreaming-bytestringExtract the last element of a &, if possible. Suitable for use with °: ÐS.mapped Q.last :: Streaming (ByteStream m) m r -> Stream (Of (Maybe Char)) m r streaming-bytestringThe & function is a generalized version of h.Žstreaming-bytestringO(1) Extract the head and tail of a á, or its return value if it is empty. This is the 'natural' uncons for an effectful byte stream.streaming-bytestring The same as Ž&, will be removed in the next version.streaming-bytestringO(n)  f xs( is the ByteStream obtained by applying f to each element of xs.‘streaming-bytestringThe ‘ function takes a ¯ and a ; and `intersperses' that byte between the elements of the :. It is analogous to the intersperse function on Streams.’streaming-bytestring’ò keeps the return value of the left-folded bytestring. Useful for simultaneous folds over a segmented bytestream.“streaming-bytestringLike ’, but suitable for use with  .”streaming-bytestring” f x= returns an infinite ByteStream of repeated applications of f to x: %iterate f x == [x, f x, f (f x), ...]•streaming-bytestring• x! is an infinite ByteStream, with x the value of every element.–streaming-bytestring\ô ties a finite ByteStream into a circular one, or equivalently, the infinite repetition of the original ByteStream.| O(n) The –1 function is analogous to the Stream 'unfoldr'. –Ô builds a ByteStream from a seed value. The function takes the element and returns ²4 if it is done producing the ByteStream or returns ´ (a,b), in which case, a( is a prepending to the ByteStream and b1 is used as the next element in a recursive call.—streaming-bytestringÓGiven some pure process that produces characters, generate a stream of bytes. The r produced by the final ¸È will be the return value at the end of the stream. Note also that the ¯% values will be truncated to 8-bits.˜streaming-bytestring˜, applied to a predicate p and a ByteStream xs2, returns the longest prefix (possibly empty) of xs of elements that satisfy p.™streaming-bytestring™ p xs$ returns the suffix remaining after ˜ p xs.šstreaming-bytestringš p is equivalent to › (µ . p).›streaming-bytestring› p xs? breaks the ByteStream into two segments. It is equivalent to (˜ p xs, ™ p xs)œstreaming-bytestringLike 2, but you can supply your own splitting predicate.streaming-bytestringO(n) Break a Ï 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 9intercalate [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 "s that are slices of the original.0Q.stdout $ Q.unlines $ Q.split 'n' "banana peel"baaa peelžstreaming-bytestringO(n) žù, applied to a predicate and a ByteStream, returns a ByteStream containing those characters that satisfy the predicate.Ÿstreaming-bytestringŸ­ turns a ByteStream into a connected stream of ByteStreams at divide at newline characters. The resulting strings do not contain newlines. This is the genuinely streaming ŸÇ which only breaks chunks, and thus never increases the use of memory.Because âs are usually read in binary mode, with no line ending conversion, this function recognizes both \n and \r\n/ endings (regardless of the current platform). streaming-bytestringThe  . function restores line breaks between layers.+Note that this is not a perfect inverse of Ÿ:Ÿ .  Ù can produce more strings than there were if some of the "lines" had embedded newlines.  . Ÿ will replace \r\n with \n.¡streaming-bytestring¡à breaks a byte stream up into a succession of byte streams corresponding to words, breaking on ¯=s representing white space. This is the genuinely streaming ¡ë. A function that returns individual strict bytestrings would concatenate even infinitely long words like  cycle "y"Ý in memory. When the stream is known to not contain unreasonably long words, you can write mapped toStrict . words0 or the like, if strict bytestrings are needed.¢streaming-bytestringThe ¢ function is analogous to the   function, on words.£streaming-bytestring£ë turns a ByteStream into a connected stream of ByteStreams at divide after a fixed number of newline characters. Unlike most of the string splitting functions in this library, this function preserves newlines characters.Like Ÿ&, this function properly handles both \n and \r\nÆ endings regardless of the current platform. It does not support \r or \n\r line endings.Ölet planets = ["Mercury","Venus","Earth","Mars","Saturn","Jupiter","Neptune","Uranus"]àS.mapsM_ (\x -> putStrLn "Chunk" >> Q.putStrLn x) $ Q.lineSplit 3 $ Q.string $ L.unlines planetsChunkMercuryVenusEarth(Chunk Mars Saturn JupiterChunk Neptune UranusôSince all characters originally present in the stream are preserved, this function satisfies the following law: $ïX n bs. concat (lineSplit n bs) ÅD bs¤streaming-bytestringPromote a vanilla ¹ into a stream.Note: Each ¯ is truncated to 8 bits.¥streaming-bytestring8Returns the number of times its argument appears in the .¦streaming-bytestring8Returns the number of times its argument appears in the . Suitable for use with °: ÍS.mapped (Q.count 'a') :: Stream (Q.ByteStream m) m r -> Stream (Of Int) m r §streaming-bytestring"Print a stream of bytes to STDOUT.¨streaming-bytestring7Print a stream of bytes to STDOUT, ending with a final n.Note: The final nã is not added atomically, and in certain multi-threaded scenarios might not appear where expected.©streaming-bytestringæTry to position the stream at the next non-whitespace input, by skipping leading whitespace. Only a  reasonableØ quantity of whitespace will be skipped before giving up and returning the rest of the stream with any remaining whitespace. Limiting the amount of whitespace consumed is a safety mechanism to avoid looping forever on a never-ending stream of whitespace from an untrusted source. For unconditional dropping of all leading whitespace, use ™ with a suitable predicate.ªstreaming-bytestringTry to read an ³ value from the  , returning m (Compose (Just val :> str)) on success, where val is the value read and strô is the rest of the input stream. If the stream of digits decodes to a value larger than can be represented by an ³, the returned value will be m (Compose (Nothing :> str)), where the content of strÆ is the same as the original stream, but some of the monadic effects may already have taken place, so the original stream MUST NOT be used. To read the remaining data, you MUST use the returned str.This function will not read an  unreasonablyå long stream of leading zero digits when trying to decode a number. When reading the first non-zero digit would require requesting a new chunk and ~32KB of leading zeros have already been read, the conversion is aborted and ²í is returned, along with the overly long run of leading zeros (and any initial explicit plus or minus sign).ªò does not ignore leading whitespace, the value must start immediately at the beginning of the input stream. Use © if you want to skip a  reasonable quantity of leading whitespace.Example6getCompose <$> (readInt . skipSomeWS) stream >>= \case)Just n :> rest -> print n >> gladly restNothing :> rest -> sadly rest£streaming-bytestringnumber of lines per groupstreaming-bytestringstream of bytesé  !123459:;<=>?@ABCDEFGOPS\_`ahjnopqrstuvwxyz{|}~€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ¡¢£¤¥¦§¨©ªé5„ƒ¤ ¢†9>;:@?=<3!4 j‘…‡ˆSžŠ‰Œ‹ABECŽ©š`™h›aœ_˜Ÿ£¡1D€‚•”\—– “’GF¦¥ªys|}§¨wvxr{tqnoupzOP 2~ None é  !123459:;<=>?@ABCDEFGOPS\_`ahjnopqrstuvwxyz{|}~€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ¡¢£¤¥¦§¨©ª None‘Rá  !123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~€‚None‘Ô#  !"º !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘GFWEXYZ[`ax\’ceghijlmqrstuv|“”•–—˜z{™š›œžŸ ¡¢£¤¥¦§¨©¤ª «¬­®§¨¯­°§±²³´µ¶ ·¸¹º»1streaming-bytestring-0.2.3-AoWoBeBGDJqIHQeDYnBUfCStreaming.ByteString.InternalStreaming.ByteStringStreaming.ByteString.Char8 Control.Foldlimpurely System.IOhSetBinaryModeControl.Monad.Trans.ResourceT runResourceTSmappedData.ByteString.Streaming.Char8Data.ByteString.Streaming"Data.ByteString.Streaming.Internal ByteStreamEmptyChunkGo ByteStringunsafeWithForeignPtrbracketByteString consChunkchunkmwrap materialize dematerializedefaultChunkSizesmallChunkSize chunkOverhead packBytes packChars unpackBytes unsafeLast unsafeInit foldrChunks foldlChunkschunkMap chunkMapM chunkMapM_ chunkFold chunkFoldM foldlChunksM foldrChunksM unfoldrNE unfoldMChunks unfoldrChunksrereadcopyfindIndexOrEnd$fMonadResourceByteStream$fMonadCatchByteStream$fMonadThrowByteStream$fMonadBasebByteStream$fMonoidByteStream$fSemigroupByteStream$fShowByteStream$fIsStringByteStream$fMFunctorTYPEByteStream$fMonadTransByteStream$fMonadIOByteStream$fMonadByteStream$fApplicativeByteStream$fFunctorByteStreamconcat distributeeffectsdrainedempty singletonpackunpack fromChunkstoChunks fromStrict toStrict_toStrictfromLazytoLazy_toLazynullnull_testNulldenullnullslength_lengthconscons'snochead_headunconsnextByte unconsChunk nextChunklast_lastappendmapfor interspersefoldrfold_folditeraterepeatcycleunfoldMunfoldrtakedropsplitAt takeWhile dropWhilebreakspan splitWithsplitgroupgroupBy intercalatecount_countfilter hGetContentsNhGetNhGetNonBlockingN hGetContents fromHandlestdinhGethGetNonBlocking writeFilereadFile appendFile getContentshPuttoHandlestdoutinteract zipWithStreamtoStreamingByteStringtoStreamingByteStringWithconcatBuilders toBuildernextCharlinesunlineswordsunwords lineSplitstringputStrputStrLn skipSomeWSreadIntbaseGHC.WordWord8Foreign.ForeignPtr.ImpwithForeignPtrGHC.PtrplusPtr(streaming-0.2.3.1-JXJ35chFBM8JdWx6NDYlQWStreaming.InternalStreamghc-prim GHC.TypesCharStreaming.Preludebytestring-0.10.10.0Data.ByteString.Internal GHC.MaybeNothingIntJust GHC.ClassesnotGHC.IO.Handle.TypesHandle&resourcet-1.2.6-ITGgISAlxDC2yvkDRVeIS5Control.Monad.Trans.Resource Data.EitherLeftGHC.BaseString