ʹF      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEuntested experimentaltwanvl@gmail.com6ImperativeLoop with no output KAn imperative loop transforming a string, using an accumulating parameter.  See Data.ByteString.Fusion Type of loop functions &A way to encode characters into bytes 8Given a character returns the length of that character, 2 and a function to write it to a memory buffer. K if the encoding can not represent the character, the io function should fail. %The size needed to store a character +Write a character and return the size used MWrite a character given a pointer to its last byte, and return the size used ARead a character from a memory buffer, return it and its length. : The buffer is guaranteed to contain a valid character. 6Return the length of the character in a memory buffer ARead a character from a memory buffer, return it and its length,  given a pointer to the last byte. : The buffer is guaranteed to contain a valid character. 7Return the length of the character in a memory buffer,  given a pointer to the last byte. ARead a character from a memory buffer, return it and its length. M The buffer is not guaranteed to contain a valid character, so that should V be verified. There is also no guarantee that the length of the buffer (also given) / is sufficient to contain a whole character. CValidate the length, should be used before peekCharSafe is called. D Can be used to remove the number of checks used by peekCharSafe. PCopy a character from one buffer to another, return the length of the character FCopy a character from one buffer to another, where the source pointer - points to the last byte of the character. ' return the length of the character. )Is ASCII a valid subset of the encoding? Is (a == b) == (toBS a == toBS b)? Is (a F b) == (toBS a F toBS b)? Is (a  isSubstringOf b) == (toBS a  isSubstringOf toBS b)? ZWhat is the maximum number of character a string with the given number of bytes contains? [What is the maximum number of bytes a string with the given number of characters contains? KWhat is the maximum size in bytes after transforming (using map) a string? !"#$%1A String using a compact, strict representation.  A CompactString a is encoded using encoding a, for example CompactString UTF8. &'()*+,-.DPerform a function given a pointer to the buffer of a CompactString /UPerform a function given a pointer to the last byte in the buffer of a CompactString 0DPerform a function given a pointer to the buffer of a CompactString 1UPerform a function given a pointer to the last byte in the buffer of a CompactString 23=Safe variant of chr, combined with return; does more checks. 3 At least GHC does not check for surrogate pairs 4(plusPtr that preserves the pointer type 5678BFail with an error message including the module name and function 9IRaise an errorr, with the message including the module name and function :;KCatch exceptions from fail in the IO monad, and wrap them in another monad <KCatch exceptions from fail in the IO monad, and wrap them in another monad G=  !"#$%&'()*+,-./0123456789:;<=%&'$7  !"#+,(*)- ./012345689:;<5   !"#  !"#$%&'&'(*))*+,,-./0123456789:;<untested experimentaltwanvl@gmail.com=KData type for accumulators which can be ignored. The rewrite rules rely on K the fact that no bottoms of this type are ever constructed; hence, we can  assume  (_ :: NoAcc) H x = x. >?HProjection functions that are fusion friendly (as in, we determine when  they are inlined) @ABCDE-Element function implementing a map and fold F/Element function implementing a map with index GH@like loopUp, but the size of the buffer can only become smaller IJKIJ=>?@ABCDEFGHIJK@?=>BACDEFGHIJK=>>?@ABCDEFGHIJKuntested experimentaltwanvl@gmail.comL A variety of K for non-empty CompactString. L omits the G check for the empty case, so there is an obligation on the programmer 9 to provide a proof that the CompactString is non-empty. M A variety of L for non-empty CompactString. M omits the G check for the empty case, so there is an obligation on the programmer 9 to provide a proof that the CompactString is non-empty. N A variety of M for non-empty CompactString. N omits the G check for the empty case, so there is an obligation on the programmer 9 to provide a proof that the CompactString is non-empty. O A variety of N for non-empty CompactString. O omits the G check for the empty case, so there is an obligation on the programmer 9 to provide a proof that the CompactString is non-empty. P)Convert a ByteString to a CompactString, V does not check whether the ByteString represents a valid string in the encoding a. LMNOPLNMOPLMNOPuntested experimentaltwanvl@gmail.com%Q?Tag representing a custom encoding optimized for memory usage. @This encoding looks like UTF-8, but is slightly more efficient. F It requires at most 3 byes per character, as opposed to 4 for UTF-8. Encoding looks like:  ( 0zzzzzzz -> 0zzzzzzz 1 00yyyyyy yzzzzzzz -> 1xxxxxxx 1yyyyyyy : 000xxxxx xxyyyyyy yzzzzzzz -> 1xxxxxxx 0yyyyyyy 1zzzzzzz XThe reasoning behind the tag bits is that this allows the char to be read both forwards  and backwards. RS4Tag representing the ISO 8859-1 encoding (latin 1). TU%Tag representing the ASCII encoding. VW6Tag representing the platform native UTF-32 encoding. XCTag representing the little endian UTF-32 encoding, aka. UTF-32LE. Y@Tag representing the big endian UTF-32 encoding, aka. UTF-32BE. Z%Tag representing the UTF-32 encoding [\6Tag representing the platform native UTF-16 encoding. ]CTag representing the little endian UTF-16 encoding, aka. UTF-16LE. ^@Tag representing the big endian UTF-16 encoding, aka. UTF-16BE. _%Tag representing the UTF-16 encoding `OClass representing endianness P+Read a 16 bit word from the given location Q*Write a 16 bit word to the given location R+Read a 32 bit word from the given location S*Write a 32 bit word to the given location TIs this a big endian encoding aThe platform native endianness b(Tag representing little endian encoding cd%Tag representing big endian encoding ef%Tag representing the UTF-8 encoding.  Use % UTF8 for UTF-8 encoded strings. gU6Length of a character is determined by the first byte V Decode a UTF8 encoded character WXYZ[7Decode an UTF16 surrogate pair, does no error checking \QRSTUVWXYZ[\]^_`abcdefgfgdebca_`^]\Z[YXWUVSTQRQRRSTTUVVWXYZ[[\]^_``abccdeefgguntested experimentaltwanvl@gmail.com]hO(1) The empty % iO(1) Convert a ^ into a % jO(n) Convert a _ into a %. kO(n) Converts a % to a _. lO(1)( Test whether a CompactString is empty. mO(n) m- returns the length of a CompactString as an `. nO(n) n1 is analogous to (:) for lists, but of different & complexity, as it requires a memcpy. oO(n) Append a byte to the end of a % pO(n) Append two CompactStrings qO(1)H Extract the first element of a CompactString, which must be non-empty. D An exception will be thrown in the case of an empty CompactString. rO(1)R Extract the elements after the head of a CompactString, which must be non-empty. D An exception will be thrown in the case of an empty CompactString. sO(1)O Extract the last element of a ByteString, which must be finite and non-empty. A An exception will be thrown in the case of an empty ByteString. tO(1) Return all the elements of a % except the last one. A An exception will be thrown in the case of an empty ByteString. uO(1) A view of the front of a %. @ headView s = if null s then Nothing else Just (head s, tail s) vO(1) A view of the back of a %. @ lastView s = if null s then Nothing else Just (init s, last s) w Reverse a % xO(n) The x function takes a ^ and a  % and ` intersperses'( that character between the elements of  the %2. It is analogous to the intersperse function on  Lists. yThe y1 function transposes the rows and columns of its  % argument. zO(n) z f xs+ is the CompactString obtained by applying f to each  element of xs,. This function is subject to array fusion. {O(n) {, applied to a predicate and a %, F returns a CompactString containing those characters that satisfy the 6 predicate. This function is subject to array fusion. |O(n) |, applied to a predicate and a %, # returns a pair of CompactStrings. C The first containing those characters that satisfy the predicate, # the second containg those that don't. }}<, applied to a binary operator, a starting value (typically F the left-identity of the operator), and a CompactString, reduces the > CompactString using the binary operator, from left to right. + This function is subject to array fusion. ~ 'foldl\'' is like }!, but strict in the accumulator. : Though actually foldl is also strict in the accumulator. 1, applied to a binary operator, a starting value F (typically the right-identity of the operator), and a CompactString, J reduces the CompactString using the binary operator, from right to left. 1, applied to a binary operator, a starting value F (typically the right-identity of the operator), and a CompactString, J reduces the CompactString using the binary operator, from right to left.  is a variant of } that has no starting value 1 argument, and thus must be applied to non-empty %. , This function is subject to array fusion. D An exception will be thrown in the case of an empty CompactString.  'foldl1\'' is like !, but strict in the accumulator. D An exception will be thrown in the case of an empty CompactString.  is a variant of & that has no starting value argument, ' and thus must be applied to non-empty %s D An exception will be thrown in the case of an empty CompactString.  'foldr1\'' is a variant of , but is strict in the  accumulator. D An exception will be thrown in the case of an empty CompactString. O(n) Concatenate a list of %s. Map a function over a % and concatenate the results 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(n)- Applied to a predicate and a CompactString,  determines if  any element of the % satisfies the predicate. O(n)- Applied to a predicate and a CompactString,  determines if  all elements of the % satisfy the predicate. O(n) " returns the maximum value from a % D An exception will be thrown in the case of an empty CompactString. O(n) " returns the minimum value from a % D An exception will be thrown in the case of an empty CompactString.  is similar to }#, but returns a list of successive 8 reduced values from the left. This function will fuse.  B 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.  This function will fuse. 0 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. The ( function behaves like a combination of z and  }<; it applies a function to each element of a CompactString, G passing an accumulating parameter from left to right, and returning a F final value of this accumulator together with the new CompactString. The ( function behaves like a combination of z and  <; it applies a function to each element of a CompactString, G passing an accumulating parameter from right to left, and returning a F final value of this accumulator together with the new CompactString. O(n)? map Char functions, provided with the index at each position. O(n)  n x is a CompactString of length n with x 2 the value of every element. The following holds: 0 replicate w c = unfoldr w (\u -> Just (u,u)) c O(n), where n# is the length of the result. The  # function is analogous to the List 'unfoldr'.  builds a D ByteString from a seed value. The function takes the element and  returns a7 if it is done producing the CompactString or returns  b (a,b), in which case, a" is the next byte in the string,  and b+ is the seed value for further production.  Examples: B 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 C 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(n)  n, applied to a CompactString xs, returns the prefix  of xs of length n, or xs itself if n > m xs. O(n)  n xs returns the suffix of xs after the first n  elements, or empty if n > m xs. O(n)  n xs is equivalent to ( n xs,  n xs). , applied to a predicate p and a CompactString xs, 0 returns the longest prefix (possibly empty) of xs of elements that  satisfy p.  p xs$ returns the suffix remaining after  p xs.  p is equivalent to  (c . p).  p xs0 breaks the ByteString into two segments. It is  equivalent to ( p xs,  p xs)  behaves like  but from the end of the %  breakEnd p == spanEnd (not.p)  behaves like  but from the end of the % We have  / spanEnd (not.isSpace) "x y z" == ("x y ","z") and  spanEnd (not . isSpace) cs  == G let (x,y) = span (not.isSpace) (reverse cs) in (reverse y, reverse x) The  function takes a % and returns a list of J CompactStrings such that the concatenation of the result is equal to the E argument. Moreover, each sublist in the result contains only equal  elements. For example,  < group "Mississippi" = ["M","i","ss","i","ss","i","pp","i"] It is a special case of !, which allows the programmer to ! supply their own equality test. The + function is the non-overloaded version of . O(n)* Return all initial segments of the given %, shortest first. O(n)( Return all final segments of the given %, longest first. 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"] 0 split 'a' "aXaXaXa" == ["","X","X","X",""] $ split 'x' "x" == ["",""] and  ! intercalate [c] . split c == id  split == splitWith . (==) CAs for all splitting functions in this library, this function does 1 not copy the substrings, it just constructs new % that  are slices of the original. O(n) Splits a % into components delimited by G separators, where the predicate returns True for a separator element. G The resulting components do not contain the separators. Two adjacent = separators result in an empty component in the output. eg. 4 splitWith (=='a') "aabbaca" == ["","","bb","c",""] # splitWith (=='a') [] == []  breaks a %% up into a list of CompactStrings at ? newline Chars. The resulting strings do not contain newlines.  is an inverse operation to . It joins lines, 0 after appending a terminating newline to each. 4 breaks a ByteString up into a list of words, which 7 were delimited by Chars representing white space. And 1 words = filter (not . null) . splitWith isSpace The  function is analogous to the  function, on words. O(n) The . function takes two CompactString and returns d * iff the first is a prefix of the second. O(n) The . function takes two CompactString and returns d * iff the first is a suffix of the second. The following holds: 4 isSuffixOf x y == reverse x `isPrefixOf` reverse y 4Check whether one string is a substring of another.  isInfixOf  p s is equivalent to not (null (findSubstrings p s)). String to search for. String to search in. 6Get the first index of a substring in another string,  or a if the string is not found.  findSubstring p s is equivalent to  listToMaybe (findSubstrings p s). String to search for. String to seach in. ?Find the indexes of all (possibly overlapping) occurances of a C substring in a string. This function uses the Knuth-Morris-Pratt  string matching algorithm. String to search for. String to seach in. O(n) %. index (subscript) operator, starting from 0. O(n)  is the % membership predicate. O(n)  is the inverse of  O(n) The ) function returns the index of the first  element in the given  which is equal to the query  element, or a 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 a, if there is no such element. The following  holds:  elemIndexEnd c xs == 5 (-) (length xs - 1) `fmap` elemIndex c (reverse xs) O(n) The  function extends , by returning M the indices of all elements equal to the query element, in ascending order. O(n) The " function takes a predicate and a %, = and returns the first element in matching the predicate, or a  if there is no such element. N find f p = case findIndex f p of Just n -> Just (p `index` n) ; _ -> Nothing The " function takes a predicate and a % and = returns the index of the first element in the CompactString  satisfying the predicate. O(n) The ( function returns the last index of the  element in the given % which satisfies the predicate,  or a3 if there is no such element. The following holds:  findIndexEnd c xs == 5 (-) (length xs - 1) `fmap` findIndex c (reverse xs) The  function extends , by returning the G indices of all elements satisfying the predicate, in ascending order. >count returns the number of times its argument appears in the % " count c = length . elemIndices c O(n) - takes two ByteStrings and returns a list of A corresponding pairs of bytes. If one input ByteString is short, A excess elements of the longer ByteString are discarded. This is  equivalent to a pair of k operations.  generalises ' by zipping with the function given as B the first argument, instead of a tupling function. For example,   (+)6 is applied to two ByteStrings to produce the list of  corresponding sums. A specialised version of  for the common case of a  simultaneous map over two %!s, to build a 3rd. Rewrite rules 6 are used to automatically covert zipWith into zipWith' when a pack is ? performed on the result of zipWith, but we also export it for  convenience. O(n) 4 transforms a list of pairs of bytes into a pair of - CompactStrings. Note that this performs two j operations.  O(n log n) Sort a CompactString =Compare two bytestrings, possibly with a different encoding. ef(Convert a CompactString to a ByteString )Convert a ByteString to a CompactString. : Fails if the ByteString is not a valid encoded string. )Convert a ByteString to a CompactString. D Raises an error if the ByteString is not a valid encoded string. gValidates a CompactString. A If the string is invalid, fails, otherwise returns the input. Validates a CompactString. K If the string is invalid, throws an error, otherwise returns the input. NConvert between two different encodings, fails if conversion is not possible. XConvert between two different encodings, raises an error if conversion is not possible. hrecode =<< validate irecode_ . validate_ AEncode a CompactString to a ByteString using the given encoding.  ( encode e = liftM toByteString . recode ;But it might be faster for some combinations of encodings. AFails if the string is cannot be encoded in the target encoding. AEncode a CompactString to a ByteString using the given encoding.  # encode_ e = toByteString . recode ;But it might be faster for some combinations of encodings. KRaises an error if the string is cannot be encoded in the target encoding. ADecode a ByteString to a CompactString using the given encoding.  & decode e = recode =<< fromByteString ;but it might be faster for some combinations of encodings. 6Fails if the ByteString is not a valid encoded string ; or if the string can not be represented in the encoding a. ADecode a ByteString to a CompactString using the given encoding.  ' decode_ e = recode_ . fromByteString_ ;but it might be faster for some combinations of encodings. @Raises an error if the ByteString is not a valid encoded string ; or if the string can not be represented in the encoding a.  Encode a %6 using the given encoding, and add a Byte Order Mark. G Byte Order Marks are common on Windows, but not on other platforms. AFails if the string is cannot be encoded in the target encoding.  Encode a %6 using the given encoding, and add a Byte Order Mark. G Byte Order Marks are common on Windows, but not on other platforms. KRaises an error if the string is cannot be encoded in the target encoding.  Decode a  into a %(, by investigating the Byte Order Mark. % If there is no BOM assumes UTF-8. 4 Fails if the input is not a valid encoded string ; or if the string can not be represented in the encoding a. 7For portability, this function should be prefered over  decode UTF8 when reading files.  Decode a  into a %(, by investigating the Byte Order Mark. % If there is no BOM assumes UTF-8. > Raises an error if the input is not a valid encoded string ; or if the string can not be represented in the encoding a. 7For portability, this function should be prefered over  decode UTF8 when reading files. jk*Validate encoding, convert to normal form lConvert between encodings m*Validate encoding, convert to normal form E Can be rewritten by rules, in particular: recodeVIO -> validateIO n,Convert between encodings, use peekCharSafe Read a line from stdin. getContents. Equivalent to hGetContents stdin 'Input is assumed to be in the encoding a, this may not be appropriate. Write a % to stdout. "Output is written in the encoding a, this may not be appropriate. Write a %+ to stdout, appending a newline character. "Output is written in the encoding a, this may not be appropriate. /The interact function takes a function of type CompactString -> CompactString L as its argument. The entire input from the standard input device is passed M to this function as its argument, and the resulting string is output on the  standard output device. It''s great for writing one line programs! $Read an entire file strictly into a %. This is far more 0 efficient than reading the characters into a _ and then using  j. Files are read using ' text mode' on Windows. (Files are assumed to be in the encoding a. $Read an entire file strictly into a %. This is far more 0 efficient than reading the characters into a _ and then using  j. Files are read using ' text mode' on Windows. GThe encoding of the file is determined based on a Byte Order Mark, see . Write a % to a file. %Files are written using the encoding a. Write a % to a file. %Files are written using the encoding a. & A Byte Order Mark is also written.  Append a % to a file. %Files are written using the encoding a.  Append a % to a file. CThe encoding of the file is determined based on a Byte Order Mark. : If the file is empty, it is written using the encoding a with a Byte Order Mark. J If the encoding can not be determined the file is assumed to be UTF-8. o Append a  to a file. / appendFile :: FilePath -> ByteString -> IO () Q TODO : Determine encoding used by the file, then append using the same encoding pMDetermine the encoding to use for a handle by examining the Byte Order Mark. = The handle should be positioned at the start of the file. Read a line from a handle #Read entire handle contents into a %. *The handle is interpreted as the encoding a. #Read entire handle contents into a %. ;The encoding is determined based on a Byte Order Mark, see . Read a % directly from the specified q. *The handle is interpreted as the encoding a.  hGetNonBlocking is identical to ", except that it will never block M waiting for data to become available, instead it returns only whatever data  is available. *The handle is interpreted as the encoding a.  Outputs a % to the specified q. "Output is written in the encoding a. A synonym for hPut, for compatibility Write a %' to a handle, appending a newline byte "Output is written in the encoding a. rCFind the byte position corresponding to the given character index,  the index must be positive. ss4 is a variant of findIndex, that returns the length E in bytes of the string if no element is found, rather than Nothing. tt/ is a variant of findIndexOrEnd, that searches ( from the end instead of from the start %QRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~{ %hijknopqsrtuvlmzwxy}~{|yhijklmnopqrstuvwxyz{|}~untested experimentaltwanvl@gmail.comw$CompactString specialized to ASCII. O(1) The empty  O(1) Convert a ^ into a  O(n) Convert a _ into a . O(n) Converts a  to a _. O(n) 1 is analogous to (:) for lists, but of different & complexity, as it requires a memcpy. O(n) Append a byte to the end of a  O(n) Append two CompactStrings O(1)H Extract the first element of a CompactString, which must be non-empty. D An exception will be thrown in the case of an empty CompactString. O(1)O Extract the last element of a ByteString, which must be finite and non-empty. A An exception will be thrown in the case of an empty ByteString. O(1)R Extract the elements after the head of a CompactString, which must be non-empty. D An exception will be thrown in the case of an empty CompactString. O(1) Return all the elements of a  except the last one. A An exception will be thrown in the case of an empty ByteString. O(1) A view of the front of a . @ headView s = if null s then Nothing else Just (head s, tail s) O(1) A view of the back of a . @ lastView s = if null s then Nothing else Just (init s, last s) O(1)( Test whether a CompactString is empty. O(n) - returns the length of a CompactString as an `. O(n)  f xs+ is the CompactString obtained by applying f to each  element of xs,. This function is subject to array fusion.  Reverse a  O(n) The  function takes a ^ and a   and ` intersperses'( that character between the elements of  the 2. It is analogous to the intersperse function on  Lists. 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. The 1 function transposes the rows and columns of its   argument. <, applied to a binary operator, a starting value (typically F the left-identity of the operator), and a CompactString, reduces the > CompactString using the binary operator, from left to right. + This function is subject to array fusion.  'foldl\'' is like !, but strict in the accumulator. : Though actually foldl is also strict in the accumulator.  is a variant of  that has no starting value 1 argument, and thus must be applied to non-empty . , This function is subject to array fusion. D An exception will be thrown in the case of an empty CompactString.  'foldl1\'' is like !, but strict in the accumulator. D An exception will be thrown in the case of an empty CompactString. 1, applied to a binary operator, a starting value F (typically the right-identity of the operator), and a CompactString, J reduces the CompactString using the binary operator, from right to left. 1, applied to a binary operator, a starting value F (typically the right-identity of the operator), and a CompactString, J reduces the CompactString using the binary operator, from right to left.  is a variant of & that has no starting value argument, ' and thus must be applied to non-empty s D An exception will be thrown in the case of an empty CompactString.  'foldr1\'' is a variant of , but is strict in the  accumulator. D An exception will be thrown in the case of an empty CompactString. O(n) Concatenate a list of s. Map a function over a  and concatenate the results O(n)- Applied to a predicate and a CompactString,  determines if  any element of the  satisfies the predicate. O(n)- Applied to a predicate and a CompactString,  determines if  all elements of the  satisfy the predicate. O(n) " returns the maximum value from a  D An exception will be thrown in the case of an empty CompactString. O(n) " returns the minimum value from a  D An exception will be thrown in the case of an empty CompactString.  is similar to #, but returns a list of successive 8 reduced values from the left. This function will fuse.  B 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.  This function will fuse. 0 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. The ( function behaves like a combination of  and  <; it applies a function to each element of a CompactString, G passing an accumulating parameter from left to right, and returning a F final value of this accumulator together with the new CompactString.  The  ( function behaves like a combination of  and  <; it applies a function to each element of a CompactString, G passing an accumulating parameter from right to left, and returning a F final value of this accumulator together with the new CompactString.  O(n)? map Char functions, provided with the index at each position.  O(n)   n x is a CompactString of length n with x 2 the value of every element. The following holds: 0 replicate w c = unfoldr w (\u -> Just (u,u)) c  O(n), where n# is the length of the result. The   # function is analogous to the List 'unfoldr'.   builds a D ByteString from a seed value. The function takes the element and  returns a7 if it is done producing the CompactString or returns  b (a,b), in which case, a" is the next byte in the string,  and b+ is the seed value for further production.  Examples: B 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 C 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(n)  n, applied to a CompactString xs, returns the prefix  of xs of length n, or xs itself if n >  xs. O(n)  n xs returns the suffix of xs after the first n  elements, or empty if n >  xs. O(n)  n xs is equivalent to ( n xs,  n xs). , applied to a predicate p and a CompactString xs, 0 returns the longest prefix (possibly empty) of xs of elements that  satisfy p.  p xs$ returns the suffix remaining after  p xs.  p xs0 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) cs  == G let (x,y) = span (not.isSpace) (reverse cs) in (reverse y, reverse x)  p is equivalent to  (c . p).  behaves like  but from the end of the   breakEnd p == spanEnd (not.p) The  function takes a  and returns a list of J CompactStrings such that the concatenation of the result is equal to the E argument. Moreover, each sublist in the result contains only equal  elements. For example,  < group "Mississippi" = ["M","i","ss","i","ss","i","pp","i"] It is a special case of !, which allows the programmer to ! supply their own equality test. The + function is the non-overloaded version of . O(n)* Return all initial segments of the given , shortest first. O(n)( Return all final segments of the given , longest first. 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"] 0 split 'a' "aXaXaXa" == ["","X","X","X",""] $ split 'x' "x" == ["",""] and  ! intercalate [c] . split c == id  split == splitWith . (==) CAs for all splitting functions in this library, this function does 1 not copy the substrings, it just constructs new  that  are slices of the original. O(n) Splits a  into components delimited by G separators, where the predicate returns True for a separator element. G The resulting components do not contain the separators. Two adjacent = separators result in an empty component in the output. eg. 4 splitWith (=='a') "aabbaca" == ["","","bb","c",""] # splitWith (=='a') [] == []  breaks a % up into a list of CompactStrings at ? newline Chars. The resulting strings do not contain newlines.  is an inverse operation to . It joins lines, 0 after appending a terminating newline to each. 4 breaks a ByteString up into a list of words, which 7 were delimited by Chars representing white space. And 1 words = filter (not . null) . splitWith isSpace  The   function is analogous to the  function, on words. !O(n) The !. function takes two CompactString and returns d * iff the first is a prefix of the second. "O(n) The ". function takes two CompactString and returns d * iff the first is a suffix of the second. The following holds: 4 isSuffixOf x y == reverse x `isPrefixOf` reverse y #4Check whether one string is a substring of another.  isInfixOf  p s is equivalent to not (null (findSubstrings p s)). String to search for. String to search in. $6Get the first index of a substring in another string,  or a if the string is not found.  findSubstring p s is equivalent to  listToMaybe (findSubstrings p s). String to search for. String to seach in. %?Find the indexes of all (possibly overlapping) occurances of a C substring in a string. This function uses the Knuth-Morris-Pratt  string matching algorithm. String to search for. String to seach in. &O(n) & is the  membership predicate. 'O(n) ' is the inverse of & (O(n) The (" function takes a predicate and a , = and returns the first element in matching the predicate, or a  if there is no such element. N find f p = case findIndex f p of Just n -> Just (p `index` n) ; _ -> Nothing )O(n) ), applied to a predicate and a , F returns a CompactString containing those characters that satisfy the 6 predicate. This function is subject to array fusion. *O(n) *, applied to a predicate and a , # returns a pair of CompactStrings. C The first containing those characters that satisfy the predicate, # the second containg those that don't. +O(n) . index (subscript) operator, starting from 0. ,O(n) The ,) function returns the index of the first  element in the given  which is equal to the query  element, or a if there is no such element. -O(n) The - function extends ,, by returning M the indices of all elements equal to the query element, in ascending order. .O(n) The .( function returns the last index of the  element in the given  which is equal to the query  element, or a, if there is no such element. The following  holds:  elemIndexEnd c xs == 5 (-) (length xs - 1) `fmap` elemIndex c (reverse xs) /The /" function takes a predicate and a  and = returns the index of the first element in the CompactString  satisfying the predicate. 0O(n) The 0( function returns the last index of the  element in the given  which satisfies the predicate,  or a3 if there is no such element. The following holds:  findIndexEnd c xs == 5 (-) (length xs - 1) `fmap` findIndex c (reverse xs) 1The 1 function extends /, by returning the G indices of all elements satisfying the predicate, in ascending order. 2>count returns the number of times its argument appears in the  " count c = length . elemIndices c 3O(n) 3- takes two ByteStrings and returns a list of A corresponding pairs of bytes. If one input ByteString is short, A excess elements of the longer ByteString are discarded. This is  equivalent to a pair of  operations. 44 generalises 3' by zipping with the function given as B the first argument, instead of a tupling function. For example,  4 (+)6 is applied to two ByteStrings to produce the list of  corresponding sums. 5A specialised version of 4 for the common case of a  simultaneous map over two !s, to build a 3rd. Rewrite rules 6 are used to automatically covert zipWith into zipWith' when a pack is ? performed on the result of zipWith, but we also export it for  convenience. 6O(n) 64 transforms a list of pairs of bytes into a pair of - CompactStrings. Note that this performs two  operations. 7 O(n log n) Sort a CompactString 8(Convert a CompactString to a ByteString 9)Convert a ByteString to a CompactString. : Fails if the ByteString is not a valid encoded string. :)Convert a ByteString to a CompactString. D Raises an error if the ByteString is not a valid encoded string. ;Validates a CompactString. A If the string is invalid, fails, otherwise returns the input. <Validates a CompactString. K If the string is invalid, throws an error, otherwise returns the input. =AEncode a CompactString to a ByteString using the given encoding.  ( encode e = liftM toByteString . recode ;But it might be faster for some combinations of encodings. AFails if the string is cannot be encoded in the target encoding. >AEncode a CompactString to a ByteString using the given encoding.  # encode_ e = toByteString . recode ;But it might be faster for some combinations of encodings. KRaises an error if the string is cannot be encoded in the target encoding. ?ADecode a ByteString to a CompactString using the given encoding.  & decode e = recode =<< fromByteString ;but it might be faster for some combinations of encodings. 6Fails if the ByteString is not a valid encoded string 5 or if the string can not be represented in ASCII. @ADecode a ByteString to a CompactString using the given encoding.  ' decode_ e = recode_ . fromByteString_ ;but it might be faster for some combinations of encodings. @Raises an error if the ByteString is not a valid encoded string 5 or if the string can not be represented in ASCII. A Encode a 6 using the given encoding, and add a Byte Order Mark. G Byte Order Marks are common on Windows, but not on other platforms. AFails if the string is cannot be encoded in the target encoding. B Encode a 6 using the given encoding, and add a Byte Order Mark. G Byte Order Marks are common on Windows, but not on other platforms. KRaises an error if the string is cannot be encoded in the target encoding. C Decode a  into a (, by investigating the Byte Order Mark. % If there is no BOM assumes UTF-8. 4 Fails if the input is not a valid encoded string 5 or if the string can not be represented in ASCII. 7For portability, this function should be prefered over  decode UTF8 when reading files. D Decode a  into a (, by investigating the Byte Order Mark. % If there is no BOM assumes UTF-8. > Raises an error if the input is not a valid encoded string 5 or if the string can not be represented in ASCII. 7For portability, this function should be prefered over  decode UTF8 when reading files. ERead a line from stdin. FgetContents. Equivalent to hGetContents stdin >Input is assumed to be in ASCII, this may not be appropriate. GWrite a  to stdout. 9Output is written in ASCII, this may not be appropriate. HWrite a + to stdout, appending a newline character. 9Output is written in ASCII, this may not be appropriate. I/The interact function takes a function of type CompactString -> CompactString L as its argument. The entire input from the standard input device is passed M to this function as its argument, and the resulting string is output on the  standard output device. It''s great for writing one line programs! J$Read an entire file strictly into a . This is far more 0 efficient than reading the characters into a _ and then using  . Files are read using ' text mode' on Windows. "Files are assumed to be in ASCII. K$Read an entire file strictly into a . This is far more 0 efficient than reading the characters into a _ and then using  . Files are read using ' text mode' on Windows. GThe encoding of the file is determined based on a Byte Order Mark, see C. LWrite a  to a file. Files are written using ASCII. MWrite a  to a file. Files are written using ASCII. & A Byte Order Mark is also written. N Append a  to a file. Files are written using ASCII. O Append a  to a file. CThe encoding of the file is determined based on a Byte Order Mark. K If the file is empty, it is written using ASCII with a Byte Order Mark. J If the encoding can not be determined the file is assumed to be UTF-8. PRead a line from a handle Q#Read entire handle contents into a . $The handle is interpreted as ASCII. R#Read entire handle contents into a . ;The encoding is determined based on a Byte Order Mark, see C. SRead a  directly from the specified q. $The handle is interpreted as ASCII. T hGetNonBlocking is identical to S", except that it will never block M waiting for data to become available, instead it returns only whatever data  is available. $The handle is interpreted as ASCII. U Outputs a  to the specified q. Output is written in ASCII. VA synonym for hPut, for compatibility WWrite a ' to a handle, appending a newline byte Output is written in ASCII. w      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWw      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWw      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWuntested experimentaltwanvl@gmail.comwX%CompactString specialized to UTF-16. YO(1) The empty X ZO(1) Convert a ^ into a X [O(n) Convert a _ into a X. \O(n) Converts a X to a _. ]O(n) ]1 is analogous to (:) for lists, but of different & complexity, as it requires a memcpy. ^O(n) Append a byte to the end of a X _O(n) Append two CompactStrings `O(1)H Extract the first element of a CompactString, which must be non-empty. D An exception will be thrown in the case of an empty CompactString. aO(1)O Extract the last element of a ByteString, which must be finite and non-empty. A An exception will be thrown in the case of an empty ByteString. bO(1)R Extract the elements after the head of a CompactString, which must be non-empty. D An exception will be thrown in the case of an empty CompactString. cO(1) Return all the elements of a X except the last one. A An exception will be thrown in the case of an empty ByteString. dO(1) A view of the front of a X. @ headView s = if null s then Nothing else Just (head s, tail s) eO(1) A view of the back of a X. @ lastView s = if null s then Nothing else Just (init s, last s) fO(1)( Test whether a CompactString is empty. gO(n) g- returns the length of a CompactString as an `. hO(n) h f xs+ is the CompactString obtained by applying f to each  element of xs,. This function is subject to array fusion. i Reverse a X jO(n) The j function takes a ^ and a  X and ` intersperses'( that character between the elements of  the X2. It is analogous to the intersperse function on  Lists. kO(n) The k function takes a X and a list of  X:s and concatenates the list after interspersing the first , argument between each element of the list. lThe l1 function transposes the rows and columns of its  X argument. mm<, applied to a binary operator, a starting value (typically F the left-identity of the operator), and a CompactString, reduces the > CompactString using the binary operator, from left to right. + This function is subject to array fusion. n 'foldl\'' is like m!, but strict in the accumulator. : Though actually foldl is also strict in the accumulator. oo is a variant of m that has no starting value 1 argument, and thus must be applied to non-empty X. , This function is subject to array fusion. D An exception will be thrown in the case of an empty CompactString. p 'foldl1\'' is like o!, but strict in the accumulator. D An exception will be thrown in the case of an empty CompactString. qq1, applied to a binary operator, a starting value F (typically the right-identity of the operator), and a CompactString, J reduces the CompactString using the binary operator, from right to left. rq1, applied to a binary operator, a starting value F (typically the right-identity of the operator), and a CompactString, J reduces the CompactString using the binary operator, from right to left. ss is a variant of q& that has no starting value argument, ' and thus must be applied to non-empty Xs D An exception will be thrown in the case of an empty CompactString. t 'foldr1\'' is a variant of s, but is strict in the  accumulator. D An exception will be thrown in the case of an empty CompactString. uO(n) Concatenate a list of Xs. vMap a function over a X and concatenate the results wO(n)- Applied to a predicate and a CompactString, w determines if  any element of the X satisfies the predicate. xO(n)- Applied to a predicate and a CompactString, w determines if  all elements of the X satisfy the predicate. yO(n) y" returns the maximum value from a X D An exception will be thrown in the case of an empty CompactString. zO(n) z" returns the minimum value from a X D An exception will be thrown in the case of an empty CompactString. {{ is similar to m#, but returns a list of successive 8 reduced values from the left. This function will fuse.  B 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.  This function will fuse. 0 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. The ( function behaves like a combination of h and  m<; it applies a function to each element of a CompactString, G passing an accumulating parameter from left to right, and returning a F final value of this accumulator together with the new CompactString. The ( function behaves like a combination of h and  q<; it applies a function to each element of a CompactString, G passing an accumulating parameter from right to left, and returning a F final value of this accumulator together with the new CompactString. O(n)? map Char functions, provided with the index at each position. O(n)  n x is a CompactString of length n with x 2 the value of every element. The following holds: 0 replicate w c = unfoldr w (\u -> Just (u,u)) c O(n), where n# is the length of the result. The  # function is analogous to the List 'unfoldr'.  builds a D ByteString from a seed value. The function takes the element and  returns a7 if it is done producing the CompactString or returns  b (a,b), in which case, a" is the next byte in the string,  and b+ is the seed value for further production.  Examples: B 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 C 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(n)  n, applied to a CompactString xs, returns the prefix  of xs of length n, or xs itself if n > g xs. O(n)  n xs returns the suffix of xs after the first n  elements, or empty if n > g xs. O(n)  n xs is equivalent to ( n xs,  n xs). , applied to a predicate p and a CompactString xs, 0 returns the longest prefix (possibly empty) of xs of elements that  satisfy p.  p xs$ returns the suffix remaining after  p xs.  p xs0 breaks the ByteString into two segments. It is  equivalent to ( p xs,  p xs)  behaves like  but from the end of the X We have  / spanEnd (not.isSpace) "x y z" == ("x y ","z") and  spanEnd (not . isSpace) cs  == G let (x,y) = span (not.isSpace) (reverse cs) in (reverse y, reverse x)  p is equivalent to  (c . p).  behaves like  but from the end of the X  breakEnd p == spanEnd (not.p) The  function takes a X and returns a list of J CompactStrings such that the concatenation of the result is equal to the E argument. Moreover, each sublist in the result contains only equal  elements. For example,  < group "Mississippi" = ["M","i","ss","i","ss","i","pp","i"] It is a special case of !, which allows the programmer to ! supply their own equality test. The + function is the non-overloaded version of . O(n)* Return all initial segments of the given X, shortest first. O(n)( Return all final segments of the given X, longest first. 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"] 0 split 'a' "aXaXaXa" == ["","X","X","X",""] $ split 'x' "x" == ["",""] and  ! intercalate [c] . split c == id  split == splitWith . (==) CAs for all splitting functions in this library, this function does 1 not copy the substrings, it just constructs new X that  are slices of the original. O(n) Splits a X into components delimited by G separators, where the predicate returns True for a separator element. G The resulting components do not contain the separators. Two adjacent = separators result in an empty component in the output. eg. 4 splitWith (=='a') "aabbaca" == ["","","bb","c",""] # splitWith (=='a') [] == []  breaks a X% up into a list of CompactStrings at ? newline Chars. The resulting strings do not contain newlines.  is an inverse operation to . It joins lines, 0 after appending a terminating newline to each. 4 breaks a ByteString up into a list of words, which 7 were delimited by Chars representing white space. And 1 words = filter (not . null) . splitWith isSpace The  function is analogous to the  function, on words. O(n) The . function takes two CompactString and returns d * iff the first is a prefix of the second. O(n) The . function takes two CompactString and returns d * iff the first is a suffix of the second. The following holds: 4 isSuffixOf x y == reverse x `isPrefixOf` reverse y 4Check whether one string is a substring of another.  isInfixOf  p s is equivalent to not (null (findSubstrings p s)). String to search for. String to search in. 6Get the first index of a substring in another string,  or a if the string is not found.  findSubstring p s is equivalent to  listToMaybe (findSubstrings p s). String to search for. String to seach in. ?Find the indexes of all (possibly overlapping) occurances of a C substring in a string. This function uses the Knuth-Morris-Pratt  string matching algorithm. String to search for. String to seach in. O(n)  is the X membership predicate. O(n)  is the inverse of  O(n) The " function takes a predicate and a X, = and returns the first element in matching the predicate, or a  if there is no such element. N find f p = case findIndex f p of Just n -> Just (p `index` n) ; _ -> Nothing O(n) , applied to a predicate and a X, F returns a CompactString containing those characters that satisfy the 6 predicate. This function is subject to array fusion. O(n) , applied to a predicate and a X, # returns a pair of CompactStrings. C The first containing those characters that satisfy the predicate, # the second containg those that don't. O(n) X. index (subscript) operator, starting from 0. O(n) The ) function returns the index of the first  element in the given  which is equal to the query  element, or a if there is no such element. O(n) The  function extends , by returning M the indices of all elements equal to the query element, in ascending order. O(n) The ( function returns the last index of the  element in the given X which is equal to the query  element, or a, if there is no such element. The following  holds:  elemIndexEnd c xs == 5 (-) (length xs - 1) `fmap` elemIndex c (reverse xs) The " function takes a predicate and a X and = returns the index of the first element in the CompactString  satisfying the predicate. O(n) The ( function returns the last index of the  element in the given X which satisfies the predicate,  or a3 if there is no such element. The following holds:  findIndexEnd c xs == 5 (-) (length xs - 1) `fmap` findIndex c (reverse xs) The  function extends , by returning the G indices of all elements satisfying the predicate, in ascending order. >count returns the number of times its argument appears in the X " count c = length . elemIndices c O(n) - takes two ByteStrings and returns a list of A corresponding pairs of bytes. If one input ByteString is short, A excess elements of the longer ByteString are discarded. This is  equivalent to a pair of \ operations.  generalises ' by zipping with the function given as B the first argument, instead of a tupling function. For example,   (+)6 is applied to two ByteStrings to produce the list of  corresponding sums. A specialised version of  for the common case of a  simultaneous map over two X!s, to build a 3rd. Rewrite rules 6 are used to automatically covert zipWith into zipWith' when a pack is ? performed on the result of zipWith, but we also export it for  convenience. O(n) 4 transforms a list of pairs of bytes into a pair of - CompactStrings. Note that this performs two [ operations.  O(n log n) Sort a CompactString (Convert a CompactString to a ByteString )Convert a ByteString to a CompactString. : Fails if the ByteString is not a valid encoded string. )Convert a ByteString to a CompactString. D Raises an error if the ByteString is not a valid encoded string. Validates a CompactString. A If the string is invalid, fails, otherwise returns the input. Validates a CompactString. K If the string is invalid, throws an error, otherwise returns the input. AEncode a CompactString to a ByteString using the given encoding.  ( encode e = liftM toByteString . recode ;But it might be faster for some combinations of encodings. AFails if the string is cannot be encoded in the target encoding. AEncode a CompactString to a ByteString using the given encoding.  # encode_ e = toByteString . recode ;But it might be faster for some combinations of encodings. KRaises an error if the string is cannot be encoded in the target encoding. ADecode a ByteString to a CompactString using the given encoding.  & decode e = recode =<< fromByteString ;but it might be faster for some combinations of encodings. 6Fails if the ByteString is not a valid encoded string ADecode a ByteString to a CompactString using the given encoding.  ' decode_ e = recode_ . fromByteString_ ;but it might be faster for some combinations of encodings. @Raises an error if the ByteString is not a valid encoded string  Encode a X6 using the given encoding, and add a Byte Order Mark. G Byte Order Marks are common on Windows, but not on other platforms. AFails if the string is cannot be encoded in the target encoding.  Encode a X6 using the given encoding, and add a Byte Order Mark. G Byte Order Marks are common on Windows, but not on other platforms. KRaises an error if the string is cannot be encoded in the target encoding.  Decode a  into a X(, by investigating the Byte Order Mark. % If there is no BOM assumes UTF-8. 4 Fails if the input is not a valid encoded string 7For portability, this function should be prefered over  decode UTF8 when reading files.  Decode a  into a X(, by investigating the Byte Order Mark. % If there is no BOM assumes UTF-8. > Raises an error if the input is not a valid encoded string 7For portability, this function should be prefered over  decode UTF8 when reading files. Read a line from stdin. getContents. Equivalent to hGetContents stdin ?Input is assumed to be in UTF-16, this may not be appropriate. Write a X to stdout. :Output is written in UTF-16, this may not be appropriate. Write a X+ to stdout, appending a newline character. :Output is written in UTF-16, this may not be appropriate. /The interact function takes a function of type CompactString -> CompactString L as its argument. The entire input from the standard input device is passed M to this function as its argument, and the resulting string is output on the  standard output device. It''s great for writing one line programs! $Read an entire file strictly into a X. This is far more 0 efficient than reading the characters into a _ and then using  [. Files are read using ' text mode' on Windows. #Files are assumed to be in UTF-16. $Read an entire file strictly into a X. This is far more 0 efficient than reading the characters into a _ and then using  [. Files are read using ' text mode' on Windows. GThe encoding of the file is determined based on a Byte Order Mark, see . Write a X to a file.  Files are written using UTF-16. Write a X to a file.  Files are written using UTF-16. & A Byte Order Mark is also written.  Append a X to a file.  Files are written using UTF-16.  Append a X to a file. CThe encoding of the file is determined based on a Byte Order Mark. L If the file is empty, it is written using UTF-16 with a Byte Order Mark. J If the encoding can not be determined the file is assumed to be UTF-8. Read a line from a handle #Read entire handle contents into a X. %The handle is interpreted as UTF-16. #Read entire handle contents into a X. ;The encoding is determined based on a Byte Order Mark, see . Read a X directly from the specified q. %The handle is interpreted as UTF-16.  hGetNonBlocking is identical to ", except that it will never block M waiting for data to become available, instead it returns only whatever data  is available. %The handle is interpreted as UTF-16.  Outputs a X to the specified q. Output is written in UTF-16. A synonym for hPut, for compatibility Write a X' to a handle, appending a newline byte Output is written in UTF-16. wXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~wXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~wXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~untested experimentaltwanvl@gmail.comw$CompactString specialized to UTF-8. O(1) The empty  O(1) Convert a ^ into a  O(n) Convert a _ into a . O(n) Converts a  to a _. O(n) 1 is analogous to (:) for lists, but of different & complexity, as it requires a memcpy. O(n) Append a byte to the end of a  O(n) Append two CompactStrings O(1)H Extract the first element of a CompactString, which must be non-empty. D An exception will be thrown in the case of an empty CompactString. O(1)O Extract the last element of a ByteString, which must be finite and non-empty. A An exception will be thrown in the case of an empty ByteString. O(1)R Extract the elements after the head of a CompactString, which must be non-empty. D An exception will be thrown in the case of an empty CompactString. O(1) Return all the elements of a  except the last one. A An exception will be thrown in the case of an empty ByteString. O(1) A view of the front of a . @ headView s = if null s then Nothing else Just (head s, tail s) O(1) A view of the back of a . @ lastView s = if null s then Nothing else Just (init s, last s) O(1)( Test whether a CompactString is empty. O(n) - returns the length of a CompactString as an `. O(n)  f xs+ is the CompactString obtained by applying f to each  element of xs,. This function is subject to array fusion.  Reverse a  O(n) The  function takes a ^ and a   and ` intersperses'( that character between the elements of  the 2. It is analogous to the intersperse function on  Lists. 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. The 1 function transposes the rows and columns of its   argument. <, applied to a binary operator, a starting value (typically F the left-identity of the operator), and a CompactString, reduces the > CompactString using the binary operator, from left to right. + This function is subject to array fusion.  'foldl\'' is like !, but strict in the accumulator. : Though actually foldl is also strict in the accumulator.  is a variant of  that has no starting value 1 argument, and thus must be applied to non-empty . , This function is subject to array fusion. D An exception will be thrown in the case of an empty CompactString.  'foldl1\'' is like !, but strict in the accumulator. D An exception will be thrown in the case of an empty CompactString. 1, applied to a binary operator, a starting value F (typically the right-identity of the operator), and a CompactString, J reduces the CompactString using the binary operator, from right to left. 1, applied to a binary operator, a starting value F (typically the right-identity of the operator), and a CompactString, J reduces the CompactString using the binary operator, from right to left.  is a variant of & that has no starting value argument, ' and thus must be applied to non-empty s D An exception will be thrown in the case of an empty CompactString.  'foldr1\'' is a variant of , but is strict in the  accumulator. D An exception will be thrown in the case of an empty CompactString. O(n) Concatenate a list of s. Map a function over a  and concatenate the results O(n)- Applied to a predicate and a CompactString,  determines if  any element of the  satisfies the predicate. O(n)- Applied to a predicate and a CompactString,  determines if  all elements of the  satisfy the predicate. O(n) " returns the maximum value from a  D An exception will be thrown in the case of an empty CompactString. O(n) " returns the minimum value from a  D An exception will be thrown in the case of an empty CompactString.  is similar to #, but returns a list of successive 8 reduced values from the left. This function will fuse.  B 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.  This function will fuse. 0 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. The ( function behaves like a combination of  and  <; it applies a function to each element of a CompactString, G passing an accumulating parameter from left to right, and returning a F final value of this accumulator together with the new CompactString. The ( function behaves like a combination of  and  <; it applies a function to each element of a CompactString, G passing an accumulating parameter from right to left, and returning a F final value of this accumulator together with the new CompactString. O(n)? map Char functions, provided with the index at each position. O(n)  n x is a CompactString of length n with x 2 the value of every element. The following holds: 0 replicate w c = unfoldr w (\u -> Just (u,u)) c O(n), where n# is the length of the result. The  # function is analogous to the List 'unfoldr'.  builds a D ByteString from a seed value. The function takes the element and  returns a7 if it is done producing the CompactString or returns  b (a,b), in which case, a" is the next byte in the string,  and b+ is the seed value for further production.  Examples: B 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 C 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(n)  n, applied to a CompactString xs, returns the prefix  of xs of length n, or xs itself if n >  xs. O(n)  n xs returns the suffix of xs after the first n  elements, or empty if n >  xs. O(n)  n xs is equivalent to ( n xs,  n xs). , applied to a predicate p and a CompactString xs, 0 returns the longest prefix (possibly empty) of xs of elements that  satisfy p.  p xs$ returns the suffix remaining after  p xs.  p xs0 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) cs  == G let (x,y) = span (not.isSpace) (reverse cs) in (reverse y, reverse x)  p is equivalent to  (c . p).  behaves like  but from the end of the   breakEnd p == spanEnd (not.p) The  function takes a  and returns a list of J CompactStrings such that the concatenation of the result is equal to the E argument. Moreover, each sublist in the result contains only equal  elements. For example,  < group "Mississippi" = ["M","i","ss","i","ss","i","pp","i"] It is a special case of !, which allows the programmer to ! supply their own equality test. The + function is the non-overloaded version of . O(n)* Return all initial segments of the given , shortest first. O(n)( Return all final segments of the given , longest first.  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"] 0 split 'a' "aXaXaXa" == ["","X","X","X",""] $ split 'x' "x" == ["",""] and  ! intercalate [c] . split c == id  split == splitWith . (==) CAs for all splitting functions in this library, this function does 1 not copy the substrings, it just constructs new  that  are slices of the original.  O(n) Splits a  into components delimited by G separators, where the predicate returns True for a separator element. G The resulting components do not contain the separators. Two adjacent = separators result in an empty component in the output. eg. 4 splitWith (=='a') "aabbaca" == ["","","bb","c",""] # splitWith (=='a') [] == []    breaks a % up into a list of CompactStrings at ? newline Chars. The resulting strings do not contain newlines.    is an inverse operation to  . It joins lines, 0 after appending a terminating newline to each.   4 breaks a ByteString up into a list of words, which 7 were delimited by Chars representing white space. And 1 words = filter (not . null) . splitWith isSpace The  function is analogous to the   function, on words. O(n) The . function takes two CompactString and returns d * iff the first is a prefix of the second. O(n) The . function takes two CompactString and returns d * iff the first is a suffix of the second. The following holds: 4 isSuffixOf x y == reverse x `isPrefixOf` reverse y 4Check whether one string is a substring of another.  isInfixOf  p s is equivalent to not (null (findSubstrings p s)). String to search for. String to search in. 6Get the first index of a substring in another string,  or a if the string is not found.  findSubstring p s is equivalent to  listToMaybe (findSubstrings p s). String to search for. String to seach in. ?Find the indexes of all (possibly overlapping) occurances of a C substring in a string. This function uses the Knuth-Morris-Pratt  string matching algorithm. String to search for. String to seach in. O(n)  is the  membership predicate. O(n)  is the inverse of  O(n) The " function takes a predicate and a , = and returns the first element in matching the predicate, or a  if there is no such element. N find f p = case findIndex f p of Just n -> Just (p `index` n) ; _ -> Nothing O(n) , applied to a predicate and a , F returns a CompactString containing those characters that satisfy the 6 predicate. This function is subject to array fusion. O(n) , applied to a predicate and a , # returns a pair of CompactStrings. C The first containing those characters that satisfy the predicate, # the second containg those that don't. O(n) . index (subscript) operator, starting from 0. O(n) The ) function returns the index of the first  element in the given  which is equal to the query  element, or a if there is no such element. O(n) The  function extends , by returning M the indices of all elements equal to the query element, in ascending order. O(n) The ( function returns the last index of the  element in the given  which is equal to the query  element, or a, if there is no such element. The following  holds:  elemIndexEnd c xs == 5 (-) (length xs - 1) `fmap` elemIndex c (reverse xs) The " function takes a predicate and a  and = returns the index of the first element in the CompactString  satisfying the predicate. O(n) The ( function returns the last index of the  element in the given  which satisfies the predicate,  or a3 if there is no such element. The following holds:  findIndexEnd c xs == 5 (-) (length xs - 1) `fmap` findIndex c (reverse xs) The  function extends , by returning the G indices of all elements satisfying the predicate, in ascending order.  >count returns the number of times its argument appears in the  " count c = length . elemIndices c !O(n) !- takes two ByteStrings and returns a list of A corresponding pairs of bytes. If one input ByteString is short, A excess elements of the longer ByteString are discarded. This is  equivalent to a pair of  operations. "" generalises !' by zipping with the function given as B the first argument, instead of a tupling function. For example,  " (+)6 is applied to two ByteStrings to produce the list of  corresponding sums. #A specialised version of " for the common case of a  simultaneous map over two !s, to build a 3rd. Rewrite rules 6 are used to automatically covert zipWith into zipWith' when a pack is ? performed on the result of zipWith, but we also export it for  convenience. $O(n) $4 transforms a list of pairs of bytes into a pair of - CompactStrings. Note that this performs two  operations. % O(n log n) Sort a CompactString &(Convert a CompactString to a ByteString ')Convert a ByteString to a CompactString. : Fails if the ByteString is not a valid encoded string. ()Convert a ByteString to a CompactString. D Raises an error if the ByteString is not a valid encoded string. )Validates a CompactString. A If the string is invalid, fails, otherwise returns the input. *Validates a CompactString. K If the string is invalid, throws an error, otherwise returns the input. +AEncode a CompactString to a ByteString using the given encoding.  ( encode e = liftM toByteString . recode ;But it might be faster for some combinations of encodings. AFails if the string is cannot be encoded in the target encoding. ,AEncode a CompactString to a ByteString using the given encoding.  # encode_ e = toByteString . recode ;But it might be faster for some combinations of encodings. KRaises an error if the string is cannot be encoded in the target encoding. -ADecode a ByteString to a CompactString using the given encoding.  & decode e = recode =<< fromByteString ;but it might be faster for some combinations of encodings. 6Fails if the ByteString is not a valid encoded string .ADecode a ByteString to a CompactString using the given encoding.  ' decode_ e = recode_ . fromByteString_ ;but it might be faster for some combinations of encodings. @Raises an error if the ByteString is not a valid encoded string / Encode a 6 using the given encoding, and add a Byte Order Mark. G Byte Order Marks are common on Windows, but not on other platforms. AFails if the string is cannot be encoded in the target encoding. 0 Encode a 6 using the given encoding, and add a Byte Order Mark. G Byte Order Marks are common on Windows, but not on other platforms. KRaises an error if the string is cannot be encoded in the target encoding. 1 Decode a  into a (, by investigating the Byte Order Mark. % If there is no BOM assumes UTF-8. 4 Fails if the input is not a valid encoded string 7For portability, this function should be prefered over  decode UTF8 when reading files. 2 Decode a  into a (, by investigating the Byte Order Mark. % If there is no BOM assumes UTF-8. > Raises an error if the input is not a valid encoded string 7For portability, this function should be prefered over  decode UTF8 when reading files. 3Read a line from stdin. 4getContents. Equivalent to hGetContents stdin >Input is assumed to be in UTF-8, this may not be appropriate. 5Write a  to stdout. 9Output is written in UTF-8, this may not be appropriate. 6Write a + to stdout, appending a newline character. 9Output is written in UTF-8, this may not be appropriate. 7/The interact function takes a function of type CompactString -> CompactString L as its argument. The entire input from the standard input device is passed M to this function as its argument, and the resulting string is output on the  standard output device. It''s great for writing one line programs! 8$Read an entire file strictly into a . This is far more 0 efficient than reading the characters into a _ and then using  . Files are read using ' text mode' on Windows. "Files are assumed to be in UTF-8. 9$Read an entire file strictly into a . This is far more 0 efficient than reading the characters into a _ and then using  . Files are read using ' text mode' on Windows. GThe encoding of the file is determined based on a Byte Order Mark, see 1. :Write a  to a file. Files are written using UTF-8. ;Write a  to a file. Files are written using UTF-8. & A Byte Order Mark is also written. < Append a  to a file. Files are written using UTF-8. = Append a  to a file. CThe encoding of the file is determined based on a Byte Order Mark. K If the file is empty, it is written using UTF-8 with a Byte Order Mark. J If the encoding can not be determined the file is assumed to be UTF-8. >Read a line from a handle ?#Read entire handle contents into a . $The handle is interpreted as UTF-8. @#Read entire handle contents into a . ;The encoding is determined based on a Byte Order Mark, see 1. ARead a  directly from the specified q. $The handle is interpreted as UTF-8. B hGetNonBlocking is identical to A", except that it will never block M waiting for data to become available, instead it returns only whatever data  is available. $The handle is interpreted as UTF-8. C Outputs a  to the specified q. Output is written in UTF-8. DA synonym for hPut, for compatibility EWrite a ' to a handle, appending a newline byte Output is written in UTF-8. w      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEw      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEw      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEu   !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKKLMNOPQRSTUVWXYZ[\]^^__``abcddefghhijjkkllmnopqrstuvwxyz{|}~3mnopstuvxwyz{qr|}~3mnopstuvxwyz{qr|}~3mnopstuvxwyz{qr|}~  v w x y          compact-string-fix-0.3.2Data.CompactString.InternalData.CompactString.FusionData.CompactString.UnsafeData.CompactString.EncodingsData.CompactStringData.CompactString.ASCIIData.CompactString.UTF16Data.CompactString.UTF8baseGHC.Base unsafeChrForeign.Storablepokepeekordbytestring-0.9.2.0Data.ByteString.InternalmemcpyinlinePerformIOPS ByteStringImperativeLoop_ImperativeLoopFoldEFLAccEFLEncoding pokeCharFun pokeCharLenpokeChar pokeCharRevpeekChar peekCharLen peekCharRevpeekCharLenRev peekCharSafevalidateLengthcopyChar copyCharRev containsASCII validEquality validOrderingvalidSubstring charCount byteCountnewSizedoUpLoop doDownLoop doUpLoopFolddoDownLoopFoldProxy CompactStringCSunCSMaybeSJustSNothingSPairS:*:unSP withBuffer withBufferEndunsafeWithBufferunsafeWithBufferEndcreate returnChrplusPtr peekByteOff pokeByteOffencoding failMessage moduleErrorerrorEmptyList unsafeTry unsafeTryIONoAccloopArrloopAccmapEFLfoldEFL filterEFLscanEFL mapAccumEFL mapIndexEFLloopUploopUpCloopDown loopUpFold loopDownFold unsafeHead unsafeTail unsafeLast unsafeInitunsafeFromByteStringCompactLatin1ASCII UTF32NativeUTF32LEUTF32BEUTF32 UTF16NativeUTF16LEUTF16BEUTF16NativeLEBEUTF8empty singletonpackunpacknulllengthconssnocappendheadtaillastinitheadViewlastViewreverse intersperse transposemapfilter partitionfoldlfoldl'foldrfoldr'foldl1foldl1'foldr1foldr1'concat concatMap intercalateanyallmaximumminimumscanlscanl1scanrscanr1 mapAccumL mapAccumR mapIndexed replicateunfoldrunfoldrNtakedropsplitAt takeWhile dropWhilebreakspanbreakEndspanEndgroupgroupByinitstailssplit splitWithlinesunlineswordsunwords isPrefixOf isSuffixOf isInfixOf findSubstringfindSubstringsindexelemnotElem elemIndex elemIndexEnd elemIndicesfind findIndex findIndexEnd findIndicescountzipzipWithzipWith'unzipsortcompare' toByteStringfromByteStringfromByteString_validate validate_recoderecode_encodeencode_decodedecode_ encodeBOM encodeBOM_ decodeBOM decodeBOM_getLine getContentsputStrputStrLninteractreadFile readFile' writeFile writeFile' appendFile appendFile'hGetLine hGetContents hGetContents'hGethGetNonBlockinghPuthPutStr hPutStrLn GHC.Classescompare userErrorsghc-primGHC.Primseq loopWrapperloopWrapperFoldGHC.ListEndian peekWord16 pokeWord16 peekWord32 pokeWord32isBE charLenUTF8 decodeUTF8_1 decodeUTF8_2 decodeUTF8_3 decodeUTF8_4 isSurrogate decodeUTF16decodeUTF16Safe doCompare GHC.TypesCharStringInt Data.MaybeNothingJustnotTruetoByteStringAsunsafeFromByteStringAsfromByteStringIOrecodeVrecodeV_ decodeBOM_IO validateIOrecodeIO recodeVIO recodeVIO_ appendHandle findEncodingGHC.IO.Handle.TypesHandle charIndexfindIndexOrEndfindIndexOrBeginRev