h$q            ! " # $ %&' ( ) * + , - . / 0 1 2 3 4 5 6 7 8 9 : ; < = > ? @ A B C D E F G H I J K L M NOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~       !!!!!!!!!!!!!!!!!!!!""""""##$$$$$$$$%%%%%%%%%&&''((((((((()))))))))))))************-(c) Bryan O'Sullivan 2009 BSD-stylebos@serpentine.comGHCSafe3R text;An exception type for representing Unicode encoding errors.textCould not decode a byte sequence because it was invalid under the given encoding, or ran out of input in mid-decode.textTried to encode a character that could not be represented under the given encoding, or ran out of input in mid-encode.text A handler for an encoding error.textA handler for a decoding error.textFunction type for handling a coding error. It is supplied with two inputs:A  that describes the error.The input value that caused the error. If the error arose because the end of input was reached or could not be identified precisely, this value will be .,If the handler returns a value wrapped with , that value will be used in the output as the replacement for the invalid input. If it returns &, no value will be used in the output.;Should the handler need to abort processing, it should use  or  an exception (preferably a ). It may use the description provided to construct a more helpful error report.textThrow a  if decoding fails.textReplace an invalid input byte with the Unicode replacement character U+FFFD. textThrow a  if encoding fails. texttextCompare portions of two arrays for equality. No bounds checking is performed.<text DestinationtextDestination offsettextSourcetext Source offsettextCount=text DestinationtextDestination offsettextSourcetext Source offsettextFirst offset in destination not to copy (i.e. not length)>textFirsttextOffset into firsttextSecondtextOffset into secondtextCount./0123456789:;<=>123./0<=9>:;85647 (c) 2008, 2009 Tom Harper, (c) 2009, 2010 Bryan O'Sullivan, (c) 2009 Duncan Coutts BSD-stylebos@serpentine.com experimentalGHCNone!NCtextWrite a character into the array at the given offset. Returns the number of  s written.?@ABC?@ABC (c) 2008, 2009 Tom Harper, (c) 2009, 2010 Bryan O'Sullivan, (c) 2009 Duncan Coutts BSD-stylebos@serpentine.com experimentalGHCNone" DEFGHIJKLM DEFGHIJKLM(c) 2008, 2009 Tom Harper, (c) 2009, 2010 Bryan O'Sullivan, (c) 2009 Duncan Coutts BSD-stylebos@serpentine.com experimentalGHCNone3& Ntext5A space efficient, packed, unboxed Unicode text type.PtextO(1) The empty N.QtextA non-inlined version of P.Rtext Construct a N without invisibly pinning its byte array in memory if its length has dwindled to zero.Ttext A useful &-like function for debugging purposes.UtextMap a  to a N -safe value.UTF-16 surrogate code points are not included in the set of Unicode scalar values, but are unfortunately admitted as valid 6 values by Haskell. They cannot be represented in a N. This function remaps those code points to the Unicode replacement character (U+FFFD, ''), and leaves other code points unchanged.Vtext:Apply a function to the first element of an optional pair.WtextChecked multiplication. Calls  if the result would overflow.XtextChecked multiplication. Calls  if the result would overflow.YtextChecked multiplication. Calls  if the result would overflow. NOPQRSTUVWXY NORSUPQVWYXTW7X7Y7(c) Bryan O'Sullivan 2009 BSD-stylebos@serpentine.com experimentalGHCNone)3ZtextO(n+m)5 Find the offsets of all non-overlapping indices of needle within haystack. The offsets returned represent uncorrected indices in the low-level "needle" array, to which its offset must be added.In (unlikely) bad cases, this algorithm's complexity degrades towards O(n*m).ZtextSubstring to search for (needle)textText to search in (haystack)ZZ(c) Roman Leshchinskiy 2008, (c) Bryan O'Sullivan 2009 BSD-stylebos@serpentine.com experimentalportableNone+[textA size in UTF-16 code units.]textThe [ of the given code point.^textThe [ of n code points.dtextMinimum of two size hints.etextMaximum of two size hints.ftext7Compute the maximum size from a size hint, if possible.gtext7Compute the maximum size from a size hint, if possible.htext0Determine the ordering relationship between two [s, or  in the indeterminate case.[\]^_`abcdefghi[_`acb]^\defghi(c) Tom Harper 2008-2009, (c) Bryan O'Sullivan 2009, (c) Duncan Coutts 2009, (c) Jasper Van der Jeugt 2011 BSD-stylebos@serpentine.com experimentalGHCNone-|otext-Intermediate result in a processing pipeline.stext!An intermediate result in a scan.vtext Strict pair.xtextRestreaming state.}text&Specialised tuple for case conversion.textThe empty stream.mnopqrstuvwxyz{|}~}~vwstuxyz{|opqrmnw2None-(c) Bryan O'Sullivan 2009, 2012 BSD-stylebos@serpentine.com experimentalGHCNoneJ-textStream the UTF-8-like packed encoding used by GHC to represent constant strings in generated code.This encoding uses the byte sequence "xc0x80" to represent NUL, and the string is NUL-terminated.textO(n)0 Adds a character to the front of a Stream Char.textO(n)) Adds a character to the end of a stream.textO(n)! Appends one Stream to the other.textO(1) Returns the first character of a Text, which must be non-empty. Subject to array fusion.textO(1) Returns the first character and remainder of a 'Stream Char', or $ if empty. Subject to array fusion.textO(n) Returns the last character of a 'Stream Char', which must be non-empty.textO(1) Returns all characters after the head of a Stream Char, which must be non-empty.textO(1) Returns all but the last character of a Stream Char, which must be non-empty.textO(1)- Tests whether a Stream Char is empty or not.textO(n). Returns the number of characters in a string.textO(n) Compares the count of characters in a string to a number. Subject to fusion.This function gives the same answer as comparing against the result of , but can short circuit if the count of characters is greater than the number or if the stream can't possibly be as long as the number supplied, and hence be more efficient.textO(n)8 Indicate whether a string contains exactly one element.textO(n)  f +xs is the Stream Char obtained by applying f to each element of xs.textO(n) Take a character and place it between each of the characters of a 'Stream Char'.textO(n) Convert a string to folded case. This function is mainly useful for performing caseless (or case insensitive) string comparisons. A string x" is a caseless match for a string y if and only if: toCaseFold x == toCaseFold yThe result string may be longer than the input string, and may differ from applying  to the input string. For instance, the Armenian small ligature men now (U+FB13) is case folded to the bigram men now (U+0574 U+0576), while the micro sign (U+00B5) is case folded to the Greek small letter letter mu (U+03BC) instead of itself.textO(n) Convert a string to upper case, using simple case conversion. The result string may be longer than the input string. For instance, the German eszett (U+00DF) maps to the two-letter sequence SS.textO(n) Convert a string to lower case, using simple case conversion. The result string may be longer than the input string. For instance, the Latin capital letter I with dot above (U+0130) maps to the sequence Latin small letter i (U+0069) followed by combining dot above (U+0307).textO(n)? Convert a string to title case, using simple case conversion.The first letter of the input is converted to title case, as is every subsequent letter that immediately follows a non-letter. Every letter that immediately follows another letter is converted to lower case.The result string may be longer than the input string. For example, the Latin small ligature  (U+FB02) is converted to the sequence Latin capital letter F (U+0046) followed by Latin small letter l (U+006C).Note: this function does not take language or culture specific rules into account. For instance, in English, different style guides disagree on whether the book name "The Hill of the Red Fox" is correctly title cased@but this function will capitalize every word.textfoldl, applied to a binary operator, a starting value (typically the left-identity of the operator), and a Stream, reduces the Stream using the binary operator, from left to right.textA strict version of foldl.textfoldl1 is a variant of foldl that has no starting value argument, and thus must be applied to non-empty Streams.textA strict version of foldl1.text, applied to a binary operator, a starting value (typically the right-identity of the operator), and a stream, reduces the stream using the binary operator, from right to left.textfoldr1 is a variant of  that has no starting value argument, and thus must be applied to non-empty streams. Subject to array fusion.textO(n)8 Concatenate a list of streams. Subject to array fusion.textMap a function over a stream that results in a stream and concatenate the results.textO(n) any p .xs determines if any character in the stream xs satisfies the predicate p.textO(n) all p 'xs determines if all characters in the Text xs satisfy the predicate p.textO(n) maximum returns the maximum value from a stream, which must be non-empty.textO(n)* minimum returns the minimum value from a Text, which must be non-empty.textO(n), where n is the length of the result. The unfoldr function is analogous to the List . unfoldr builds a stream from a seed value. The function takes the element and returns Nothing if it is done producing the stream or returns Just (a,b), in which case, a is the next Char in the string, and b is the seed value for further production.textO(n) Like ,  builds a stream from a seed value. However, the length of the result is limited by the first argument to (. This function is more efficient than ( when the length of the result is known.textO(n)  n, applied to a stream, returns the prefix of the stream of length n, or the stream itself if n+ is greater than the length of the stream.textO(n)  n, applied to a stream, returns the suffix of the stream after the first n$ characters, or the empty stream if n+ is greater than the length of the stream.text, applied to a predicate p and a stream, returns the longest prefix (possibly empty) of elements that satisfy p.text p xs$ returns the suffix remaining after  p xs.textO(n) The  function takes two ms and returns ) iff the first is a prefix of the second.textO(n) $ is the stream membership predicate.textO(n) The  function takes a predicate and a stream, and returns the first element in matching the predicate, or  if there is no such element.textO(n)4 Stream index (subscript) operator, starting from 0.textO(n) , applied to a predicate and a stream, returns a stream containing those characters that satisfy the predicate.textThe  function takes a predicate and a stream and returns the index of the first element in the stream satisfying the predicate.textzipWith generalises zip by zipping with the function given as the first argument, instead of a tupling function.textO(n) The  function returns the number of times the query element appears in the given stream.55%(c) 2009, 2010, 2011 Bryan O'Sullivan BSD-stylebos@serpentine.comportableNoneQ textO(1) A variant of  for non-empty N.  omits the check for the empty case, so there is an obligation on the programmer to provide a proof that the N is non-empty.textO(1) A variant of  for non-empty N.  omits the check for the empty case, so there is an obligation on the programmer to provide a proof that the N is non-empty.textO(1) Iterate (unsafely) one step forwards through a UTF-16 array, returning the current character and the delta to add to give the next offset to iterate at.textO(1) Iterate one step through a UTF-16 array, returning the delta to add to give the next offset to iterate at.textO(1) Iterate one step backwards through a UTF-16 array, returning the current character and the delta to add (i.e. a negative number) to give the next offset to iterate at.textO(1) Iterate one step backwards through a UTF-16 array, returning the delta to add (i.e. a negative number) to give the next offset to iterate at.textO(1) Return the length of a N in units of Word16. This is useful for sizing a target array appropriately before using unsafeCopyToPtr.textO(1) Unchecked take of k Word16s from the front of a N.textO(1) Unchecked drop of k Word16s from the front of a N.%&&%(c) 2011 Bryan O'Sullivan BSD-stylebos@serpentine.com experimentalGHCNoneR(c) Tom Harper 2008-2009, (c) Bryan O'Sullivan 2009-2010, (c) Duncan Coutts 2009 BSD-stylebos@serpentine.com experimentalGHCNoneW textO(n) Convert a N into a 'Stream Char'.textO(n) Convert a N. into a 'Stream Char', but iterate backwards.textO(n) Convert a 'Stream Char' into a N.textO(n)$ Reverse the characters of a string.textO(n) Perform the equivalent of scanr7 over a list, only with the input and result reversed.textO(n) Like unfoldr,  builds a stream from a seed value. However, the length of the result is limited by the first argument to (. This function is more efficient than unfoldr( when the length of the result is known.textO(n)4 stream index (subscript) operator, starting from 0.textThe  function takes a predicate and a stream and returns the index of the first element in the stream satisfying the predicate.textO(n) The count function returns the number of times the query element appears in the given stream.textO(n) Like a combination of map and foldl'+. Applies a function to each element of a N, passing an accumulating parameter from left to right, and returns a final N.mnopqrmnopqr,(c) 2009-2015 Bryan O'Sullivan BSD-stylebos@serpentine.com experimentalGHC TrustworthyY~textO(n) Convert a N into a . Subject to fusion.textO(n)! Convert a literal string into a N. if c == '.' then '!' else c) message"I am not angry! Not at all!"Subject to fusion. Performs replacement on invalid scalar values.textO(n) The  function takes a N and a list of Ns and concatenates the list after interspersing the first argument between each element of the list.Example::T.intercalate "NI!" ["We", "seek", "the", "Holy", "Grail"] "WeNI!seekNI!theNI!HolyNI!Grail"textO(n) The  function takes a character and places it between the characters of a N.Example:T.intersperse '.' "SHIELD" "S.H.I.E.L.D"Subject to fusion. Performs replacement on invalid scalar values.textO(n)$ Reverse the characters of a string.Example:T.reverse "desrever" "reversed",Subject to fusion (fuses with its argument).textO(m+n)- Replace every non-overlapping occurrence of needle in haystack with  replacement.:This function behaves as though it was defined as follows: (replace needle replacement haystack =  replacement ( needle haystack) As this suggests, each occurrence is replaced exactly once. So if needle occurs in  replacement, that occurrence will not! itself be replaced recursively:replace "oo" "foo" "oo""foo"$In cases where several instances of needle/ overlap, only the first one will be replaced:replace "ofo" "bar" "ofofo""barfo"In (unlikely) bad cases, this function's time complexity degrades towards O(n*m).textO(n)5 Convert a string to folded case. Subject to fusion.This function is mainly useful for performing caseless (also known as case insensitive) string comparisons. A string x" is a caseless match for a string y if and only if: toCaseFold x == toCaseFold yThe result string may be longer than the input string, and may differ from applying  to the input string. For instance, the Armenian small ligature "" (men now, U+FB13) is case folded to the sequence " " (men, U+0574) followed by " " (now, U+0576), while the Greek "" (micro sign, U+00B5) is case folded to "" (small letter mu, U+03BC) instead of itself.textO(n) Convert a string to lower case, using simple case conversion. Subject to fusion.The result string may be longer than the input string. For instance, "" (Latin capital letter I with dot above, U+0130) maps to the sequence "i" (Latin small letter i, U+0069) followed by " " (combining dot above, U+0307).textO(n) Convert a string to upper case, using simple case conversion. Subject to fusion.The result string may be longer than the input string. For instance, the German "" (eszett, U+00DF) maps to the two-letter sequence "SS".textO(n) Convert a string to title case, using simple case conversion. Subject to fusion.The first letter of the input is converted to title case, as is every subsequent letter that immediately follows a non-letter. Every letter that immediately follows another letter is converted to lower case.The result string may be longer than the input string. For example, the Latin small ligature  (U+FB02) is converted to the sequence Latin capital letter F (U+0046) followed by Latin small letter l (U+006C).Note: this function does not take language or culture specific rules into account. For instance, in English, different style guides disagree on whether the book name "The Hill of the Red Fox" is correctly title cased@but this function will capitalize every word.textO(n) Left-justify a string to the given length, using the specified fill character on the right. Subject to fusion. Performs replacement on invalid scalar values. Examples:justifyLeft 7 'x' "foo" "fooxxxx"justifyLeft 3 'x' "foobar""foobar"textO(n) Right-justify a string to the given length, using the specified fill character on the left. Performs replacement on invalid scalar values. Examples:justifyRight 7 'x' "bar" "xxxxbar"justifyRight 3 'x' "foobar""foobar"textO(n) Center a string to the given length, using the specified fill character on either side. Performs replacement on invalid scalar values. Examples:center 8 'x' "HS" "xxxHSxxx"textO(n) The 2 function transposes the rows and columns of its N) argument. Note that this function uses , , and the list version of transpose, and is thus not very efficient. Examples:transpose ["green","orange"]["go","rr","ea","en","ng","e"]transpose ["blue","red"]["br","le","ud","e"]textO(n) , applied to a binary operator, a starting value (typically the left-identity of the operator), and a N, reduces the N using the binary operator, from left to right. Subject to fusion.textO(n) A strict version of . Subject to fusion.textO(n) A variant of  that has no starting value argument, and thus must be applied to a non-empty N. Subject to fusion.textO(n) A strict version of . Subject to fusion.textO(n) , applied to a binary operator, a starting value (typically the right-identity of the operator), and a N, reduces the N using the binary operator, from right to left. Subject to fusion.textO(n) A variant of  that has no starting value argument, and thus must be applied to a non-empty N. Subject to fusion.textO(n) Concatenate a list of Ns.textO(n) Map a function over a N that results in a N, and concatenate the results.textO(n)  p t* determines whether any character in the N t satisfies the predicate p. Subject to fusion.textO(n)  p t+ determines whether all characters in the N t satisfy the predicate p. Subject to fusion.textO(n) " returns the maximum value from a N., which must be non-empty. Subject to fusion.textO(n) " returns the minimum value from a N., which must be non-empty. Subject to fusion.textO(n)  is similar to , but returns a list of successive reduced values from the left. Subject to fusion. Performs replacement on invalid scalar values. 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.textO(n)  is a variant of  that has no starting value argument. Performs replacement on invalid scalar values. .scanl1 f [x1, x2, ...] == [x1, x1 `f` x2, ...]textO(n)  is the right-to-left dual of 2. Performs replacement on invalid scalar values. 1scanr f v == reverse . scanl (flip f) v . reversetextO(n)  is a variant of  that has no starting value argument. Performs replacement on invalid scalar values.textO(n) Like a combination of  and +. Applies a function to each element of a N, passing an accumulating parameter from left to right, and returns a final N2. Performs replacement on invalid scalar values.textThe ( function behaves like a combination of  and a strict .; it applies a function to each element of a N, passing an accumulating parameter from right to left, and returning a final value of this accumulator together with the new N1. Performs replacement on invalid scalar values.textO(n*m)  n t is a N consisting of the input t repeated n times.textO(n), where n" is the length of the result. The $ function is analogous to the List .  builds a N from a seed value. The function takes the element and returns  if it is done producing the N , otherwise  (a,b). In this case, a is the next  in the string, and b is the seed value for further production. Subject to fusion. Performs replacement on invalid scalar values.textO(n) Like ,  builds a N from a seed value. However, the length of the result should be limited by the first argument to (. This function is more efficient than  when the maximum length of the result is known and correct, otherwise its performance is similar to . Subject to fusion. Performs replacement on invalid scalar values.textO(n)  n, applied to a N, returns the prefix of the N of length n , or the N itself if n< is greater than the length of the Text. Subject to fusion.textO(n)  n t, returns the suffix remaining after taking n characters from the end of t. Examples:takeEnd 3 "foobar""bar"textO(n)  n, applied to a N, returns the suffix of the N after the first n characters, or the empty N if n$ is greater than the length of the N. Subject to fusion.textO(n)  n t. returns the prefix remaining after dropping n characters from the end of t. Examples:dropEnd 3 "foobar""foo"textO(n) , applied to a predicate p and a N, returns the longest prefix (possibly empty) of elements that satisfy p. Subject to fusion.textO(n) , applied to a predicate p and a N, returns the longest suffix (possibly empty) of elements that satisfy p . Examples:takeWhileEnd (=='o') "foo""oo"textO(n)  p t% returns the suffix remaining after  p t. Subject to fusion.textO(n)  p t returns the prefix remaining after dropping characters that satisfy the predicate p from the end of t. Examples:dropWhileEnd (=='.') "foo...""foo"textO(n)  p t returns the substring remaining after dropping characters that satisfy the predicate p% from both the beginning and end of t. Subject to fusion.textO(n): Remove leading white space from a string. Equivalent to: dropWhile isSpacetextO(n); Remove trailing white space from a string. Equivalent to: dropWhileEnd isSpacetextO(n) Remove leading and trailing white space from a string. Equivalent to: dropAround isSpacetextO(n)  n t4 returns a pair whose first element is a prefix of t of length n, and whose second is the remainder of the string. It is equivalent to ( n t,  n t).textO(n) , applied to a predicate p and text t, returns a pair whose first element is the longest prefix (possibly empty) of t of elements that satisfy p1, and whose second is the remainder of the list.T.span (=='0') "000AB" ("000","AB")textO(n)  is like , but the prefix returned is over elements that fail the predicate p.T.break (=='c') "180cm" ("180","cm")textO(n)7 Group characters in a string according to a predicate.textO(n)* Group characters in a string by equality.textO(n)* Return all initial segments of the given N, shortest first.textO(n)( Return all final segments of the given N, longest first.textO(m+n) Break a N$ into pieces separated by the first N argument (which cannot be empty), consuming the delimiter. An empty delimiter is invalid, and will cause an error to be raised. Examples:!splitOn "\r\n" "a\r\nb\r\nd\r\ne"["a","b","d","e"] splitOn "aaa" "aaaXaaaXaaaXaaa"["","X","X","X",""]splitOn "x" "x"["",""]and intercalate s . splitOn s == id splitOn (singleton c) == split (==c)(Note: the string s$ to split on above cannot be empty.)In (unlikely) bad cases, this function's time complexity degrades towards O(n*m).textO(n) Splits a N 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.split (=='a') "aabbaca"["","","bb","c",""]split (=='a') ""[""]textO(n) Splits a N into components of length k. The last element may be shorter than the other chunks, depending on the length of the input. Examples:chunksOf 3 "foobarbaz"["foo","bar","baz"]chunksOf 4 "haskell.org"["hask","ell.","org"]textO(n) The " function takes a predicate and a N<, and returns the first element matching the predicate, or 1 if there is no such element. Subject to fusion.textO(n) The " function takes a predicate and a N, and returns the pair of Ns with elements which do and do not satisfy the predicate, respectively; i.e. 1partition p t == (filter p t, filter (not . p) t)textO(n) , applied to a predicate and a N , returns a N9 containing those characters that satisfy the predicate.textO(n+m) Find the first instance of needle (which must be non-) in haystack=. The first element of the returned tuple is the prefix of haystack before needle. is matched. The second is the remainder of haystack, starting with the match. Examples:breakOn "::" "a::b::c"("a","::b::c")breakOn "/" "foobar" ("foobar","")Laws: append prefix match == haystack where (prefix, match) = breakOn needle haystackIf you need to break a string by a substring repeatedly (e.g. you want to break on every instance of a substring), use , instead, as it has lower startup overhead.In (unlikely) bad cases, this function's time complexity degrades towards O(n*m).textO(n+m) Similar to +, but searches from the end of the string.9The first element of the returned tuple is the prefix of haystack( up to and including the last match of needle#. The second is the remainder of haystack, following the match.breakOnEnd "::" "a::b::c"("a::b::","c")textO(n+m)' Find all non-overlapping instances of needle in haystack8. Each element of the returned list consists of a pair:The entire string prior to the kth match (i.e. the prefix)The k1th match, followed by the remainder of the string Examples:breakOnAll "::" ""[]breakOnAll "/" "a/b/c/"+[("a","/b/c/"),("a/b","/c/"),("a/b/c","/")]In (unlikely) bad cases, this function's time complexity degrades towards O(n*m).The needle parameter may not be empty.textO(n) N index (subscript) operator, starting from 0. Subject to fusion.textO(n) The " function takes a predicate and a N4 and returns the index of the first element in the N. satisfying the predicate. Subject to fusion.textO(n+m) The  function returns the number of times the query string appears in the given N. An empty query string is invalid, and will cause an error to be raised.In (unlikely) bad cases, this function's time complexity degrades towards O(n*m).textO(n)  takes two Ns and returns a list of corresponding pairs of bytes. If one input N* is short, excess elements of the longer N1 are discarded. This is equivalent to a pair of  operations.textO(n)  generalises  by zipping with the function given as the first argument, instead of a tupling function. Performs replacement on invalid scalar values.textO(n) Breaks a N' up into a list of words, delimited by s representing white space.textO(n) Breaks a N up into a list of Ns at newline 1s. The resulting strings do not contain newlines.textO(n)= Joins lines, after appending a terminating newline to each.textO(n)+ Joins words using single space characters.textO(n) The  function takes two Ns and returns = iff the first is a prefix of the second. Subject to fusion.textO(n) The  function takes two Ns and returns ) iff the first is a suffix of the second.textO(n+m) The  function takes two Ns and returns  iff the first is contained, wholly and intact, anywhere within the second.In (unlikely) bad cases, this function's time complexity degrades towards O(n*m).textO(n) Return the suffix of the second string if its prefix matches the entire first string. Examples:stripPrefix "foo" "foobar" Just "bar"stripPrefix "" "baz" Just "baz"stripPrefix "foo" "quux"Nothing%This is particularly useful with the  ViewPatterns extension to GHC, as follows: {-# LANGUAGE ViewPatterns #-} import Data.Text as T fnordLength :: Text -> Int fnordLength (stripPrefix "fnord" -> Just suf) = T.length suf fnordLength _ = -1textO(n) Find the longest non-empty common prefix of two strings and return it, along with the suffixes of each string at which they no longer match.If the strings do not have a common prefix or either one is empty, this function returns . Examples:!commonPrefixes "foobar" "fooquux"Just ("foo","bar","quux") commonPrefixes "veeble" "fetzer"NothingcommonPrefixes "" "baz"NothingtextO(n) Return the prefix of the second string if its suffix matches the entire first string. Examples:stripSuffix "bar" "foobar" Just "foo"stripSuffix "" "baz" Just "baz"stripSuffix "foo" "quux"Nothing%This is particularly useful with the  ViewPatterns extension to GHC, as follows: {-# LANGUAGE ViewPatterns #-} import Data.Text as T quuxLength :: Text -> Int quuxLength (stripSuffix "quux" -> Just pre) = T.length pre quuxLength _ = -1textO(n) Make a distinct copy of the given string, sharing no storage with the original string.As an example, suppose you read a large string, of which you need only a small portion. If you do not use , the entire original array will be kept alive in memory by the smaller string. Making a copy "breaks the link" to the original array, allowing it to be garbage collected if there are no other live references to it.textOnly defined for  base-4.7.0.0 and latertext0This instance has similar considerations to the  instance: it preserves abstraction at the cost of inefficiency.textThis instance preserves data abstraction at the cost of inefficiency. We omit reflection services for the sake of data abstraction.>This instance was created by copying the updated behavior of Data.Set.-. and Data.Map./0. If you feel a mistake has been made, please feel free to submit improvements.+The original discussion is archived here: https://mail.haskell.org/pipermail/haskell-cafe/2010-January/072379.html0could we get a Data instance for Data.Text.Text?5The followup discussion that changed the behavior of -. and /0 is archived here: http://markmail.org/message/trovdc6zkphyi3cr#query:+page:1+mid:a46der3iacwjcf6n+state:results)Proposal: Allow gunfold for Data.Map, ...texttexttext Non-orphan  instance only defined for  base-4.9.0.0 and later; orphan instances for older GHCs are provided by the  -http://hackage.haskell.org/package/semigroups semigroups packagetextneedle? to search for. If this string is empty, an error will occur.text replacement to replace needle with.texthaystack in which to search.textString to split on. If this string is empty, an error will occur.text Input text.textneedle to search fortexthaystack in which to searchNPNP5(c) 2010, 2011 Bryan O'Sullivan BSD-stylebos@serpentine.comGHC Trustworthy ItextRead some text. If the read succeeds, return its value and the remaining text, otherwise an error message.textRead a decimal integer. The input must begin with at least one decimal digit, and is consumed until a non-digit or end of string is reached.This function does not handle leading sign characters. If you need to handle signed input, use  .Note: For fixed-width integer types, this function does not attempt to detect overflow, so a sufficiently long input may give incorrect results. If you are worried about overflow, use  for your result type.text?Read a hexadecimal integer, consisting of an optional leading "0x" followed by at least one hexadecimal digit. Input is consumed until a non-hex-digit or end of string is reached. This function is case insensitive.This function does not handle leading sign characters. If you need to handle signed input, use  .Note: For fixed-width integer types, this function does not attempt to detect overflow, so a sufficiently long input may give incorrect results. If you are worried about overflow, use  for your result type.text)Read an optional leading sign character ('-' or '+';) and apply it to the result of applying the given reader.textRead a rational number.This function accepts an optional leading sign character, followed by at least one decimal digit. The syntax similar to that accepted by the . function, with the exception that a trailing '.' or 'e' not& followed by a number is not consumed.&Examples (with behaviour identical to ): rational "3" == Right (3.0, "") rational "3.1" == Right (3.1, "") rational "3e4" == Right (30000.0, "") rational "3.1e4" == Right (31000.0, "") rational ".3" == Left "input does not start with a digit" rational "e3" == Left "input does not start with a digit"Examples of differences from : rational "3.foo" == Right (3.0, ".foo") rational "3e" == Right (3.0, "e")textRead a rational number.8The syntax accepted by this function is the same as for .Note0: This function is almost ten times faster than !, but is slightly less accurate.The  type supports about 16 decimal places of accuracy. For 94.2% of numbers, this function and  give identical results, but for the remaining 5.8%, this function loses precision around the 15th decimal place. For 0.001% of numbers, this function will lose precision at the 13th or 14th decimal place.(c) 2009, 2010 Bryan O'Sullivan BSD-stylebos@serpentine.com experimentalGHCNone3u textCheck the invariant strictly.textCheck the invariant lazily.text)Display the internal structure of a lazy .textSmart constructor for %. Guarantees the data type invariant.textSmart constructor for .textConsume the chunks of a lazy  with a natural right fold.textConsume the chunks of a lazy 8 with a strict, tail-recursive, accumulating left fold.text=Currently set to 16 KiB, less the memory management overhead.textCurrently set to 128 bytes, less the memory management overhead.textThe memory management overhead. Currently this is tuned for GHC only.  1(c) 2013 Bryan O'Sullivan BSD-stylebos@serpentine.com experimentalGHCNone3 (c) 2009, 2010 Bryan O'Sullivan BSD-stylebos@serpentine.com experimentalGHCNone9textO(n+m)5 Find the offsets of all non-overlapping indices of needle within haystack.This function is strict in needle2, and lazy (as far as possible) in the chunks of haystack.In (unlikely) bad cases, this algorithm's complexity degrades towards O(n*m).textSubstring to search for (needle)textText to search in (haystack) (c) 2009, 2010 Bryan O'Sullivan BSD-stylebos@serpentine.com experimentalGHCNonetextO(n) Convert a  into a 'Stream Char'.textO(n) Convert a 'Stream Char' into a , using the given chunk size.textO(n) Convert a 'Stream Char' into a  , using .textO(n), Returns the number of characters in a text.textO(n) Like unfoldr,  builds a stream from a seed value. However, the length of the result is limited by the first argument to (. This function is more efficient than unfoldr( when the length of the result is known.textO(n)4 stream index (subscript) operator, starting from 0.textO(n) The count function returns the number of times the query element appears in the given stream.!(c) 2009, 2010 Bryan O'Sullivan BSD-stylebos@serpentine.comportable Trustworthy5text Deprecated . Decode a  ByteString& containing 7-bit ASCII encoded text.text Decode a  ByteString2 containing Latin-1 (aka ISO-8859-1) encoded text.text Decode a  ByteString containing UTF-8 encoded text.text Decode a  ByteString: containing UTF-8 encoded text that is known to be valid.If the input contains any invalid UTF-8 data, an exception will be thrown that cannot be caught in pure code. For more control over the handling of invalid data, use  or .text Decode a  ByteString containing UTF-8 encoded text..If the input contains any invalid UTF-8 data, the relevant exception will be returned, otherwise the decoded text.Note: this function is not lazy, as it must decode its entire input before it can return a result. If you need lazy (streaming) decoding, use  in lenient mode.text!Encode text using UTF-8 encoding.textEncode text to a ByteString  using UTF-8 encoding.textEncode text using UTF-8 encoding and escape the ASCII characters using a .Use this function is to implement efficient encoders for text-based formats like JSON or HTML.text/Decode text from little endian UTF-16 encoding.text/Decode text from little endian UTF-16 encoding.If the input contains any invalid little endian UTF-16 data, an exception will be thrown. For more control over the handling of invalid data, use .text,Decode text from big endian UTF-16 encoding.text,Decode text from big endian UTF-16 encoding.If the input contains any invalid big endian UTF-16 data, an exception will be thrown. For more control over the handling of invalid data, use .text0Encode text using little endian UTF-16 encoding.text-Encode text using big endian UTF-16 encoding.text/Decode text from little endian UTF-32 encoding.text/Decode text from little endian UTF-32 encoding.If the input contains any invalid little endian UTF-32 data, an exception will be thrown. For more control over the handling of invalid data, use .text,Decode text from big endian UTF-32 encoding.text,Decode text from big endian UTF-32 encoding.If the input contains any invalid big endian UTF-32 data, an exception will be thrown. For more control over the handling of invalid data, use .text0Encode text using little endian UTF-32 encoding.text-Encode text using big endian UTF-32 encoding.%(c) 2009, 2010, 2012 Bryan O'Sullivan BSD-stylebos@serpentine.comGHC Trustworthy GtextO(n) Convert a  into a .Subject to fusion. Performs replacement on invalid scalar values.textO(n) Convert a  into a . Subject to fusion.textO(1) Convert a character into a Text. Subject to fusion. Performs replacement on invalid scalar values.textO(c) Convert a list of strict Ns into a lazy .textO(n) Convert a lazy  into a list of strict Ns.textO(n) Convert a lazy  into a strict N.textO(c) Convert a strict N into a lazy .textO(1)$ Adds a character to the front of a . Subject to fusion.textO(n)" Adds a character to the end of a . This copies the entire array in the process, unless fused. Subject to fusion.textO(n/c) Appends one  to another. Subject to fusion.textO(1)+ Returns the first character and rest of a , or  if empty. Subject to fusion.textO(1)" Returns the first character of a /, which must be non-empty. Subject to fusion.textO(1), Returns all characters after the head of a /, which must be non-empty. Subject to fusion.textO(n/c)) Returns all but the last character of a /, which must be non-empty. Subject to fusion.textO(n/c) Returns the  and  of a , or  if empty.It is no faster than using  and .textO(1) Tests whether a & is empty or not. Subject to fusion.textO(n/c)! Returns the last character of a /, which must be non-empty. Subject to fusion.textO(n)' Returns the number of characters in a . Subject to fusion.textO(n)& Compare the count of characters in a ! to a number. Subject to fusion.This function gives the same answer as comparing against the result of , but can short circuit if the count of characters is greater than the number, and hence be more efficient.textO(n)  f t is the  obtained by applying f to each element of t. Subject to fusion. Performs replacement on invalid scalar values.textO(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.textO(n) The  function takes a character and places it between the characters of a . Subject to fusion. Performs replacement on invalid scalar values.textO(n) Left-justify a string to the given length, using the specified fill character on the right. Subject to fusion. Performs replacement on invalid scalar values. Examples: justifyLeft 7 'x' "foo" == "fooxxxx" justifyLeft 3 'x' "foobar" == "foobar"textO(n) Right-justify a string to the given length, using the specified fill character on the left. Performs replacement on invalid scalar values. Examples: justifyRight 7 'x' "bar" == "xxxxbar" justifyRight 3 'x' "foobar" == "foobar"textO(n) Center a string to the given length, using the specified fill character on either side. Performs replacement on invalid scalar values. Examples: center 8 'x' "HS" = "xxxHSxxx"textO(n) The 2 function transposes the rows and columns of its ) argument. Note that this function uses , , and the list version of transpose, and is thus not very efficient.textO(n)  t returns the elements of t in reverse order.textO(m+n)- Replace every non-overlapping occurrence of needle in haystack with  replacement.:This function behaves as though it was defined as follows: (replace needle replacement haystack =  replacement ( needle haystack) As this suggests, each occurrence is replaced exactly once. So if needle occurs in  replacement, that occurrence will not! itself be replaced recursively:  replace "oo" "foo" "oo" == "foo"$In cases where several instances of needle/ overlap, only the first one will be replaced: &replace "ofo" "bar" "ofofo" == "barfo"In (unlikely) bad cases, this function's time complexity degrades towards O(n*m).textO(n)5 Convert a string to folded case. Subject to fusion.This function is mainly useful for performing caseless (or case insensitive) string comparisons. A string x" is a caseless match for a string y if and only if: toCaseFold x == toCaseFold yThe result string may be longer than the input string, and may differ from applying  to the input string. For instance, the Armenian small ligature men now (U+FB13) is case folded to the bigram men now (U+0574 U+0576), while the micro sign (U+00B5) is case folded to the Greek small letter letter mu (U+03BC) instead of itself.textO(n) Convert a string to lower case, using simple case conversion. Subject to fusion.The result string may be longer than the input string. For instance, the Latin capital letter I with dot above (U+0130) maps to the sequence Latin small letter i (U+0069) followed by combining dot above (U+0307).textO(n) Convert a string to upper case, using simple case conversion. Subject to fusion.The result string may be longer than the input string. For instance, the German eszett (U+00DF) maps to the two-letter sequence SS.textO(n) Convert a string to title case, using simple case conversion. Subject to fusion.The first letter of the input is converted to title case, as is every subsequent letter that immediately follows a non-letter. Every letter that immediately follows another letter is converted to lower case.The result string may be longer than the input string. For example, the Latin small ligature  (U+FB02) is converted to the sequence Latin capital letter F (U+0046) followed by Latin small letter l (U+006C).Note: this function does not take language or culture specific rules into account. For instance, in English, different style guides disagree on whether the book name "The Hill of the Red Fox" is correctly title cased@but this function will capitalize every word.textO(n) , applied to a binary operator, a starting value (typically the left-identity of the operator), and a , reduces the  using the binary operator, from left to right. Subject to fusion.textO(n) A strict version of . Subject to fusion.textO(n) A variant of  that has no starting value argument, and thus must be applied to a non-empty . Subject to fusion.textO(n) A strict version of . Subject to fusion.textO(n) , applied to a binary operator, a starting value (typically the right-identity of the operator), and a , reduces the  using the binary operator, from right to left. Subject to fusion.textO(n) A variant of  that has no starting value argument, and thus must be applied to a non-empty . Subject to fusion.textO(n) Concatenate a list of s.textO(n) Map a function over a  that results in a , and concatenate the results.textO(n)  p t* determines whether any character in the  t satisfies the predicate p. Subject to fusion.textO(n)  p t+ determines whether all characters in the  t satisfy the predicate p. Subject to fusion.textO(n) " returns the maximum value from a ., which must be non-empty. Subject to fusion.textO(n) " returns the minimum value from a ., which must be non-empty. Subject to fusion.textO(n)  is similar to , but returns a list of successive reduced values from the left. Subject to fusion. Performs replacement on invalid scalar values. 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.textO(n)  is a variant of  that has no starting value argument. Performs replacement on invalid scalar values. .scanl1 f [x1, x2, ...] == [x1, x1 `f` x2, ...]textO(n)  is the right-to-left dual of 2. Performs replacement on invalid scalar values. 1scanr f v == reverse . scanl (flip f) v . reversetextO(n)  is a variant of  that has no starting value argument. Performs replacement on invalid scalar values.textO(n) Like a combination of  and +. Applies a function to each element of a , passing an accumulating parameter from left to right, and returns a final 2. Performs replacement on invalid scalar values.textThe ( function behaves like a combination of  and a strict .; it applies a function to each element of a , passing an accumulating parameter from right to left, and returning a final value of this accumulator together with the new 1. Performs replacement on invalid scalar values.text x is an infinite , with x the value of every element.textO(n*m)  n t is a  consisting of the input t repeated n times.text ties a finite, non-empty  into a circular one, or equivalently, the infinite repetition of the original .text f x returns an infinite  of repeated applications of f to x: %iterate f x == [x, f x, f (f x), ...]textO(n), where n" is the length of the result. The $ function is analogous to the List .  builds a  from a seed value. The function takes the element and returns  if it is done producing the  , otherwise  (a,b). In this case, a is the next  in the string, and b is the seed value for further production. Subject to fusion. Performs replacement on invalid scalar values.textO(n) Like ,  builds a  from a seed value. However, the length of the result should be limited by the first argument to (. This function is more efficient than  when the maximum length of the result is known and correct, otherwise its performance is similar to . Subject to fusion. Performs replacement on invalid scalar values.textO(n)  n, applied to a , returns the prefix of the  of length n , or the  itself if n< is greater than the length of the Text. Subject to fusion.textO(n)  n t, returns the suffix remaining after taking n characters from the end of t. Examples: takeEnd 3 "foobar" == "bar"textO(n)  n, applied to a , returns the suffix of the  after the first n characters, or the empty  if n$ is greater than the length of the . Subject to fusion.textO(n)  n t. returns the prefix remaining after dropping n characters from the end of t. Examples: dropEnd 3 "foobar" == "foo"textO(n) , applied to a predicate p and a , returns the longest prefix (possibly empty) of elements that satisfy p. Subject to fusion.textO(n) , applied to a predicate p and a , returns the longest suffix (possibly empty) of elements that satisfy p . Examples: "takeWhileEnd (=='o') "foo" == "oo"textO(n)  p t% returns the suffix remaining after  p t. Subject to fusion.textO(n)  p t returns the prefix remaining after dropping characters that satisfy the predicate p from the end of t. Examples: &dropWhileEnd (=='.') "foo..." == "foo"textO(n)  p t returns the substring remaining after dropping characters that satisfy the predicate p% from both the beginning and end of t.textO(n): Remove leading white space from a string. Equivalent to: dropWhile isSpacetextO(n); Remove trailing white space from a string. Equivalent to: dropWhileEnd isSpacetextO(n) Remove leading and trailing white space from a string. Equivalent to: dropAround isSpacetextO(n)  n t4 returns a pair whose first element is a prefix of t of length n, and whose second is the remainder of the string. It is equivalent to ( n t,  n t).textO(n+m) Find the first instance of needle (which must be non-) in haystack=. The first element of the returned tuple is the prefix of haystack before needle. is matched. The second is the remainder of haystack, starting with the match. Examples: breakOn "::" "a::b::c" ==> ("a", "::b::c") breakOn "/" "foobar" ==> ("foobar", "")Laws: append prefix match == haystack where (prefix, match) = breakOn needle haystackIf you need to break a string by a substring repeatedly (e.g. you want to break on every instance of a substring), use , instead, as it has lower startup overhead.This function is strict in its first argument, and lazy in its second.In (unlikely) bad cases, this function's time complexity degrades towards O(n*m).textO(n+m) Similar to *, but searches from the end of the string.9The first element of the returned tuple is the prefix of haystack( up to and including the last match of needle#. The second is the remainder of haystack, following the match. -breakOnEnd "::" "a::b::c" ==> ("a::b::", "c")textO(n+m)' Find all non-overlapping instances of needle in haystack8. Each element of the returned list consists of a pair:The entire string prior to the kth match (i.e. the prefix)The k1th match, followed by the remainder of the string Examples: breakOnAll "::" "" ==> [] breakOnAll "/" "a/b/c/" ==> [("a", "/b/c/"), ("a/b", "/c/"), ("a/b/c", "/")]This function is strict in its first argument, and lazy in its second.In (unlikely) bad cases, this function's time complexity degrades towards O(n*m).The needle parameter may not be empty.textO(n)  is like , but the prefix returned is over elements that fail the predicate p.T.break (=='c') "180cm" ("180","cm")textO(n) , applied to a predicate p and text t, returns a pair whose first element is the longest prefix (possibly empty) of t of elements that satisfy p1, and whose second is the remainder of the list.T.span (=='0') "000AB" ("000","AB")textThe  function takes a  and returns a list of s such that the concatenation of the result is equal to the argument. Moreover, each sublist in the result contains only equal elements. For example, :group "Mississippi" = ["M","i","ss","i","ss","i","pp","i"]It is a special case of , which allows the programmer to supply their own equality test.textThe + function is the non-overloaded version of .textO(n)* Return all initial segments of the given , shortest first.textO(n)( Return all final segments of the given , longest first.textO(m+n) Break a $ into pieces separated by the first  argument (which cannot be an empty string), consuming the delimiter. An empty delimiter is invalid, and will cause an error to be raised. Examples: splitOn "\r\n" "a\r\nb\r\nd\r\ne" == ["a","b","d","e"] splitOn "aaa" "aaaXaaaXaaaXaaa" == ["","X","X","X",""] splitOn "x" "x" == ["",""]and intercalate s . splitOn s == id splitOn (singleton c) == split (==c)(Note: the string s$ to split on above cannot be empty.)This function is strict in its first argument, and lazy in its second.In (unlikely) bad cases, this function's time complexity degrades towards O(n*m).textO(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. split (=='a') "aabbaca" == ["","","bb","c",""] split (=='a') [] == [""]textO(n) Splits a  into components of length k. The last element may be shorter than the other chunks, depending on the length of the input. Examples: chunksOf 3 "foobarbaz" == ["foo","bar","baz"] chunksOf 4 "haskell.org" == ["hask","ell.","org"]textO(n) Breaks a  up into a list of s at newline 1s. The resulting strings do not contain newlines.textO(n) Breaks a ' up into a list of words, delimited by s representing white space.textO(n)= Joins lines, after appending a terminating newline to each.textO(n)+ Joins words using single space characters.textO(n) The  function takes two s and returns = iff the first is a prefix of the second. Subject to fusion.textO(n) The  function takes two s and returns ) iff the first is a suffix of the second.textO(n+m) The  function takes two s and returns  iff the first is contained, wholly and intact, anywhere within the second.This function is strict in its first argument, and lazy in its second.In (unlikely) bad cases, this function's time complexity degrades towards O(n*m).textO(n) Return the suffix of the second string if its prefix matches the entire first string. Examples: stripPrefix "foo" "foobar" == Just "bar" stripPrefix "" "baz" == Just "baz" stripPrefix "foo" "quux" == Nothing%This is particularly useful with the  ViewPatterns extension to GHC, as follows: {-# LANGUAGE ViewPatterns #-} import Data.Text.Lazy as T fnordLength :: Text -> Int fnordLength (stripPrefix "fnord" -> Just suf) = T.length suf fnordLength _ = -1textO(n) Find the longest non-empty common prefix of two strings and return it, along with the suffixes of each string at which they no longer match.If the strings do not have a common prefix or either one is empty, this function returns . Examples: commonPrefixes "foobar" "fooquux" == Just ("foo","bar","quux") commonPrefixes "veeble" "fetzer" == Nothing commonPrefixes "" "baz" == NothingtextO(n) Return the prefix of the second string if its suffix matches the entire first string. Examples: stripSuffix "bar" "foobar" == Just "foo" stripSuffix "" "baz" == Just "baz" stripSuffix "foo" "quux" == Nothing%This is particularly useful with the  ViewPatterns extension to GHC, as follows: {-# LANGUAGE ViewPatterns #-} import Data.Text.Lazy as T quuxLength :: Text -> Int quuxLength (stripSuffix "quux" -> Just pre) = T.length pre quuxLength _ = -1textO(n) , applied to a predicate and a  , returns a 9 containing those characters that satisfy the predicate.textO(n) The " function takes a predicate and a ?, and returns the first element in matching the predicate, or 1 if there is no such element. Subject to fusion.textO(n) The " function takes a predicate and a , and returns the pair of s with elements which do and do not satisfy the predicate, respectively; i.e. 1partition p t == (filter p t, filter (not . p) t)textO(n)  index (subscript) operator, starting from 0. Subject to fusion.textO(n+m) The  function returns the number of times the query string appears in the given . An empty query string is invalid, and will cause an error to be raised.In (unlikely) bad cases, this function's time complexity degrades towards O(n*m).textO(n)  takes two s and returns a list of corresponding pairs of bytes. If one input * is short, excess elements of the longer 1 are discarded. This is equivalent to a pair of  operations.textO(n)  generalises  by zipping with the function given as the first argument, instead of a tupling function. Performs replacement on invalid scalar values.textOnly defined for  base-4.7.0.0 and latertext0This instance has similar considerations to the  instance: it preserves abstraction at the cost of inefficiency.textThis instance preserves data abstraction at the cost of inefficiency. We omit reflection services for the sake of data abstraction.>This instance was created by copying the updated behavior of  Data.Text.2texttexttext Non-orphan  instance only defined for  base-4.9.0.0 and later; orphan instances for older GHCs are provided by the  -http://hackage.haskell.org/package/semigroups semigroups packagetextneedle? to search for. If this string is empty, an error will occur.text replacement to replace needle with.texthaystack in which to search.textneedle to search fortexthaystack in which to searchtextString to split on. If this string is empty, an error will occur.text Input text.5"(c) 2010, 2011 Bryan O'Sullivan BSD-stylebos@serpentine.comGHCSafe StextRead some text. If the read succeeds, return its value and the remaining text, otherwise an error message.textRead a decimal integer. The input must begin with at least one decimal digit, and is consumed until a non-digit or end of string is reached.This function does not handle leading sign characters. If you need to handle signed input, use  .Note: For fixed-width integer types, this function does not attempt to detect overflow, so a sufficiently long input may give incorrect results. If you are worried about overflow, use  for your result type.text?Read a hexadecimal integer, consisting of an optional leading "0x" followed by at least one hexadecimal digit. Input is consumed until a non-hex-digit or end of string is reached. This function is case insensitive.This function does not handle leading sign characters. If you need to handle signed input, use  .Note: For fixed-width integer types, this function does not attempt to detect overflow, so a sufficiently long input may give incorrect results. If you are worried about overflow, use  for your result type.text)Read an optional leading sign character ('-' or '+';) and apply it to the result of applying the given reader.textRead a rational number.This function accepts an optional leading sign character, followed by at least one decimal digit. The syntax similar to that accepted by the . function, with the exception that a trailing '.' or 'e' not& followed by a number is not consumed. Examples: rational "3" == Right (3.0, "") rational "3.1" == Right (3.1, "") rational "3e4" == Right (30000.0, "") rational "3.1e4" == Right (31000.0, "") rational ".3" == Left "input does not start with a digit" rational "e3" == Left "input does not start with a digit"Examples of differences from : rational "3.foo" == Right (3.0, ".foo") rational "3e" == Right (3.0, "e")textRead a rational number.8The syntax accepted by this function is the same as for .Note0: This function is almost ten times faster than !, but is slightly less accurate.The  type supports about 16 decimal places of accuracy. For 94.2% of numbers, this function and  give identical results, but for the remaining 5.8%, this function loses precision around the 15th decimal place. For 0.001% of numbers, this function will lose precision at the 13th or 14th decimal place.#(c) 2009, 2010 Bryan O'Sullivan, (c) 2009 Simon Marlow BSD-stylebos@serpentine.com experimentalGHCNone#$UtextRead a single line of input from a handle, constructing a list of decoded chunks as we go. When we're done, transform them into the destination type.textRead a single chunk of strict text from a buffer. Used by both the strict and lazy implementations of hGetContents.%>(c) 2013 Bryan O'Sullivan (c) 2010 Johan TibellBSD-style (see LICENSE)%Johan Tibell  experimentalportable to Hugs and GHCNone] textA Builder# is an efficient way to build lazy Text values. There are several functions for constructing builders, but only one to inspect them: to extract any data, you have to turn them into lazy Text values using  toLazyText.(Internally, a builder constructs a lazy Text by filling arrays piece by piece. As each buffer is filled, it is 'popped' off, to become a new chunk of the resulting lazy Text,. All this is hidden from the user of the Builder.textO(1). A Builder& taking a single character, satisfying  ( c) =  ctextO(1). A Builder taking a N , satisfying  ( t) =  [t]textO(1). A Builder taking a String , satisfying  ( s) =  [S.pack s]textO(1). A Builder taking a lazy Text , satisfying  ( t) = ttextO(n). Extract a lazy Text from a Builder with a default buffer size. The construction work takes place if and when the relevant part of the lazy Text is demanded.textO(n). Extract a lazy Text from a Builder, using the given size for the initial buffer. The construction work takes place if and when the relevant part of the lazy Text is demanded.If the initial buffer is too small to hold all data, subsequent buffers will be the default buffer size.textO(1). Pop the strict Text we have constructed so far, if any, yielding a new chunk in the result lazy Text.textEnsure that there are at least n many elements available.text Ensure that n+ many elements are available, and then use f) to write some elements into the memory.  $>(c) 2013 Bryan O'Sullivan (c) 2010 Johan TibellBSD-style (see LICENSE)%Johan Tibell portable to Hugs and GHC Trustworthy^&(c) 2011 MailRank, Inc. BSD-stylebos@serpentine.com experimentalGHCNone_text%Unsafe conversion for decimal digits.text The normal 4 function with right associativity instead of left.4' Trustworthy_('(c) The University of Glasgow 1994-2002see libraries/base/LICENSE Trustworthy dWtext0Control the rendering of floating point numbers.textScientific notation (e.g. 2.3e123).textStandard decimal notation.text(Use decimal notation for values between 0.1 and  9,999,999$, and scientific notation otherwise.textShow a signed  value to full precision, using standard decimal notation for arguments whose absolute value lies between 0.1 and  9,999,999$, and scientific notation otherwise.textEncode a signed  according to $ and optionally requested precision.This corresponds to the show{E,F,G}Float operations provided by base's Numeric module.NOTE: The functions in  base-4.12) changed the serialisation in case of a Just 0 precision; this version of text5 still provides the serialisation as implemented in  base-4.11. The next major version of text! will switch to the more correct  base-4.12 serialisation.text#Number of decimal places to render.)(c) 2009, 2010 Bryan O'Sullivan, (c) 2009 Simon Marlow BSD-stylebos@serpentine.comGHC Trustworthy#$l textThe  function reads a file and returns the contents of the file as a string. The entire file is read strictly, as with .textWrite a string to a file. The file is truncated to zero length before writing begins.text!Write a string the end of a file.text Experimental., Read a single chunk of strict text from a . The size of the chunk depends on the amount of input currently buffered.This function blocks only if there is no data available, and EOF has not yet been reached. Once EOF is reached, this function returns an empty string instead of throwing an exception.text!Read the remaining contents of a  as a string. The  is closed once the contents have been read, or if an exception is thrown.Internally, this function reads a chunk at a time from the lower-level buffering abstraction, and concatenates the chunks into a single string once the entire file has been read.As a result, it requires approximately twice as much memory as its result to construct its result. For files more than a half of available RAM in size, this may result in memory exhaustion.text!Read a single line from a handle.textWrite a string to a handle.text2Write a string to a handle, followed by a newline.textThe # function takes a function of type  Text -> Text 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.textRead all user input on  as a single string.text&Read a single line of user input from .textWrite a string to .textWrite a string to , followed by a newline.  *(c) 2009, 2010 Bryan O'Sullivan, (c) 2009 Simon Marlow BSD-stylebos@serpentine.comGHC Trustworthy#$p textRead a file and return its contents as a string. The file is read lazily, as with .textWrite a string to a file. The file is truncated to zero length before writing begins.text!Write a string the end of a file.text(Lazily read the remaining contents of a . The 7 will be closed after the read completes, or on error.text!Read a single line from a handle.textWrite a string to a handle.text2Write a string to a handle, followed by a newline.textThe # function takes a function of type  Text -> Text as its argument. The entire input from the standard input device is passed (lazily) to this function as its argument, and the resulting string is output on the standard output device.textLazily read all user input on  as a single string.text&Read a single line of user input from .textWrite a string to .textWrite a string to , followed by a newline.  3456789:;<=>?@ABCDEFGHIJKLM N N O P Q R S T U V W X+Y+Z [ \ ] ^ _ ` a b b c d d e f g h i j k l m n o p q r s t i u v w I x y J K z {22k|}~kM,,,M@2k       !!!!!!!!!!!!!!!!!!!!M@""""""##%%%%%%%%%%%%%%%%%&&''((((((((()))))))))))))************333333333333333333333#text-1.2.4.1-9XjLg7jyO9JFRb8fG3DntTData.Text.UnsafeData.Text.Encoding.Error%Data.Text.Internal.Builder.Int.Digits.Data.Text.Internal.Builder.RealFloat.Functions#Data.Text.Internal.ByteStringCompat!Data.Text.Internal.Encoding.Utf16!Data.Text.Internal.Encoding.Utf32Data.Text.Internal.FunctionsData.Text.Internal.ReadData.Text.Internal.Unsafe.ShiftData.Text.ArrayData.Text.Internal.Unsafe.Char Data.Text.Internal.Encoding.Utf8 Data.TextData.Text.InternalData.Text.Internal.SearchData.Text.Internal.Fusion.SizeData.Text.Internal.Fusion.Types%Data.Text.Internal.Fusion.CaseMapping Data.Text.Internal.Fusion.CommonData.Text.Internal.PrivateData.Text.Internal.Fusion)Data.Text.Internal.Encoding.Fusion.Common'Data.Text.Internal.Lazy.Encoding.Fusion"Data.Text.Internal.Encoding.FusionData.Text.EncodingData.Text.ForeignData.Text.ReadData.Text.LazyData.Text.Internal.LazyData.Text.Internal.Lazy.SearchData.Text.Internal.Lazy.FusionData.Text.Lazy.EncodingData.Text.Lazy.ReadData.Text.Internal.IOData.Text.Lazy.BuilderData.Text.Internal.Builder$Data.Text.Internal.Builder.FunctionsData.Text.Lazy.Builder.Int Data.Text.Lazy.Builder.RealFloat Data.Text.IOData.Text.Lazy.IOData.Text.Internal.UnsafeData.Text.ShowData.SetSetData.MapMapData.Text.Lazy.InternalTextbase GHC.IO.UnsafeunsafeDupablePerformIOUnicodeException DecodeError EncodeError OnEncodeError OnDecodeErrorOnError strictDecode lenientDecode strictEncodeignorereplace$fNFDataUnicodeException$fExceptionUnicodeException$fShowUnicodeException$fEqUnicodeExceptiondigitsroundTomkBSwithBSchr2 validate1 validate2validate intersperseTIParserPrunPIReaderperhaps hexDigitToInt digitToInt$fMonadIParser$fApplicativeIParser$fFunctorIParserinlinePerformIOinlineInterleaveST UnsafeShiftshiftLshiftR$fUnsafeShiftInt$fUnsafeShiftWord64$fUnsafeShiftWord32$fUnsafeShiftWord16MArraymaBAArrayaBAnew unsafeFreeze unsafeIndex unsafeWritetoListemptyrunrun2copyMcopyIequalord unsafeChr unsafeChr8 unsafeChr32ord2ord3ord4chr3chr4 validate3 validate4empty_texttextPshowTextsafefirstfmulmul64mul32indicesSizeexactlycharSizecodePointsSize exactSizemaxSize betweenSize unionSize unknownSizesmallerlarger upperBound lowerBound compareSizeisEmpty $fNumSize$fEqSize $fShowSizeStreamStepDoneSkipYieldScanScan1Scan2PairS:*:RSRS0RS1RS2RS3CC $fOrdStream $fEqStream upperMapping lowerMapping titleMapping foldMapping singleton streamList unstreamListstreamCString#conssnocappendheadunconslasttailinitnulllengthIcompareLengthI isSingletonmap toCaseFoldtoUppertoLowertoTitle justifyLeftIfoldlfoldl'foldl1foldl1'foldrfoldr1 intercalateconcat concatMapanyallmaximumminimumscanlreplicateCharI replicateIunfoldr unfoldrNItakedrop takeWhile dropWhile isPrefixOfelemfindByindexIfilter findIndexIzipWith countCharIIter unsafeHead unsafeTailiteriter_ reverseIter reverseIter_ lengthWord16 takeWord16 dropWord16span_runTextstream reverseStreamunstreamlengthreverse reverseScanrunfoldrNindex findIndex countChar mapAccumLunpackunpackCString#restreamUtf16BErestreamUtf16LErestreamUtf32BErestreamUtf32LE streamUtf8 streamUtf16LE streamUtf16BE streamUtf32BE streamUtf32LE streamASCIIDecodingSome decodeASCII decodeLatin1decodeUtf8WithstreamDecodeUtf8streamDecodeUtf8With decodeUtf8 decodeUtf8'encodeUtf8BuilderencodeUtf8BuilderEscaped encodeUtf8decodeUtf16LEWith decodeUtf16LEdecodeUtf16BEWith decodeUtf16BE encodeUtf16LE encodeUtf16BEdecodeUtf32LEWith decodeUtf32LEdecodeUtf32BEWith decodeUtf32BE encodeUtf32LE encodeUtf32BE$fShowDecoding$fEqDecoderState$fShowDecoderState$fNumDecoderState$fStorableDecoderState $fEqCodePoint$fShowCodePoint$fNumCodePoint$fStorableCodePointI16fromPtrunsafeCopyToPtruseAsPtr asForeignPtrpeekCStringLenwithCStringLen $fBoundedI16 $fEnumI16$fEqI16 $fIntegralI16$fNumI16$fOrdI16 $fReadI16 $fRealI16 $fShowI16packunsnoc compareLength justifyLeft justifyRightcenter transposescanl1scanrscanr1 mapAccumR replicatetakeEnddropEnd takeWhileEnd dropWhileEnd dropAround stripStartstripEndstripsplitAtspanbreakgroupBygroupinitstailssplitOnsplitchunksOffind partitionbreakOn breakOnEnd breakOnAllcountzipwordslinesunlinesunwords isSuffixOf isInfixOf stripPrefixcommonPrefixes stripSuffixcopy$fPrintfArgText$fLiftLiftedRepText $fDataText $fBinaryText $fNFDataText $fIsListText$fIsStringText $fMonoidText$fSemigroupText $fReadText $fOrdText$fEqTextReaderdecimal hexadecimalsignedrationaldoubleEmptyChunkstrictInvariant lazyInvariant showStructurechunk foldrChunks foldlChunksdefaultChunkSizesmallChunkSize chunkOverheadunstreamChunks fromChunkstoChunkstoStrict fromStrictrepeatcycleiterate $fShowText hGetLineWith readChunkBuilderfromText fromString fromLazyText toLazyTexttoLazyTextWithflush ensureFreewriteNappend' $fOrdBuilder $fEqBuilder $fShowBuilder$fIsStringBuilder$fMonoidBuilder$fSemigroupBuilderi2d<>FPFormatExponentFixedGeneric realFloatformatRealFloat$fEnumFPFormat$fReadFPFormat$fShowFPFormatreadFile writeFile appendFile hGetChunk hGetContentshGetLinehPutStr hPutStrLninteract getContentsgetLineputStrputStrLnGHC.BaseString GHC.MaybeNothingJustGHC.Errerror GHC.ExceptionthrowGHC.STSTGHC.WordWord16GHC.Showshowghc-prim GHC.TypesCharTrueGHC.Listbytestring-0.10.10.0Data.ByteString.Lazy.Internal ByteStringWord8Data.ByteString.Internal Data.ByteString.Builder.Internal%Data.ByteString.Builder.Prim.Internal BoundedPrimGHC.PtrPtr Data.OldList Data.DataData Semigroupinteger-wired-inGHC.Integer.TypeInteger Text.ReadreadDoublemappend GHC.Float RealFloatGHC.IO.Handle.TypesHandleGHC.IO.Handle.FDstdinstdout