h,pL      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefgh ijklmnopqrstuv w x y z { | } ~                                                                                                                                                                                                                                                                                                       02010-2011 Simon Meier, 2010 Jasper van der JeugtBSD3-style (see LICENSE) Simon Meier unstable, privateGHCUnsafe'78=!A builder primitive that always results in sequence of bytes that is no longer than a pre-determined bound.A builder primitive that always results in a sequence of bytes of a pre-determined, fixed size.0The type used for sizes and sizeBounds of sizes.6Type-constructors supporting lifting of type-products.!Contravariant functors as in the  contravariant package.A fmap-like operator for builder primitives, both bounded and fixed size.Builder primitives are contravariant so it's like the normal fmap, but backwards (look at the type). (If it helps to remember, the operator symbol is like ( $) but backwards.)We can use it for example to prepend and/or append fixed values to an primitive.  import Data.ByteString.Builder.Prim as P showEncoding ((\x -> ('\'', (x, '\''))) >$< fixed3) 'x' = "'x'" where fixed3 = P.char7 >*< P.char7 >*< P.char7Note that the rather verbose syntax for composition stems from the requirement to be able to compute the size / size bound at compile time.A pairing/concatenation operator for builder primitives, both bounded and fixed size. For example, ?toLazyByteString (primFixed (char7 >*< char7) ('x','y')) = "xy")We can combine multiple primitives using  multiple times. toLazyByteString (primFixed (char7 >*< char7 >*< char7) ('x',('y','z'))) = "xyz"5The size of the sequences of bytes generated by this . The 1 that always results in the zero-length sequence. Encode a pair by encoding its first component and then its second component. Change a primitives such that it first applies a function to the value to be encoded.Note that primitives are   0http://hackage.haskell.org/package/contravariant". Hence, the following laws hold. contramapF id = id contramapF f . contramapF g = contramapF (g . f)  Convert a  to a .Lift a  to a .>The bound on the size of sequences of bytes generated by this . bytestring  Change a  such that it first applies a function to the value to be encoded. Note that s are   0http://hackage.haskell.org/package/contravariant". Hence, the following laws hold. contramapB id = id contramapB f . contramapB g = contramapB (g . f)The 1 that always results in the zero-length sequence.Encode a pair by encoding its first component and then its second component. Encode an  value using the first  for  values and the second  for  values.Note that the functions , , and  (written below using ) suffice to construct :s for all non-recursive algebraic datatypes. For example, maybeB :: BoundedPrim () -> BoundedPrim a -> BoundedPrim (Maybe a) maybeB nothing just =  (Left ()) Right  eitherB nothing just Conditionally select a . For example, we can implement the ASCII primitive that drops characters with Unicode codepoints above 127 as follows. charASCIIDrop =  (< '\128') ( )  Select an implementation depending on bitness. Throw a compile time error if bitness is neither 32 nor 64.       (c) 2011 Simon MeierBSD3-style (see LICENSE) Simon Meier  experimentalGHCNone'78=U&An encoding table for Base16 encoding.The encoding table for hexadecimal values with lower-case characters; e.g., deadbeef.Encode an octet as 16bit word comprising both encoded nibbles ordered according to the host endianness. Writing these 16bit to memory will write the nibbles in the correct order (i.e. big-endian).(c) 2010 Simon MeierBSD3-style (see LICENSE) Simon Meier  experimentalGHCNone'78= c Encode a  using a  encoding. Encode a  using a  encoding.(c) Lawrence Wu 2021 BSD-stylelawrencejwu@gmail.com Safe-Inferred'78="Bound for bits of  2^k / 5^q for floatsBound for bits of  5^-e2-q / 2^k for floatsBound for bits of  5^-e2-q / 2^k for doublesBound for bits of  2^k / 5^q for doubles$Number of bits in a positive integer*Used for table generation of 2^k / 5^q + 1*Used for table generation of 5^-e2-q / 2^k8Breaks each integer into two Word64s (lowBits, highBits) (c) Don Stewart 2006-2008 (c) Duncan Coutts 2006-2012 BSD-style.dons00@gmail.com, duncan@community.haskell.orgunstable non-portableUnsafe '(78=Fh1 The type of exception raised by P; and on failure by overflow-checked arithmetic operations. bytestring 'Type synonym for the strict flavour of  . &A space-efficient representation of a / vector, supporting many efficient operations.A  8 contains 8-bit bytes, or by using the operations from Data.ByteString.Char87 it can be interpreted as containing 8-bit characters.! bytestring )) foreignPtr offset length represents a   with data backed by a given  foreignPtr, starting at a given offset in bytes and of a specified length.+This pattern is used to emulate the legacy   data constructor, so that pre-existing code generally doesn't need to change to benefit from the simplified !5 constructor and can continue to function unchanged.Note: Matching with this constructor will always be given a 0 offset, as the base will be manipulated by  instead.* bytestring Most operations on a  , need to read from the buffer given by its ForeignPtr Word8' field. But since most operations on  ByteString are (nominally) pure, their implementations cannot see the IO state thread that was used to initialize the contents of that buffer. This means that under some circumstances, these buffer-reads may be executed before the writes used to initialize the buffer are executed, with unpredictable results.*8 exists to help solve this problem. At runtime, a call * x is equivalent to  pure $! x, but the former is more opaque to the simplifier, so that reads from the pointer in its result cannot be executed until the * x call is complete.5The opaque bits evaporate during CorePrep, so using * incurs no direct overhead.+ bytestring  Variant of ? that calls *,, is a variant of findIndex, that returns the length of the string if no element is found, rather than Nothing.1O(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  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 > must point to a null-terminated buffer (as is the case with  "string"# literals in GHC). Use 2 if you know the length of the string statically. An example: (literalFS = unsafePackAddress "literal"#This function is unsafe7. If you modify the buffer pointed to by the original 7 this modification will be reflected in the resulting  ByteString$, breaking referential transparency."Note this also won't work if your  has embedded '\0' characters in the string, as strlen will return too short a length.2 bytestring See 1. This function is similar, but takes an additional length argument rather then computing it with strlen. Therefore embedding '\0' characters is possible.3 bytestring See 1. This function has similar behavior. Prefer this function when the address in known to be an Addr# literal. In that context, there is no need for the sequencing guarantees that 6 provides. On GHC 9.0 and up, this function uses the FinalPtr data constructor for ForeignPtrContents.4 bytestring See 3. This function is similar, but takes an additional length argument rather then computing it with strlen. Therefore embedding '\0' characters is possible.=5The 0 pointer. Used to indicate the empty Bytestring.>O(1)& Build a ByteString from a ForeignPtr.If you do not need the offset parameter then you should be using  or  instead.? bytestring @O(1)+ Deconstruct a ForeignPtr from a ByteStringA bytestring O(1)+ Deconstruct a ForeignPtr from a ByteString8A way of creating ByteStrings outside the IO monad. The Int2 argument gives the final size of the ByteString.Like  but instead of giving the final size of the ByteString, it is just an upper bound. The inner action returns the actual size. Unlike  the ByteString is not reallocated if the final size is less than the estimated size.Create ByteString of size l and use action f to fill its contents.Given a maximum size l and an action f that fills the   starting at the given * and returns the actual utilized length,  l f returns the filled  .Like >, but also returns an additional value created by the action.Given the maximum size needed and a function to make the contents of a ByteString, createFpAndTrim makes the  . The generating function is required to return the actual final size (<= the maximum size), and the resulting byte array is reallocated to this size.createFpAndTrim is the main mechanism for creating custom, efficient ByteString functions, using Haskell or C functions to fill the space.B8A way of creating ByteStrings outside the IO monad. The Int2 argument gives the final size of the ByteString.CLike B but instead of giving the final size of the ByteString, it is just an upper bound. The inner action returns the actual size. Unlike H the ByteString is not reallocated if the final size is less than the estimated size.D bytestring ECreate ByteString of size l and use action f to fill its contents.FGiven a maximum size l and an action f that fills the   starting at the given * and returns the actual utilized length, G l f returns the filled  .G bytestring Like F>, but also returns an additional value created by the action.HGiven the maximum size needed and a function to make the contents of a ByteString, createAndTrim makes the  . The generating function is required to return the actual final size (<= the maximum size), and the resulting byte array is reallocated to this size.createAndTrim is the main mechanism for creating custom, efficient ByteString functions, using Haskell or C functions to fill the space.J Wrapper of # with faster implementation for GHC still neededKO(1) The empty  Repeats the given ByteString n times. Polymorphic wrapper to make sure any generated specializations are reasonably small.%Repeats the given ByteString n times.LConversion between  and . Should compile to a no-op.MUnsafe conversion between  and . This is a no-op and silently truncates to 8 bits Chars > '255'. It is provided as convenience for ByteString construction.NSelects words corresponding to white-space characters in the Latin-1 rangeO3Selects white-space characters in the Latin-1 rangeP Raises a 0, with a message using the given function name.Q%Add two non-negative numbers. Calls P on overflow.R,Multiplies two non-negative numbers. Calls P on overflow.Attempts to convert an  value to an  , returning ) if doing so would result in an overflow.S0This "function" has a superficial similarity to  but it is in fact a malevolent agent of chaos. It unpicks the seams of reality (and the  monad) so that the normal rules no longer apply. It lulls you into thinking it is reasonable, but when you are not looking it stabs you in the back and aliases all of your mutable buffers. The carcass of many a seasoned Haskell programmer lie strewn at its feet.!Witness the trail of destruction: https://github.com/haskell/bytestring/commit/71c4b438c675aa360c79d79acc9a491e7bbc26e7 https://github.com/haskell/bytestring/commit/210c656390ae617d9ee3b8bcff5c88dd17cef8da https://github.com/haskell/aeson/commit/720b857e2e0acf2edc4f5512f2b217a89449a89d ,https://ghc.haskell.org/trac/ghc/ticket/3486 ,https://ghc.haskell.org/trac/ghc/ticket/3487 ,https://ghc.haskell.org/trac/ghc/ticket/7270 1https://gitlab.haskell.org/ghc/ghc/-/issues/222047Do not talk about "safe"! You do not know what is safe!Yield not to its blasphemous call! Flee traveller! Flee or you will be corrupted and devoured!Vdeprecated since bytestring-0.11.5.0Wdeprecated since bytestring-0.11.5.0 bytestring Beware:  truncates multi-byte characters to octets. e.g. "````a`a`" becomes 6knh~Qn bytestring >OffsetLength?Length@(ptr, offset, length)A (ptr, length)SM#X&%$'"(QREHIFG*K,>?ONJTUWV+=P-.56@A9;:<78BCD12/043L !)(c) Don Stewart 2006-2008 (c) Duncan Coutts 2006-2012 BSD-style.dons00@gmail.com, duncan@community.haskell.orgunstable non-portableNone'78=G=SM#X&%$'"(QREHIFG*K,>?ONJTUWV+=P-.56@A9;:<78BCD12/043L !)> !)),-5/.6079;8:<1234KEFGHIBCDJ+>@?A=*PQR(XTUWV'&%$#"LMNOS(c) Don Stewart 2006-2008 (c) Duncan Coutts 2006-2011 BSD-style.dons00@gmail.com, duncan@community.haskell.orgunstable non-portableUnsafe'78=OY bytestring %Type synonym for the lazy flavour of Z.Z&A space-efficient representation of a / vector, supporting many efficient operations.A Y8 contains 8-bit bytes, or by using the operations from Data.ByteString.Lazy.Char87 it can be interpreted as containing 8-bit characters.a5The data type invariant: Every ByteString is either [ or consists of non-null  $s. All functions must preserve this.bLazily checks that the given Z satisfies the data type's "no empty chunks" invariant, raising an exception in place of the first chunk that does not satisfy the invariant.cSmart constructor for \%. Guarantees the data type invariant.dConsume the chunks of a lazy ByteString with a natural right fold.eConsume the chunks of a lazy ByteString with a strict, tail-recursive, accumulating left fold.fThe chunk size used for I/O. Currently set to 32k, less the memory management overheadgThe recommended chunk size. Currently set to 4k, less the memory management overheadhThe memory management overhead. Currently this is tuned for GHC only.%Repeats the given ByteString n times.iO(1) Convert a   into a Y.jO(n) Convert a Y into a  .Note that this is an  expensive" operation that forces the whole Y into memory and then copies all the data. If possible, try to avoid converting back and forth between strict and lazy bytestrings.lBeware:  truncates multi-byte characters to octets. e.g. "````a`a`" becomes 6knh~Qnm bytestring bchfedia]^gj_`Z\[YZ[\Ycdeabfgh]^_`ij /(c) Duncan Coutts 2012-2013, Julian Ospald 2022 BSD-stylehasufell@posteo.destableghc onlyUnsafe '78=vA compact representation of a  vector.&It has a lower memory overhead than a   and does not contribute to heap fragmentation. It can be converted to or from a   (at the cost of copying the string data). It supports very few other operations.w bytestring x bytestring y Prior to bytestring-0.12 y was a genuine constructor of v, but now it is a bundled pattern synonym, provided as a compatibility shim.zO(1) . The empty v.{O(1) The length of a v.|O(1) Test whether a v is empty.}O(1) v- index (subscript) operator, starting from 0.+This is a partial function, consider using ~ instead.~ bytestring O(1) v& index, starting from 0, that returns  if: 0 <= n < length bs bytestring O(1) v& index, starting from 0, that returns  if: 0 <= n < length bsO(1)) Unsafe indexing without bounds checking.Given the maximum size needed and a function to make the contents of a ShortByteString, createAndTrim makes the v. The generating function is required to return the actual final size (<= the maximum size) and the result value. The resulting byte array is realloced to this size.0Like createAndTrim, but with two buffers at onceO(n) . Convert a   into a v.7This makes a copy, so does not retain the input string.O(n) . Convert a v into a  . bytestring O(1) Convert a  into a vO(n). Convert a list into a vO(n) . Convert a v into a list. bytestring O(n) Append a byte to the end of a v"Note: copies the entire byte array bytestring O(n)  is analogous to (:) for lists."Note: copies the entire byte array bytestring O(1) Extract the last element of a ShortByteString, which must be finite and non-empty. An exception will be thrown in the case of an empty ShortByteString.+This is a partial function, consider using  instead. bytestring O(n) Extract the elements after the head of a ShortByteString, which must be non-empty. An exception will be thrown in the case of an empty ShortByteString.+This is a partial function, consider using  instead."Note: copies the entire byte array bytestring O(n) Extract the  and ! of a ShortByteString, returning  if it is empty. bytestring O(1) Extract the first element of a ShortByteString, which must be non-empty. An exception will be thrown in the case of an empty ShortByteString.+This is a partial function, consider using  instead. bytestring O(n) Return all the elements of a v except the last one. An exception will be thrown in the case of an empty ShortByteString.+This is a partial function, consider using  instead."Note: copies the entire byte array bytestring O(n) Extract the  and ! of a ShortByteString, returning  if it is empty. bytestring O(n)  f xs- is the ShortByteString obtained by applying f to each element of xs. bytestring O(n)  xs% efficiently returns the elements of xs in reverse order. bytestring O(n) The  function takes a v and a list of vs and concatenates the list after interspersing the first argument between each element of the list. bytestring , applied to a binary operator, a starting value (typically the left-identity of the operator), and a ShortByteString, reduces the ShortByteString using the binary operator, from left to right. bytestring  is like  , but strict in the accumulator. bytestring , applied to a binary operator, a starting value (typically the right-identity of the operator), and a ShortByteString, reduces the ShortByteString using the binary operator, from right to left. bytestring  is like  , but strict in the accumulator. bytestring  is a variant of  that has no starting value argument, and thus must be applied to non-empty vs. An exception will be thrown in the case of an empty ShortByteString. bytestring  is like , but strict in the accumulator. An exception will be thrown in the case of an empty ShortByteString. bytestring  is a variant of  that has no starting value argument, and thus must be applied to non-empty vs An exception will be thrown in the case of an empty ShortByteString. bytestring  is a variant of $, but is strict in the accumulator. bytestring O(n) Applied to a predicate and a v, $ determines if all elements of the v satisfy the predicate. bytestring O(n) Applied to a predicate and a v, # determines if any element of the v satisfies the predicate. bytestring O(n)  n, applied to a ShortByteString xs, returns the prefix of xs of length n, or xs itself if n > { xs."Note: copies the entire byte array bytestring  Similar to !", returns the longest (possibly empty) prefix of elements satisfying the predicate. bytestring O(n)  n xs is equivalent to  ({ xs - n) xs . Takes n! elements from end of bytestring.takeEnd 3 "abcdefg""efg"takeEnd 0 "abcdefg"""takeEnd 4 "abc""abc" bytestring Returns the longest (possibly empty) suffix of elements satisfying the predicate. p is equivalent to  .  p . . bytestring O(n)  n xs returns the suffix of xs after the first n elements, or z if n > { xs."Note: copies the entire byte array bytestring O(n)  n xs is equivalent to  ({ xs - n) xs . Drops n! elements from end of bytestring.dropEnd 3 "abcdefg""abcd"dropEnd 0 "abcdefg" "abcdefg"dropEnd 4 "abc""" bytestring  Similar to !#, drops the longest (possibly empty) prefix of elements satisfying the predicate and returns the remainder."Note: copies the entire byte array bytestring  Similar to !$, drops the longest (possibly empty) suffix of elements satisfying the predicate and returns the remainder. p is equivalent to  .  p . . bytestring >Returns the longest (possibly empty) suffix of elements which do not8 satisfy the predicate and the remainder of the string. p is equivalent to  (not . p) and to ( (not . p) &&&  (not . p)). bytestring  Similar to !%, returns the longest (possibly empty) prefix of elements which do not8 satisfy the predicate and the remainder of the string. p is equivalent to  (not . p) and to ( (not . p) &&&  (not . p)). bytestring  Similar to !&, returns the longest (possibly empty) prefix of elements satisfying the predicate and the remainder of the string. p is equivalent to  (not . p) and to ( p &&&  p). bytestring Returns the longest (possibly empty) suffix of elements satisfying the predicate and the remainder of the string. p is equivalent to  (not . p) and to ( p &&&  p).We have 0spanEnd (not . isSpace) "x y z" == ("x y ", "z")and spanEnd (not . isSpace) sbs == let (x, y) = span (not . isSpace) (reverse sbs) in (reverse y, reverse x) bytestring O(n)  n sbs is equivalent to ( n sbs,  n sbs).Note: copies the substrings bytestring O(n) Break a v into pieces separated by the byte argument, consuming the delimiter. I.e. split 10 "a\nb\nd\ne" == ["a","b","d","e"] -- fromEnum '\n' == 10 split 97 "aXaXaXa" == ["","X","X","X",""] -- fromEnum 'a' == 97 split 120 "x" == ["",""] -- fromEnum 'x' == 120 split undefined "" == [] -- and not [""]and 9intercalate [c] . split c == id split == splitWith . (==)Note: copies the substrings bytestring O(n) Splits a v 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 (==97) "aabbaca" == ["","","bb","c",""] -- fromEnum 'a' == 97 splitWith undefined "" == [] -- and not [""] bytestring O(n) The 1 function takes two ShortByteStrings and returns  the remainder of the second iff the first is its suffix, and otherwise . bytestring O(n) The 1 function takes two ShortByteStrings and returns  the remainder of the second iff the first is its prefix, and otherwise . bytestring O(n)  n x is a ShortByteString of length n with x2 the value of every element. The following holds: .replicate w c = unfoldr w (\u -> Just (u,u)) c bytestring O(n), where n# is the length of the result. The 0 function is analogous to the List 'unfoldr'.  builds a ShortByteString from a seed value. The function takes the element and returns 9 if it is done producing the ShortByteString or returns  (a,b), in which case, a& is the next byte in the string, and b* is the seed value for further production.=This function is not efficient/safe. It will build a list of [Word8]) and run the generator until it returns 7, otherwise recurse infinitely, then finally create a v./If you know the maximum length, consider using . Examples:  unfoldr (\x -> if x <= 5 then Just (x, x + 1) else Nothing) 0 == pack [0, 1, 2, 3, 4, 5] bytestring O(n) Like ,  builds a ShortByteString from a seed value. However, the length of the result is limited by the first argument to (. This function is more efficient than 1 when the maximum length of the result is known.The following equation relates  and : ,fst (unfoldrN n f s) == take n (unfoldr f s) bytestring 3Check whether one string is a substring of another. bytestring O(n) The 1 function takes two ShortByteStrings and returns * iff the first is a prefix of the second. bytestring O(n) The 1 function takes two ShortByteStrings and returns * iff the first is a suffix of the second.The following holds: 2isSuffixOf x y == reverse x `isPrefixOf` reverse y 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: 0break (== c) l == breakSubstring (singleton c) l7For 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 occurrence of a string: snd (breakSubstring x y)1To take the parts of a string before a delimiter: fst (breakSubstring x y)Note that calling `breakSubstring x` does some preprocessing work, so you should avoid unnecessarily duplicating breakSubstring calls with the same pattern. bytestring O(n)  is the v membership predicate. bytestring O(n) , applied to a predicate and a ShortByteString, returns a ShortByteString containing those characters that satisfy the predicate. bytestring O(n) The  function takes a predicate and a ShortByteString, and returns the first element in matching the predicate, or  if there is no such element. find f p = case findIndex f p of Just n -> Just (p ! n) ; _ -> Nothing bytestring O(n) The  function takes a predicate a ShortByteString and returns the pair of ShortByteStrings with elements which do and do not satisfy the predicate, respectively; i.e., 6partition p bs == (filter p sbs, filter (not . p) sbs) bytestring O(n) The ? function returns the index of the first element in the given v* which is equal to the query element, or  if there is no such element. bytestring O(n) The  function extends , by returning the indices of all elements equal to the query element, in ascending order. bytestring count returns the number of times its argument appears in the ShortByteString bytestring O(n) The " function takes a predicate and a v and returns the index of the first element in the ShortByteString satisfying the predicate. bytestring O(n) The  function extends , by returning the indices of all elements satisfying the predicate, in ascending order. bytestring O(n). Construct a new ShortByteString from a CString. The resulting ShortByteString' is an immutable copy of the original CString4, and is managed on the Haskell heap. The original CString must be null terminated. bytestring O(n). Construct a new ShortByteString from a  CStringLen. The resulting ShortByteString& is an immutable copy of the original  CStringLen. The ShortByteString is a normal Haskell value and will be managed on the Haskell heap. bytestring O(n) construction. Use a ShortByteString. with a function requiring a null-terminated CString. The CString is a copy and will be freed automatically; it must not be stored or used after the subcomputation finishes. bytestring O(n) construction. Use a ShortByteString with a function requiring a  . As for , this function makes a copy of the original ShortByteString. It must not be stored or used after the subcomputation finishes.5Beware that this function does not add a terminating NUL byte at the end of . If you need to construct a pointer to a null-terminated sequence, use 0 (and measure length independently if desired). bytestring O(n) Check whether a v represents valid UTF-8.Beware:  truncates multi-byte characters to octets. e.g. "````a`a`" becomes 6knh~Qn bytestring Lexicographic order.String to search forString to search in+Head and tail of string broken at substring source dataoffset into source destinationnumber of bytes to copy source datanumber of bytes to copyarray 1offset for array 1array 2offset for array 2length to compare like memcmpz}~{|vywxvywxyz|{}~ /(c) Duncan Coutts 2012-2013, Julian Ospald 2022 BSD-stylehasufell@posteo.destableghc only Trustworthy'78=z}~{|vywxvwyxyz|{}~(c) Don Stewart 2006-2008 (c) Duncan Coutts 2006-2011 BSD-style.dons00@gmail.com, duncan@community.haskell.org provisional non-portableUnsafe'78= A variety of  for non-empty ByteStrings.  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. A variety of  for non-empty ByteStrings. . omits the check for the empty case. As with , the programmer must provide a separate proof that the ByteString is non-empty. A variety of  for non-empty ByteStrings. . omits the check for the empty case. As with , the programmer must provide a separate proof that the ByteString is non-empty. A variety of  for non-empty ByteStrings. . omits the check for the empty case. As with , the programmer must provide a separate proof that the ByteString is non-empty.Unsafe  : index (subscript) operator, starting from 0, returning a  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. A variety of  which omits the checks on n so there is an obligation on the programmer to provide a proof that  0 <= n <=  xs. A variety of  which omits the checks on n so there is an obligation on the programmer to provide a proof that  0 <= n <=  xs.O(1) ) provides constant-time construction of  s, which is ideal for string literals. It packs a sequence of bytes into a  , given a raw . 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 underlying  is later modified, this change will be reflected in the resulting  %, breaking referential transparency.%If in doubt, don't use this function.O(1) Construct a   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  ./Explicitly run the finaliser associated with a  . References to this value after finalisation may generate invalid memory references.This function is unsafe, as there may be other  s referring to the same underlying pages. If you use this, you need to have a proof of some kind that all  s ever generated from the underlying byte array are no longer live.O(n) Build a   from a . 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  is later modified, this change will be reflected in the resulting  %, breaking referential transparency.O(1) Build a   from a . This value will have no finalizer associated with it, and will not be garbage collected by Haskell. This operation has O(1)6 complexity as we already know the final size, so no  strlen(3) is required.This function is unsafe. If the original  is later modified, this change will be reflected in the resulting  %, breaking referential transparency.O(n) Build a   from a malloced . This value will have a free(3) finalizer associated to it.This function is unsafe. If the original  is later modified, this change will be reflected in the resulting  %, 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  not allocated with '(.O(1) Build a   from a malloced . This value will have a free(3) finalizer associated to it.This function is unsafe. If the original  is later modified, this change will be reflected in the resulting  %, 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  not allocated with '(.O(1) construction Use a   with a function requiring a .6This function does zero copying, and merely unwraps a   to appear as a . It is unsafe in two ways: After calling this function the 6 shares the underlying byte buffer with the original  . Thus modifying the >, either in C, or using poke, will cause the contents of the  6 to change, breaking referential transparency. Other  1s created by sharing (such as those produced via  or 1) will also reflect these changes. Modifying the ; will break referential transparency. To avoid this, use )%, which makes a copy of the original  .s are often passed to functions that require them to be null-terminated. If the original  + wasn't null terminated, neither will the  be. It is the programmers responsibility to guarantee that the  . is indeed null terminated. If in doubt, use ).The memory may freed at any point after the subcomputation terminates, so the pointer to the storage must *not* be used after this.O(1) construction Use a   with a function requiring a .6This function does zero copying, and merely unwraps a   to appear as a . It is unsafe: After calling this function the 6 shares the underlying byte buffer with the original  . Thus modifying the >, either in C, or using poke, will cause the contents of the  6 to change, breaking referential transparency. Other  1s created by sharing (such as those produced via  or 1) will also reflect these changes. Modifying the ; will break referential transparency. To avoid this, use *%, which makes a copy of the original  .If + is given, it will pass (,-, 0).11(c) The University of Glasgow 2001, (c) David Roundy 2003-2005, (c) Simon Marlow 2005, (c) Bjorn Bringert 2006, (c) Don Stewart 2005-2008, (c) Duncan Coutts 2006-2013 BSD-style.dons00@gmail.com, duncan@community.haskell.orgstableportable Trustworthy'78=OO(1) Convert a  into a  ;A static blob of all possible bytes (0x00 to 0xff) in orderO(n) Convert a [] into a  .8For applications with large numbers of string literals, 5 can be a bottleneck. In such cases, consider using 1 (GHC only).O(n) Converts a   to a []. bytestring  Convert a  to a  .The  type is expected to use the file system encoding as reported by ./. This encoding allows for round-tripping of arbitrary data on platforms that allow arbitrary bytes in their paths. This conversion function does the same thing that 01 would do when decoding the .This function is in  because the file system encoding can be changed. If the encoding can be assumed to be constant in your use case, you may invoke this function via unsafePerformIO. bytestring  Convert a   to a .;This function uses the file system encoding, and resulting s can be safely used with standard IO functions and will reference the correct path in the presence of arbitrary non-UTF-8 encoded paths.This function is in  because the file system encoding can be changed. If the encoding can be assumed to be constant in your use case, you may invoke this function via unsafePerformIO.O(1)$ Test whether a ByteString is empty.O(1) * returns the length of a ByteString as an .O(n)  is analogous to (:) for lists, but of different complexity, as it requires making a copy.O(n) Append a byte to the end of a  O(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.+This is a partial function, consider using  instead.O(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.+This is a partial function, consider using  instead.O(1) Extract the  and  of a ByteString, returning  if it is empty.O(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.+This is a partial function, consider using  instead.O(1) Returns all the elements of a   except the last one. An exception will be thrown in the case of an empty ByteString.+This is a partial function, consider using  instead.O(1) Extract the  and  of a ByteString, returning  if it is empty.O(n) Append two ByteStringsO(n)  f xs( is the ByteString obtained by applying f to each element of xs.O(n)  xs% efficiently returns the elements of xs in reverse order.O(n) The  function takes a  and a  ; and `intersperses' that byte between the elements of the  9. It is analogous to the intersperse function on Lists.The 2 function transposes the rows and columns of its   argument., 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. is like  , but strict in the accumulator., 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. is like  , but strict in the accumulator. is a variant of  that has no starting value argument, and thus must be applied to non-empty  s. An exception will be thrown in the case of an empty ByteString. is like , but strict in the accumulator. An exception will be thrown in the case of an empty ByteString. is a variant of  that has no starting value argument, and thus must be applied to non-empty  s An exception will be thrown in the case of an empty ByteString. is a variant of $, but is strict in the accumulator.O(n)# Concatenate a list of ByteStrings.Map a function over a   and concatenate the resultsO(n)* Applied to a predicate and a ByteString, # determines if any element of the   satisfies the predicate.Is any element of   equal to c?O(n) Applied to a predicate and a  , $ determines if all elements of the   satisfy the predicate.O(n) " returns the maximum value from a   An exception will be thrown in the case of an empty ByteString.O(n) " returns the minimum value from a   An exception will be thrown in the case of an empty ByteString.The ( function behaves like a combination of  and ; 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.The ( function behaves like a combination of  and ; 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. is similar to , 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  Just (u,u)) c)O(n), where n# is the length of the result. The 0 function is analogous to the List 'unfoldr'.  builds a ByteString from a seed value. The function takes the element and returns 4 if it is done producing the ByteString or returns  (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]O(n) Like ,  builds a ByteString from a seed value. However, the length of the result is limited by the first argument to (. This function is more efficient than 1 when the maximum length of the result is known.The following equation relates  and : ,fst (unfoldrN n f s) == take n (unfoldr f s)O(1)  n, applied to a ByteString xs, returns the prefix of xs of length n, or xs itself if n >  xs. bytestring O(1)  n xs is equivalent to  ( xs - n) xs . Takes n! elements from end of bytestring.takeEnd 3 "abcdefg""efg"takeEnd 0 "abcdefg"""takeEnd 4 "abc""abc"O(1)  n xs returns the suffix of xs after the first n elements, or K if n >  xs. bytestring O(1)  n xs is equivalent to  ( xs - n) xs . Drops n! elements from end of bytestring.dropEnd 3 "abcdefg""abcd"dropEnd 0 "abcdefg" "abcdefg"dropEnd 4 "abc"""O(1)  n xs is equivalent to ( n xs,  n xs). Similar to !", returns the longest (possibly empty) prefix of elements satisfying the predicate. bytestring Returns the longest (possibly empty) suffix of elements satisfying the predicate. p is equivalent to  .  p . . Similar to !#, drops the longest (possibly empty) prefix of elements satisfying the predicate and returns the remainder. bytestring  Similar to !$, drops the longest (possibly empty) suffix of elements satisfying the predicate and returns the remainder. p is equivalent to  .  p . . Similar to !%, returns the longest (possibly empty) prefix of elements which do not8 satisfy the predicate and the remainder of the string. p is equivalent to  (not . p) and to ( (not . p) &&&  (not . p)).Under GHC, a rewrite rule will transform break (==) into a call to the specialised breakByte: 6break ((==) x) = breakByte x break (==x) = breakByte x breaks its ByteString argument at the first occurrence of the specified byte. It is more efficient than  as it is implemented with  memchr(3). I.e. break (==99) "abcd" == breakByte 99 "abcd" -- fromEnum 'c' == 99>Returns the longest (possibly empty) suffix of elements which do not8 satisfy the predicate and the remainder of the string. p is equivalent to  (not . p) and to ( (not . p) &&&  (not . p)). Similar to !&, returns the longest (possibly empty) prefix of elements satisfying the predicate and the remainder of the string. p is equivalent to  (not . p) and to ( p &&&  p). breaks its ByteString argument at the first occurrence of a byte other than its argument. It is more efficient than 'span (==)' ?span (==99) "abcd" == spanByte 99 "abcd" -- fromEnum 'c' == 99Returns the longest (possibly empty) suffix of elements satisfying the predicate and the remainder of the string. p is equivalent to  (not . p) and to ( p &&&  p).We have 0spanEnd (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)O(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 (==97) "aabbaca" == ["","","bb","c",""] -- fromEnum 'a' == 97 splitWith undefined "" == [] -- and not [""]O(n) Break a   into pieces separated by the byte argument, consuming the delimiter. I.e. split 10 "a\nb\nd\ne" == ["a","b","d","e"] -- fromEnum '\n' == 10 split 97 "aXaXaXa" == ["","X","X","X",""] -- fromEnum 'a' == 97 split 120 "x" == ["",""] -- fromEnum 'x' == 120 split undefined "" == [] -- and not [""]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.The  function takes a ByteString and returns a list of ByteStrings such that the concatenation of the result is equal to the argument. Moreover, each string 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 , which allows the programmer to supply their own equality test. It is about 40% faster than  groupBy (==)The + function is the non-overloaded version of .O(n) The  function takes a   and a list of  s and concatenates the list after interspersing the first argument between each element of the list.O(1)  - index (subscript) operator, starting from 0.+This is a partial function, consider using  instead. bytestring O(1)  & index, starting from 0, that returns  if: 0 <= n < length bs bytestring O(1)  & index, starting from 0, that returns  if: 0 <= n < length bsO(n) The ? function returns the index of the first element in the given  * which is equal to the query element, or  if there is no such element. This implementation uses memchr(3).O(n) The > function returns the last index of the element in the given  * which is equal to the query element, or 3 if there is no such element. The following holds: elemIndexEnd c xs = case elemIndex c (reverse xs) of Nothing -> Nothing Just i -> Just (length xs - 1 - i)O(n) The  function extends , by returning the indices of all elements equal to the query element, in ascending order. This implementation uses memchr(3).count returns the number of times its argument appears in the ByteString count = length . elemIndicesBut more efficiently than using length on the intermediate list.O(n) The " function takes a predicate and a   and returns the index of the first element in the ByteString satisfying the predicate. bytestring O(n) The " function takes a predicate and a   and returns the index of the last element in the ByteString satisfying the predicate.O(n) The  function extends , by returning the indices of all elements satisfying the predicate, in ascending order.O(n)  is the   membership predicate.O(n)  is the inverse of O(n) , applied to a predicate and a ByteString, returns a ByteString containing those characters that satisfy the predicate.O(n) The  function takes a predicate and a ByteString, and returns the first element in matching the predicate, or  if there is no such element. find f p = case findIndex f p of Just n -> Just (p ! n) ; _ -> NothingO(n) The  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., 4partition p bs == (filter p xs, filter (not . p) xs)O(n) The , function takes two ByteStrings and returns ) if the first is a prefix of the second. bytestring O(n) The , function takes two ByteStrings and returns  the remainder of the second iff the first is its prefix, and otherwise .O(n) The , function takes two ByteStrings and returns * iff the first is a suffix of the second.The following holds: 2isSuffixOf x y == reverse x `isPrefixOf` reverse yHowever, the real implementation uses memcmp to compare the end of the string only, with no reverse required..O(n) The , function takes two ByteStrings and returns  the remainder of the second iff the first is its suffix, and otherwise .3Check whether one string is a substring of another. bytestring O(n) Check whether a   represents valid UTF-8.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: 0break (== c) l == breakSubstring (singleton c) l7For 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 occurrence of a string: snd (breakSubstring x y)1To take the parts of a string before a delimiter: fst (breakSubstring x y)Note that calling `breakSubstring x` does some preprocessing work, so you should avoid unnecessarily duplicating breakSubstring calls with the same pattern.O(n)  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  operations. generalises  by zipping with the function given as the first argument, instead of a tupling function. For example,  (+) is applied to two ByteStrings to produce the list of corresponding sums. bytestring A specialised version of  for the common case of a simultaneous map over two ByteStrings, to build a 3rd.O(n)  transforms a list of pairs of bytes into a pair of ByteStrings. Note that this performs two  operations.O(n)+ Returns all initial segments of the given  , shortest first. bytestring O(n)+ Returns all initial segments of the given  , shortest first.O(n)) Returns all final segments of the given  , longest first. bytestring O(n)) Returns all final segments of the given  , longest first.O(n)4 Sort a ByteString efficiently, using counting sort.O(n) construction Use a  ByteString. with a function requiring a null-terminated CString. The CString is a copy and will be freed automatically; it must not be stored or used after the subcomputation finishes.O(n) construction Use a  ByteString with a function requiring a  . As for , this function makes a copy of the original  ByteString. It must not be stored or used after the subcomputation finishes.?Beware that this function is not required to add a terminating NUL byte at the end of the  it provides. If you need to construct a pointer to a null-terminated sequence, use 0 (and measure length independently if desired).O(n). Construct a new  ByteString from a CString. The resulting  ByteString' is an immutable copy of the original CString4, and is managed on the Haskell heap. The original CString must be null terminated.O(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.O(n) Make a copy of the   with its own storage. This is mainly useful to allow the rest of the data pointed to by the   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.Read a line from stdin.Read a line from a handle Outputs a   to the specified . Similar to  except that it will never block. Instead it returns any tail that did not get written. This tail may be K in the case that the whole string was written, or the whole original string if nothing was written. Partial writes are also possible.Note: on Windows and with Haskell implementation other than GHC, this function does not work correctly; it behaves identically to .A synonym for , for compatibilityWrite a ByteString to .Read a   directly from the specified . This is far more efficient than reading the characters into a  and then using . 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 K if EOF has been reached. is implemented in terms of .If the handle is a pipe or socket, and the writing end is closed, # will behave as if EOF was reached.hGetNonBlocking is similar to , 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,  returns K.Note: on Windows and with Haskell implementation other than GHC, this function does not work correctly; it behaves identically to .Like , except that a shorter   may be returned if there are not enough bytes immediately available to satisfy the whole request.  only blocks if there is no data available, and EOF has not yet been reached.0Read a handle's entire contents strictly into a  .This function reads chunks at a time, increasing the chunk size on each read. The final string is then reallocated to the appropriate size. For files > half of available memory, this may lead to memory exhaustion. Consider using  in this case.The Handle is closed once the contents have been read, or if an exception is thrown.getContents. Read stdin strictly. Equivalent to hGetContents stdin The - is closed after the contents have been read./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.$Read an entire file strictly into a  .Write a   to a file. Append a   to a file.)accumulator -> element -> new accumulatorstarting value of accumulatorinput of length noutput of length n+1)element -> accumulator -> new accumulatorstarting value of accumulatorinput of length noutput of length n+1String to search forString to search in+Head and tail of string broken at substringfirst read sizeinitial buffer size incrementKij  Kij2None'78= Intermediate result from scanning a chunk, final output is obtained via convert$ after all the chunks are processed. reads an  from the beginning of the  . If there is no - at the beginning of the string, it returns  , otherwise it just returns the # read, and the rest of the string. does not ignore leading whitespace, the value must start immediately at the beginning of the input string.Examples6readInteger "-000111222333444555666777888999 all done"/Just (-111222333444555666777888999," all done")8readInteger "+1: readInteger also accepts a leading '+'"4Just (1, ": readInteger also accepts a leading '+'")"readInteger "not a decimal number"Nothing reads a # number from the beginning of the  . If there is no 4 number at the beginning of the string, it returns , otherwise it just returns the number read, and the rest of the string. does not ignore leading whitespace, the value must start with a decimal digit immediately at the beginning of the input string. Leading + signs are not accepted.Examples5readNatural "000111222333444555666777888999 all done".Just (111222333444555666777888999," all done");readNatural "+000111222333444555666777888999 explicit sign"Nothing"readNatural "not a decimal number"NothingLargest decimal digit count that never overflows the accumulator The base 10 logarithm of 2 is ~0.30103, therefore 2^n has at least 1 + floor (0.3 n) decimal digits. Therefore  floor (0.3 n)0, digits cannot overflow the upper bound of an n-bit word.10-power base for little-endian sequence of ~Word-sized "digits" Input chunk Chunk lengthaccumulated elementpartial digit countaccumulated MSB elements3None'78= Intermediate result from scanning a chunk, final output is converted to the requested type once all chunks are processed.Try to read a signed  value from the   , returning Just (val, str) on success, where val is the value read and str is the rest of the input string. If the sequence of digits decodes to a value larger than can be represented by an , the returned value will be . does not ignore leading whitespace, the value must start immediately at the beginning of the input string.ExamplesreadInt "-1729 sum of cubes"Just (-1729," sum of cubes")0readInt "+1: readInt also accepts a leading '+'"0Just (1, ": readInt also accepts a leading '+'")readInt "not a decimal number"Nothing1readInt "12345678901234567890 overflows maxBound"Nothing3readInt "-12345678901234567890 underflows minBound"Nothing A variant of  specialised to . A variant of  specialised to . A variant of  specialised to .Try to read a  value from the   , returning Just (val, str) on success, where val is the value read and str is the rest of the input string. If the sequence of digits decodes to a value larger than can be represented by a , the returned value will be . does not ignore leading whitespace, the value must start with a decimal digit immediately at the beginning of the input string. Leading + signs are not accepted.ExamplesreadWord "1729 sum of cubes"Just (1729," sum of cubes")%readWord "+1729 has an explicit sign"NothingreadWord "not a decimal number"Nothing2readWord "98765432109876543210 overflows maxBound"Nothing A variant of  specialised to . A variant of  specialised to . A variant of  specialised to . A variant of  specialised to . A variant of  specialised to .Polymorphic Int*/Word* readerProcess as many digits as we can, returning the additional number of digits found and the updated accumulator. If the accumulator would overflow return .abs(maxBound/minBound)  10 Input stringFirst digit valuemaximum non-overflow value  10maximum non-overflow vavlue  10 Input buffer Input length#Accumulated value of leading digits>Bytes read and final accumulator, or else overflow indication ?(c) Don Stewart 2006 (c) Duncan Coutts 2006-2011 BSD-style.dons00@gmail.com, duncan@community.haskell.orgstableportable Trustworthy'78=^O(1) The empty ZO(1) Convert a  into a ZO(n) Convert a '[Word8]' into a Z.O(n) Converts a Z to a '[Word8]'.O(c) Convert a list of   into a YO(c) Convert a Y into a list of  O(1)$ Test whether a ByteString is empty.O(c) * returns the length of a ByteString as an O(1)  is analogous to !4 for lists.O(1) Unlike ,  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 ByteStrings.O(n/c) Append a byte to the end of a ZO(1) Extract the first element of a ByteString, which must be non-empty.+This is a partial function, consider using  instead.O(1) Extract the  and  of a ByteString, returning  if it is empty.O(1) Extract the elements after the head of a ByteString, which must be non-empty.+This is a partial function, consider using  instead.O(n/c) Extract the last element of a ByteString, which must be finite and non-empty.+This is a partial function, consider using  instead.O(n/c) Returns all the elements of a Z except the last one.+This is a partial function, consider using  instead.O(n/c) Extract the  and  of a ByteString, returning  if it is empty.It is no faster than using  and O(n/c) Append two ByteStringsO(n)  f xs( is the ByteString obtained by applying f to each element of xs.O(n)  xs returns the elements of xs in reverse order.The  function takes a  and a Z; and `intersperses' that byte between the elements of the Z8. It is analogous to the intersperse function on Lists.The 2 function transposes the rows and columns of its Z argument., 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. is like  , but strict in the accumulator., 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. bytestring  is like  , but strict in the accumulator. is a variant of  that has no starting value argument, and thus must be applied to non-empty Zs. is like  , but strict in the accumulator. is a variant of  that has no starting value argument, and thus must be applied to non-empty Zs bytestring  is like  , but strict in the accumulator.O(n)# Concatenate a list of ByteStrings.Map a function over a Z and concatenate the resultsO(n)* Applied to a predicate and a ByteString, # determines if any element of the Z satisfies the predicate.O(n) Applied to a predicate and a Z, $ determines if all elements of the Z satisfy the predicate.O(n) " returns the maximum value from a ZO(n) " returns the minimum value from a Z bytestring O(c)  compares the length of a Z to an The ( function behaves like a combination of  and ; 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.The ( function behaves like a combination of  and ; 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. is similar to , 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   xs. bytestring O(c)  n xs is equivalent to  ( xs - n) xs . Takes n! elements from end of bytestring.takeEnd 3 "abcdefg""efg"takeEnd 0 "abcdefg"""takeEnd 4 "abc""abc"!Helper function for implementing  and O(n/c)  n xs returns the suffix of xs after the first n elements, or  if n >  xs. bytestring O(n)  n xs is equivalent to  ( xs - n) xs . Drops n! elements from end of bytestring.dropEnd 3 "abcdefg""abcd"dropEnd 0 "abcdefg" "abcdefg"dropEnd 4 "abc"""O(n/c)  n xs is equivalent to ( n xs,  n xs). Similar to !", returns the longest (possibly empty) prefix of elements satisfying the predicate. bytestring Returns the longest (possibly empty) suffix of elements satisfying the predicate. p is equivalent to  .  p . . {-# LANGUAGE OverloadedLists #-)takeWhileEnd even [1,2,3,4,6][4,6] Similar to !#, drops the longest (possibly empty) prefix of elements satisfying the predicate and returns the remainder. bytestring  Similar to !$, drops the longest (possibly empty) suffix of elements satisfying the predicate and returns the remainder. p is equivalent to  .  p . . {-# LANGUAGE OverloadedLists #-)dropWhileEnd even [1,2,3,4,6][1,2,3] Similar to !%, returns the longest (possibly empty) prefix of elements which do not8 satisfy the predicate and the remainder of the string. p is equivalent to  (not . p) and to ( (not . p) &&&  (not . p)). bytestring >Returns the longest (possibly empty) suffix of elements which do not8 satisfy the predicate and the remainder of the string. p is equivalent to  (not . p) and to ( (not . p) &&&  (not . p)). Similar to !&, returns the longest (possibly empty) prefix of elements satisfying the predicate and the remainder of the string. p is equivalent to  (not . p) and to ( p &&&  p). bytestring Returns the longest (possibly empty) suffix of elements satisfying the predicate and the remainder of the string. p is equivalent to  (not . p) and to ( p &&&  p).We have 0spanEnd (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)O(n) Splits a Z 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 (==97) "aabbaca" == ["","","bb","c",""] -- fromEnum 'a' == 97 splitWith undefined "" == [] -- and not [""]O(n) Break a Z into pieces separated by the byte argument, consuming the delimiter. I.e. split 10 "a\nb\nd\ne" == ["a","b","d","e"] -- fromEnum '\n' == 10 split 97 "aXaXaXa" == ["","X","X","X",""] -- fromEnum 'a' == 97 split 120 "x" == ["",""] -- fromEnum 'x' == 120 split undefined "" == [] -- and not [""]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 Z#s that are slices of the original.The  function takes a ByteString and returns a list of ByteStrings such that the concatenation of the result is equal to the argument. Moreover, each string 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 , which allows the programmer to supply their own equality test.The + function is the non-overloaded version of .O(n) The  function takes a Z and a list of Zs and concatenates the list after interspersing the first argument between each element of the list.O(c) Z- index (subscript) operator, starting from 0.+This is a partial function, consider using  instead. bytestring O(c) Z& index, starting from 0, that returns  if: 0 <= n < length bs bytestring O(1) Z& index, starting from 0, that returns  if: 0 <= n < length bsO(n) The ? function returns the index of the first element in the given Z* which is equal to the query element, or  if there is no such element. This implementation uses memchr(3). bytestring O(n) The > function returns the last index of the element in the given Z* which is equal to the query element, or 3 if there is no such element. The following holds: elemIndexEnd c xs = case elemIndex c (reverse xs) of Nothing -> Nothing Just i -> Just (length xs - 1 - i)O(n) The  function extends , by returning the indices of all elements equal to the query element, in ascending order. This implementation uses memchr(3).count returns the number of times its argument appears in the ByteString count = length . elemIndicesBut more efficiently than using length on the intermediate list.The " function takes a predicate and a Z and returns the index of the first element in the ByteString satisfying the predicate. bytestring The " function takes a predicate and a Z and returns the index of the last element in the ByteString satisfying the predicate.O(n) The  function takes a predicate and a ByteString, and returns the first element in matching the predicate, or  if there is no such element. find f p = case findIndex f p of Just n -> Just (p ! n) ; _ -> NothingThe  function extends , by returning the indices of all elements satisfying the predicate, in ascending order.O(n)  is the Z membership predicate.O(n)  is the inverse of O(n) , applied to a predicate and a ByteString, returns a ByteString containing those characters that satisfy the predicate.O(n) The  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., 4partition p bs == (filter p xs, filter (not . p) xs)O(n) The , function takes two ByteStrings and returns * iff the first is a prefix of the second. bytestring O(n) The , function takes two ByteStrings and returns  the remainder of the second iff the first is its prefix, and otherwise .O(n) The , function takes two ByteStrings and returns * iff the first is a suffix of the second.The following holds: 2isSuffixOf x y == reverse x `isPrefixOf` reverse yO(n) The , function takes two ByteStrings and returns  the remainder of the second iff the first is its suffix, and otherwise .O(n)  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  operations. generalises  by zipping with the function given as the first argument, instead of a tupling function. For example,  (+) is applied to two ByteStrings to produce the list of corresponding sums. bytestring A specialised version of  for the common case of a simultaneous map over two ByteStrings, to build a 3rd.O(n)  transforms a list of pairs of bytes into a pair of ByteStrings. Note that this performs two  operations.*Returns all initial segments of the given Z, shortest first. bytestring *Returns all initial segments of the given Z, shortest first.O(n)) Returns all final segments of the given Z, longest first. bytestring O(n)) Returns all final segments of the given Z, longest first.O(n) Make a copy of the Z with its own storage. This is mainly useful to allow the rest of the data pointed to by the Z 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.Read entire handle contents lazily into a Z). 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.The handle is closed on EOF.Read n bytes into a Z, directly from the specified , in chunks of size k.hGetNonBlockingN is similar to , 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.Read entire handle contents lazily into a Z;. Chunks are read on demand, using the default chunk size.File handles are closed on EOF if all the file is read, or through garbage collection otherwise.Read n bytes into a Z, directly from the specified .hGetNonBlocking is similar to , 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,  returns .Note: on Windows and with Haskell implementation other than GHC, this function does not work correctly; it behaves identically to .Read an entire file lazily into a Z.The , will be held open until EOF is encountered.3Note that this function's implementation relies on 3. The reader is advised to read its documentation.Write a Z to a file. Append a Z to a file.9getContents. Equivalent to hGetContents stdin. Will read lazily Outputs a Z to the specified .The chunks will be written one at a time. Other threads might write to the  in between, and hence - alone is not suitable for concurrent writes. Similar to  except that it will never block. Instead it returns any tail that did not get written. This tail may be  in the case that the whole string was written, or the whole original string if nothing was written. Partial writes are also possible.Note: on Windows and with Haskell implementation other than GHC, this function does not work correctly; it behaves identically to .A synonym for , for compatibilityWrite a ByteString to .The chunks will be written one at a time. Other threads might write to the  in between, and hence - alone is not suitable for concurrent writes./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.)accumulator -> element -> new accumulatorstarting value of accumulatorinput of length noutput of length n+1)element -> accumulator -> new accumulatorstarting value of accumulatorinput of length noutput of length n+1What to do when one chunk of output is ready (The StrictByteString will not be empty.)*What to do when the split-point is reached?Number of bytes to leave at the end (must be strictly positive)Input ByteStringedijZYZYijde5None'78=h Intermediate result from scanning a chunk, final output is obtained via convert$ after all the chunks are processed. reads an  from the beginning of the Z. If there is no - at the beginning of the string, it returns  , otherwise it just returns the # read, and the rest of the string. does not ignore leading whitespace, the value must start immediately at the beginning of the input string.Examples6readInteger "-000111222333444555666777888999 all done"/Just (-111222333444555666777888999," all done")8readInteger "+1: readInteger also accepts a leading '+'"4Just (1, ": readInteger also accepts a leading '+'")"readInteger "not a decimal number"Nothing reads a # number from the beginning of the Z. If there is no 4 number at the beginning of the string, it returns , otherwise it just returns the number read, and the rest of the string. does not ignore leading whitespace, the value must start with a decimal digit immediately at the beginning of the input string. Leading + signs are not accepted.Examples5readNatural "000111222333444555666777888999 all done".Just (111222333444555666777888999," all done");readNatural "+000111222333444555666777888999 explicit sign"Nothing"readNatural "not a decimal number"NothingLargest decimal digit count that never overflows the accumulator The base 10 logarithm of 2 is ~0.30103, therefore 2^n has at least 1 + floor (0.3 n) decimal digits. Therefore  floor (0.3 n)0, digits cannot overflow the upper bound of an n-bit word.10-power base for little-endian sequence of ~Word-sized "digits" Input chunk Chunk lengthaccumulated elementpartial digit countaccumulated MSB elements6None'78=rN Intermediate result from scanning a chunk, final output is converted to the requested type once all chunks are processed.Try to read a signed  value from the Z , returning Just (val, str) on success, where val is the value read and str is the rest of the input string. If the sequence of digits decodes to a value larger than can be represented by an , the returned value will be . does not ignore leading whitespace, the value must start immediately at the beginning of the input string.ExamplesreadInt "-1729 sum of cubes"Just (-1729," sum of cubes")0readInt "+1: readInt also accepts a leading '+'"0Just (1, ": readInt also accepts a leading '+'")readInt "not a decimal number"Nothing1readInt "12345678901234567890 overflows maxBound"Nothing3readInt "-12345678901234567890 underflows minBound"Nothing A variant of  specialised to . A variant of  specialised to . A variant of  specialised to .Try to read a  value from the Z , returning Just (val, str) on success, where val is the value read and str is the rest of the input string. If the sequence of digits decodes to a value larger than can be represented by a , the returned value will be . does not ignore leading whitespace, the value must start with a decimal digit immediately at the beginning of the input string. Leading + signs are not accepted.ExamplesreadWord "1729 sum of cubes"Just (1729," sum of cubes")%readWord "+1729 has an explicit sign"NothingreadWord "not a decimal number"Nothing2readWord "98765432109876543210 overflows maxBound"Nothing A variant of  specialised to . A variant of  specialised to . A variant of  specialised to . A variant of  specialised to . A variant of  specialised to .Polymorphic Int*/Word* readerProcess as many digits as we can, returning the additional number of digits found and the updated accumulator. If the accumulator would overflow return .abs(maxBound/minBound)  10 Input stringFirst digit valuemaximum non-overflow value  10maximum non-overflow vavlue  10 Input buffer Input length#Accumulated value of leading digits>Bytes read and final accumulator, or else overflow indication  (c) Don Stewart 2006-2008 (c) Duncan Coutts 2006-2011 BSD-style.dons00@gmail.com, duncan@community.haskell.orgstableportable Trustworthy'78=O(1) Convert a  into a ZO(n) Convert a  into a Z.O(n) Converts a Z to a .O(1)  is analogous to !4 for lists.O(1) Unlike ,  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 ByteStrings.O(n) Append a Char to the end of a Z. Similar to ", this function performs a memcpy.O(1) Extract the first element of a ByteString, which must be non-empty.O(1) Extract the head and tail of a ByteString, returning Nothing if it is empty.O(n/c) Extract the  and 4 of a ByteString, returning Nothing if it is empty.O(1) Extract the last element of a packed string, which must be non-empty.O(n)  f xs( is the ByteString obtained by applying f to each element of xsO(n) The  function takes a Char and a Z< and `intersperses' that Char between the elements of the Z8. It is analogous to the intersperse function on Lists., 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.. is like foldl, but strict in the accumulator., 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. bytestring  is like  , but strict in the accumulator. is a variant of  that has no starting value argument, and thus must be applied to non-empty Zs. is like  , but strict in the accumulator. is a variant of  that has no starting value argument, and thus must be applied to non-empty Zs bytestring  is like  , but strict in the accumulator.Map a function over a Z and concatenate the results)Applied to a predicate and a ByteString, # determines if any element of the Z satisfies the predicate.Applied to a predicate and a Z, $ determines if all elements of the Z satisfy the predicate." returns the maximum value from a Z" returns the minimum value from a Z is similar to , 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. bytestring  is a variant of % that has no starting value argument. .scanl1 f [x1, x2, ...] == [x1, x1 `f` x2, ...] bytestring  is similar to , but returns a list of successive reduced values from the right. scanr f z [..., x{n-1}, xn] == [..., x{n-1} `f` (xn `f` z), xn `f` z, z] Note that  function returns the last index of the element in the given Z* which is equal to the query element, or 3 if there is no such element. The following holds: elemIndexEnd c xs = case elemIndex c (reverse xs) of Nothing -> Nothing Just i -> Just (length xs - 1 - i)O(n) The  function extends , by returning the indices of all elements equal to the query element, in ascending order.The " function takes a predicate and a Z and returns the index of the first element in the ByteString satisfying the predicate. bytestring The " function takes a predicate and a Z and returns the index of the last element in the ByteString satisfying the predicate.The  function extends , by returning the indices of all elements satisfying the predicate, in ascending order.count returns the number of times its argument appears in the ByteString ?count == length . elemIndices count '\n' == length . linesBut more efficiently than using length on the intermediate list.O(n)  is the Z1 membership predicate. This implementation uses  memchr(3).O(n)  is the inverse of O(n) , applied to a predicate and a ByteString, returns a ByteString containing those characters that satisfy the predicate. bytestring O(n) The  function takes a predicate and a ByteString, and returns the first element in matching the predicate, or  if there is no such element.O(n)  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  operations, and so space usage may be large for multi-megabyte ByteStrings generalises  by zipping with the function given as the first argument, instead of a tupling function. For example,  (+) is applied to two ByteStrings to produce the list of corresponding sums. bytestring A specialised version of  for the common case of a simultaneous map over two ByteStrings, to build a 3rd. bytestring O(n)  transforms a list of pairs of chars into a pair of ByteStrings. Note that this performs two  operations. lazily splits a ByteString into a list of ByteStrings at newline Chars ('\n'). The resulting strings do not contain newlines. The first chunk of the result is only strict in the first chunk of the input. Note that it does not regard CR ('\r') as a newline character.9 joins lines, appending a terminating newline after each.Equivalent to " . Data.List.concatMap (\x -> [x,  '\n']). breaks a ByteString up into a list of words, which were delimited by Chars representing white space. And tokens isSpace = wordsThe  function is analogous to the  function, on words.9Write a ByteString to a handle, appending a newline byte.The chunks will be written one at a time, followed by a newline. Other threads might write to the  in between, and hence - alone is not suitable for concurrent writes.Write a ByteString to , appending a newline byte.The chunks will be written one at a time, followed by a newline. Other threads might write to the  in between, and hence - alone is not suitable for concurrent writes.)element -> accumulator -> new accumulatorstarting value of accumulatorinput of length noutput of length n+1ijZZij (c) Don Stewart 2006-2008 (c) Duncan Coutts 2006-2011 BSD-style.dons00@gmail.com, duncan@community.haskell.orgstableportable Trustworthy'78=̲O(1) Convert a  into a  O(n) Convert a  into a  For applications with large numbers of string literals, pack can be a bottleneck.O(n) Converts a   to a .O(n)  is analogous to (:) for lists, but of different complexity, as it requires a memcpy.O(n) Append a Char to the end of a  . Similar to ", this function performs a memcpy.O(1) Extract the head and tail of a ByteString, returning Nothing if it is empty.O(1) Extract the  and 4 of a ByteString, returning Nothing if it is empty.O(1) Extract the first element of a ByteString, which must be non-empty.O(1) Extract the last element of a packed string, which must be non-empty.O(n)  f xs( is the ByteString obtained by applying f to each element of xsO(n) The  function takes a Char and a  < and `intersperses' that Char between the elements of the  8. It is analogous to the intersperse function on Lists., 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.. is like foldl, but strict in the accumulator., 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. is a strict variant of foldr is a variant of  that has no starting value argument, and thus must be applied to non-empty  s.A strict version of  is a variant of  that has no starting value argument, and thus must be applied to non-empty  sA strict variant of foldr1Map a function over a   and concatenate the results)Applied to a predicate and a ByteString, # determines if any element of the   satisfies the predicate.Applied to a predicate and a  , $ determines if all elements of the   satisfy the predicate." returns the maximum value from a  " returns the minimum value from a  The ( function behaves like a combination of  and ; 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.The ( function behaves like a combination of  and ; 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. is similar to , 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. is a variant of % that has no starting value argument: .scanl1 f [x1, x2, ...] == [x1, x1 `f` x2, ...])scanr is the right-to-left dual of scanl. is a variant of % that has no starting value argument.O(n)  n x is a ByteString of length n with x2 the value of every element. The following holds: .replicate w c = unfoldr w (\u -> Just (u,u)) cThis implementation uses  memset(3)O(n), where n# is the length of the result. The 0 function is analogous to the List 'unfoldr'.  builds a ByteString from a seed value. The function takes the element and returns 4 if it is done producing the ByteString or returns  (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"O(n) Like ,  builds a ByteString from a seed value. However, the length of the result is limited by the first argument to (. This function is more efficient than 1 when the maximum length of the result is known.The following equation relates  and : &unfoldrN n f s == take n (unfoldr f s), applied to a predicate p and a ByteString xs2, returns the longest prefix (possibly empty) of xs of elements that satisfy p. bytestring , applied to a predicate p and a ByteString xs2, returns the longest suffix (possibly empty) of xs of elements that satisfy p. p xs$ returns the suffix remaining after  p xs. bytestring  p xs$ returns the prefix remaining after  p xs. p is equivalent to  ( . p). breaks its ByteString argument at the first occurrence of the specified char. It is more efficient than  as it is implemented with  memchr(3). I.e. ,break (=='c') "abcd" == breakChar 'c' "abcd" p xs? breaks the ByteString into two segments. It is equivalent to ( p xs,  p xs) behaves like  but from the end of the   . 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) behaves like  but from the end of the  breakEnd p == spanEnd (not.p)O(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" == ["",""] split undefined "" == [] -- and not [""]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.O(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 undefined "" == [] -- and not [""]The + function is the non-overloaded version of .O(1)  - index (subscript) operator, starting from 0. bytestring O(1)  & index, starting from 0, that returns  if: 0 <= n < length bs bytestring O(1)  & index, starting from 0, that returns  if: 0 <= n < length bsO(n) The ? function returns the index of the first element in the given  6 which is equal (by memchr) to the query element, or  if there is no such element.O(n) The > function returns the last index of the element in the given  * which is equal to the query element, or 3 if there is no such element. The following holds: elemIndexEnd c xs = case elemIndex c (reverse xs) of Nothing -> Nothing Just i -> Just (length xs - 1 - i)O(n) The  function extends , by returning the indices of all elements equal to the query element, in ascending order.The " function takes a predicate and a   and returns the index of the first element in the ByteString satisfying the predicate. bytestring O(n) The " function takes a predicate and a   and returns the index of the last element in the ByteString satisfying the predicate.The  function extends , by returning the indices of all elements satisfying the predicate, in ascending order.count returns the number of times its argument appears in the ByteString count = length . elemIndicesAlso count '\n' == length . linesBut more efficiently than using length on the intermediate list.O(n)  is the  1 membership predicate. This implementation uses  memchr(3).O(n)  is the inverse of O(n) , applied to a predicate and a ByteString, returns a ByteString containing those characters that satisfy the predicate. bytestring O(n) The  function takes a predicate and a ByteString, and returns the first element in matching the predicate, or  if there is no such element.O(n)  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  operations, and so space usage may be large for multi-megabyte ByteStrings generalises  by zipping with the function given as the first argument, instead of a tupling function. For example,  (+) is applied to two ByteStrings to produce the list of corresponding sums. bytestring A specialised version of  for the common case of a simultaneous map over two ByteStrings, to build a 3rd. transforms a list of pairs of Chars into a pair of ByteStrings. Note that this performs two  operations. returns the pair of ByteStrings when the argument is broken at the first whitespace byte. I.e. break isSpace == breakSpace bytestring  efficiently returns the   argument with white space Chars removed from the front. It is more efficient than calling dropWhile for removing whitespace. I.e. dropWhile isSpace == dropSpace bytestring /Remove leading and trailing white space from a  . breaks a ByteString up into a list of ByteStrings at newline Chars ('\n'1). The resulting strings do not contain newlines. Note that it does not regard CR ('\r') as a newline character.9 joins lines, appending a terminating newline after each.Equivalent to " . Data.List.concatMap (\x -> [x,  '\n']). breaks a ByteString up into a list of words, which were delimited by Chars representing white space.The  function is analogous to the  function, on words.Read a line from stdin.Read a line from a handle9Write a ByteString to a handle, appending a newline byte.Unlike , this is not atomic: other threads might write to the handle between writing of the bytestring and the newline.Write a ByteString to , appending a newline byte.Unlike 4, this is not atomic: other threads might write to 3 between writing of the bytestring and the newline.Kij  Kij (c) 2010 - 2011 Simon MeierBSD3-style (see LICENSE) Simon Meier unstable, privateGHCUnsafe'78=@<+A buffer allocation strategy for executing s.A  action denotes a computation of a value that writes a stream of bytes as a side-effect. s are strict in their side-effect; i.e., the stream of bytes will always be written before the computed value is returned.s are a generalization of s. The typical use case is the implementation of an encoding that might fail (e.g., an interface to the  (https://hackage.haskell.org/package/zlibzlib compression library or the conversion from Base64 encoded data to 8-bit data). For a , the only way to handle and report such a failure is ignore it or call . In contrast,  actions are expressive enough to allow reporting and handling such a failure in a pure fashion. () actions are isomorphic to s. The functions  and  convert between these two types. Where possible, you should use ;s, as sequencing them is slightly cheaper than sequencing 4s because they do not carry around a computed value.'s denote sequences of bytes. They are  s where $ is the zero-length sequence and ! is concatenation, which runs in O(1).&s abstract signals to the caller of a . There are three signals: , , or 'insertChunks signalss may be called *multiple times* and they must not rise an async. exception./A stream of chunks that are constructed in the  monad.This datatype serves as the common interface for the buffer-by-buffer execution of a  by '. Typical users of this interface are # or iteratee-style libraries like  enumerator.:The partially filled last buffer together with the result.Yield a  non-empty  .A  together with the  of free bytes. The filled space starts at offset 0 and ends at the first free byte.A range of bytes in a buffer represented by the pointer to the first byte of the range and the pointer to the first byte after the range.9Combined size of the filled and free space in the buffer.(Allocate a new buffer of the given size.Convert the filled part of a  to a  .Prepend the filled part of a  to a 89 trimming it if necessary.A smart constructor for yielding one chunk that ignores the chunk if it is empty. Convert a  () to a 89 using . Convert a 0 to a lazy tuple of the result and the written 89 using .Signal that the current " is done and has computed a value.'Signal that the current buffer is full.Signal that a  # chunk should be inserted directly.Fill a  using a . Construct a . In contrast to s, !s are referentially transparent.&The final build step that returns the  signal.Run a  with the .Run a .The  denoting a zero-length sequence of bytes. This function is only exported for use in rewriting rules. Use  otherwise.Concatenate two s. This function is only exported for use in rewriting rules. Use  otherwise.;Flush the current buffer. This introduces a chunk boundary. Construct a  action. In contrast to s, s are referentially transparent in the sense that sequencing the same  multiple times yields every time the same value with the same side-effect.Run a . Synonym for  from ; used in rewriting rules. Synonym for  from  and  from ; used in rewriting rules.Run a  as a side-effect of a  () action. Convert a  () action to a .Run a - action redirecting the produced output to a .!The output is buffered using the s associated buffer. If this buffer is too small to execute one step of the 9 action, then it is replaced with a large enough buffer. Execute a  and return the computed result and the bytes written during the computation as a 89.This function is strict in the computed result and lazy in the writing of the bytes. For example, given infinitePut = sequence_ (repeat (putBuilder (word8 1))) >> return 0 evaluating the expression 'fst $ putToLazyByteString infinitePut 3does not terminate, while evaluating the expression 0L.head $ snd $ putToLazyByteString infinitePut $does terminate and yields the value  1 :: Word8.An illustrative example for these strictness properties is the implementation of Base64 decoding ( #http://en.wikipedia.org/wiki/Base64). *type DecodingState = ... decodeBase64 ::   -> DecodingState -> + (Maybe DecodingState) decodeBase64 = ... The above function takes a   supposed to represent Base64 encoded data and the current decoding state. It writes the decoded bytes as the side-effect of the  and returns the new decoding state, if the decoding of all data in the  & was successful. The checking if the   represents Base64 encoded data and the actual decoding are fused. This makes the common case, where all data represents Base64 encoded data, more efficient. It also implies that all data must be decoded before the final decoding state can be returned. s are intended for implementing such fused checking and decoding/encoding, which is reflected in their strictness properties. Execute a  with a buffer-allocation strategy and a continuation. For example,  is implemented as follows. putToLazyByteString =  ( 8: 8;) (x -> (x, L.empty))  n! ensures that there are at least n free bytes for the following .Copy the bytes from a   into the output stream. Construct a  that copies the  s, if it is smaller than the treshold, and inserts it directly otherwise. For example, byteStringThreshold 1024 copies  s whose size is less or equal to 1kb, and inserts them directly otherwise. This implies that the average chunk-size of the generated 89 may be as low as 513 bytes, as there could always be just a single byte between the directly inserted 1025 byte,  s. Construct a  that copies the  .Use this function to create s from smallish (<= 4kb)  's or if you need to guarantee that the  1 is not shared with the chunks generated by the . Construct a  that always inserts the   directly as a chunk.This implies flushing the output buffer, even if it contains just a single byte. You should therefore use  only for large (> 8kb)  s. Otherwise, the generated chunks are too fragmented to be processed efficiently afterwards. Construct a  that copies the <=.Copy the bytes from a <= into the output stream. Construct a ( that uses the thresholding strategy of  for each chunk of the 89. Construct a  that copies the 89. Construct a  that inserts all chunks of the 89 directly. Create a + denoting the same sequence of bytes as a  . The  inserts large  s directly, but copies small ones to ensure that the generated chunks are large on average. Create a 0 denoting the same sequence of bytes as a lazy 89. The  inserts large chunks of the 89 directly, but copies small ones to ensure that the generated chunks are large on average.The maximal size of a   that is copied. 2 * 8:- to guarantee that on average a chunk is of 8:.6Create a custom allocation strategy. See the code for  and  for examples.>Sanitize a buffer size; i.e., make it at least the size of an .!Use this strategy for generating 89s whose chunks are discarded right after they are generated. For example, if you just generate them to write them to a network socket.!Use this strategy for generating 89s whose chunks are likely to survive one garbage collection. This strategy trims buffers that are filled less than half in order to avoid spilling too much memory. Execute a & and return the generated chunks as a 89>. The work is performed lazy, i.e., only when a chunk of the 89 is forced.Heavy inlining. Execute a " with custom execution parameters.This function is inlined despite its heavy code-size to allow fusing with the allocation strategy. For example, the default  execution function  > is defined as follows. {-# NOINLINE toLazyByteString #-} toLazyByteString = toLazyByteStringWith ( 8: 8; ) L.Empty where L.Empty is the zero-length 89.&In most cases, the parameters used by >2 give good performance. A sub-performing case of >" is executing short (<128 bytes) s. In this case, the allocation overhead for the first 4kb buffer and the trimming cost dominate the cost of executing the ". You can avoid this problem using >toLazyByteStringWith (safeStrategy 128 smallChunkSize) L.EmptyThis reduces the allocation and trimming overhead, as all generated 89s fit into the first buffer and there is no trimming required, if more than 64 bytes and less than 128 bytes are written. Convert a  to a  stream by executing it on #s allocated according to the given . bytestring  bytestring  Like the NFData instance for StrictByteString, this does not force the ForeignPtrContents field of the underlying  ForeignPtr.For long or infinite lists use  because it uses LazyByteString otherwise use  which uses StrictByteString.Next free byte in current Computed valueMinimal size of next .Next free byte in current . to run on the next . This & may assume that it is called with a  of at least the required minimal size; i.e., the caller of this  must guarantee this.Next free byte in current Chunk to insert. to run on next "Build step to use for filling the . Handling the  signal Handling the  signal Handling the  signalBuffer range to fill."Value computed while filling this .A function that fills a +, calls the continuation with the updated = once its done, and signals its caller how to proceed using , , or .This function must be referentially transparent; i.e., calling it multiple times with equally sized s must result in the same sequence of bytes being written. If you need mutable state, then you must allocate it anew upon each call of this function. Moreover, this function must call the continuation once its done. Otherwise, concatenation of s does not work. Finally, this function must write to all bytes that it claims it has written. Otherwise, the resulting  is not guaranteed to be referentially transparent and sensitive data might leak. to run& that writes the byte stream of this  and signals  upon completion. to run Continuation A function that fills a +, calls the continuation with the updated  and its computed value once its done, and signals its caller how to proceed using , , or  signals.This function must be referentially transparent; i.e., calling it multiple times with equally sized s must result in the same sequence of bytes being written and the same value being computed. If you need mutable state, then you must allocate it anew upon each call of this function. Moreover, this function must call the continuation once its done. Otherwise, monadic sequencing of s does not work. Finally, this function must write to all bytes that it claims it has written. Otherwise, the resulting  is not guaranteed to be referentially transparent and sensitive data might leak. Put to run, that first writes the byte stream of this / and then yields the computed value using the  signal. to execute Result and 89 written as its side-effect!Buffer allocation strategy to useContinuation to use for computing the final result and the tail of its side-effect (the written bytes). to execute Resulting 89Input  .Input <=.Buffer allocation function.If 7 is given, then a new first buffer should be allocated.If  (oldBuf, minSize), is given, then a buffer with minimal size minSize* must be returned. The strategy may reuse oldBuf only if oldBuf is large enough and the consumer can guarantee that this will not result in a violation of referential transparency.Warning: for multithreaded programs, it is generally unsafe to reuse buffers when using the consumers of # in this package. For example, if  is called with an  that reuses buffers, evaluating the result by multiple threads simultaneously may lead to corrupted output.Default buffer size. A predicate trim used allocated returning 9, if the buffer should be trimmed before it is returned.Size of the first bufferSize of successive buffersAn allocation strategy that does not trim any of the filled buffers before converting it to a chunkSize of first bufferSize of successive buffersAn allocation strategy that guarantees that at least half of the allocated memory is used for live data!Buffer allocation strategy to use89+ to use as the tail of the generated lazy 89 to execute Resulting 89!Buffer allocation strategy to use to execute7hfg7gfh? Safe-Inferred'78= If the host is little-endian, applies the given function to the given arg. If the host is big-endian, returns the second argument unchanged.If the host is little-endian, returns the second argument unchanged. If the host is big-endian, applies the given function to the given arg.@(c) Matthew Craven 2023-2024 BSD-styleclyring@gmail.cominternal non-portableNone'78= *A(c) Lawrence Wu 2021 BSD-stylelawrencejwu@gmail.comNone%&'78=<Bookkeeping state for finding the shortest, correctly-rounded representation. The same trimming algorithm is similar enough for 32- and 64-bit floats9Wrapper for polymorphic handling of 32- and 64-bit floats#ifdef for 64-bit word that seems to work on both 32- and 64-bit platformsSpecial rendering for NaN, positive/negative 0, and positive/negative infinity. These are based on the IEEE representation of non-numbers.Infinity8sign = 0 for positive infinity, 1 for negative infinity.biased exponent = all 1 bits.fraction = all 0 bits.NaNsign = either 0 or 1 (ignored)biased exponent = all 1 bits.&fraction = anything except all 0 bits.We also handle 0 specially here so that the exponent rendering is more correct.sign = either 0 or 1.biased exponent = all 0 bits.fraction = all 0 bits.*Build a full bit-mask of specified length.e.g showHex (mask 12) [] = "fff"(Convert boolean false to 0 and true to 1(Convert boolean false to 0 and true to 1Monomorphic conversion for  Int32 -> IntMonomorphic conversion for  Int -> Int32Monomorphic conversion for  Word32 -> IntMonomorphic conversion for  Word64 -> IntMonomorphic conversion for Word32 -> Word64Monomorphic conversion for Word64 -> Word32Returns the number of decimal digits in v, which must not contain more than 9 digits.Returns the number of decimal digits in v, which must not contain more than 17 digits.?Storable.poke a String into a Ptr Word8, converting through c2wUnsafe creation of a bounded primitive of String at most length 0Renders NonNumbersAndZero into bounded primitivePart of the calculation on whether to round up the decimal representation. This is currently a constant function to match behavior in Base  and is implemented as acceptBounds _ = False +For round-to-even and correct shortest, use +acceptBounds v = ((v `quot` 4) .&. 1) == 0 ?Returns e == 0 ? 1 : ceil(log_2(5^e)); requires 0 <= e <= 3528.4Returns floor(log_10(2^e)); requires 0 <= e <= 1650.4Returns floor(log_10(5^e)); requires 0 <= e <= 2620.%Boxed versions of the functions above%Boxed versions of the functions above%Boxed versions of the functions aboveReturns w / 10Returns w % 10Returns (w / 10, w % 10)Returns w / 100Returns (w / 10000, w % 10000)Returns w / 5Returns w % 5Returns w / 10Returns w / 100Returns (w / 10000, w % 10000)Returns (w / 10, w % 10)Returns w / 5Returns w % 5Returns (w / 5, w % 5)9Wrap a unboxed function on Int# into the boxed equivalentBoxed version of  for 64 bitsReturns the number of times w is divisible by 5Returns True if value is divisible by 5^pReturns True if value is divisible by 2^pTrim digits and update bookkeeping state when the table-computed step results in trailing zeros (the general case, happens rarely)NB: This function isn't actually necessary so long as acceptBounds is always False since we don't do anything different with the trailing-zero information directly: - vuIsTrailingZeros is always False. We can see this by noting that in all places where vuTrailing can possible be True, we must have acceptBounds be True (accept_smaller) - The final result doesn't change the lastRemovedDigit for rounding anywayTrim digits and update bookkeeping state when the table-computed step results has no trailing zeros (common case)Returns the correctly rounded decimal representation mantissa based on if we need to round up (next decimal place >= 5) or if we are outside the boundsConvert a single-digit number to the ascii ordinal e.g '1' -> 0x310Index into the 64-bit word lookup table providedIndex into the 128-bit word lookup table provided Return (# high-64-bits , low-64-bits #)NB: The lookup tables we use store the low 64 bits in host-byte-order then the high 64 bits in host-byte-order)Packs 2 bytes [lsb, msb] into 16-bit word-Unpacks a 16-bit word into 2 bytes [lsb, msb]?Static array of 2-digit pairs 00..99 for faster ascii renderingGHC Trustworthy'78=(G%Encoding single unsigned bytes as-is. Encoding s in big endian format. Encoding s in little endian format. Encoding s in big endian format. Encoding s in little endian format. Encoding s in big endian format. Encoding s in little endian format.Encode a single native machine . The s is encoded in host order, host endian form, for the machine you are on. On a 64 bit machine the  is an 8 byte value, on a 32 bit machine, 4 bytes. Values encoded this way are not portable to different endian or word sized machines, without conversion. Encoding +s in native host order and host endianness. Encoding +s in native host order and host endianness. Encoding +s in native host order and host endianness.#Encoding single signed bytes as-is. Encoding s in big endian format. Encoding s in little endian format. Encoding s in big endian format. Encoding s in little endian format. Encoding s in big endian format. Encoding s in little endian format.Encode a single native machine . The s is encoded in host order, host endian form, for the machine you are on. On a 64 bit machine the  is an 8 byte value, on a 32 bit machine, 4 bytes. Values encoded this way are not portable to different endian or integer sized machines, without conversion. Encoding +s in native host order and host endianness. Encoding +s in native host order and host endianness. Encoding +s in native host order and host endianness. Encode a  in big endian format. Encode a  in little endian format. Encode a  in big endian format. Encode a  in little endian format. Encode a  in native host order and host endianness. Values written this way are not portable to different endian machines, without conversion. Encode a * in native host order and host endianness.C(c) 2010 Jasper Van der Jeugt (c) 2010 - 2011 Simon MeierBSD3-style (see LICENSE) Simon Meier GHCNone'78=-Encode the least 7-bits of a  using the ASCII encoding.Decimal encoding of an .Decimal encoding of an .Decimal encoding of an .Decimal encoding of an .Decimal encoding of an .Decimal encoding of a .Decimal encoding of a .Decimal encoding of a .Decimal encoding of a .Decimal encoding of a .Hexadecimal encoding of a .Hexadecimal encoding of a .Hexadecimal encoding of a .Hexadecimal encoding of a .Hexadecimal encoding of a . Encode a & using 2 nibbles (hexadecimal digits). Encode a  using 4 nibbles. Encode a  using 8 nibbles. Encode a  using 16 nibbles. Encode a & using 2 nibbles (hexadecimal digits). Encode a  using 4 nibbles. Encode a  using 8 nibbles. Encode a  using 16 nibbles.Encode an IEEE  using 8 nibbles.Encode an IEEE  using 16 nibbles.(c) 2010-2011 Simon Meier (c) 2010 Jasper van der JeugtBSD3-style (see LICENSE) Simon Meier GHC Trustworthy'78=:FEncode a value with a .2Encode a list of values from left-to-right with a .*Encode a list of values represented as an DE with a .Heavy inlining. Encode all bytes of a   from left-to-right with a . This function is quite versatile. For example, we can use it to construct a  that maps every byte before copying it to the buffer to be filled. mapToBuilder :: (Word8 -> Word8) -> S.StrictByteString -> Builder mapToBuilder f = primMapByteStringFixed (contramapF f word8)#We can also use it to hex-encode a   as shown by the FG example above.Heavy inlining. Encode all bytes of a 89 from left-to-right with a . Create a $ that encodes values with the given .We rewrite consecutive uses of 4 such that the bound-checks are fused. For example, 9primBounded (word32 c1) `mappend` primBounded (word32 c2)%is rewritten such that the resulting  checks only once, if ther are at 8 free bytes, instead of checking twice, if there are 4 free bytes. This optimization is not observationally equivalent in a strict sense, as it influences the boundaries of the generated chunks. However, for a user of this library it is observationally equivalent, as chunk boundaries of a 89 can only be observed through the internal interface. Moreover, we expect that all primitives write much fewer than 4kb (the default short buffer size). Hence, it is safe to ignore the additional memory spilled due to the more aggressive buffer wrapping introduced by this optimization. Create a 6 that encodes a list of values consecutively using a 7 for each element. This function is more efficient than mconcat . map (primBounded w)or foldMap (primBounded w)9because it moves several variables out of the inner loop. Create a > that encodes a sequence generated from a seed value using a  for each sequence element. Create a  that encodes each  of a   using a . For example, we can write a  that filters a   as follows. 2import qualified Data.ByteString.Builder.Prim as P >filterBS p = P.condB p (P.liftFixedToBounded P.word8) P.emptyBChunk-wise application of . bytestring  A null-terminated ASCII encoded HI). Null characters are not representable. bytestring  A null-terminated UTF-8 encoded HI%. Null characters can be encoded as  0xc0 0x80.Char8 encode a .UTF-8 encode a .Encode a Unicode character to another datatype, using UTF-8. This function acts as an abstract way of encoding characters, as it is unaware of what needs to happen with the resulting bytes: you have to specify functions to deal with those. 1-byte UTF-8 2-byte UTF-8 3-byte UTF-8 4-byte UTF-8Input Result  J(c) Lawrence Wu 2021 BSD-stylelawrencejwu@gmail.comNone'78=@Table of 5^(-e2-q) / 2^k + 1 5fmap (fnorm float_pow5_bitcount) [0..float_max_split]Table of 2^k / 5^q + 1 = 0Handle case e2 < 0Returns the decimal representation of the given mantissa and exponent of a 32-bit Float using the ryu algorithm.-Split a Float into (sign, mantissa, exponent)Dispatches to ! and applies the given formatters%Render a Float in scientific notationReturns the decimal representation of a Float. NaN and Infinity will return `FloatingDecimal 0 0`K(c) Lawrence Wu 2021 BSD-stylelawrencejwu@gmail.comNone'78=GTable of 5^(-e2-q) / 2^k + 1 splitWord128s $ fmap (fnorm double_pow5_bitcount) [0..double_max_split]Table of 2^k / 5^q + 1 splitWord128s $ fmap (finv double_pow5_inv_bitcount) [0..double_max_inv_split]Number of mantissa bits of a 64-bit float. The number of significant bits (floatDigits (undefined :: Double)) is 53 since we have a leading 1 for normal floats and 0 for subnormal floats)Number of exponent bits of a 64-bit float6Bias in encoded 64-bit float representation (2^10 - 1)Quick check for small integersRemoves trailing (decimal) zeros for small integers in the range [1, 2^53)Multiply a 64-bit number with a 128-bit number while keeping the upper 64 bits. Then shift by specified amount minus 64>Index into the 128-bit word lookup table double_pow5_inv_split:Index into the 128-bit word lookup table double_pow5_split"Take the high bits of m * 5^-e2-q  2^k  2^q-kTake the high bits of m * 2^k  5^q  2^-e2+q+kHandle case e2 >= 0Handle case e2 < 0Returns the decimal representation of the given mantissa and exponent of a 64-bit Double using the ryu algorithm..Split a Double into (sign, mantissa, exponent)Dispatches to  or ! and applies the given formatters&Render a Double in scientific notationReturns the decimal representation of a Double. NaN and Infinity will return `FloatingDecimal 0 0`(c) Lawrence Wu 2021 BSD-stylelawrencejwu@gmail.comNone'78=Q!ByteString float-to-string formatscientific notation;standard notation with `Maybe Int` digits after the decimaldispatches to scientific or standard notation based on the exponent bytestring Format type for use with  and ."Returns a rendered Float. Matches 2 in displaying in standard or scientific notation  floatDec =   #Returns a rendered Double. Matches 2 in displaying in standard or scientific notation  doubleDec =    bytestring Standard notation with n decimal places bytestring Standard notation with the 'default precision' (decimal places matching ) bytestring Scientific notation with 'default precision' (decimal places matching ) bytestring Standard or scientific notation depending on the exponent. Matches  bytestring Returns a rendered Float. Returns the 'shortest' representation in scientific notation and takes an optional precision argument in standard notation. Also see .With standard notation, the precision argument is used to truncate (or extend with 0s) the 'shortest' rendered Float. The 'default precision' does no such modifications and will return as many decimal places as the representation demands.e.g"formatFloat (standard 1) 1.2345e-2"0.0"#formatFloat (standard 10) 1.2345e-2"0.0123450000".formatFloat standardDefaultPrecision 1.2345e-2 "0.01234"formatFloat scientific 12.345 "1.2345e1"formatFloat generic 12.345"12.345" bytestring Returns a rendered Double. Returns the 'shortest' representation in scientific notation and takes an optional precision argument in standard notation. Also see .With standard notation, the precision argument is used to truncate (or extend with 0s) the 'shortest' rendered Float. The 'default precision' does no such modifications and will return as many decimal places as the representation demands.e.g#formatDouble (standard 1) 1.2345e-2"0.0"$formatDouble (standard 10) 1.2345e-2"0.0123450000"/formatDouble standardDefaultPrecision 1.2345e-2 "0.01234"formatDouble scientific 12.345 "1.2345e1"formatDouble generic 12.345"12.345"Char7 encode a .Char7 encode a . Encodes a  if input is negativeSpecial rendering for Nan, Infinity, and 0. See RealFloat.Internal.NonNumbersAndZero,Returns a list of decimal digits in a Word64Show a floating point value in standard notation. Based on GHC.Float.showFloat  (c) 2010 Jasper Van der Jeugt (c) 2010-2011 Simon MeierBSD3-style (see LICENSE) Simon Meier GHC Trustworthy'78=]After running a ; action there are three possibilities for what comes next:This means we're all done. All the builder data has now been written.This indicates that there may be more data to write. It gives you the next  action. You should call that action with an appropriate buffer. The int indicates the minimum# buffer size required by the next 3 action. That is, if you call the next action you must6 supply it with a buffer length of at least this size.In addition to the data that has just been written into your buffer by the 9 action, it gives you a pre-existing chunk of data as a  ". It also gives you the following  action. It is safe to run this following action using a buffer with as much free space as was left by the previous run action.A $ represents the result of running a . It unfolds as a sequence of chunks of data. These chunks come in two forms:an IO action for writing the Builder's data into a user-supplied memory buffer./a pre-existing chunks of data represented by a  While this is rather low level, it provides you with full flexibility in how the data is written out.The  itself is an IO action: you supply it with a buffer (as a pointer and length) and it will write data into the buffer. It returns a number indicating how many bytes were actually written (which can be 0). It also returns a " which describes what comes next.Turn a  into its initial  action.Encode a single native machine . The  is encoded in host order, host endian form, for the machine you're on. On a 64 bit machine the  is an 8 byte value, on a 32 bit machine, 4 bytes. Values encoded this way are not portable to different endian or int sized machines, without conversion. Encode a * in native host order and host endianness. Encode a * in native host order and host endianness. Encode a * in native host order and host endianness.Encode a single native machine . The  is encoded in host order, host endian form, for the machine you're on. On a 64 bit machine the  is an 8 byte value, on a 32 bit machine, 4 bytes. Values encoded this way are not portable to different endian or word sized machines, without conversion. Encode a * in native host order and host endianness. Encode a * in native host order and host endianness. Encode a * in native host order and host endianness. Encode a  in native host order. Values encoded this way are not portable to different endian machines, without conversion. Encode a  in native host order.fggfF(c) 2010 - 2011 Simon MeierBSD3-style (see LICENSE) Simon Meier GHCNone'78=fDecimal encoding of an  using the ASCII digits.e.g. toLazyByteString (int8Dec 42) = "42" toLazyByteString (int8Dec (-1)) = "-1"Decimal encoding of an  using the ASCII digits.Decimal encoding of an  using the ASCII digits.Decimal encoding of an  using the ASCII digits.Decimal encoding of an  using the ASCII digits.Decimal encoding of a  using the ASCII digits.Decimal encoding of a  using the ASCII digits.Decimal encoding of a  using the ASCII digits.Decimal encoding of a  using the ASCII digits.Decimal encoding of a  using the ASCII digits.#Shortest hexadecimal encoding of a  using lower-case characters.#Shortest hexadecimal encoding of a  using lower-case characters.#Shortest hexadecimal encoding of a  using lower-case characters.#Shortest hexadecimal encoding of a  using lower-case characters.#Shortest hexadecimal encoding of a  using lower-case characters. Encode a & using 2 nibbles (hexadecimal digits). Encode a  using 4 nibbles. Encode a  using 8 nibbles. Encode a  using 16 nibbles. Encode a & using 2 nibbles (hexadecimal digits). Encode a  using 4 nibbles. Encode a  using 8 nibbles. Encode a  using 16 nibbles.Encode an IEEE  using 8 nibbles.Encode an IEEE  using 16 nibbles.Encode each byte of a  $ using its fixed-width hex encoding.Encode each byte of a 89$ using its fixed-width hex encoding.$Maximal power of 10 fitting into an  without using the MSB. 10 ^ 9 for 32 bit ints (31 * log 2 / log 10 = 9.33) 10 ^ 18 for 64 bit ints (63 * log 2 / log 10 = 18.96)2FIXME: Think about also using the MSB. For 64 bit s this makes a difference.Decimal encoding of an  using the ASCII digits.(c) 2010 Jasper Van der Jeugt (c) 2010 - 2011 Simon MeierBSD3-style (see LICENSE) Simon Meier GHC Trustworthy'78=oD Output a  to a . The + is executed directly on the buffer of the . If the buffer is too small (or not present), then it is replaced with a large enough buffer.It is recommended that the  is set to binary and 0L mode. See 0M and 0N.%This function is more efficient than hPut .  because in many cases no buffer allocation has to be done. Moreover, the results of several executions of short s are concatenated in the 9s buffer, therefore avoiding unnecessary buffer flushes. bytestring Write a  to a file. Similarly to ., this function is more efficient than using O .  with a file handle."Encode a single signed byte as-is.$Encode a single unsigned byte as-is. Encode an  in little endian format. Encode an  in little endian format. Encode an  in little endian format. Encode a  in little endian format. Encode a  in little endian format. Encode a  in little endian format. Encode a  in little endian format. Encode a  in little endian format. Encode an  in big endian format. Encode an  in big endian format. Encode an  in big endian format. Encode a  in big endian format. Encode a  in big endian format. Encode a  in big endian format. Encode a  in big endian format. Encode a  in big endian format.Char7 encode a .Char7 encode a .Char8 encode a .Char8 encode a .UTF-8 encode a .UTF-8 encode a . Note that  performs no codepoint validation and consequently may emit invalid UTF-8 if asked (e.g. single surrogates). bytestring =PQRPQSTUVWXYZ[\]^_`abcdefghijklmnop qrstuvwxyz{|}~+9q~;: = = =  +                                    "     # $  % &        E                   ) *             E"#$%&)*O223333333333+E"#$%&O556666666666                                   E "  # $ %  &                                                             E  "  # $ % &                                                            +       O                 >          BBBBBBBBBBBBBBBBBBBBBBBBBBBBCCCCCCCCCCCCCCCCCCCCCCCCCCFFFFFFFFFFFFFFFFFFFFFFFFFFGFFPPPPPPPPPPPPP  P PPPPPPPPIPPPPP22223PPPPP3333PP555566666  PPPP  P PP PPP   PP???PPP@@@@@@AAAAAAAAAAAAAAAAAAAAPAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAJJJJJJJJJJJJJJJJJJJJJKKKKKKKKKKKKKKKKKKKKKKKPFbytestring-0.12.2.0-d3f3Data.ByteString.InternalData.ByteString.Builder.Prim%Data.ByteString.Builder.Prim.InternalData.ByteStringData.ByteString.UnsafeData.ByteString.LazyData.ByteString.Lazy.InternalData.ByteString.Builder.Extra Data.ByteString.Builder.InternalData.ByteString.ShortData.ByteString.Short.InternalData.ByteString.Char8Data.ByteString.Lazy.Char8Data.ByteString.Builder!Data.ByteString.Builder.RealFloatchar745,Data.ByteString.Builder.Prim.Internal.Base16.Data.ByteString.Builder.Prim.Internal.Floating0Data.ByteString.Builder.RealFloat.TableGeneratorData.ByteString.Internal.TypeunsafePackAddressLenunsafePackCStringLenunsafePackCStringFinalizerForeign.ForeignPtrmallocForeignPtrBytesSystem.IO.UnsafeunsafePerformIOSStrictByteStringPrelude takeWhile dropWhile dropWhileEndbreakspanForeign.Marshal.Allocmalloc useAsCStringuseAsCStringLenempty Foreign.PtrnullPtrGHC.IO.EncodinggetFileSystemEncoding System.IOopenFileData.ByteString.ReadNatData.ByteString.ReadInt:Data.ByteString.Lazy.ReadNatData.ByteString.Lazy.ReadIntPLLazyByteStringsmallChunkSizedefaultChunkSizeSHShortByteStringtoLazyByteStringData.ByteString.Utils.ByteOrder%Data.ByteString.Utils.UnalignedAccess*Data.ByteString.Builder.RealFloat.Internal#Data.ByteString.Builder.Prim.Binary"Data.ByteString.Builder.Prim.ASCII Data.ListunfoldrData.ByteString.Builder.ASCII byteStringHexForeign.C.StringCString%Data.ByteString.Builder.RealFloat.F2S%Data.ByteString.Builder.RealFloat.D2SBlockBufferinghSetBinaryMode hSetBufferinghPut ghc-internalGHC.Internal.ForeignPtrunsafeWithForeignPtrplusForeignPtr BoundedPrim FixedPrimSize>$<>*< fixedPrimsizerunFemptyFpairF contramapFtoBliftFixedToBounded storableToF sizeBound boundedPrim boudedPrimrunB contramapBemptyBpairBeitherBcondBcaseWordSize_32_64$fMonoidalFixedPrim$fContravariantFixedPrim$fMonoidalBoundedPrim$fContravariantBoundedPrimSizeOverflowException ByteStringBSc_sortc_count c_minimum c_maximum c_intersperse c_reversec_strlenPSdeferForeignPtrAvailabilitymkDeferredByteStringfindIndexOrLength packBytes packCharsunsafePackLenBytesunsafePackLenCharsunsafePackAddressunsafePackLenAddressunsafePackLiteralunsafePackLenLiteralpackUptoLenBytespackUptoLenChars unpackBytes unpackCharsunpackAppendBytesLazyunpackAppendCharsLazyunpackAppendBytesStrictunpackAppendCharsStrictnullForeignPtrfromForeignPtrfromForeignPtr0 toForeignPtr toForeignPtr0 unsafeCreateunsafeCreateUptoNunsafeCreateUptoN'create createUptoN createUptoN' createAndTrimcreateAndTrim'mallocByteStringw2cc2w isSpaceWord8 isSpaceChar8 overflowError checkedAddcheckedMultiplyaccursedUnutterablePerformIOmemchrmemcmpmemsetmemcpyc_free_finalizerEmptyChunk invariantcheckInvariantchunk foldrChunks foldlChunks chunkOverhead fromStricttoStrict$fDataByteString$fIsStringByteString$fIsListByteString$fReadByteString$fShowByteString$fNFDataByteString$fMonoidByteString$fSemigroupByteString$fOrdByteString$fEqByteString$fLiftBoxedRepByteStringunShortByteStringSBSlengthnullindex indexMaybe!? unsafeIndextoShort fromShort singletonpackunpackappendconcatsnocconslasttailunconsheadinitunsnocmapreverse intercalatefoldlfoldl'foldrfoldr'foldl1foldl1'foldr1foldr1'allanytaketakeEnd takeWhileEnddropdropEndbreakEndspanEndsplitAtsplit splitWith stripSuffix stripPrefix replicateunfoldrN isInfixOf isPrefixOf isSuffixOfbreakSubstringelemfilterfind partition elemIndex elemIndicescount findIndex findIndices copyToPtr createFromPtr packCStringpackCStringLen isValidUtf8$fIsStringShortByteString$fIsListShortByteString$fReadShortByteString$fShowShortByteString$fMonoidShortByteString$fSemigroupShortByteString$fOrdShortByteString$fEqShortByteString$fLiftBoxedRepShortByteString$fDataShortByteString$fGenericShortByteString$fNFDataShortByteString unsafeHead unsafeTail unsafeInit unsafeLast unsafeTake unsafeDropunsafeFinalizeunsafePackCStringunsafePackMallocCStringunsafePackMallocCStringLenunsafeUseAsCStringunsafeUseAsCStringLen fromFilePath toFilePath intersperse transpose concatMapmaximumminimum mapAccumL mapAccumRscanlscanl1scanrscanr1groupgroupBy elemIndexEnd findIndexEndnotElemzipzipWith packZipWithunzipinitsinitsNEtailstailsNEsortcopygetLinehGetLinehPutNonBlockinghPutStrputStrhGethGetNonBlockinghGetSome hGetContents getContentsinteractreadFile writeFile appendFile readInteger readNaturalreadInt readInt32 readInt16readInt8readWord readWord32 readWord16 readWord8 readInt64 readWord64 fromChunkstoChunkscons' compareLengthiteraterepeatcyclelinesunlineswordsunwords hPutStrLnputStrLn dropSpacestripAllocationStrategyPutBuilder BuildSignal BuildStep ChunkIOStreamFinishedYield1Buffer BufferRange bufferSize newBufferbyteStringFromBufferciosUnitToLazyByteStringciosToLazyByteStringdone bufferFull insertChunkfillWithBuildStepbuilderfinalBuildStep runBuilderrunBuilderWithflushputrunPut putBuilderfromPutputToLazyByteStringputToLazyByteStringWith ensureFreebyteStringThresholdbyteStringCopybyteStringInsertshortByteStringlazyByteStringThresholdlazyByteStringCopylazyByteStringInsert byteStringlazyByteStringmaximalCopySizecustomStrategyuntrimmedStrategy safeStrategytoLazyByteStringWithbuildStepToCIOS$fNFDataBufferRange$fNFDataBuffer$fIsListBuilder$fMonoidBuilder$fSemigroupBuilder $fMonadPut$fApplicativePut $fFunctorPutword8word16BEword16LEword32BEword32LEword64BEword64LEwordHost word16Host word32Host word64Hostint8int16BEint16LEint32BEint32LEint64BEint64LEintHost int16Host int32Host int64HostfloatBEfloatLEdoubleBEdoubleLE floatHost doubleHostint8Decint16Decint32Decint64DecintDecword8Dec word16Dec word32Dec word64DecwordDecword8Hex word16Hex word32Hex word64HexwordHex word8HexFixedword16HexFixedword32HexFixedword64HexFixed int8HexFixed int16HexFixed int32HexFixed int64HexFixed floatHexFixeddoubleHexFixed primFixedprimMapListFixedprimUnfoldrFixedprimMapByteStringFixedprimMapLazyByteStringFixed primBoundedprimMapListBoundedprimUnfoldrBoundedprimMapByteStringBoundedprimMapLazyByteStringBoundedcstring cstringUtf8char8charUtf8 FloatFormatfloatDec doubleDecstandardstandardDefaultPrecision scientificgeneric formatFloat formatDouble$fShowFormatModeNextDoneMore BufferWriterlazyByteStringHex integerDec hPutBuilderstring7string8 stringUtf8 $fShowBuilder$fIsStringBuilderMonoidal ContravariantGHC.Internal.Data.EitherEitherLeftRightGHC.Internal.Data.Maybemaybe EncodingTable lowerTableencode8_as_16hencodeFloatViaWord32Fghc-prim GHC.TypesFloatGHC.Internal.WordWord32encodeDoubleViaWord64FDoubleWord64GHC.Internal.FloatcastDoubleToWord64castFloatToWord32float_pow5_inv_bitcountfloat_pow5_bitcountdouble_pow5_bitcountdouble_pow5_inv_bitcountblenfinvfnorm splitWord128scase128case64double_max_inv_splitdouble_max_splitfloat_max_inv_splitfloat_max_splitWord8GHC.PrimAddr#IOunsafeCreateFpunsafeCreateFpUptoNcreateFpAndTrimcreateFp createFpUptoNGHC.Internal.PtrPtrcreateFpUptoN'eqstimesPolymorphicstimesNonNegativeIntCharcheckedIntegerToInt ghc-bignumGHC.Num.IntegerIntegerIntGHC.Internal.MaybeNothingGHC.Internal.Data.String fromString cIsValidUtf8cIsValidUtf8BAcIsValidUtf8BASafecIsValidUtf8Safe c_count_ba c_elem_index c_int_decc_int_dec_padded9c_long_long_int_decc_long_long_int_dec_padded18c_long_long_uint_decc_long_long_uint_hex c_uint_dec c_uint_hexcreateFpAndTrim'memcpyFpminusForeignPtrpeekFp peekFpByteOffpokeFp pokeFpByteOffunsafeCreateFpUptoN'unsafeDupablePerformIOtimesJustcreateAndTrim2True&GHC.Internal.Foreign.C.String.Encoding CStringLencompareByteArraysOffGHC.Internal.ListGHC.Internal.Data.FoldableallBytesGHC.Internal.IOFilePathanyByte breakBytespanByteGHC.Internal.IO.Handle.TypesHandleGHC.Internal.IO.StdHandlesstdoutGHC.Internal.BaseStringGHC.Internal.IO.Handle.TexthGetBufhGetContentsSizeHintResultGHC.Num.NaturalNaturalsafeLogsafeBase natdigitsGHC.Internal.IntInt32Int16Int8WordWord16Int64_read_digitsOverflow _readDecimalGHC.Internal.RealmoddivsplitAtEndFold hGetContentsNhGetNhGetNonBlockingN GHC.Classesnot breakChar breakSpaceGHC.Internal.ErrerrorMonoidmemptymappendtrimmedChunkFromBufferyield1GHC.Internal.IO.Unsafeap_l<* Applicativeap_r*>>>MonadwrappedBytesCopyStepshortByteStringCopyStepsanitizeGHC.Internal.IsListfromList fromListNwhenLittleEndian whenBigEndian hostByteOrderGHC.Internal.ByteOrder ByteOrder BigEndian LittleEndianunalignedReadU64unalignedWriteDoubleunalignedWriteFloatunalignedWriteU16unalignedWriteU32unalignedWriteU64 BoundsStateMantissaWORD64NonNumbersAndZeromask boolToWord32 boolToWord64 int32ToInt intToInt32 word32ToInt word64ToIntword32ToWord64word64ToWord32decimalLength9decimalLength17pokeAll boundStringmaxEncodedLengthtoCharsNonNumbersAndZero acceptBoundsGHC.Internal.Showshowpow5bitsUnboxedlog10pow2Unboxedlog10pow5Unboxedpow5bits log10pow2 log10pow5fquot10frem10 fquotRem10fquot100 fquotRem10000fquot5frem5dquot10dquot100 dquotRem10000 dquotRem10dquot5drem5 dquotRem5wrapped timesWord2 timesWord2# pow5_factormultipleOfPowerOf5multipleOfPowerOf2 trimTrailingtrimNoTrailingclosestCorrectlyRoundedtoAscii getWord64At getWord128At packWord16 unpackWord16 digit_tableunsafeAt copyWord16poke writeMantissa writeExponent writeSigntoCharsScientificlastRemovedDigitvuvuIsTrailingZerosvvvvIsTrailingZerosvwexponent_all_onemantissa_non_zeronegativeencodeCharUtf8float_pow5_splitfloat_pow5_inv_splitfloat_mantissa_bitsfloat_exponent_bits float_bias mulShift32get_float_pow5_inv_splitget_float_pow5_splitmulPow5InvDivPow2mulPow5DivPow2f2dGTf2dLTf2d breakdownf2s'f2sf2IntermediateFloatingDecimal fexponent fmantissadouble_pow5_splitdouble_pow5_inv_splitdouble_mantissa_bitsdouble_exponent_bits double_bias d2dSmallIntunifySmallTrailing mulShift64get_double_pow5_inv_splitget_double_pow5_splitd2dGTd2dLTd2dd2s'd2sd2Intermediate dexponent dmantissa FormatMode FScientific FStandardFGenericsignGHC.Internal.Num- specialStrdigits showStandardmaxPow10