-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | An efficient packed Unicode text type.
°5u
°5uAn efficient packed, immutable Unicode text type (both strict and
°5ulazy), with a powerful loop fusion optimization framework.
°5u
°5uThe <a>Text</a> type represents Unicode character strings, in a time
°5uand space-efficient manner. This package provides text processing
°5ucapabilities that are optimized for performance critical use, both in
°5uterms of large data quantities and high speed.
°5u
°5uThe <a>Text</a> type provides character-encoding, type-safe case
°5uconversion via whole-string case conversion functions. It also
°5uprovides a range of functions for converting <a>Text</a> values to and
°5ufrom <a>ByteStrings</a>, using several standard encodings.
°5u
°5uEfficient locale-sensitive support for text IO is also supported.
°5u
°5uThese modules are intended to be imported qualified, to avoid name
°5uclashes with Prelude functions, e.g.
°5u
°5u<pre>
°5uimport qualified Data.Text as T
°5u</pre>
°5u
°5uTo use an extended and very rich family of functions for working with
°5uUnicode text (including normalization, regular expressions,
°5unon-standard encodings, text breaking, and locales), see the
°5u<tt>text-icu</tt> package:
°5u<a>http://hackage.haskell.org/package/text-icu</a>
@package text
@version 1.2.3.0


-- | Types and functions for dealing with encoding and decoding errors in
°5uUnicode text.
°5u
°5uThe standard functions for encoding and decoding text are strict,
°5uwhich is to say that they throw exceptions on invalid input. This is
°5uoften unhelpful on real world input, so alternative functions exist
°5uthat accept custom handlers for dealing with invalid inputs. These
°5u<a>OnError</a> handlers are normal Haskell functions. You can use one
°5uof the presupplied functions in this module, or you can write a custom
°5uhandler of your own.
module Data.Text.Encoding.Error

-- | An exception type for representing Unicode encoding errors.
data UnicodeException

-- | Could not decode a byte sequence because it was invalid under the
°5ugiven encoding, or ran out of input in mid-decode.
DecodeError :: String -> (Maybe Word8) -> UnicodeException

-- | Tried to encode a character that could not be represented under the
°5ugiven encoding, or ran out of input in mid-encode.

-- | <i>Deprecated: This constructor is never used, and will be
°5uremoved.</i>
EncodeError :: String -> (Maybe Char) -> UnicodeException

-- | Function type for handling a coding error. It is supplied with two
°5uinputs:
°5u
°5u<ul>
°5u<li>A <a>String</a> that describes the error.</li>
°5u<li>The input value that caused the error. If the error arose because
°5uthe end of input was reached or could not be identified precisely,
°5uthis value will be <a>Nothing</a>.</li>
°5u</ul>
°5u
°5uIf the handler returns a value wrapped with <a>Just</a>, that value
°5uwill be used in the output as the replacement for the invalid input.
°5uIf it returns <a>Nothing</a>, no value will be used in the output.
°5u
°5uShould the handler need to abort processing, it should use
°5u<a>error</a> or <a>throw</a> an exception (preferably a
°5u<a>UnicodeException</a>). It may use the description provided to
°5uconstruct a more helpful error report.
type OnError a b = String -> Maybe a -> Maybe b

-- | A handler for a decoding error.
type OnDecodeError = OnError Word8 Char

-- | A handler for an encoding error.

-- | <i>Deprecated: This exception is never used in practice, and will be
°5uremoved.</i>
type OnEncodeError = OnError Char Word8

-- | Replace an invalid input byte with the Unicode replacement character
°5uU+FFFD.
lenientDecode :: OnDecodeError

-- | Throw a <a>UnicodeException</a> if decoding fails.
strictDecode :: OnDecodeError

-- | Throw a <a>UnicodeException</a> if encoding fails.

-- | <i>Deprecated: This function always throws an exception, and will be
°5uremoved.</i>
strictEncode :: OnEncodeError

-- | Ignore an invalid input, substituting nothing in the output.
ignore :: OnError a b

-- | Replace an invalid input with a valid output.
replace :: b -> OnError a b
instance GHC.Classes.Eq Data.Text.Encoding.Error.UnicodeException
instance GHC.Show.Show Data.Text.Encoding.Error.UnicodeException
instance GHC.Exception.Exception Data.Text.Encoding.Error.UnicodeException
instance Control.DeepSeq.NFData Data.Text.Encoding.Error.UnicodeException

module Data.Text.Internal.Builder.Int.Digits
digits :: ByteString


-- | <i>Warning</i>: this is an internal module, and does not have a stable
°5uAPI or name. Functions in this module may not check or enforce
°5upreconditions expected by public modules. Use at your own risk!
module Data.Text.Internal.Builder.RealFloat.Functions
roundTo :: Int -> [Int] -> (Int, [Int])


-- | <i>Warning</i>: this is an internal module, and does not have a stable
°5uAPI or name. Functions in this module may not check or enforce
°5upreconditions expected by public modules. Use at your own risk!
°5u
°5uBasic UTF-16 validation and character manipulation.
module Data.Text.Internal.Encoding.Utf16
chr2 :: Word16 -> Word16 -> Char
validate1 :: Word16 -> Bool
validate2 :: Word16 -> Word16 -> Bool


-- | <i>Warning</i>: this is an internal module, and does not have a stable
°5uAPI or name. Functions in this module may not check or enforce
°5upreconditions expected by public modules. Use at your own risk!
°5u
°5uBasic UTF-32 validation.
module Data.Text.Internal.Encoding.Utf32
validate :: Word32 -> Bool


-- | <i>Warning</i>: this is an internal module, and does not have a stable
°5uAPI or name. Functions in this module may not check or enforce
°5upreconditions expected by public modules. Use at your own risk!
°5u
°5uUseful functions.
module Data.Text.Internal.Functions

-- | A lazier version of Data.List.intersperse. The other version causes
°5uspace leaks!
intersperse :: a -> [a] -> [a]


-- | Common internal functions for reading textual data.
module Data.Text.Internal.Read
type IReader t a = t -> Either String (a, t)
newtype IParser t a
P :: IReader t a -> IParser t a
[runP] :: IParser t a -> IReader t a
data T
T :: !Integer -> !Int -> T
digitToInt :: Char -> Int
hexDigitToInt :: Char -> Int
perhaps :: a -> IParser t a -> IParser t a
instance GHC.Base.Functor (Data.Text.Internal.Read.IParser t)
instance GHC.Base.Applicative (Data.Text.Internal.Read.IParser t)
instance GHC.Base.Monad (Data.Text.Internal.Read.IParser t)


-- | <i>Warning</i>: this is an internal module, and does not have a stable
°5uAPI or name. Functions in this module may not check or enforce
°5upreconditions expected by public modules. Use at your own risk!
°5u
°5uA module containing <i>unsafe</i> operations, for <i>very very
°5ucareful</i> use in <i>heavily tested</i> code.
module Data.Text.Internal.Unsafe

-- | Allow an <a>ST</a> computation to be deferred lazily. When passed an
°5uaction of type <a>ST</a> <tt>s</tt> <tt>a</tt>, the action will only
°5ube performed when the value of <tt>a</tt> is demanded.
°5u
°5uThis function is identical to the normal unsafeInterleaveST, but is
°5uinlined and hence faster.
°5u
°5u<i>Note</i>: This operation is highly unsafe, as it can introduce
°5uexternally visible non-determinism into an <a>ST</a> action.
inlineInterleaveST :: ST s a -> ST s a

-- | Just like unsafePerformIO, but we inline it. Big performance gains as
°5uit exposes lots of things to further inlining. <i>Very unsafe</i>. In
°5uparticular, you should do no memory allocation inside an
°5u<a>inlinePerformIO</a> block. On Hugs this is just
°5u<tt>unsafePerformIO</tt>.
inlinePerformIO :: IO a -> a


-- | <i>Warning</i>: this is an internal module, and does not have a stable
°5uAPI or name. Functions in this module may not check or enforce
°5upreconditions expected by public modules. Use at your own risk!
°5u
°5uFast, unchecked bit shifting functions.
module Data.Text.Internal.Unsafe.Shift

-- | This is a workaround for poor optimisation in GHC 6.8.2. It fails to
°5unotice constant-width shifts, and adds a test and branch to every
°5ushift. This imposes about a 10% performance hit.
°5u
°5uThese functions are undefined when the amount being shifted by is
°5ugreater than the size in bits of a machine Int#.
class UnsafeShift a
shiftL :: UnsafeShift a => a -> Int -> a
shiftR :: UnsafeShift a => a -> Int -> a
instance Data.Text.Internal.Unsafe.Shift.UnsafeShift GHC.Word.Word16
instance Data.Text.Internal.Unsafe.Shift.UnsafeShift GHC.Word.Word32
instance Data.Text.Internal.Unsafe.Shift.UnsafeShift GHC.Word.Word64
instance Data.Text.Internal.Unsafe.Shift.UnsafeShift GHC.Types.Int


-- | Packed, unboxed, heap-resident arrays. Suitable for performance
°5ucritical use, both in terms of large data quantities and high speed.
°5u
°5uThis module is intended to be imported <tt>qualified</tt>, to avoid
°5uname clashes with <a>Prelude</a> functions, e.g.
°5u
°5u<pre>
°5uimport qualified Data.Text.Array as A
°5u</pre>
°5u
°5uThe names in this module resemble those in the <a>Array</a> family of
°5umodules, but are shorter due to the assumption of qualified naming.
module Data.Text.Array

-- | Immutable array type.
data Array
Array :: ByteArray# -> Array
[aBA] :: Array -> ByteArray#

-- | Mutable array type, for use in the ST monad.
data MArray s
MArray :: MutableByteArray# s -> MArray s
[maBA] :: MArray s -> MutableByteArray# s

-- | Copy some elements of a mutable array.
copyM :: MArray s -> Int -> MArray s -> Int -> Int -> ST s ()

-- | Copy some elements of an immutable array.
copyI :: MArray s -> Int -> Array -> Int -> Int -> ST s ()

-- | An empty immutable array.
empty :: Array

-- | Compare portions of two arrays for equality. No bounds checking is
°5uperformed.
equal :: Array -> Int -> Array -> Int -> Int -> Bool

-- | Run an action in the ST monad and return an immutable array of its
°5uresult.
run :: (forall s. ST s (MArray s)) -> Array

-- | Run an action in the ST monad and return an immutable array of its
°5uresult paired with whatever else the action returns.
run2 :: (forall s. ST s (MArray s, a)) -> (Array, a)

-- | Convert an immutable array to a list.
toList :: Array -> Int -> Int -> [Word16]

-- | Freeze a mutable array. Do not mutate the <a>MArray</a> afterwards!
unsafeFreeze :: MArray s -> ST s Array

-- | Unchecked read of an immutable array. May return garbage or crash on
°5uan out-of-bounds access.
unsafeIndex :: Array -> Int -> Word16

-- | Create an uninitialized mutable array.
new :: forall s. Int -> ST s (MArray s)

-- | Unchecked write of a mutable array. May return garbage or crash on an
°5uout-of-bounds access.
unsafeWrite :: MArray s -> Int -> Word16 -> ST s ()


-- | <i>Warning</i>: this is an internal module, and does not have a stable
°5uAPI or name. Functions in this module may not check or enforce
°5upreconditions expected by public modules. Use at your own risk!
°5u
°5uFast character manipulation functions.
module Data.Text.Internal.Unsafe.Char
ord :: Char -> Int
unsafeChr :: Word16 -> Char
unsafeChr8 :: Word8 -> Char
unsafeChr32 :: Word32 -> Char

-- | Write a character into the array at the given offset. Returns the
°5unumber of <a>Word16</a>s written.
unsafeWrite :: MArray s -> Int -> Char -> ST s Int


-- | <i>Warning</i>: this is an internal module, and does not have a stable
°5uAPI or name. Functions in this module may not check or enforce
°5upreconditions expected by public modules. Use at your own risk!
°5u
°5uBasic UTF-8 validation and character manipulation.
module Data.Text.Internal.Encoding.Utf8
ord2 :: Char -> (Word8, Word8)
ord3 :: Char -> (Word8, Word8, Word8)
ord4 :: Char -> (Word8, Word8, Word8, Word8)
chr2 :: Word8 -> Word8 -> Char
chr3 :: Word8 -> Word8 -> Word8 -> Char
chr4 :: Word8 -> Word8 -> Word8 -> Word8 -> Char
validate1 :: Word8 -> Bool
validate2 :: Word8 -> Word8 -> Bool
validate3 :: Word8 -> Word8 -> Word8 -> Bool
validate4 :: Word8 -> Word8 -> Word8 -> Word8 -> Bool


-- | A module containing private <a>Text</a> internals. This exposes the
°5u<a>Text</a> representation and low level construction functions.
°5uModules which extend the <a>Text</a> system may need to use this
°5umodule.
°5u
°5uYou should not use this module unless you are determined to monkey
°5uwith the internals, as the functions here do just about nothing to
°5upreserve data invariants. You have been warned!
module Data.Text.Internal

-- | A space efficient, packed, unboxed Unicode text type.
data Text
Text :: {-# UNPACK #-} !Array -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> Text

-- | Construct a <a>Text</a> without invisibly pinning its byte array in
°5umemory if its length has dwindled to zero.
text :: Array -> Int -> Int -> Text

-- | <i>Deprecated: Use text instead</i>
textP :: Array -> Int -> Int -> Text

-- | Map a <a>Char</a> to a <a>Text</a>-safe value.
°5u
°5uUTF-16 surrogate code points are not included in the set of Unicode
°5uscalar values, but are unfortunately admitted as valid <a>Char</a>
°5uvalues by Haskell. They cannot be represented in a <a>Text</a>. This
°5ufunction remaps those code points to the Unicode replacement character
°5u(U+FFFD, '�'), and leaves other code points unchanged.
safe :: Char -> Char

-- | <i>O(1)</i> The empty <a>Text</a>.
empty :: Text

-- | A non-inlined version of <a>empty</a>.
empty_ :: Text

-- | Apply a function to the first element of an optional pair.
firstf :: (a -> c) -> Maybe (a, b) -> Maybe (c, b)

-- | Checked multiplication. Calls <a>error</a> if the result would
°5uoverflow.
mul :: Int -> Int -> Int
infixl 7 `mul`

-- | Checked multiplication. Calls <a>error</a> if the result would
°5uoverflow.
mul32 :: Int32 -> Int32 -> Int32
infixl 7 `mul32`

-- | Checked multiplication. Calls <a>error</a> if the result would
°5uoverflow.
mul64 :: Int64 -> Int64 -> Int64
infixl 7 `mul64`

-- | A useful <a>show</a>-like function for debugging purposes.
showText :: Text -> String


-- | Fast substring search for <a>Text</a>, based on work by Boyer, Moore,
°5uHorspool, Sunday, and Lundh.
°5u
°5uReferences:
°5u
°5u<ul>
°5u<li>R. S. Boyer, J. S. Moore: A Fast String Searching Algorithm.
°5uCommunications of the ACM, 20, 10, 762-772 (1977)</li>
°5u<li>R. N. Horspool: Practical Fast Searching in Strings. Software -
°5uPractice and Experience 10, 501-506 (1980)</li>
°5u<li>D. M. Sunday: A Very Fast Substring Search Algorithm.
°5uCommunications of the ACM, 33, 8, 132-142 (1990)</li>
°5u<li>F. Lundh: The Fast Search Algorithm.
°5u<a>http://effbot.org/zone/stringlib.htm</a> (2006)</li>
°5u</ul>
module Data.Text.Internal.Search

-- | <i>O(n+m)</i> Find the offsets of all non-overlapping indices of
°5u<tt>needle</tt> within <tt>haystack</tt>. The offsets returned
°5urepresent uncorrected indices in the low-level "needle" array, to
°5uwhich its offset must be added.
°5u
°5uIn (unlikely) bad cases, this algorithm's complexity degrades towards
°5u<i>O(n*m)</i>.
indices :: Text -> Text -> [Int]


-- | <i>Warning</i>: this is an internal module, and does not have a stable
°5uAPI or name. Functions in this module may not check or enforce
°5upreconditions expected by public modules. Use at your own risk!
°5u
°5uSize hints.
module Data.Text.Internal.Fusion.Size
data Size
exactly :: Size -> Maybe Int
exactSize :: Int -> Size
maxSize :: Int -> Size
betweenSize :: Int -> Int -> Size
unknownSize :: Size

-- | Minimum of two size hints.
smaller :: Size -> Size -> Size

-- | Maximum of two size hints.
larger :: Size -> Size -> Size

-- | Compute the maximum size from a size hint, if possible.
upperBound :: Int -> Size -> Int

-- | Compute the maximum size from a size hint, if possible.
lowerBound :: Int -> Size -> Int
compareSize :: Size -> Int -> Maybe Ordering
isEmpty :: Size -> Bool
instance GHC.Show.Show Data.Text.Internal.Fusion.Size.Size
instance GHC.Classes.Eq Data.Text.Internal.Fusion.Size.Size
instance GHC.Num.Num Data.Text.Internal.Fusion.Size.Size


-- | <i>Warning</i>: this is an internal module, and does not have a stable
°5uAPI or name. Functions in this module may not check or enforce
°5upreconditions expected by public modules. Use at your own risk!
°5u
°5uCore stream fusion functionality for text.
module Data.Text.Internal.Fusion.Types

-- | Specialised tuple for case conversion.
data CC s
CC :: !s -> {-# UNPACK #-} !Char -> {-# UNPACK #-} !Char -> CC s

-- | Strict pair.
data PairS a b
(:*:) :: !a -> !b -> PairS a b

-- | An intermediate result in a scan.
data Scan s
Scan1 :: {-# UNPACK #-} !Char -> !s -> Scan s
Scan2 :: {-# UNPACK #-} !Char -> !s -> Scan s

-- | Restreaming state.
data RS s
RS0 :: !s -> RS s
RS1 :: !s -> {-# UNPACK #-} !Word8 -> RS s
RS2 :: !s -> {-# UNPACK #-} !Word8 -> {-# UNPACK #-} !Word8 -> RS s
RS3 :: !s -> {-# UNPACK #-} !Word8 -> {-# UNPACK #-} !Word8 -> {-# UNPACK #-} !Word8 -> RS s

-- | Intermediate result in a processing pipeline.
data Step s a
Done :: Step s a
Skip :: !s -> Step s a
Yield :: !a -> !s -> Step s a
data Stream a
Stream :: (s -> Step s a) -> !s -> !Size -> Stream a

-- | The empty stream.
empty :: Stream a
instance GHC.Classes.Eq a => GHC.Classes.Eq (Data.Text.Internal.Fusion.Types.Stream a)
instance GHC.Classes.Ord a => GHC.Classes.Ord (Data.Text.Internal.Fusion.Types.Stream a)

module Data.Text.Internal.Fusion.CaseMapping
upperMapping :: forall s. Char -> s -> Step (CC s) Char
lowerMapping :: forall s. Char -> s -> Step (CC s) Char
titleMapping :: forall s. Char -> s -> Step (CC s) Char
foldMapping :: forall s. Char -> s -> Step (CC s) Char


-- | <i>Warning</i>: this is an internal module, and does not have a stable
°5uAPI or name. Functions in this module may not check or enforce
°5upreconditions expected by public modules. Use at your own risk!
°5u
°5uCommon stream fusion functionality for text.
module Data.Text.Internal.Fusion.Common
singleton :: Char -> Stream Char
streamList :: [a] -> Stream a
unstreamList :: Stream a -> [a]

-- | Stream the UTF-8-like packed encoding used by GHC to represent
°5uconstant strings in generated code.
°5u
°5uThis encoding uses the byte sequence "xc0x80" to represent NUL, and
°5uthe string is NUL-terminated.
streamCString# :: Addr# -> Stream Char

-- | <i>O(n)</i> Adds a character to the front of a Stream Char.
cons :: Char -> Stream Char -> Stream Char

-- | <i>O(n)</i> Adds a character to the end of a stream.
snoc :: Stream Char -> Char -> Stream Char

-- | <i>O(n)</i> Appends one Stream to the other.
append :: Stream Char -> Stream Char -> Stream Char

-- | <i>O(1)</i> Returns the first character of a Text, which must be
°5unon-empty. Subject to array fusion.
head :: Stream Char -> Char

-- | <i>O(1)</i> Returns the first character and remainder of a 'Stream
°5uChar', or <a>Nothing</a> if empty. Subject to array fusion.
uncons :: Stream Char -> Maybe (Char, Stream Char)

-- | <i>O(n)</i> Returns the last character of a 'Stream Char', which must
°5ube non-empty.
last :: Stream Char -> Char

-- | <i>O(1)</i> Returns all characters after the head of a Stream Char,
°5uwhich must be non-empty.
tail :: Stream Char -> Stream Char

-- | <i>O(1)</i> Returns all but the last character of a Stream Char, which
°5umust be non-empty.
init :: Stream Char -> Stream Char

-- | <i>O(1)</i> Tests whether a Stream Char is empty or not.
null :: Stream Char -> Bool

-- | <i>O(n)</i> Returns the number of characters in a string.
lengthI :: Integral a => Stream Char -> a

-- | <i>O(n)</i> Compares the count of characters in a string to a number.
°5uSubject to fusion.
°5u
°5uThis function gives the same answer as comparing against the result of
°5u<a>lengthI</a>, but can short circuit if the count of characters is
°5ugreater than the number or if the stream can't possibly be as long as
°5uthe number supplied, and hence be more efficient.
compareLengthI :: Integral a => Stream Char -> a -> Ordering

-- | <i>O(n)</i> Indicate whether a string contains exactly one element.
isSingleton :: Stream Char -> Bool

-- | <i>O(n)</i> <a>map</a> <tt>f </tt>xs is the Stream Char obtained by
°5uapplying <tt>f</tt> to each element of <tt>xs</tt>.
map :: (Char -> Char) -> Stream Char -> Stream Char
intercalate :: Stream Char -> [Stream Char] -> Stream Char

-- | <i>O(n)</i> Take a character and place it between each of the
°5ucharacters of a 'Stream Char'.
intersperse :: Char -> Stream Char -> Stream Char

-- | <i>O(n)</i> Convert a string to folded case. This function is mainly
°5uuseful for performing caseless (or case insensitive) string
°5ucomparisons.
°5u
°5uA string <tt>x</tt> is a caseless match for a string <tt>y</tt> if and
°5uonly if:
°5u
°5u<pre>
°5utoCaseFold x == toCaseFold y
°5u</pre>
°5u
°5uThe result string may be longer than the input string, and may differ
°5ufrom applying <a>toLower</a> to the input string. For instance, the
°5uArmenian small ligature men now (U+FB13) is case folded to the bigram
°5umen now (U+0574 U+0576), while the micro sign (U+00B5) is case folded
°5uto the Greek small letter letter mu (U+03BC) instead of itself.
toCaseFold :: Stream Char -> Stream Char

-- | <i>O(n)</i> Convert a string to lower case, using simple case
°5uconversion. The result string may be longer than the input string. For
°5uinstance, the Latin capital letter I with dot above (U+0130) maps to
°5uthe sequence Latin small letter i (U+0069) followed by combining dot
°5uabove (U+0307).
toLower :: Stream Char -> Stream Char

-- | <i>O(n)</i> Convert a string to title case, using simple case
°5uconversion.
°5u
°5uThe first letter of the input is converted to title case, as is every
°5usubsequent letter that immediately follows a non-letter. Every letter
°5uthat immediately follows another letter is converted to lower case.
°5u
°5uThe result string may be longer than the input string. For example,
°5uthe Latin small ligature ﬂ (U+FB02) is converted to the sequence Latin
°5ucapital letter F (U+0046) followed by Latin small letter l (U+006C).
°5u
°5u<i>Note</i>: this function does not take language or culture specific
°5urules into account. For instance, in English, different style guides
°5udisagree on whether the book name "The Hill of the Red Fox" is
°5ucorrectly title cased—but this function will capitalize <i>every</i>
°5uword.
toTitle :: Stream Char -> Stream Char

-- | <i>O(n)</i> Convert a string to upper case, using simple case
°5uconversion. The result string may be longer than the input string. For
°5uinstance, the German eszett (U+00DF) maps to the two-letter sequence
°5uSS.
toUpper :: Stream Char -> Stream Char
justifyLeftI :: Integral a => a -> Char -> Stream Char -> Stream Char

-- | foldl, applied to a binary operator, a starting value (typically the
°5uleft-identity of the operator), and a Stream, reduces the Stream using
°5uthe binary operator, from left to right.
foldl :: (b -> Char -> b) -> b -> Stream Char -> b

-- | A strict version of foldl.
foldl' :: (b -> Char -> b) -> b -> Stream Char -> b

-- | foldl1 is a variant of foldl that has no starting value argument, and
°5uthus must be applied to non-empty Streams.
foldl1 :: (Char -> Char -> Char) -> Stream Char -> Char

-- | A strict version of foldl1.
foldl1' :: (Char -> Char -> Char) -> Stream Char -> Char

-- | <a>foldr</a>, applied to a binary operator, a starting value
°5u(typically the right-identity of the operator), and a stream, reduces
°5uthe stream using the binary operator, from right to left.
foldr :: (Char -> b -> b) -> b -> Stream Char -> b

-- | foldr1 is a variant of <a>foldr</a> that has no starting value
°5uargument, and thus must be applied to non-empty streams. Subject to
°5uarray fusion.
foldr1 :: (Char -> Char -> Char) -> Stream Char -> Char

-- | <i>O(n)</i> Concatenate a list of streams. Subject to array fusion.
concat :: [Stream Char] -> Stream Char

-- | Map a function over a stream that results in a stream and concatenate
°5uthe results.
concatMap :: (Char -> Stream Char) -> Stream Char -> Stream Char

-- | <i>O(n)</i> any <tt>p </tt>xs determines if any character in the
°5ustream <tt>xs</tt> satisfies the predicate <tt>p</tt>.
any :: (Char -> Bool) -> Stream Char -> Bool

-- | <i>O(n)</i> all <tt>p </tt>xs determines if all characters in the
°5u<tt>Text</tt> <tt>xs</tt> satisfy the predicate <tt>p</tt>.
all :: (Char -> Bool) -> Stream Char -> Bool

-- | <i>O(n)</i> maximum returns the maximum value from a stream, which
°5umust be non-empty.
maximum :: Stream Char -> Char

-- | <i>O(n)</i> minimum returns the minimum value from a <tt>Text</tt>,
°5uwhich must be non-empty.
minimum :: Stream Char -> Char
scanl :: (Char -> Char -> Char) -> Char -> Stream Char -> Stream Char
replicateCharI :: Integral a => a -> Char -> Stream Char
replicateI :: Int64 -> Stream Char -> Stream Char

-- | <i>O(n)</i>, where <tt>n</tt> is the length of the result. The unfoldr
°5ufunction is analogous to the List <a>unfoldr</a>. unfoldr builds a
°5ustream from a seed value. The function takes the element and returns
°5uNothing if it is done producing the stream or returns Just (a,b), in
°5uwhich case, a is the next Char in the string, and b is the seed value
°5ufor further production.
unfoldr :: (a -> Maybe (Char, a)) -> a -> Stream Char

-- | <i>O(n)</i> Like <a>unfoldr</a>, <a>unfoldrNI</a> builds a stream from
°5ua seed value. However, the length of the result is limited by the
°5ufirst argument to <a>unfoldrNI</a>. This function is more efficient
°5uthan <a>unfoldr</a> when the length of the result is known.
unfoldrNI :: Integral a => a -> (b -> Maybe (Char, b)) -> b -> Stream Char

-- | <i>O(n)</i> take n, applied to a stream, returns the prefix of the
°5ustream of length <tt>n</tt>, or the stream itself if <tt>n</tt> is
°5ugreater than the length of the stream.
take :: Integral a => a -> Stream Char -> Stream Char

-- | <i>O(n)</i> drop n, applied to a stream, returns the suffix of the
°5ustream after the first <tt>n</tt> characters, or the empty stream if
°5u<tt>n</tt> is greater than the length of the stream.
drop :: Integral a => a -> Stream Char -> Stream Char

-- | takeWhile, applied to a predicate <tt>p</tt> and a stream, returns the
°5ulongest prefix (possibly empty) of elements that satisfy p.
takeWhile :: (Char -> Bool) -> Stream Char -> Stream Char

-- | dropWhile <tt>p </tt>xs returns the suffix remaining after takeWhile
°5u<tt>p </tt>xs.
dropWhile :: (Char -> Bool) -> Stream Char -> Stream Char

-- | <i>O(n)</i> The <a>isPrefixOf</a> function takes two <a>Stream</a>s
°5uand returns <a>True</a> iff the first is a prefix of the second.
isPrefixOf :: (Eq a) => Stream a -> Stream a -> Bool

-- | <i>O(n)</i> elem is the stream membership predicate.
elem :: Char -> Stream Char -> Bool

-- | <i>O(n)</i> <a>filter</a>, applied to a predicate and a stream,
°5ureturns a stream containing those characters that satisfy the
°5upredicate.
filter :: (Char -> Bool) -> Stream Char -> Stream Char

-- | <i>O(n)</i> The <a>findBy</a> function takes a predicate and a stream,
°5uand returns the first element in matching the predicate, or
°5u<a>Nothing</a> if there is no such element.
findBy :: (Char -> Bool) -> Stream Char -> Maybe Char

-- | <i>O(n)</i> Stream index (subscript) operator, starting from 0.
indexI :: Integral a => Stream Char -> a -> Char

-- | The <a>findIndexI</a> function takes a predicate and a stream and
°5ureturns the index of the first element in the stream satisfying the
°5upredicate.
findIndexI :: Integral a => (Char -> Bool) -> Stream Char -> Maybe a

-- | <i>O(n)</i> The <a>countCharI</a> function returns the number of times
°5uthe query element appears in the given stream.
countCharI :: Integral a => Char -> Stream Char -> a

-- | zipWith generalises <tt>zip</tt> by zipping with the function given as
°5uthe first argument, instead of a tupling function.
zipWith :: (a -> a -> b) -> Stream a -> Stream a -> Stream b


-- | A module containing unsafe <a>Text</a> operations, for very very
°5ucareful use in heavily tested code.
module Data.Text.Unsafe

-- | Allow an <a>ST</a> computation to be deferred lazily. When passed an
°5uaction of type <a>ST</a> <tt>s</tt> <tt>a</tt>, the action will only
°5ube performed when the value of <tt>a</tt> is demanded.
°5u
°5uThis function is identical to the normal unsafeInterleaveST, but is
°5uinlined and hence faster.
°5u
°5u<i>Note</i>: This operation is highly unsafe, as it can introduce
°5uexternally visible non-determinism into an <a>ST</a> action.
inlineInterleaveST :: ST s a -> ST s a

-- | Just like unsafePerformIO, but we inline it. Big performance gains as
°5uit exposes lots of things to further inlining. <i>Very unsafe</i>. In
°5uparticular, you should do no memory allocation inside an
°5u<a>inlinePerformIO</a> block. On Hugs this is just
°5u<tt>unsafePerformIO</tt>.
inlinePerformIO :: IO a -> a

-- | This version of <a>unsafePerformIO</a> is more efficient because it
°5uomits the check that the IO is only being performed by a single
°5uthread. Hence, when you use <a>unsafeDupablePerformIO</a>, there is a
°5upossibility that the IO action may be performed multiple times (on a
°5umultiprocessor), and you should therefore ensure that it gives the
°5usame results each time. It may even happen that one of the duplicated
°5uIO actions is only run partially, and then interrupted in the middle
°5uwithout an exception being raised. Therefore, functions like
°5u<tt>bracket</tt> cannot be used safely within
°5u<a>unsafeDupablePerformIO</a>.
unsafeDupablePerformIO :: () => IO a -> a
data Iter
Iter :: {-# UNPACK #-} !Char -> {-# UNPACK #-} !Int -> Iter

-- | <i>O(1)</i> Iterate (unsafely) one step forwards through a UTF-16
°5uarray, returning the current character and the delta to add to give
°5uthe next offset to iterate at.
iter :: Text -> Int -> Iter

-- | <i>O(1)</i> Iterate one step through a UTF-16 array, returning the
°5udelta to add to give the next offset to iterate at.
iter_ :: Text -> Int -> Int

-- | <i>O(1)</i> Iterate one step backwards through a UTF-16 array,
°5ureturning the current character and the delta to add (i.e. a negative
°5unumber) to give the next offset to iterate at.
reverseIter :: Text -> Int -> (Char, Int)

-- | <i>O(1)</i> Iterate one step backwards through a UTF-16 array,
°5ureturning the delta to add (i.e. a negative number) to give the next
°5uoffset to iterate at.
reverseIter_ :: Text -> Int -> Int

-- | <i>O(1)</i> A variant of <a>head</a> for non-empty <a>Text</a>.
°5u<a>unsafeHead</a> omits the check for the empty case, so there is an
°5uobligation on the programmer to provide a proof that the <a>Text</a>
°5uis non-empty.
unsafeHead :: Text -> Char

-- | <i>O(1)</i> A variant of <a>tail</a> for non-empty <a>Text</a>.
°5u<a>unsafeTail</a> omits the check for the empty case, so there is an
°5uobligation on the programmer to provide a proof that the <a>Text</a>
°5uis non-empty.
unsafeTail :: Text -> Text

-- | <i>O(1)</i> Return the length of a <a>Text</a> in units of
°5u<tt>Word16</tt>. This is useful for sizing a target array
°5uappropriately before using <tt>unsafeCopyToPtr</tt>.
lengthWord16 :: Text -> Int

-- | <i>O(1)</i> Unchecked take of <tt>k</tt> <tt>Word16</tt>s from the
°5ufront of a <a>Text</a>.
takeWord16 :: Int -> Text -> Text

-- | <i>O(1)</i> Unchecked drop of <tt>k</tt> <tt>Word16</tt>s from the
°5ufront of a <a>Text</a>.
dropWord16 :: Int -> Text -> Text


module Data.Text.Internal.Private
runText :: (forall s. (MArray s -> Int -> ST s Text) -> ST s Text) -> Text
span_ :: (Char -> Bool) -> Text -> (# Text, Text #)


-- | <i>Warning</i>: this is an internal module, and does not have a stable
°5uAPI or name. Functions in this module may not check or enforce
°5upreconditions expected by public modules. Use at your own risk!
°5u
°5uText manipulation functions represented as fusible operations over
°5ustreams.
module Data.Text.Internal.Fusion
data Stream a
Stream :: (s -> Step s a) -> !s -> !Size -> Stream a

-- | Intermediate result in a processing pipeline.
data Step s a
Done :: Step s a
Skip :: !s -> Step s a
Yield :: !a -> !s -> Step s a

-- | <i>O(n)</i> Convert a <a>Text</a> into a 'Stream Char'.
stream :: Text -> Stream Char

-- | <i>O(n)</i> Convert a 'Stream Char' into a <a>Text</a>.
unstream :: Stream Char -> Text

-- | <i>O(n)</i> Convert a <a>Text</a> into a 'Stream Char', but iterate
°5ubackwards.
reverseStream :: Text -> Stream Char
length :: Stream Char -> Int

-- | <i>O(n)</i> Reverse the characters of a string.
reverse :: Stream Char -> Text

-- | <i>O(n)</i> Perform the equivalent of <tt>scanr</tt> over a list, only
°5uwith the input and result reversed.
reverseScanr :: (Char -> Char -> Char) -> Char -> Stream Char -> Stream Char

-- | <i>O(n)</i> Like a combination of <tt>map</tt> and <tt>foldl'</tt>.
°5uApplies a function to each element of a <a>Text</a>, passing an
°5uaccumulating parameter from left to right, and returns a final
°5u<a>Text</a>.
mapAccumL :: (a -> Char -> (a, Char)) -> a -> Stream Char -> (a, Text)

-- | <i>O(n)</i> Like <tt>unfoldr</tt>, <a>unfoldrN</a> builds a stream
°5ufrom a seed value. However, the length of the result is limited by the
°5ufirst argument to <a>unfoldrN</a>. This function is more efficient
°5uthan <tt>unfoldr</tt> when the length of the result is known.
unfoldrN :: Int -> (a -> Maybe (Char, a)) -> a -> Stream Char

-- | <i>O(n)</i> stream index (subscript) operator, starting from 0.
index :: Stream Char -> Int -> Char

-- | The <a>findIndex</a> function takes a predicate and a stream and
°5ureturns the index of the first element in the stream satisfying the
°5upredicate.
findIndex :: (Char -> Bool) -> Stream Char -> Maybe Int

-- | <i>O(n)</i> The <tt>count</tt> function returns the number of times
°5uthe query element appears in the given stream.
countChar :: Char -> Stream Char -> Int


-- | <i>Warning</i>: this is an internal module, and does not have a stable
°5uAPI or name. Use at your own risk!
°5u
°5uFusible <a>Stream</a>-oriented functions for converting between
°5u<tt>Text</tt> and several common encodings.
module Data.Text.Internal.Encoding.Fusion.Common
restreamUtf16LE :: Stream Char -> Stream Word8
restreamUtf16BE :: Stream Char -> Stream Word8
restreamUtf32LE :: Stream Char -> Stream Word8
restreamUtf32BE :: Stream Char -> Stream Word8


-- | <i>Warning</i>: this is an internal module, and does not have a stable
°5uAPI or name. Functions in this module may not check or enforce
°5upreconditions expected by public modules. Use at your own risk!
°5u
°5uFusible <a>Stream</a>-oriented functions for converting between lazy
°5u<tt>Text</tt> and several common encodings.
module Data.Text.Internal.Lazy.Encoding.Fusion

-- | <i>O(n)</i> Convert a lazy <a>ByteString</a> into a 'Stream Char',
°5uusing UTF-8 encoding.
streamUtf8 :: OnDecodeError -> ByteString -> Stream Char

-- | <i>O(n)</i> Convert a <a>ByteString</a> into a 'Stream Char', using
°5ulittle endian UTF-16 encoding.
streamUtf16LE :: OnDecodeError -> ByteString -> Stream Char

-- | <i>O(n)</i> Convert a <a>ByteString</a> into a 'Stream Char', using
°5ubig endian UTF-16 encoding.
streamUtf16BE :: OnDecodeError -> ByteString -> Stream Char

-- | <i>O(n)</i> Convert a <a>ByteString</a> into a 'Stream Char', using
°5ulittle endian UTF-32 encoding.
streamUtf32LE :: OnDecodeError -> ByteString -> Stream Char

-- | <i>O(n)</i> Convert a <a>ByteString</a> into a 'Stream Char', using
°5ubig endian UTF-32 encoding.
streamUtf32BE :: OnDecodeError -> ByteString -> Stream Char

-- | <i>O(n)</i> Convert a <a>Stream</a> <a>Word8</a> to a lazy
°5u<a>ByteString</a>.
unstream :: Stream Word8 -> ByteString


-- | <i>Warning</i>: this is an internal module, and does not have a stable
°5uAPI or name. Functions in this module may not check or enforce
°5upreconditions expected by public modules. Use at your own risk!
°5u
°5uFusible <a>Stream</a>-oriented functions for converting between
°5u<tt>Text</tt> and several common encodings.
module Data.Text.Internal.Encoding.Fusion

-- | <i>Deprecated: Do not use this function</i>
streamASCII :: ByteString -> Stream Char

-- | <i>O(n)</i> Convert a <a>ByteString</a> into a 'Stream Char', using
°5uUTF-8 encoding.
streamUtf8 :: OnDecodeError -> ByteString -> Stream Char

-- | <i>O(n)</i> Convert a <a>ByteString</a> into a 'Stream Char', using
°5ulittle endian UTF-16 encoding.
streamUtf16LE :: OnDecodeError -> ByteString -> Stream Char

-- | <i>O(n)</i> Convert a <a>ByteString</a> into a 'Stream Char', using
°5ubig endian UTF-16 encoding.
streamUtf16BE :: OnDecodeError -> ByteString -> Stream Char

-- | <i>O(n)</i> Convert a <a>ByteString</a> into a 'Stream Char', using
°5ulittle endian UTF-32 encoding.
streamUtf32LE :: OnDecodeError -> ByteString -> Stream Char

-- | <i>O(n)</i> Convert a <a>ByteString</a> into a 'Stream Char', using
°5ubig endian UTF-32 encoding.
streamUtf32BE :: OnDecodeError -> ByteString -> Stream Char

-- | <i>O(n)</i> Convert a <a>Stream</a> <a>Word8</a> to a
°5u<a>ByteString</a>.
unstream :: Stream Word8 -> ByteString


-- | Functions for converting <a>Text</a> values to and from
°5u<a>ByteString</a>, using several standard encodings.
°5u
°5uTo gain access to a much larger family of encodings, use the
°5u<tt>text-icu</tt> package:
°5u<a>http://hackage.haskell.org/package/text-icu</a>
module Data.Text.Encoding

-- | <i>Deprecated</i>. Decode a <a>ByteString</a> containing 7-bit ASCII
°5uencoded text.

-- | <i>Deprecated: Use decodeUtf8 instead</i>
decodeASCII :: ByteString -> Text

-- | Decode a <a>ByteString</a> containing Latin-1 (aka ISO-8859-1) encoded
°5utext.
°5u
°5u<a>decodeLatin1</a> is semantically equivalent to <tt>Data.Text.pack .
°5uData.ByteString.Char8.unpack</tt>
decodeLatin1 :: ByteString -> Text

-- | Decode a <a>ByteString</a> containing UTF-8 encoded text that is known
°5uto be valid.
°5u
°5uIf the input contains any invalid UTF-8 data, an exception will be
°5uthrown that cannot be caught in pure code. For more control over the
°5uhandling of invalid data, use <a>decodeUtf8'</a> or
°5u<a>decodeUtf8With</a>.
decodeUtf8 :: ByteString -> Text

-- | Decode text from little endian UTF-16 encoding.
°5u
°5uIf the input contains any invalid little endian UTF-16 data, an
°5uexception will be thrown. For more control over the handling of
°5uinvalid data, use <a>decodeUtf16LEWith</a>.
decodeUtf16LE :: ByteString -> Text

-- | Decode text from big endian UTF-16 encoding.
°5u
°5uIf the input contains any invalid big endian UTF-16 data, an exception
°5uwill be thrown. For more control over the handling of invalid data,
°5uuse <a>decodeUtf16BEWith</a>.
decodeUtf16BE :: ByteString -> Text

-- | Decode text from little endian UTF-32 encoding.
°5u
°5uIf the input contains any invalid little endian UTF-32 data, an
°5uexception will be thrown. For more control over the handling of
°5uinvalid data, use <a>decodeUtf32LEWith</a>.
decodeUtf32LE :: ByteString -> Text

-- | Decode text from big endian UTF-32 encoding.
°5u
°5uIf the input contains any invalid big endian UTF-32 data, an exception
°5uwill be thrown. For more control over the handling of invalid data,
°5uuse <a>decodeUtf32BEWith</a>.
decodeUtf32BE :: ByteString -> Text

-- | Decode a <a>ByteString</a> containing UTF-8 encoded text.
°5u
°5uIf the input contains any invalid UTF-8 data, the relevant exception
°5uwill be returned, otherwise the decoded text.
decodeUtf8' :: ByteString -> Either UnicodeException Text

-- | Decode a <a>ByteString</a> containing UTF-8 encoded text.
decodeUtf8With :: OnDecodeError -> ByteString -> Text

-- | Decode text from little endian UTF-16 encoding.
decodeUtf16LEWith :: OnDecodeError -> ByteString -> Text

-- | Decode text from big endian UTF-16 encoding.
decodeUtf16BEWith :: OnDecodeError -> ByteString -> Text

-- | Decode text from little endian UTF-32 encoding.
decodeUtf32LEWith :: OnDecodeError -> ByteString -> Text

-- | Decode text from big endian UTF-32 encoding.
decodeUtf32BEWith :: OnDecodeError -> ByteString -> Text

-- | Decode, in a stream oriented way, a <a>ByteString</a> containing UTF-8
°5uencoded text that is known to be valid.
°5u
°5uIf the input contains any invalid UTF-8 data, an exception will be
°5uthrown (either by this function or a continuation) that cannot be
°5ucaught in pure code. For more control over the handling of invalid
°5udata, use <a>streamDecodeUtf8With</a>.
streamDecodeUtf8 :: ByteString -> Decoding

-- | Decode, in a stream oriented way, a <a>ByteString</a> containing UTF-8
°5uencoded text.
streamDecodeUtf8With :: OnDecodeError -> ByteString -> Decoding

-- | A stream oriented decoding result.
data Decoding
Some :: Text -> ByteString -> (ByteString -> Decoding) -> Decoding

-- | Encode text using UTF-8 encoding.
encodeUtf8 :: Text -> ByteString

-- | Encode text using little endian UTF-16 encoding.
encodeUtf16LE :: Text -> ByteString

-- | Encode text using big endian UTF-16 encoding.
encodeUtf16BE :: Text -> ByteString

-- | Encode text using little endian UTF-32 encoding.
encodeUtf32LE :: Text -> ByteString

-- | Encode text using big endian UTF-32 encoding.
encodeUtf32BE :: Text -> ByteString

-- | Encode text to a ByteString <a>Builder</a> using UTF-8 encoding.
encodeUtf8Builder :: Text -> Builder

-- | Encode text using UTF-8 encoding and escape the ASCII characters using
°5ua <a>BoundedPrim</a>.
°5u
°5uUse this function is to implement efficient encoders for text-based
°5uformats like JSON or HTML.
encodeUtf8BuilderEscaped :: BoundedPrim Word8 -> Text -> Builder
instance Foreign.Storable.Storable Data.Text.Encoding.DecoderState
instance GHC.Num.Num Data.Text.Encoding.DecoderState
instance GHC.Show.Show Data.Text.Encoding.DecoderState
instance GHC.Classes.Eq Data.Text.Encoding.DecoderState
instance Foreign.Storable.Storable Data.Text.Encoding.CodePoint
instance GHC.Num.Num Data.Text.Encoding.CodePoint
instance GHC.Show.Show Data.Text.Encoding.CodePoint
instance GHC.Classes.Eq Data.Text.Encoding.CodePoint
instance GHC.Show.Show Data.Text.Encoding.Decoding


-- | Support for using <a>Text</a> data with native code via the Haskell
°5uforeign function interface.
module Data.Text.Foreign

-- | A type representing a number of UTF-16 code units.
data I16

-- | <i>O(n)</i> Create a new <a>Text</a> from a <a>Ptr</a> <a>Word16</a>
°5uby copying the contents of the array.
fromPtr :: Ptr Word16 -> I16 -> IO Text

-- | <i>O(n)</i> Perform an action on a temporary, mutable copy of a
°5u<a>Text</a>. The copy is freed as soon as the action returns.
useAsPtr :: Text -> (Ptr Word16 -> I16 -> IO a) -> IO a

-- | <i>O(n)</i> Make a mutable copy of a <a>Text</a>.
asForeignPtr :: Text -> IO (ForeignPtr Word16, I16)

-- | <i>O(n)</i> Decode a C string with explicit length, which is assumed
°5uto have been encoded as UTF-8. If decoding fails, a
°5u<tt>UnicodeException</tt> is thrown.
peekCStringLen :: CStringLen -> IO Text

-- | Marshal a <a>Text</a> into a C string encoded as UTF-8 in temporary
°5ustorage, with explicit length information. The encoded string may
°5ucontain NUL bytes, and is not followed by a trailing NUL byte.
°5u
°5uThe temporary storage is freed when the subcomputation terminates
°5u(either normally or via an exception), so the pointer to the temporary
°5ustorage must <i>not</i> be used after this function returns.
withCStringLen :: Text -> (CStringLen -> IO a) -> IO a

-- | <i>O(1)</i> Return the length of a <a>Text</a> in units of
°5u<tt>Word16</tt>. This is useful for sizing a target array
°5uappropriately before using <tt>unsafeCopyToPtr</tt>.
lengthWord16 :: Text -> Int

-- | <i>O(n)</i> Copy a <a>Text</a> to an array. The array is assumed to be
°5ubig enough to hold the contents of the entire <a>Text</a>.
unsafeCopyToPtr :: Text -> Ptr Word16 -> IO ()

-- | <i>O(1)</i> Return the suffix of the <a>Text</a>, with <tt>n</tt>
°5u<a>Word16</a> units dropped from its beginning.
°5u
°5uIf <tt>n</tt> would cause the <a>Text</a> to begin inside a surrogate
°5upair, the beginning of the suffix will be advanced by one additional
°5u<a>Word16</a> unit to maintain its validity.
dropWord16 :: I16 -> Text -> Text

-- | <i>O(1)</i> Return the prefix of the <a>Text</a> of <tt>n</tt>
°5u<a>Word16</a> units in length.
°5u
°5uIf <tt>n</tt> would cause the <a>Text</a> to end inside a surrogate
°5upair, the end of the prefix will be advanced by one additional
°5u<a>Word16</a> unit to maintain its validity.
takeWord16 :: I16 -> Text -> Text
instance GHC.Show.Show Data.Text.Foreign.I16
instance GHC.Real.Real Data.Text.Foreign.I16
instance GHC.Read.Read Data.Text.Foreign.I16
instance GHC.Classes.Ord Data.Text.Foreign.I16
instance GHC.Num.Num Data.Text.Foreign.I16
instance GHC.Real.Integral Data.Text.Foreign.I16
instance GHC.Classes.Eq Data.Text.Foreign.I16
instance GHC.Enum.Enum Data.Text.Foreign.I16
instance GHC.Enum.Bounded Data.Text.Foreign.I16


-- | A time and space-efficient implementation of Unicode text. Suitable
°5ufor performance critical use, both in terms of large data quantities
°5uand high speed.
°5u
°5u<i>Note</i>: Read below the synopsis for important notes on the use of
°5uthis module.
°5u
°5uThis module is intended to be imported <tt>qualified</tt>, to avoid
°5uname clashes with <a>Prelude</a> functions, e.g.
°5u
°5u<pre>
°5uimport qualified Data.Text as T
°5u</pre>
°5u
°5uTo use an extended and very rich family of functions for working with
°5uUnicode text (including normalization, regular expressions,
°5unon-standard encodings, text breaking, and locales), see <a>the
°5utext-icu package</a>.
module Data.Text

-- | A space efficient, packed, unboxed Unicode text type.
data Text

-- | <i>O(n)</i> Convert a <a>String</a> into a <a>Text</a>. Subject to
°5ufusion. Performs replacement on invalid scalar values.
pack :: String -> Text

-- | <i>O(n)</i> Convert a <a>Text</a> into a <a>String</a>. Subject to
°5ufusion.
unpack :: Text -> String

-- | <i>O(1)</i> Convert a character into a Text. Subject to fusion.
°5uPerforms replacement on invalid scalar values.
singleton :: Char -> Text

-- | <i>O(1)</i> The empty <a>Text</a>.
empty :: Text

-- | <i>O(n)</i> Adds a character to the front of a <a>Text</a>. This
°5ufunction is more costly than its <tt>List</tt> counterpart because it
°5urequires copying a new array. Subject to fusion. Performs replacement
°5uon invalid scalar values.
cons :: Char -> Text -> Text
infixr 5 `cons`

-- | <i>O(n)</i> Adds a character to the end of a <a>Text</a>. This copies
°5uthe entire array in the process, unless fused. Subject to fusion.
°5uPerforms replacement on invalid scalar values.
snoc :: Text -> Char -> Text

-- | <i>O(n)</i> Appends one <a>Text</a> to the other by copying both of
°5uthem into a new <a>Text</a>. Subject to fusion.
append :: Text -> Text -> Text

-- | <i>O(1)</i> Returns the first character and rest of a <a>Text</a>, or
°5u<a>Nothing</a> if empty. Subject to fusion.
uncons :: Text -> Maybe (Char, Text)

-- | <i>O(1)</i> Returns all but the last character and the last character
°5uof a <a>Text</a>, or <a>Nothing</a> if empty.
unsnoc :: Text -> Maybe (Text, Char)

-- | <i>O(1)</i> Returns the first character of a <a>Text</a>, which must
°5ube non-empty. Subject to fusion.
head :: Text -> Char

-- | <i>O(1)</i> Returns the last character of a <a>Text</a>, which must be
°5unon-empty. Subject to fusion.
last :: Text -> Char

-- | <i>O(1)</i> Returns all characters after the head of a <a>Text</a>,
°5uwhich must be non-empty. Subject to fusion.
tail :: Text -> Text

-- | <i>O(1)</i> Returns all but the last character of a <a>Text</a>, which
°5umust be non-empty. Subject to fusion.
init :: Text -> Text

-- | <i>O(1)</i> Tests whether a <a>Text</a> is empty or not. Subject to
°5ufusion.
null :: Text -> Bool

-- | <i>O(n)</i> Returns the number of characters in a <a>Text</a>. Subject
°5uto fusion.
length :: Text -> Int

-- | <i>O(n)</i> Compare the count of characters in a <a>Text</a> to a
°5unumber. Subject to fusion.
°5u
°5uThis function gives the same answer as comparing against the result of
°5u<a>length</a>, but can short circuit if the count of characters is
°5ugreater than the number, and hence be more efficient.
compareLength :: Text -> Int -> Ordering

-- | <i>O(n)</i> <a>map</a> <tt>f</tt> <tt>t</tt> is the <a>Text</a>
°5uobtained by applying <tt>f</tt> to each element of <tt>t</tt>. Subject
°5uto fusion. Performs replacement on invalid scalar values.
map :: (Char -> Char) -> Text -> Text

-- | <i>O(n)</i> The <a>intercalate</a> function takes a <a>Text</a> and a
°5ulist of <a>Text</a>s and concatenates the list after interspersing the
°5ufirst argument between each element of the list.
intercalate :: Text -> [Text] -> Text

-- | <i>O(n)</i> The <a>intersperse</a> function takes a character and
°5uplaces it between the characters of a <a>Text</a>. Subject to fusion.
°5uPerforms replacement on invalid scalar values.
intersperse :: Char -> Text -> Text

-- | <i>O(n)</i> The <a>transpose</a> function transposes the rows and
°5ucolumns of its <a>Text</a> argument. Note that this function uses
°5u<a>pack</a>, <a>unpack</a>, and the list version of transpose, and is
°5uthus not very efficient.
transpose :: [Text] -> [Text]

-- | <i>O(n)</i> Reverse the characters of a string. Subject to fusion.
reverse :: Text -> Text

-- | <i>O(m+n)</i> Replace every non-overlapping occurrence of
°5u<tt>needle</tt> in <tt>haystack</tt> with <tt>replacement</tt>.
°5u
°5uThis function behaves as though it was defined as follows:
°5u
°5u<pre>
°5ureplace needle replacement haystack =
°5u  <a>intercalate</a> replacement (<a>splitOn</a> needle haystack)
°5u</pre>
°5u
°5uAs this suggests, each occurrence is replaced exactly once. So if
°5u<tt>needle</tt> occurs in <tt>replacement</tt>, that occurrence will
°5u<i>not</i> itself be replaced recursively:
°5u
°5u<pre>
°5ureplace "oo" "foo" "oo" == "foo"
°5u</pre>
°5u
°5uIn cases where several instances of <tt>needle</tt> overlap, only the
°5ufirst one will be replaced:
°5u
°5u<pre>
°5ureplace "ofo" "bar" "ofofo" == "barfo"
°5u</pre>
°5u
°5uIn (unlikely) bad cases, this function's time complexity degrades
°5utowards <i>O(n*m)</i>.
replace :: Text -> Text -> Text -> Text

-- | <i>O(n)</i> Convert a string to folded case. Subject to fusion.
°5u
°5uThis function is mainly useful for performing caseless (also known as
°5ucase insensitive) string comparisons.
°5u
°5uA string <tt>x</tt> is a caseless match for a string <tt>y</tt> if and
°5uonly if:
°5u
°5u<pre>
°5utoCaseFold x == toCaseFold y
°5u</pre>
°5u
°5uThe result string may be longer than the input string, and may differ
°5ufrom applying <a>toLower</a> to the input string. For instance, the
°5uArmenian small ligature "ﬓ" (men now, U+FB13) is case folded to the
°5usequence "մ" (men, U+0574) followed by "ն" (now, U+0576), while the
°5uGreek "µ" (micro sign, U+00B5) is case folded to "μ" (small letter mu,
°5uU+03BC) instead of itself.
toCaseFold :: Text -> Text

-- | <i>O(n)</i> Convert a string to lower case, using simple case
°5uconversion. Subject to fusion.
°5u
°5uThe result string may be longer than the input string. For instance,
°5u"İ" (Latin capital letter I with dot above, U+0130) maps to the
°5usequence "i" (Latin small letter i, U+0069) followed by " ̇"
°5u(combining dot above, U+0307).
toLower :: Text -> Text

-- | <i>O(n)</i> Convert a string to upper case, using simple case
°5uconversion. Subject to fusion.
°5u
°5uThe result string may be longer than the input string. For instance,
°5uthe German "ß" (eszett, U+00DF) maps to the two-letter sequence "SS".
toUpper :: Text -> Text

-- | <i>O(n)</i> Convert a string to title case, using simple case
°5uconversion. Subject to fusion.
°5u
°5uThe first letter of the input is converted to title case, as is every
°5usubsequent letter that immediately follows a non-letter. Every letter
°5uthat immediately follows another letter is converted to lower case.
°5u
°5uThe result string may be longer than the input string. For example,
°5uthe Latin small ligature ﬂ (U+FB02) is converted to the sequence Latin
°5ucapital letter F (U+0046) followed by Latin small letter l (U+006C).
°5u
°5u<i>Note</i>: this function does not take language or culture specific
°5urules into account. For instance, in English, different style guides
°5udisagree on whether the book name "The Hill of the Red Fox" is
°5ucorrectly title cased—but this function will capitalize <i>every</i>
°5uword.
toTitle :: Text -> Text

-- | <i>O(n)</i> Left-justify a string to the given length, using the
°5uspecified fill character on the right. Subject to fusion. Performs
°5ureplacement on invalid scalar values.
°5u
°5uExamples:
°5u
°5u<pre>
°5ujustifyLeft 7 'x' "foo"    == "fooxxxx"
°5ujustifyLeft 3 'x' "foobar" == "foobar"
°5u</pre>
justifyLeft :: Int -> Char -> Text -> Text

-- | <i>O(n)</i> Right-justify a string to the given length, using the
°5uspecified fill character on the left. Performs replacement on invalid
°5uscalar values.
°5u
°5uExamples:
°5u
°5u<pre>
°5ujustifyRight 7 'x' "bar"    == "xxxxbar"
°5ujustifyRight 3 'x' "foobar" == "foobar"
°5u</pre>
justifyRight :: Int -> Char -> Text -> Text

-- | <i>O(n)</i> Center a string to the given length, using the specified
°5ufill character on either side. Performs replacement on invalid scalar
°5uvalues.
°5u
°5uExamples:
°5u
°5u<pre>
°5ucenter 8 'x' "HS" = "xxxHSxxx"
°5u</pre>
center :: Int -> Char -> Text -> Text

-- | <i>O(n)</i> <a>foldl</a>, applied to a binary operator, a starting
°5uvalue (typically the left-identity of the operator), and a
°5u<a>Text</a>, reduces the <a>Text</a> using the binary operator, from
°5uleft to right. Subject to fusion.
foldl :: (a -> Char -> a) -> a -> Text -> a

-- | <i>O(n)</i> A strict version of <a>foldl</a>. Subject to fusion.
foldl' :: (a -> Char -> a) -> a -> Text -> a

-- | <i>O(n)</i> A variant of <a>foldl</a> that has no starting value
°5uargument, and thus must be applied to a non-empty <a>Text</a>. Subject
°5uto fusion.
foldl1 :: (Char -> Char -> Char) -> Text -> Char

-- | <i>O(n)</i> A strict version of <a>foldl1</a>. Subject to fusion.
foldl1' :: (Char -> Char -> Char) -> Text -> Char

-- | <i>O(n)</i> <a>foldr</a>, applied to a binary operator, a starting
°5uvalue (typically the right-identity of the operator), and a
°5u<a>Text</a>, reduces the <a>Text</a> using the binary operator, from
°5uright to left. Subject to fusion.
foldr :: (Char -> a -> a) -> a -> Text -> a

-- | <i>O(n)</i> A variant of <a>foldr</a> that has no starting value
°5uargument, and thus must be applied to a non-empty <a>Text</a>. Subject
°5uto fusion.
foldr1 :: (Char -> Char -> Char) -> Text -> Char

-- | <i>O(n)</i> Concatenate a list of <a>Text</a>s.
concat :: [Text] -> Text

-- | <i>O(n)</i> Map a function over a <a>Text</a> that results in a
°5u<a>Text</a>, and concatenate the results.
concatMap :: (Char -> Text) -> Text -> Text

-- | <i>O(n)</i> <a>any</a> <tt>p</tt> <tt>t</tt> determines whether any
°5ucharacter in the <a>Text</a> <tt>t</tt> satisfies the predicate
°5u<tt>p</tt>. Subject to fusion.
any :: (Char -> Bool) -> Text -> Bool

-- | <i>O(n)</i> <a>all</a> <tt>p</tt> <tt>t</tt> determines whether all
°5ucharacters in the <a>Text</a> <tt>t</tt> satisfy the predicate
°5u<tt>p</tt>. Subject to fusion.
all :: (Char -> Bool) -> Text -> Bool

-- | <i>O(n)</i> <a>maximum</a> returns the maximum value from a
°5u<a>Text</a>, which must be non-empty. Subject to fusion.
maximum :: Text -> Char

-- | <i>O(n)</i> <a>minimum</a> returns the minimum value from a
°5u<a>Text</a>, which must be non-empty. Subject to fusion.
minimum :: Text -> Char

-- | <i>O(n)</i> <a>scanl</a> is similar to <a>foldl</a>, but returns a
°5ulist of successive reduced values from the left. Subject to fusion.
°5uPerforms replacement on invalid scalar values.
°5u
°5u<pre>
°5uscanl f z [x1, x2, ...] == [z, z `f` x1, (z `f` x1) `f` x2, ...]
°5u</pre>
°5u
°5uNote that
°5u
°5u<pre>
°5ulast (scanl f z xs) == foldl f z xs.
°5u</pre>
scanl :: (Char -> Char -> Char) -> Char -> Text -> Text

-- | <i>O(n)</i> <a>scanl1</a> is a variant of <a>scanl</a> that has no
°5ustarting value argument. Subject to fusion. Performs replacement on
°5uinvalid scalar values.
°5u
°5u<pre>
°5uscanl1 f [x1, x2, ...] == [x1, x1 `f` x2, ...]
°5u</pre>
scanl1 :: (Char -> Char -> Char) -> Text -> Text

-- | <i>O(n)</i> <a>scanr</a> is the right-to-left dual of <a>scanl</a>.
°5uPerforms replacement on invalid scalar values.
°5u
°5u<pre>
°5uscanr f v == reverse . scanl (flip f) v . reverse
°5u</pre>
scanr :: (Char -> Char -> Char) -> Char -> Text -> Text

-- | <i>O(n)</i> <a>scanr1</a> is a variant of <a>scanr</a> that has no
°5ustarting value argument. Subject to fusion. Performs replacement on
°5uinvalid scalar values.
scanr1 :: (Char -> Char -> Char) -> Text -> Text

-- | <i>O(n)</i> Like a combination of <a>map</a> and <a>foldl'</a>.
°5uApplies a function to each element of a <a>Text</a>, passing an
°5uaccumulating parameter from left to right, and returns a final
°5u<a>Text</a>. Performs replacement on invalid scalar values.
mapAccumL :: (a -> Char -> (a, Char)) -> a -> Text -> (a, Text)

-- | The <a>mapAccumR</a> function behaves like a combination of <a>map</a>
°5uand a strict <a>foldr</a>; it applies a function to each element of a
°5u<a>Text</a>, passing an accumulating parameter from right to left, and
°5ureturning a final value of this accumulator together with the new
°5u<a>Text</a>. Performs replacement on invalid scalar values.
mapAccumR :: (a -> Char -> (a, Char)) -> a -> Text -> (a, Text)

-- | <i>O(n*m)</i> <a>replicate</a> <tt>n</tt> <tt>t</tt> is a <a>Text</a>
°5uconsisting of the input <tt>t</tt> repeated <tt>n</tt> times.
replicate :: Int -> Text -> Text

-- | <i>O(n)</i>, where <tt>n</tt> is the length of the result. The
°5u<a>unfoldr</a> function is analogous to the List <a>unfoldr</a>.
°5u<a>unfoldr</a> builds a <a>Text</a> from a seed value. The function
°5utakes the element and returns <a>Nothing</a> if it is done producing
°5uthe <a>Text</a>, otherwise <a>Just</a> <tt>(a,b)</tt>. In this case,
°5u<tt>a</tt> is the next <a>Char</a> in the string, and <tt>b</tt> is
°5uthe seed value for further production. Subject to fusion. Performs
°5ureplacement on invalid scalar values.
unfoldr :: (a -> Maybe (Char, a)) -> a -> Text

-- | <i>O(n)</i> Like <a>unfoldr</a>, <a>unfoldrN</a> builds a <a>Text</a>
°5ufrom a seed value. However, the length of the result should be limited
°5uby the first argument to <a>unfoldrN</a>. This function is more
°5uefficient than <a>unfoldr</a> when the maximum length of the result is
°5uknown and correct, otherwise its performance is similar to
°5u<a>unfoldr</a>. Subject to fusion. Performs replacement on invalid
°5uscalar values.
unfoldrN :: Int -> (a -> Maybe (Char, a)) -> a -> Text

-- | <i>O(n)</i> <a>take</a> <tt>n</tt>, applied to a <a>Text</a>, returns
°5uthe prefix of the <a>Text</a> of length <tt>n</tt>, or the <a>Text</a>
°5uitself if <tt>n</tt> is greater than the length of the Text. Subject
°5uto fusion.
take :: Int -> Text -> Text

-- | <i>O(n)</i> <a>takeEnd</a> <tt>n</tt> <tt>t</tt> returns the suffix
°5uremaining after taking <tt>n</tt> characters from the end of
°5u<tt>t</tt>.
°5u
°5uExamples:
°5u
°5u<pre>
°5utakeEnd 3 "foobar" == "bar"
°5u</pre>
takeEnd :: Int -> Text -> Text

-- | <i>O(n)</i> <a>drop</a> <tt>n</tt>, applied to a <a>Text</a>, returns
°5uthe suffix of the <a>Text</a> after the first <tt>n</tt> characters,
°5uor the empty <a>Text</a> if <tt>n</tt> is greater than the length of
°5uthe <a>Text</a>. Subject to fusion.
drop :: Int -> Text -> Text

-- | <i>O(n)</i> <a>dropEnd</a> <tt>n</tt> <tt>t</tt> returns the prefix
°5uremaining after dropping <tt>n</tt> characters from the end of
°5u<tt>t</tt>.
°5u
°5uExamples:
°5u
°5u<pre>
°5udropEnd 3 "foobar" == "foo"
°5u</pre>
dropEnd :: Int -> Text -> Text

-- | <i>O(n)</i> <a>takeWhile</a>, applied to a predicate <tt>p</tt> and a
°5u<a>Text</a>, returns the longest prefix (possibly empty) of elements
°5uthat satisfy <tt>p</tt>. Subject to fusion.
takeWhile :: (Char -> Bool) -> Text -> Text

-- | <i>O(n)</i> <a>takeWhileEnd</a>, applied to a predicate <tt>p</tt> and
°5ua <a>Text</a>, returns the longest suffix (possibly empty) of elements
°5uthat satisfy <tt>p</tt>. Subject to fusion. Examples:
°5u
°5u<pre>
°5utakeWhileEnd (=='o') "foo" == "oo"
°5u</pre>
takeWhileEnd :: (Char -> Bool) -> Text -> Text

-- | <i>O(n)</i> <a>dropWhile</a> <tt>p</tt> <tt>t</tt> returns the suffix
°5uremaining after <a>takeWhile</a> <tt>p</tt> <tt>t</tt>. Subject to
°5ufusion.
dropWhile :: (Char -> Bool) -> Text -> Text

-- | <i>O(n)</i> <a>dropWhileEnd</a> <tt>p</tt> <tt>t</tt> returns the
°5uprefix remaining after dropping characters that satisfy the predicate
°5u<tt>p</tt> from the end of <tt>t</tt>. Subject to fusion.
°5u
°5uExamples:
°5u
°5u<pre>
°5udropWhileEnd (=='.') "foo..." == "foo"
°5u</pre>
dropWhileEnd :: (Char -> Bool) -> Text -> Text

-- | <i>O(n)</i> <a>dropAround</a> <tt>p</tt> <tt>t</tt> returns the
°5usubstring remaining after dropping characters that satisfy the
°5upredicate <tt>p</tt> from both the beginning and end of <tt>t</tt>.
°5uSubject to fusion.
dropAround :: (Char -> Bool) -> Text -> Text

-- | <i>O(n)</i> Remove leading and trailing white space from a string.
°5uEquivalent to:
°5u
°5u<pre>
°5udropAround isSpace
°5u</pre>
strip :: Text -> Text

-- | <i>O(n)</i> Remove leading white space from a string. Equivalent to:
°5u
°5u<pre>
°5udropWhile isSpace
°5u</pre>
stripStart :: Text -> Text

-- | <i>O(n)</i> Remove trailing white space from a string. Equivalent to:
°5u
°5u<pre>
°5udropWhileEnd isSpace
°5u</pre>
stripEnd :: Text -> Text

-- | <i>O(n)</i> <a>splitAt</a> <tt>n t</tt> returns a pair whose first
°5uelement is a prefix of <tt>t</tt> of length <tt>n</tt>, and whose
°5usecond is the remainder of the string. It is equivalent to
°5u<tt>(<a>take</a> n t, <a>drop</a> n t)</tt>.
splitAt :: Int -> Text -> (Text, Text)

-- | <i>O(n+m)</i> Find the first instance of <tt>needle</tt> (which must
°5ube non-<a>null</a>) in <tt>haystack</tt>. The first element of the
°5ureturned tuple is the prefix of <tt>haystack</tt> before
°5u<tt>needle</tt> is matched. The second is the remainder of
°5u<tt>haystack</tt>, starting with the match.
°5u
°5uExamples:
°5u
°5u<pre>
°5ubreakOn "::" "a::b::c" ==&gt; ("a", "::b::c")
°5ubreakOn "/" "foobar"   ==&gt; ("foobar", "")
°5u</pre>
°5u
°5uLaws:
°5u
°5u<pre>
°5uappend prefix match == haystack
°5u  where (prefix, match) = breakOn needle haystack
°5u</pre>
°5u
°5uIf you need to break a string by a substring repeatedly (e.g. you want
°5uto break on every instance of a substring), use <a>breakOnAll</a>
°5uinstead, as it has lower startup overhead.
°5u
°5uIn (unlikely) bad cases, this function's time complexity degrades
°5utowards <i>O(n*m)</i>.
breakOn :: Text -> Text -> (Text, Text)

-- | <i>O(n+m)</i> Similar to <a>breakOn</a>, but searches from the end of
°5uthe string.
°5u
°5uThe first element of the returned tuple is the prefix of
°5u<tt>haystack</tt> up to and including the last match of
°5u<tt>needle</tt>. The second is the remainder of <tt>haystack</tt>,
°5ufollowing the match.
°5u
°5u<pre>
°5ubreakOnEnd "::" "a::b::c" ==&gt; ("a::b::", "c")
°5u</pre>
breakOnEnd :: Text -> Text -> (Text, Text)

-- | <i>O(n)</i> <a>break</a> is like <a>span</a>, but the prefix returned
°5uis over elements that fail the predicate <tt>p</tt>.
break :: (Char -> Bool) -> Text -> (Text, Text)

-- | <i>O(n)</i> <a>span</a>, applied to a predicate <tt>p</tt> and text
°5u<tt>t</tt>, returns a pair whose first element is the longest prefix
°5u(possibly empty) of <tt>t</tt> of elements that satisfy <tt>p</tt>,
°5uand whose second is the remainder of the list.
span :: (Char -> Bool) -> Text -> (Text, Text)

-- | <i>O(n)</i> Group characters in a string by equality.
group :: Text -> [Text]

-- | <i>O(n)</i> Group characters in a string according to a predicate.
groupBy :: (Char -> Char -> Bool) -> Text -> [Text]

-- | <i>O(n)</i> Return all initial segments of the given <a>Text</a>,
°5ushortest first.
inits :: Text -> [Text]

-- | <i>O(n)</i> Return all final segments of the given <a>Text</a>,
°5ulongest first.
tails :: Text -> [Text]

-- | <i>O(m+n)</i> Break a <a>Text</a> into pieces separated by the first
°5u<a>Text</a> argument (which cannot be empty), consuming the delimiter.
°5uAn empty delimiter is invalid, and will cause an error to be raised.
°5u
°5uExamples:
°5u
°5u<pre>
°5usplitOn "\r\n" "a\r\nb\r\nd\r\ne" == ["a","b","d","e"]
°5usplitOn "aaa"  "aaaXaaaXaaaXaaa"  == ["","X","X","X",""]
°5usplitOn "x"    "x"                == ["",""]
°5u</pre>
°5u
°5uand
°5u
°5u<pre>
°5uintercalate s . splitOn s         == id
°5usplitOn (singleton c)             == split (==c)
°5u</pre>
°5u
°5u(Note: the string <tt>s</tt> to split on above cannot be empty.)
°5u
°5uIn (unlikely) bad cases, this function's time complexity degrades
°5utowards <i>O(n*m)</i>.
splitOn :: Text -> Text -> [Text]

-- | <i>O(n)</i> Splits a <a>Text</a> into components delimited by
°5useparators, where the predicate returns True for a separator element.
°5uThe resulting components do not contain the separators. Two adjacent
°5useparators result in an empty component in the output. eg.
°5u
°5u<pre>
°5usplit (=='a') "aabbaca" == ["","","bb","c",""]
°5usplit (=='a') ""        == [""]
°5u</pre>
split :: (Char -> Bool) -> Text -> [Text]

-- | <i>O(n)</i> Splits a <a>Text</a> into components of length <tt>k</tt>.
°5uThe last element may be shorter than the other chunks, depending on
°5uthe length of the input. Examples:
°5u
°5u<pre>
°5uchunksOf 3 "foobarbaz"   == ["foo","bar","baz"]
°5uchunksOf 4 "haskell.org" == ["hask","ell.","org"]
°5u</pre>
chunksOf :: Int -> Text -> [Text]

-- | <i>O(n)</i> Breaks a <a>Text</a> up into a list of <a>Text</a>s at
°5unewline <a>Char</a>s. The resulting strings do not contain newlines.
lines :: Text -> [Text]

-- | <i>O(n)</i> Breaks a <a>Text</a> up into a list of words, delimited by
°5u<a>Char</a>s representing white space.
words :: Text -> [Text]

-- | <i>O(n)</i> Joins lines, after appending a terminating newline to
°5ueach.
unlines :: [Text] -> Text

-- | <i>O(n)</i> Joins words using single space characters.
unwords :: [Text] -> Text

-- | <i>O(n)</i> The <a>isPrefixOf</a> function takes two <a>Text</a>s and
°5ureturns <a>True</a> iff the first is a prefix of the second. Subject
°5uto fusion.
isPrefixOf :: Text -> Text -> Bool

-- | <i>O(n)</i> The <a>isSuffixOf</a> function takes two <a>Text</a>s and
°5ureturns <a>True</a> iff the first is a suffix of the second.
isSuffixOf :: Text -> Text -> Bool

-- | <i>O(n+m)</i> The <a>isInfixOf</a> function takes two <a>Text</a>s and
°5ureturns <a>True</a> iff the first is contained, wholly and intact,
°5uanywhere within the second.
°5u
°5uIn (unlikely) bad cases, this function's time complexity degrades
°5utowards <i>O(n*m)</i>.
isInfixOf :: Text -> Text -> Bool

-- | <i>O(n)</i> Return the suffix of the second string if its prefix
°5umatches the entire first string.
°5u
°5uExamples:
°5u
°5u<pre>
°5ustripPrefix "foo" "foobar" == Just "bar"
°5ustripPrefix ""    "baz"    == Just "baz"
°5ustripPrefix "foo" "quux"   == Nothing
°5u</pre>
°5u
°5uThis is particularly useful with the <tt>ViewPatterns</tt> extension
°5uto GHC, as follows:
°5u
°5u<pre>
°5u{-# LANGUAGE ViewPatterns #-}
°5uimport Data.Text as T
°5u
°5ufnordLength :: Text -&gt; Int
°5ufnordLength (stripPrefix "fnord" -&gt; Just suf) = T.length suf
°5ufnordLength _                                 = -1
°5u</pre>
stripPrefix :: Text -> Text -> Maybe Text

-- | <i>O(n)</i> Return the prefix of the second string if its suffix
°5umatches the entire first string.
°5u
°5uExamples:
°5u
°5u<pre>
°5ustripSuffix "bar" "foobar" == Just "foo"
°5ustripSuffix ""    "baz"    == Just "baz"
°5ustripSuffix "foo" "quux"   == Nothing
°5u</pre>
°5u
°5uThis is particularly useful with the <tt>ViewPatterns</tt> extension
°5uto GHC, as follows:
°5u
°5u<pre>
°5u{-# LANGUAGE ViewPatterns #-}
°5uimport Data.Text as T
°5u
°5uquuxLength :: Text -&gt; Int
°5uquuxLength (stripSuffix "quux" -&gt; Just pre) = T.length pre
°5uquuxLength _                                = -1
°5u</pre>
stripSuffix :: Text -> Text -> Maybe Text

-- | <i>O(n)</i> Find the longest non-empty common prefix of two strings
°5uand return it, along with the suffixes of each string at which they no
°5ulonger match.
°5u
°5uIf the strings do not have a common prefix or either one is empty,
°5uthis function returns <a>Nothing</a>.
°5u
°5uExamples:
°5u
°5u<pre>
°5ucommonPrefixes "foobar" "fooquux" == Just ("foo","bar","quux")
°5ucommonPrefixes "veeble" "fetzer"  == Nothing
°5ucommonPrefixes "" "baz"           == Nothing
°5u</pre>
commonPrefixes :: Text -> Text -> Maybe (Text, Text, Text)

-- | <i>O(n)</i> <a>filter</a>, applied to a predicate and a <a>Text</a>,
°5ureturns a <a>Text</a> containing those characters that satisfy the
°5upredicate.
filter :: (Char -> Bool) -> Text -> Text

-- | <i>O(n+m)</i> Find all non-overlapping instances of <tt>needle</tt> in
°5u<tt>haystack</tt>. Each element of the returned list consists of a
°5upair:
°5u
°5u<ul>
°5u<li>The entire string prior to the <i>k</i>th match (i.e. the
°5uprefix)</li>
°5u<li>The <i>k</i>th match, followed by the remainder of the string</li>
°5u</ul>
°5u
°5uExamples:
°5u
°5u<pre>
°5ubreakOnAll "::" ""
°5u==&gt; []
°5ubreakOnAll "/" "a/b/c/"
°5u==&gt; [("a", "/b/c/"), ("a/b", "/c/"), ("a/b/c", "/")]
°5u</pre>
°5u
°5uIn (unlikely) bad cases, this function's time complexity degrades
°5utowards <i>O(n*m)</i>.
°5u
°5uThe <tt>needle</tt> parameter may not be empty.
breakOnAll :: Text -> Text -> [(Text, Text)]

-- | <i>O(n)</i> The <a>find</a> function takes a predicate and a
°5u<a>Text</a>, and returns the first element matching the predicate, or
°5u<a>Nothing</a> if there is no such element.
find :: (Char -> Bool) -> Text -> Maybe Char

-- | <i>O(n)</i> The <a>partition</a> function takes a predicate and a
°5u<a>Text</a>, and returns the pair of <a>Text</a>s with elements which
°5udo and do not satisfy the predicate, respectively; i.e.
°5u
°5u<pre>
°5upartition p t == (filter p t, filter (not . p) t)
°5u</pre>
partition :: (Char -> Bool) -> Text -> (Text, Text)

-- | <i>O(n)</i> <a>Text</a> index (subscript) operator, starting from 0.
index :: Text -> Int -> Char

-- | <i>O(n)</i> The <a>findIndex</a> function takes a predicate and a
°5u<a>Text</a> and returns the index of the first element in the
°5u<a>Text</a> satisfying the predicate. Subject to fusion.
findIndex :: (Char -> Bool) -> Text -> Maybe Int

-- | <i>O(n+m)</i> The <a>count</a> function returns the number of times
°5uthe query string appears in the given <a>Text</a>. An empty query
°5ustring is invalid, and will cause an error to be raised.
°5u
°5uIn (unlikely) bad cases, this function's time complexity degrades
°5utowards <i>O(n*m)</i>.
count :: Text -> Text -> Int

-- | <i>O(n)</i> <a>zip</a> takes two <a>Text</a>s and returns a list of
°5ucorresponding pairs of bytes. If one input <a>Text</a> is short,
°5uexcess elements of the longer <a>Text</a> are discarded. This is
°5uequivalent to a pair of <a>unpack</a> operations.
zip :: Text -> Text -> [(Char, Char)]

-- | <i>O(n)</i> <a>zipWith</a> generalises <a>zip</a> by zipping with the
°5ufunction given as the first argument, instead of a tupling function.
°5uPerforms replacement on invalid scalar values.
zipWith :: (Char -> Char -> Char) -> Text -> Text -> Text

-- | <i>O(n)</i> Make a distinct copy of the given string, sharing no
°5ustorage with the original string.
°5u
°5uAs an example, suppose you read a large string, of which you need only
°5ua small portion. If you do not use <a>copy</a>, the entire original
°5uarray will be kept alive in memory by the smaller string. Making a
°5ucopy "breaks the link" to the original array, allowing it to be
°5ugarbage collected if there are no other live references to it.
copy :: Text -> Text

-- | <i>O(n)</i> Convert a literal string into a <a>Text</a>. Subject to
°5ufusion.
°5u
°5uThis is exposed solely for people writing GHC rewrite rules.
unpackCString# :: Addr# -> Text
instance GHC.Classes.Eq Data.Text.Internal.Text
instance GHC.Classes.Ord Data.Text.Internal.Text
instance GHC.Read.Read Data.Text.Internal.Text
instance GHC.Base.Semigroup Data.Text.Internal.Text
instance GHC.Base.Monoid Data.Text.Internal.Text
instance Data.String.IsString Data.Text.Internal.Text
instance GHC.Exts.IsList Data.Text.Internal.Text
instance Control.DeepSeq.NFData Data.Text.Internal.Text
instance Data.Binary.Class.Binary Data.Text.Internal.Text
instance Data.Data.Data Data.Text.Internal.Text
instance Text.Printf.PrintfArg Data.Text.Internal.Text


-- | Functions used frequently when reading textual data.
module Data.Text.Read

-- | Read some text. If the read succeeds, return its value and the
°5uremaining text, otherwise an error message.
type Reader a = IReader Text a

-- | Read a decimal integer. The input must begin with at least one decimal
°5udigit, and is consumed until a non-digit or end of string is reached.
°5u
°5uThis function does not handle leading sign characters. If you need to
°5uhandle signed input, use <tt><a>signed</a> <a>decimal</a></tt>.
°5u
°5u<i>Note</i>: For fixed-width integer types, this function does not
°5uattempt to detect overflow, so a sufficiently long input may give
°5uincorrect results. If you are worried about overflow, use
°5u<a>Integer</a> for your result type.
decimal :: Integral a => Reader a

-- | Read a hexadecimal integer, consisting of an optional leading
°5u<tt>"0x"</tt> followed by at least one hexadecimal digit. Input is
°5uconsumed until a non-hex-digit or end of string is reached. This
°5ufunction is case insensitive.
°5u
°5uThis function does not handle leading sign characters. If you need to
°5uhandle signed input, use <tt><a>signed</a> <a>hexadecimal</a></tt>.
°5u
°5u<i>Note</i>: For fixed-width integer types, this function does not
°5uattempt to detect overflow, so a sufficiently long input may give
°5uincorrect results. If you are worried about overflow, use
°5u<a>Integer</a> for your result type.
hexadecimal :: Integral a => Reader a

-- | Read an optional leading sign character (<tt>'-'</tt> or <tt>'+'</tt>)
°5uand apply it to the result of applying the given reader.
signed :: Num a => Reader a -> Reader a

-- | Read a rational number.
°5u
°5uThis function accepts an optional leading sign character, followed by
°5uat least one decimal digit. The syntax similar to that accepted by the
°5u<a>read</a> function, with the exception that a trailing <tt>'.'</tt>
°5uor <tt>'e'</tt> <i>not</i> followed by a number is not consumed.
°5u
°5uExamples (with behaviour identical to <a>read</a>):
°5u
°5u<pre>
°5urational "3"     == Right (3.0, "")
°5urational "3.1"   == Right (3.1, "")
°5urational "3e4"   == Right (30000.0, "")
°5urational "3.1e4" == Right (31000.0, "")
°5urational ".3"    == Left "input does not start with a digit"
°5urational "e3"    == Left "input does not start with a digit"
°5u</pre>
°5u
°5uExamples of differences from <a>read</a>:
°5u
°5u<pre>
°5urational "3.foo" == Right (3.0, ".foo")
°5urational "3e"    == Right (3.0, "e")
°5u</pre>
rational :: Fractional a => Reader a

-- | Read a rational number.
°5u
°5uThe syntax accepted by this function is the same as for
°5u<a>rational</a>.
°5u
°5u<i>Note</i>: This function is almost ten times faster than
°5u<a>rational</a>, but is slightly less accurate.
°5u
°5uThe <a>Double</a> type supports about 16 decimal places of accuracy.
°5uFor 94.2% of numbers, this function and <a>rational</a> give identical
°5uresults, but for the remaining 5.8%, this function loses precision
°5uaround the 15th decimal place. For 0.001% of numbers, this function
°5uwill lose precision at the 13th or 14th decimal place.
double :: Reader Double


-- | <i>Warning</i>: this is an internal module, and does not have a stable
°5uAPI or name. Functions in this module may not check or enforce
°5upreconditions expected by public modules. Use at your own risk!
°5u
°5uA module containing private <a>Text</a> internals. This exposes the
°5u<a>Text</a> representation and low level construction functions.
°5uModules which extend the <a>Text</a> system may need to use this
°5umodule.
module Data.Text.Internal.Lazy
data Text
Empty :: Text
Chunk :: {-# UNPACK #-} !Text -> Text -> Text

-- | Smart constructor for <a>Chunk</a>. Guarantees the data type
°5uinvariant.
chunk :: Text -> Text -> Text

-- | Smart constructor for <a>Empty</a>.
empty :: Text

-- | Consume the chunks of a lazy <a>Text</a> with a natural right fold.
foldrChunks :: (Text -> a -> a) -> a -> Text -> a

-- | Consume the chunks of a lazy <a>Text</a> with a strict,
°5utail-recursive, accumulating left fold.
foldlChunks :: (a -> Text -> a) -> a -> Text -> a

-- | Check the invariant strictly.
strictInvariant :: Text -> Bool

-- | Check the invariant lazily.
lazyInvariant :: Text -> Text

-- | Display the internal structure of a lazy <a>Text</a>.
showStructure :: Text -> String

-- | Currently set to 16 KiB, less the memory management overhead.
defaultChunkSize :: Int

-- | Currently set to 128 bytes, less the memory management overhead.
smallChunkSize :: Int

-- | The memory management overhead. Currently this is tuned for GHC only.
chunkOverhead :: Int


-- | This module has been renamed to <a>Lazy</a>. This name for the module
°5uwill be removed in the next major release.

-- | <i>Deprecated: Use Data.Text.Internal.Lazy instead</i>
module Data.Text.Lazy.Internal


-- | <i>Warning</i>: this is an internal module, and does not have a stable
°5uAPI or name. Functions in this module may not check or enforce
°5upreconditions expected by public modules. Use at your own risk!
°5u
°5uFast substring search for lazy <a>Text</a>, based on work by Boyer,
°5uMoore, Horspool, Sunday, and Lundh. Adapted from the strict
°5uimplementation.
module Data.Text.Internal.Lazy.Search

-- | <i>O(n+m)</i> Find the offsets of all non-overlapping indices of
°5u<tt>needle</tt> within <tt>haystack</tt>.
°5u
°5uThis function is strict in <tt>needle</tt>, and lazy (as far as
°5upossible) in the chunks of <tt>haystack</tt>.
°5u
°5uIn (unlikely) bad cases, this algorithm's complexity degrades towards
°5u<i>O(n*m)</i>.
indices :: Text -> Text -> [Int64]


-- | <i>Warning</i>: this is an internal module, and does not have a stable
°5uAPI or name. Functions in this module may not check or enforce
°5upreconditions expected by public modules. Use at your own risk!
°5u
°5uCore stream fusion functionality for text.
module Data.Text.Internal.Lazy.Fusion

-- | <i>O(n)</i> Convert a <a>Text</a> into a 'Stream Char'.
stream :: Text -> Stream Char

-- | <i>O(n)</i> Convert a 'Stream Char' into a <a>Text</a>, using
°5u<a>defaultChunkSize</a>.
unstream :: Stream Char -> Text

-- | <i>O(n)</i> Convert a 'Stream Char' into a <a>Text</a>, using the
°5ugiven chunk size.
unstreamChunks :: Int -> Stream Char -> Text

-- | <i>O(n)</i> Returns the number of characters in a text.
length :: Stream Char -> Int64

-- | <i>O(n)</i> Like <tt>unfoldr</tt>, <a>unfoldrN</a> builds a stream
°5ufrom a seed value. However, the length of the result is limited by the
°5ufirst argument to <a>unfoldrN</a>. This function is more efficient
°5uthan <tt>unfoldr</tt> when the length of the result is known.
unfoldrN :: Int64 -> (a -> Maybe (Char, a)) -> a -> Stream Char

-- | <i>O(n)</i> stream index (subscript) operator, starting from 0.
index :: Stream Char -> Int64 -> Char

-- | <i>O(n)</i> The <tt>count</tt> function returns the number of times
°5uthe query element appears in the given stream.
countChar :: Char -> Stream Char -> Int64


-- | Functions for converting lazy <a>Text</a> values to and from lazy
°5u<tt>ByteString</tt>, using several standard encodings.
°5u
°5uTo gain access to a much larger variety of encodings, use the
°5u<tt>text-icu</tt> package:
°5u<a>http://hackage.haskell.org/package/text-icu</a>
module Data.Text.Lazy.Encoding

-- | <i>Deprecated</i>. Decode a <tt>ByteString</tt> containing 7-bit ASCII
°5uencoded text.

-- | <i>Deprecated: Use decodeUtf8 instead</i>
decodeASCII :: ByteString -> Text

-- | Decode a <tt>ByteString</tt> containing Latin-1 (aka ISO-8859-1)
°5uencoded text.
decodeLatin1 :: ByteString -> Text

-- | Decode a <tt>ByteString</tt> containing UTF-8 encoded text that is
°5uknown to be valid.
°5u
°5uIf the input contains any invalid UTF-8 data, an exception will be
°5uthrown that cannot be caught in pure code. For more control over the
°5uhandling of invalid data, use <a>decodeUtf8'</a> or
°5u<a>decodeUtf8With</a>.
decodeUtf8 :: ByteString -> Text

-- | Decode text from little endian UTF-16 encoding.
°5u
°5uIf the input contains any invalid little endian UTF-16 data, an
°5uexception will be thrown. For more control over the handling of
°5uinvalid data, use <a>decodeUtf16LEWith</a>.
decodeUtf16LE :: ByteString -> Text

-- | Decode text from big endian UTF-16 encoding.
°5u
°5uIf the input contains any invalid big endian UTF-16 data, an exception
°5uwill be thrown. For more control over the handling of invalid data,
°5uuse <a>decodeUtf16BEWith</a>.
decodeUtf16BE :: ByteString -> Text

-- | Decode text from little endian UTF-32 encoding.
°5u
°5uIf the input contains any invalid little endian UTF-32 data, an
°5uexception will be thrown. For more control over the handling of
°5uinvalid data, use <a>decodeUtf32LEWith</a>.
decodeUtf32LE :: ByteString -> Text

-- | Decode text from big endian UTF-32 encoding.
°5u
°5uIf the input contains any invalid big endian UTF-32 data, an exception
°5uwill be thrown. For more control over the handling of invalid data,
°5uuse <a>decodeUtf32BEWith</a>.
decodeUtf32BE :: ByteString -> Text

-- | Decode a <tt>ByteString</tt> containing UTF-8 encoded text..
°5u
°5uIf the input contains any invalid UTF-8 data, the relevant exception
°5uwill be returned, otherwise the decoded text.
°5u
°5u<i>Note</i>: this function is <i>not</i> lazy, as it must decode its
°5uentire input before it can return a result. If you need lazy
°5u(streaming) decoding, use <a>decodeUtf8With</a> in lenient mode.
decodeUtf8' :: ByteString -> Either UnicodeException Text

-- | Decode a <tt>ByteString</tt> containing UTF-8 encoded text.
decodeUtf8With :: OnDecodeError -> ByteString -> Text

-- | Decode text from little endian UTF-16 encoding.
decodeUtf16LEWith :: OnDecodeError -> ByteString -> Text

-- | Decode text from big endian UTF-16 encoding.
decodeUtf16BEWith :: OnDecodeError -> ByteString -> Text

-- | Decode text from little endian UTF-32 encoding.
decodeUtf32LEWith :: OnDecodeError -> ByteString -> Text

-- | Decode text from big endian UTF-32 encoding.
decodeUtf32BEWith :: OnDecodeError -> ByteString -> Text
encodeUtf8 :: Text -> ByteString

-- | Encode text using little endian UTF-16 encoding.
encodeUtf16LE :: Text -> ByteString

-- | Encode text using big endian UTF-16 encoding.
encodeUtf16BE :: Text -> ByteString

-- | Encode text using little endian UTF-32 encoding.
encodeUtf32LE :: Text -> ByteString

-- | Encode text using big endian UTF-32 encoding.
encodeUtf32BE :: Text -> ByteString
encodeUtf8Builder :: Text -> Builder
encodeUtf8BuilderEscaped :: BoundedPrim Word8 -> Text -> Builder


-- | A time and space-efficient implementation of Unicode text using lists
°5uof packed arrays.
°5u
°5u<i>Note</i>: Read below the synopsis for important notes on the use of
°5uthis module.
°5u
°5uThe representation used by this module is suitable for high
°5uperformance use and for streaming large quantities of data. It
°5uprovides a means to manipulate a large body of text without requiring
°5uthat the entire content be resident in memory.
°5u
°5uSome operations, such as <a>concat</a>, <a>append</a>, <a>reverse</a>
°5uand <a>cons</a>, have better time complexity than their
°5u<a>Data.Text</a> equivalents, due to the underlying representation
°5ubeing a list of chunks. For other operations, lazy <a>Text</a>s are
°5uusually within a few percent of strict ones, but often with better
°5uheap usage if used in a streaming fashion. For data larger than
°5uavailable memory, or if you have tight memory constraints, this module
°5uwill be the only option.
°5u
°5uThis module is intended to be imported <tt>qualified</tt>, to avoid
°5uname clashes with <a>Prelude</a> functions. eg.
°5u
°5u<pre>
°5uimport qualified Data.Text.Lazy as L
°5u</pre>
module Data.Text.Lazy
data Text

-- | <i>O(n)</i> Convert a <a>String</a> into a <a>Text</a>.
°5u
°5uSubject to fusion. Performs replacement on invalid scalar values.
pack :: String -> Text

-- | <i>O(n)</i> Convert a <a>Text</a> into a <a>String</a>. Subject to
°5ufusion.
unpack :: Text -> String

-- | <i>O(1)</i> Convert a character into a Text. Subject to fusion.
°5uPerforms replacement on invalid scalar values.
singleton :: Char -> Text

-- | Smart constructor for <a>Empty</a>.
empty :: Text

-- | <i>O(c)</i> Convert a list of strict <a>Text</a>s into a lazy
°5u<a>Text</a>.
fromChunks :: [Text] -> Text

-- | <i>O(n)</i> Convert a lazy <a>Text</a> into a list of strict
°5u<a>Text</a>s.
toChunks :: Text -> [Text]

-- | <i>O(n)</i> Convert a lazy <a>Text</a> into a strict <a>Text</a>.
toStrict :: Text -> Text

-- | <i>O(c)</i> Convert a strict <a>Text</a> into a lazy <a>Text</a>.
fromStrict :: Text -> Text

-- | Consume the chunks of a lazy <a>Text</a> with a natural right fold.
foldrChunks :: (Text -> a -> a) -> a -> Text -> a

-- | Consume the chunks of a lazy <a>Text</a> with a strict,
°5utail-recursive, accumulating left fold.
foldlChunks :: (a -> Text -> a) -> a -> Text -> a

-- | <i>O(1)</i> Adds a character to the front of a <a>Text</a>. Subject to
°5ufusion.
cons :: Char -> Text -> Text
infixr 5 `cons`

-- | <i>O(n)</i> Adds a character to the end of a <a>Text</a>. This copies
°5uthe entire array in the process, unless fused. Subject to fusion.
snoc :: Text -> Char -> Text

-- | <i>O(n/c)</i> Appends one <a>Text</a> to another. Subject to fusion.
append :: Text -> Text -> Text

-- | <i>O(1)</i> Returns the first character and rest of a <a>Text</a>, or
°5u<a>Nothing</a> if empty. Subject to fusion.
uncons :: Text -> Maybe (Char, Text)

-- | <i>O(n/c)</i> Returns the <a>init</a> and <a>last</a> of a
°5u<a>Text</a>, or <a>Nothing</a> if empty.
°5u
°5u<ul>
°5u<li>It is no faster than using <a>init</a> and <a>last</a>.</li>
°5u</ul>
unsnoc :: Text -> Maybe (Text, Char)

-- | <i>O(1)</i> Returns the first character of a <a>Text</a>, which must
°5ube non-empty. Subject to fusion.
head :: Text -> Char

-- | <i>O(n/c)</i> Returns the last character of a <a>Text</a>, which must
°5ube non-empty. Subject to fusion.
last :: Text -> Char

-- | <i>O(1)</i> Returns all characters after the head of a <a>Text</a>,
°5uwhich must be non-empty. Subject to fusion.
tail :: Text -> Text

-- | <i>O(n/c)</i> Returns all but the last character of a <a>Text</a>,
°5uwhich must be non-empty. Subject to fusion.
init :: Text -> Text

-- | <i>O(1)</i> Tests whether a <a>Text</a> is empty or not. Subject to
°5ufusion.
null :: Text -> Bool

-- | <i>O(n)</i> Returns the number of characters in a <a>Text</a>. Subject
°5uto fusion.
length :: Text -> Int64

-- | <i>O(n)</i> Compare the count of characters in a <a>Text</a> to a
°5unumber. Subject to fusion.
°5u
°5uThis function gives the same answer as comparing against the result of
°5u<a>length</a>, but can short circuit if the count of characters is
°5ugreater than the number, and hence be more efficient.
compareLength :: Text -> Int64 -> Ordering

-- | <i>O(n)</i> <a>map</a> <tt>f</tt> <tt>t</tt> is the <a>Text</a>
°5uobtained by applying <tt>f</tt> to each element of <tt>t</tt>. Subject
°5uto fusion. Performs replacement on invalid scalar values.
map :: (Char -> Char) -> Text -> Text

-- | <i>O(n)</i> The <a>intercalate</a> function takes a <a>Text</a> and a
°5ulist of <a>Text</a>s and concatenates the list after interspersing the
°5ufirst argument between each element of the list.
intercalate :: Text -> [Text] -> Text

-- | <i>O(n)</i> The <a>intersperse</a> function takes a character and
°5uplaces it between the characters of a <a>Text</a>. Subject to fusion.
°5uPerforms replacement on invalid scalar values.
intersperse :: Char -> Text -> Text

-- | <i>O(n)</i> The <a>transpose</a> function transposes the rows and
°5ucolumns of its <a>Text</a> argument. Note that this function uses
°5u<a>pack</a>, <a>unpack</a>, and the list version of transpose, and is
°5uthus not very efficient.
transpose :: [Text] -> [Text]

-- | <i>O(n)</i> <a>reverse</a> <tt>t</tt> returns the elements of
°5u<tt>t</tt> in reverse order.
reverse :: Text -> Text

-- | <i>O(m+n)</i> Replace every non-overlapping occurrence of
°5u<tt>needle</tt> in <tt>haystack</tt> with <tt>replacement</tt>.
°5u
°5uThis function behaves as though it was defined as follows:
°5u
°5u<pre>
°5ureplace needle replacement haystack =
°5u  <a>intercalate</a> replacement (<a>splitOn</a> needle haystack)
°5u</pre>
°5u
°5uAs this suggests, each occurrence is replaced exactly once. So if
°5u<tt>needle</tt> occurs in <tt>replacement</tt>, that occurrence will
°5u<i>not</i> itself be replaced recursively:
°5u
°5u<pre>
°5ureplace "oo" "foo" "oo" == "foo"
°5u</pre>
°5u
°5uIn cases where several instances of <tt>needle</tt> overlap, only the
°5ufirst one will be replaced:
°5u
°5u<pre>
°5ureplace "ofo" "bar" "ofofo" == "barfo"
°5u</pre>
°5u
°5uIn (unlikely) bad cases, this function's time complexity degrades
°5utowards <i>O(n*m)</i>.
replace :: Text -> Text -> Text -> Text

-- | <i>O(n)</i> Convert a string to folded case. Subject to fusion.
°5u
°5uThis function is mainly useful for performing caseless (or case
°5uinsensitive) string comparisons.
°5u
°5uA string <tt>x</tt> is a caseless match for a string <tt>y</tt> if and
°5uonly if:
°5u
°5u<pre>
°5utoCaseFold x == toCaseFold y
°5u</pre>
°5u
°5uThe result string may be longer than the input string, and may differ
°5ufrom applying <a>toLower</a> to the input string. For instance, the
°5uArmenian small ligature men now (U+FB13) is case folded to the bigram
°5umen now (U+0574 U+0576), while the micro sign (U+00B5) is case folded
°5uto the Greek small letter letter mu (U+03BC) instead of itself.
toCaseFold :: Text -> Text

-- | <i>O(n)</i> Convert a string to lower case, using simple case
°5uconversion. Subject to fusion.
°5u
°5uThe result string may be longer than the input string. For instance,
°5uthe Latin capital letter I with dot above (U+0130) maps to the
°5usequence Latin small letter i (U+0069) followed by combining dot above
°5u(U+0307).
toLower :: Text -> Text

-- | <i>O(n)</i> Convert a string to upper case, using simple case
°5uconversion. Subject to fusion.
°5u
°5uThe result string may be longer than the input string. For instance,
°5uthe German eszett (U+00DF) maps to the two-letter sequence SS.
toUpper :: Text -> Text

-- | <i>O(n)</i> Convert a string to title case, using simple case
°5uconversion. Subject to fusion.
°5u
°5uThe first letter of the input is converted to title case, as is every
°5usubsequent letter that immediately follows a non-letter. Every letter
°5uthat immediately follows another letter is converted to lower case.
°5u
°5uThe result string may be longer than the input string. For example,
°5uthe Latin small ligature ﬂ (U+FB02) is converted to the sequence Latin
°5ucapital letter F (U+0046) followed by Latin small letter l (U+006C).
°5u
°5u<i>Note</i>: this function does not take language or culture specific
°5urules into account. For instance, in English, different style guides
°5udisagree on whether the book name "The Hill of the Red Fox" is
°5ucorrectly title cased—but this function will capitalize <i>every</i>
°5uword.
toTitle :: Text -> Text

-- | <i>O(n)</i> Left-justify a string to the given length, using the
°5uspecified fill character on the right. Subject to fusion. Performs
°5ureplacement on invalid scalar values.
°5u
°5uExamples:
°5u
°5u<pre>
°5ujustifyLeft 7 'x' "foo"    == "fooxxxx"
°5ujustifyLeft 3 'x' "foobar" == "foobar"
°5u</pre>
justifyLeft :: Int64 -> Char -> Text -> Text

-- | <i>O(n)</i> Right-justify a string to the given length, using the
°5uspecified fill character on the left. Performs replacement on invalid
°5uscalar values.
°5u
°5uExamples:
°5u
°5u<pre>
°5ujustifyRight 7 'x' "bar"    == "xxxxbar"
°5ujustifyRight 3 'x' "foobar" == "foobar"
°5u</pre>
justifyRight :: Int64 -> Char -> Text -> Text

-- | <i>O(n)</i> Center a string to the given length, using the specified
°5ufill character on either side. Performs replacement on invalid scalar
°5uvalues.
°5u
°5uExamples:
°5u
°5u<pre>
°5ucenter 8 'x' "HS" = "xxxHSxxx"
°5u</pre>
center :: Int64 -> Char -> Text -> Text

-- | <i>O(n)</i> <a>foldl</a>, applied to a binary operator, a starting
°5uvalue (typically the left-identity of the operator), and a
°5u<a>Text</a>, reduces the <a>Text</a> using the binary operator, from
°5uleft to right. Subject to fusion.
foldl :: (a -> Char -> a) -> a -> Text -> a

-- | <i>O(n)</i> A strict version of <a>foldl</a>. Subject to fusion.
foldl' :: (a -> Char -> a) -> a -> Text -> a

-- | <i>O(n)</i> A variant of <a>foldl</a> that has no starting value
°5uargument, and thus must be applied to a non-empty <a>Text</a>. Subject
°5uto fusion.
foldl1 :: (Char -> Char -> Char) -> Text -> Char

-- | <i>O(n)</i> A strict version of <a>foldl1</a>. Subject to fusion.
foldl1' :: (Char -> Char -> Char) -> Text -> Char

-- | <i>O(n)</i> <a>foldr</a>, applied to a binary operator, a starting
°5uvalue (typically the right-identity of the operator), and a
°5u<a>Text</a>, reduces the <a>Text</a> using the binary operator, from
°5uright to left. Subject to fusion.
foldr :: (Char -> a -> a) -> a -> Text -> a

-- | <i>O(n)</i> A variant of <a>foldr</a> that has no starting value
°5uargument, and thus must be applied to a non-empty <a>Text</a>. Subject
°5uto fusion.
foldr1 :: (Char -> Char -> Char) -> Text -> Char

-- | <i>O(n)</i> Concatenate a list of <a>Text</a>s.
concat :: [Text] -> Text

-- | <i>O(n)</i> Map a function over a <a>Text</a> that results in a
°5u<a>Text</a>, and concatenate the results.
concatMap :: (Char -> Text) -> Text -> Text

-- | <i>O(n)</i> <a>any</a> <tt>p</tt> <tt>t</tt> determines whether any
°5ucharacter in the <a>Text</a> <tt>t</tt> satisfies the predicate
°5u<tt>p</tt>. Subject to fusion.
any :: (Char -> Bool) -> Text -> Bool

-- | <i>O(n)</i> <a>all</a> <tt>p</tt> <tt>t</tt> determines whether all
°5ucharacters in the <a>Text</a> <tt>t</tt> satisfy the predicate
°5u<tt>p</tt>. Subject to fusion.
all :: (Char -> Bool) -> Text -> Bool

-- | <i>O(n)</i> <a>maximum</a> returns the maximum value from a
°5u<a>Text</a>, which must be non-empty. Subject to fusion.
maximum :: Text -> Char

-- | <i>O(n)</i> <a>minimum</a> returns the minimum value from a
°5u<a>Text</a>, which must be non-empty. Subject to fusion.
minimum :: Text -> Char

-- | <i>O(n)</i> <a>scanl</a> is similar to <a>foldl</a>, but returns a
°5ulist of successive reduced values from the left. Subject to fusion.
°5uPerforms replacement on invalid scalar values.
°5u
°5u<pre>
°5uscanl f z [x1, x2, ...] == [z, z `f` x1, (z `f` x1) `f` x2, ...]
°5u</pre>
°5u
°5uNote that
°5u
°5u<pre>
°5ulast (scanl f z xs) == foldl f z xs.
°5u</pre>
scanl :: (Char -> Char -> Char) -> Char -> Text -> Text

-- | <i>O(n)</i> <a>scanl1</a> is a variant of <a>scanl</a> that has no
°5ustarting value argument. Subject to fusion. Performs replacement on
°5uinvalid scalar values.
°5u
°5u<pre>
°5uscanl1 f [x1, x2, ...] == [x1, x1 `f` x2, ...]
°5u</pre>
scanl1 :: (Char -> Char -> Char) -> Text -> Text

-- | <i>O(n)</i> <a>scanr</a> is the right-to-left dual of <a>scanl</a>.
°5uPerforms replacement on invalid scalar values.
°5u
°5u<pre>
°5uscanr f v == reverse . scanl (flip f) v . reverse
°5u</pre>
scanr :: (Char -> Char -> Char) -> Char -> Text -> Text

-- | <i>O(n)</i> <a>scanr1</a> is a variant of <a>scanr</a> that has no
°5ustarting value argument. Performs replacement on invalid scalar
°5uvalues.
scanr1 :: (Char -> Char -> Char) -> Text -> Text

-- | <i>O(n)</i> Like a combination of <a>map</a> and <a>foldl'</a>.
°5uApplies a function to each element of a <a>Text</a>, passing an
°5uaccumulating parameter from left to right, and returns a final
°5u<a>Text</a>. Performs replacement on invalid scalar values.
mapAccumL :: (a -> Char -> (a, Char)) -> a -> Text -> (a, Text)

-- | The <a>mapAccumR</a> function behaves like a combination of <a>map</a>
°5uand a strict <a>foldr</a>; it applies a function to each element of a
°5u<a>Text</a>, passing an accumulating parameter from right to left, and
°5ureturning a final value of this accumulator together with the new
°5u<a>Text</a>. Performs replacement on invalid scalar values.
mapAccumR :: (a -> Char -> (a, Char)) -> a -> Text -> (a, Text)

-- | <tt><a>repeat</a> x</tt> is an infinite <a>Text</a>, with <tt>x</tt>
°5uthe value of every element.
repeat :: Char -> Text

-- | <i>O(n*m)</i> <a>replicate</a> <tt>n</tt> <tt>t</tt> is a <a>Text</a>
°5uconsisting of the input <tt>t</tt> repeated <tt>n</tt> times.
replicate :: Int64 -> Text -> Text

-- | <a>cycle</a> ties a finite, non-empty <a>Text</a> into a circular one,
°5uor equivalently, the infinite repetition of the original <a>Text</a>.
cycle :: Text -> Text

-- | <tt><a>iterate</a> f x</tt> returns an infinite <a>Text</a> of
°5urepeated applications of <tt>f</tt> to <tt>x</tt>:
°5u
°5u<pre>
°5uiterate f x == [x, f x, f (f x), ...]
°5u</pre>
iterate :: (Char -> Char) -> Char -> Text

-- | <i>O(n)</i>, where <tt>n</tt> is the length of the result. The
°5u<a>unfoldr</a> function is analogous to the List <a>unfoldr</a>.
°5u<a>unfoldr</a> builds a <a>Text</a> from a seed value. The function
°5utakes the element and returns <a>Nothing</a> if it is done producing
°5uthe <a>Text</a>, otherwise <a>Just</a> <tt>(a,b)</tt>. In this case,
°5u<tt>a</tt> is the next <a>Char</a> in the string, and <tt>b</tt> is
°5uthe seed value for further production. Performs replacement on invalid
°5uscalar values.
unfoldr :: (a -> Maybe (Char, a)) -> a -> Text

-- | <i>O(n)</i> Like <a>unfoldr</a>, <a>unfoldrN</a> builds a <a>Text</a>
°5ufrom a seed value. However, the length of the result should be limited
°5uby the first argument to <a>unfoldrN</a>. This function is more
°5uefficient than <a>unfoldr</a> when the maximum length of the result is
°5uknown and correct, otherwise its performance is similar to
°5u<a>unfoldr</a>. Performs replacement on invalid scalar values.
unfoldrN :: Int64 -> (a -> Maybe (Char, a)) -> a -> Text

-- | <i>O(n)</i> <a>take</a> <tt>n</tt>, applied to a <a>Text</a>, returns
°5uthe prefix of the <a>Text</a> of length <tt>n</tt>, or the <a>Text</a>
°5uitself if <tt>n</tt> is greater than the length of the Text. Subject
°5uto fusion.
take :: Int64 -> Text -> Text

-- | <i>O(n)</i> <a>takeEnd</a> <tt>n</tt> <tt>t</tt> returns the suffix
°5uremaining after taking <tt>n</tt> characters from the end of
°5u<tt>t</tt>.
°5u
°5uExamples:
°5u
°5u<pre>
°5utakeEnd 3 "foobar" == "bar"
°5u</pre>
takeEnd :: Int64 -> Text -> Text

-- | <i>O(n)</i> <a>drop</a> <tt>n</tt>, applied to a <a>Text</a>, returns
°5uthe suffix of the <a>Text</a> after the first <tt>n</tt> characters,
°5uor the empty <a>Text</a> if <tt>n</tt> is greater than the length of
°5uthe <a>Text</a>. Subject to fusion.
drop :: Int64 -> Text -> Text

-- | <i>O(n)</i> <a>dropEnd</a> <tt>n</tt> <tt>t</tt> returns the prefix
°5uremaining after dropping <tt>n</tt> characters from the end of
°5u<tt>t</tt>.
°5u
°5uExamples:
°5u
°5u<pre>
°5udropEnd 3 "foobar" == "foo"
°5u</pre>
dropEnd :: Int64 -> Text -> Text

-- | <i>O(n)</i> <a>takeWhile</a>, applied to a predicate <tt>p</tt> and a
°5u<a>Text</a>, returns the longest prefix (possibly empty) of elements
°5uthat satisfy <tt>p</tt>. Subject to fusion.
takeWhile :: (Char -> Bool) -> Text -> Text

-- | <i>O(n)</i> <a>takeWhileEnd</a>, applied to a predicate <tt>p</tt> and
°5ua <a>Text</a>, returns the longest suffix (possibly empty) of elements
°5uthat satisfy <tt>p</tt>. Examples:
°5u
°5u<pre>
°5utakeWhileEnd (=='o') "foo" == "oo"
°5u</pre>
takeWhileEnd :: (Char -> Bool) -> Text -> Text

-- | <i>O(n)</i> <a>dropWhile</a> <tt>p</tt> <tt>t</tt> returns the suffix
°5uremaining after <a>takeWhile</a> <tt>p</tt> <tt>t</tt>. Subject to
°5ufusion.
dropWhile :: (Char -> Bool) -> Text -> Text

-- | <i>O(n)</i> <a>dropWhileEnd</a> <tt>p</tt> <tt>t</tt> returns the
°5uprefix remaining after dropping characters that satisfy the predicate
°5u<tt>p</tt> from the end of <tt>t</tt>.
°5u
°5uExamples:
°5u
°5u<pre>
°5udropWhileEnd (=='.') "foo..." == "foo"
°5u</pre>
dropWhileEnd :: (Char -> Bool) -> Text -> Text

-- | <i>O(n)</i> <a>dropAround</a> <tt>p</tt> <tt>t</tt> returns the
°5usubstring remaining after dropping characters that satisfy the
°5upredicate <tt>p</tt> from both the beginning and end of <tt>t</tt>.
°5uSubject to fusion.
dropAround :: (Char -> Bool) -> Text -> Text

-- | <i>O(n)</i> Remove leading and trailing white space from a string.
°5uEquivalent to:
°5u
°5u<pre>
°5udropAround isSpace
°5u</pre>
strip :: Text -> Text

-- | <i>O(n)</i> Remove leading white space from a string. Equivalent to:
°5u
°5u<pre>
°5udropWhile isSpace
°5u</pre>
stripStart :: Text -> Text

-- | <i>O(n)</i> Remove trailing white space from a string. Equivalent to:
°5u
°5u<pre>
°5udropWhileEnd isSpace
°5u</pre>
stripEnd :: Text -> Text

-- | <i>O(n)</i> <a>splitAt</a> <tt>n t</tt> returns a pair whose first
°5uelement is a prefix of <tt>t</tt> of length <tt>n</tt>, and whose
°5usecond is the remainder of the string. It is equivalent to
°5u<tt>(<a>take</a> n t, <a>drop</a> n t)</tt>.
splitAt :: Int64 -> Text -> (Text, Text)

-- | <i>O(n)</i> <a>span</a>, applied to a predicate <tt>p</tt> and text
°5u<tt>t</tt>, returns a pair whose first element is the longest prefix
°5u(possibly empty) of <tt>t</tt> of elements that satisfy <tt>p</tt>,
°5uand whose second is the remainder of the list.
span :: (Char -> Bool) -> Text -> (Text, Text)

-- | <i>O(n+m)</i> Find the first instance of <tt>needle</tt> (which must
°5ube non-<a>null</a>) in <tt>haystack</tt>. The first element of the
°5ureturned tuple is the prefix of <tt>haystack</tt> before
°5u<tt>needle</tt> is matched. The second is the remainder of
°5u<tt>haystack</tt>, starting with the match.
°5u
°5uExamples:
°5u
°5u<pre>
°5ubreakOn "::" "a::b::c" ==&gt; ("a", "::b::c")
°5ubreakOn "/" "foobar"   ==&gt; ("foobar", "")
°5u</pre>
°5u
°5uLaws:
°5u
°5u<pre>
°5uappend prefix match == haystack
°5u  where (prefix, match) = breakOn needle haystack
°5u</pre>
°5u
°5uIf you need to break a string by a substring repeatedly (e.g. you want
°5uto break on every instance of a substring), use <a>breakOnAll</a>
°5uinstead, as it has lower startup overhead.
°5u
°5uThis function is strict in its first argument, and lazy in its second.
°5u
°5uIn (unlikely) bad cases, this function's time complexity degrades
°5utowards <i>O(n*m)</i>.
breakOn :: Text -> Text -> (Text, Text)

-- | <i>O(n+m)</i> Similar to <a>breakOn</a>, but searches from the end of
°5uthe string.
°5u
°5uThe first element of the returned tuple is the prefix of
°5u<tt>haystack</tt> up to and including the last match of
°5u<tt>needle</tt>. The second is the remainder of <tt>haystack</tt>,
°5ufollowing the match.
°5u
°5u<pre>
°5ubreakOnEnd "::" "a::b::c" ==&gt; ("a::b::", "c")
°5u</pre>
breakOnEnd :: Text -> Text -> (Text, Text)

-- | <i>O(n)</i> <a>break</a> is like <a>span</a>, but the prefix returned
°5uis over elements that fail the predicate <tt>p</tt>.
break :: (Char -> Bool) -> Text -> (Text, Text)

-- | The <a>group</a> function takes a <a>Text</a> and returns a list of
°5u<a>Text</a>s such that the concatenation of the result is equal to the
°5uargument. Moreover, each sublist in the result contains only equal
°5uelements. For example,
°5u
°5u<pre>
°5ugroup "Mississippi" = ["M","i","ss","i","ss","i","pp","i"]
°5u</pre>
°5u
°5uIt is a special case of <a>groupBy</a>, which allows the programmer to
°5usupply their own equality test.
group :: Text -> [Text]

-- | The <a>groupBy</a> function is the non-overloaded version of
°5u<a>group</a>.
groupBy :: (Char -> Char -> Bool) -> Text -> [Text]

-- | <i>O(n)</i> Return all initial segments of the given <a>Text</a>,
°5ushortest first.
inits :: Text -> [Text]

-- | <i>O(n)</i> Return all final segments of the given <a>Text</a>,
°5ulongest first.
tails :: Text -> [Text]

-- | <i>O(m+n)</i> Break a <a>Text</a> into pieces separated by the first
°5u<a>Text</a> argument (which cannot be an empty string), consuming the
°5udelimiter. An empty delimiter is invalid, and will cause an error to
°5ube raised.
°5u
°5uExamples:
°5u
°5u<pre>
°5usplitOn "\r\n" "a\r\nb\r\nd\r\ne" == ["a","b","d","e"]
°5usplitOn "aaa"  "aaaXaaaXaaaXaaa"  == ["","X","X","X",""]
°5usplitOn "x"    "x"                == ["",""]
°5u</pre>
°5u
°5uand
°5u
°5u<pre>
°5uintercalate s . splitOn s         == id
°5usplitOn (singleton c)             == split (==c)
°5u</pre>
°5u
°5u(Note: the string <tt>s</tt> to split on above cannot be empty.)
°5u
°5uThis function is strict in its first argument, and lazy in its second.
°5u
°5uIn (unlikely) bad cases, this function's time complexity degrades
°5utowards <i>O(n*m)</i>.
splitOn :: Text -> Text -> [Text]

-- | <i>O(n)</i> Splits a <a>Text</a> into components delimited by
°5useparators, where the predicate returns True for a separator element.
°5uThe resulting components do not contain the separators. Two adjacent
°5useparators result in an empty component in the output. eg.
°5u
°5u<pre>
°5usplit (=='a') "aabbaca" == ["","","bb","c",""]
°5usplit (=='a') []        == [""]
°5u</pre>
split :: (Char -> Bool) -> Text -> [Text]

-- | <i>O(n)</i> Splits a <a>Text</a> into components of length <tt>k</tt>.
°5uThe last element may be shorter than the other chunks, depending on
°5uthe length of the input. Examples:
°5u
°5u<pre>
°5uchunksOf 3 "foobarbaz"   == ["foo","bar","baz"]
°5uchunksOf 4 "haskell.org" == ["hask","ell.","org"]
°5u</pre>
chunksOf :: Int64 -> Text -> [Text]

-- | <i>O(n)</i> Breaks a <a>Text</a> up into a list of <a>Text</a>s at
°5unewline <a>Char</a>s. The resulting strings do not contain newlines.
lines :: Text -> [Text]

-- | <i>O(n)</i> Breaks a <a>Text</a> up into a list of words, delimited by
°5u<a>Char</a>s representing white space.
words :: Text -> [Text]

-- | <i>O(n)</i> Joins lines, after appending a terminating newline to
°5ueach.
unlines :: [Text] -> Text

-- | <i>O(n)</i> Joins words using single space characters.
unwords :: [Text] -> Text

-- | <i>O(n)</i> The <a>isPrefixOf</a> function takes two <a>Text</a>s and
°5ureturns <a>True</a> iff the first is a prefix of the second. Subject
°5uto fusion.
isPrefixOf :: Text -> Text -> Bool

-- | <i>O(n)</i> The <a>isSuffixOf</a> function takes two <a>Text</a>s and
°5ureturns <a>True</a> iff the first is a suffix of the second.
isSuffixOf :: Text -> Text -> Bool

-- | <i>O(n+m)</i> The <a>isInfixOf</a> function takes two <a>Text</a>s and
°5ureturns <a>True</a> iff the first is contained, wholly and intact,
°5uanywhere within the second.
°5u
°5uThis function is strict in its first argument, and lazy in its second.
°5u
°5uIn (unlikely) bad cases, this function's time complexity degrades
°5utowards <i>O(n*m)</i>.
isInfixOf :: Text -> Text -> Bool

-- | <i>O(n)</i> Return the suffix of the second string if its prefix
°5umatches the entire first string.
°5u
°5uExamples:
°5u
°5u<pre>
°5ustripPrefix "foo" "foobar" == Just "bar"
°5ustripPrefix ""    "baz"    == Just "baz"
°5ustripPrefix "foo" "quux"   == Nothing
°5u</pre>
°5u
°5uThis is particularly useful with the <tt>ViewPatterns</tt> extension
°5uto GHC, as follows:
°5u
°5u<pre>
°5u{-# LANGUAGE ViewPatterns #-}
°5uimport Data.Text.Lazy as T
°5u
°5ufnordLength :: Text -&gt; Int
°5ufnordLength (stripPrefix "fnord" -&gt; Just suf) = T.length suf
°5ufnordLength _                                 = -1
°5u</pre>
stripPrefix :: Text -> Text -> Maybe Text

-- | <i>O(n)</i> Return the prefix of the second string if its suffix
°5umatches the entire first string.
°5u
°5uExamples:
°5u
°5u<pre>
°5ustripSuffix "bar" "foobar" == Just "foo"
°5ustripSuffix ""    "baz"    == Just "baz"
°5ustripSuffix "foo" "quux"   == Nothing
°5u</pre>
°5u
°5uThis is particularly useful with the <tt>ViewPatterns</tt> extension
°5uto GHC, as follows:
°5u
°5u<pre>
°5u{-# LANGUAGE ViewPatterns #-}
°5uimport Data.Text.Lazy as T
°5u
°5uquuxLength :: Text -&gt; Int
°5uquuxLength (stripSuffix "quux" -&gt; Just pre) = T.length pre
°5uquuxLength _                                = -1
°5u</pre>
stripSuffix :: Text -> Text -> Maybe Text

-- | <i>O(n)</i> Find the longest non-empty common prefix of two strings
°5uand return it, along with the suffixes of each string at which they no
°5ulonger match.
°5u
°5uIf the strings do not have a common prefix or either one is empty,
°5uthis function returns <a>Nothing</a>.
°5u
°5uExamples:
°5u
°5u<pre>
°5ucommonPrefixes "foobar" "fooquux" == Just ("foo","bar","quux")
°5ucommonPrefixes "veeble" "fetzer"  == Nothing
°5ucommonPrefixes "" "baz"           == Nothing
°5u</pre>
commonPrefixes :: Text -> Text -> Maybe (Text, Text, Text)

-- | <i>O(n)</i> <a>filter</a>, applied to a predicate and a <a>Text</a>,
°5ureturns a <a>Text</a> containing those characters that satisfy the
°5upredicate.
filter :: (Char -> Bool) -> Text -> Text

-- | <i>O(n)</i> The <a>find</a> function takes a predicate and a
°5u<a>Text</a>, and returns the first element in matching the predicate,
°5uor <a>Nothing</a> if there is no such element.
find :: (Char -> Bool) -> Text -> Maybe Char

-- | <i>O(n+m)</i> Find all non-overlapping instances of <tt>needle</tt> in
°5u<tt>haystack</tt>. Each element of the returned list consists of a
°5upair:
°5u
°5u<ul>
°5u<li>The entire string prior to the <i>k</i>th match (i.e. the
°5uprefix)</li>
°5u<li>The <i>k</i>th match, followed by the remainder of the string</li>
°5u</ul>
°5u
°5uExamples:
°5u
°5u<pre>
°5ubreakOnAll "::" ""
°5u==&gt; []
°5ubreakOnAll "/" "a/b/c/"
°5u==&gt; [("a", "/b/c/"), ("a/b", "/c/"), ("a/b/c", "/")]
°5u</pre>
°5u
°5uThis function is strict in its first argument, and lazy in its second.
°5u
°5uIn (unlikely) bad cases, this function's time complexity degrades
°5utowards <i>O(n*m)</i>.
°5u
°5uThe <tt>needle</tt> parameter may not be empty.
breakOnAll :: Text -> Text -> [(Text, Text)]

-- | <i>O(n)</i> The <a>partition</a> function takes a predicate and a
°5u<a>Text</a>, and returns the pair of <a>Text</a>s with elements which
°5udo and do not satisfy the predicate, respectively; i.e.
°5u
°5u<pre>
°5upartition p t == (filter p t, filter (not . p) t)
°5u</pre>
partition :: (Char -> Bool) -> Text -> (Text, Text)

-- | <i>O(n)</i> <a>Text</a> index (subscript) operator, starting from 0.
index :: Text -> Int64 -> Char

-- | <i>O(n+m)</i> The <a>count</a> function returns the number of times
°5uthe query string appears in the given <a>Text</a>. An empty query
°5ustring is invalid, and will cause an error to be raised.
°5u
°5uIn (unlikely) bad cases, this function's time complexity degrades
°5utowards <i>O(n*m)</i>.
count :: Text -> Text -> Int64

-- | <i>O(n)</i> <a>zip</a> takes two <a>Text</a>s and returns a list of
°5ucorresponding pairs of bytes. If one input <a>Text</a> is short,
°5uexcess elements of the longer <a>Text</a> are discarded. This is
°5uequivalent to a pair of <a>unpack</a> operations.
zip :: Text -> Text -> [(Char, Char)]

-- | <i>O(n)</i> <a>zipWith</a> generalises <a>zip</a> by zipping with the
°5ufunction given as the first argument, instead of a tupling function.
°5uPerforms replacement on invalid scalar values.
zipWith :: (Char -> Char -> Char) -> Text -> Text -> Text
instance GHC.Classes.Eq Data.Text.Internal.Lazy.Text
instance GHC.Classes.Ord Data.Text.Internal.Lazy.Text
instance GHC.Show.Show Data.Text.Internal.Lazy.Text
instance GHC.Read.Read Data.Text.Internal.Lazy.Text
instance GHC.Base.Semigroup Data.Text.Internal.Lazy.Text
instance GHC.Base.Monoid Data.Text.Internal.Lazy.Text
instance Data.String.IsString Data.Text.Internal.Lazy.Text
instance GHC.Exts.IsList Data.Text.Internal.Lazy.Text
instance Control.DeepSeq.NFData Data.Text.Internal.Lazy.Text
instance Data.Binary.Class.Binary Data.Text.Internal.Lazy.Text
instance Data.Data.Data Data.Text.Internal.Lazy.Text
instance Text.Printf.PrintfArg Data.Text.Internal.Lazy.Text


-- | Functions used frequently when reading textual data.
module Data.Text.Lazy.Read

-- | Read some text. If the read succeeds, return its value and the
°5uremaining text, otherwise an error message.
type Reader a = IReader Text a

-- | Read a decimal integer. The input must begin with at least one decimal
°5udigit, and is consumed until a non-digit or end of string is reached.
°5u
°5uThis function does not handle leading sign characters. If you need to
°5uhandle signed input, use <tt><a>signed</a> <a>decimal</a></tt>.
°5u
°5u<i>Note</i>: For fixed-width integer types, this function does not
°5uattempt to detect overflow, so a sufficiently long input may give
°5uincorrect results. If you are worried about overflow, use
°5u<a>Integer</a> for your result type.
decimal :: Integral a => Reader a

-- | Read a hexadecimal integer, consisting of an optional leading
°5u<tt>"0x"</tt> followed by at least one hexadecimal digit. Input is
°5uconsumed until a non-hex-digit or end of string is reached. This
°5ufunction is case insensitive.
°5u
°5uThis function does not handle leading sign characters. If you need to
°5uhandle signed input, use <tt><a>signed</a> <a>hexadecimal</a></tt>.
°5u
°5u<i>Note</i>: For fixed-width integer types, this function does not
°5uattempt to detect overflow, so a sufficiently long input may give
°5uincorrect results. If you are worried about overflow, use
°5u<a>Integer</a> for your result type.
hexadecimal :: Integral a => Reader a

-- | Read an optional leading sign character (<tt>'-'</tt> or <tt>'+'</tt>)
°5uand apply it to the result of applying the given reader.
signed :: Num a => Reader a -> Reader a

-- | Read a rational number.
°5u
°5uThis function accepts an optional leading sign character, followed by
°5uat least one decimal digit. The syntax similar to that accepted by the
°5u<a>read</a> function, with the exception that a trailing <tt>'.'</tt>
°5uor <tt>'e'</tt> <i>not</i> followed by a number is not consumed.
°5u
°5uExamples:
°5u
°5u<pre>
°5urational "3"     == Right (3.0, "")
°5urational "3.1"   == Right (3.1, "")
°5urational "3e4"   == Right (30000.0, "")
°5urational "3.1e4" == Right (31000.0, "")
°5urational ".3"    == Left "input does not start with a digit"
°5urational "e3"    == Left "input does not start with a digit"
°5u</pre>
°5u
°5uExamples of differences from <a>read</a>:
°5u
°5u<pre>
°5urational "3.foo" == Right (3.0, ".foo")
°5urational "3e"    == Right (3.0, "e")
°5u</pre>
rational :: Fractional a => Reader a

-- | Read a rational number.
°5u
°5uThe syntax accepted by this function is the same as for
°5u<a>rational</a>.
°5u
°5u<i>Note</i>: This function is almost ten times faster than
°5u<a>rational</a>, but is slightly less accurate.
°5u
°5uThe <a>Double</a> type supports about 16 decimal places of accuracy.
°5uFor 94.2% of numbers, this function and <a>rational</a> give identical
°5uresults, but for the remaining 5.8%, this function loses precision
°5uaround the 15th decimal place. For 0.001% of numbers, this function
°5uwill lose precision at the 13th or 14th decimal place.
double :: Reader Double


-- | <i>Warning</i>: this is an internal module, and does not have a stable
°5uAPI or name. Functions in this module may not check or enforce
°5upreconditions expected by public modules. Use at your own risk!
°5u
°5uLow-level support for text I/O.
module Data.Text.Internal.IO

-- | Read a single line of input from a handle, constructing a list of
°5udecoded chunks as we go. When we're done, transform them into the
°5udestination type.
hGetLineWith :: ([Text] -> t) -> Handle -> IO t

-- | Read a single chunk of strict text from a buffer. Used by both the
°5ustrict and lazy implementations of hGetContents.
readChunk :: Handle__ -> CharBuffer -> IO Text


-- | <i>Warning</i>: this is an internal module, and does not have a stable
°5uAPI or name. Functions in this module may not check or enforce
°5upreconditions expected by public modules. Use at your own risk!
°5u
°5uEfficient construction of lazy <tt>Text</tt> values. The principal
°5uoperations on a <tt>Builder</tt> are <tt>singleton</tt>,
°5u<tt>fromText</tt>, and <tt>fromLazyText</tt>, which construct new
°5ubuilders, and <a>mappend</a>, which concatenates two builders.
°5u
°5uTo get maximum performance when building lazy <tt>Text</tt> values
°5uusing a builder, associate <tt>mappend</tt> calls to the right. For
°5uexample, prefer
°5u
°5u<pre>
°5usingleton 'a' `mappend` (singleton 'b' `mappend` singleton 'c')
°5u</pre>
°5u
°5uto
°5u
°5u<pre>
°5usingleton 'a' `mappend` singleton 'b' `mappend` singleton 'c'
°5u</pre>
°5u
°5uas the latter associates <tt>mappend</tt> to the left.
module Data.Text.Internal.Builder

-- | A <tt>Builder</tt> is an efficient way to build lazy <tt>Text</tt>
°5uvalues. There are several functions for constructing builders, but
°5uonly one to inspect them: to extract any data, you have to turn them
°5uinto lazy <tt>Text</tt> values using <tt>toLazyText</tt>.
°5u
°5uInternally, a builder constructs a lazy <tt>Text</tt> by filling
°5uarrays piece by piece. As each buffer is filled, it is 'popped' off,
°5uto become a new chunk of the resulting lazy <tt>Text</tt>. All this is
°5uhidden from the user of the <tt>Builder</tt>.
data Builder

-- | <i>O(n).</i> Extract a lazy <tt>Text</tt> from a <tt>Builder</tt> with
°5ua default buffer size. The construction work takes place if and when
°5uthe relevant part of the lazy <tt>Text</tt> is demanded.
toLazyText :: Builder -> Text

-- | <i>O(n).</i> Extract a lazy <tt>Text</tt> from a <tt>Builder</tt>,
°5uusing the given size for the initial buffer. The construction work
°5utakes place if and when the relevant part of the lazy <tt>Text</tt> is
°5udemanded.
°5u
°5uIf the initial buffer is too small to hold all data, subsequent
°5ubuffers will be the default buffer size.
toLazyTextWith :: Int -> Builder -> Text

-- | <i>O(1).</i> A <tt>Builder</tt> taking a single character, satisfying
°5u
°5u<ul>
°5u<li><pre><a>toLazyText</a> (<a>singleton</a> c) = <a>singleton</a>
°5uc</pre></li>
°5u</ul>
singleton :: Char -> Builder

-- | <i>O(1).</i> A <tt>Builder</tt> taking a <a>Text</a>, satisfying
°5u
°5u<ul>
°5u<li><pre><a>toLazyText</a> (<a>fromText</a> t) = <a>fromChunks</a>
°5u[t]</pre></li>
°5u</ul>
fromText :: Text -> Builder

-- | <i>O(1).</i> A <tt>Builder</tt> taking a lazy <tt>Text</tt>,
°5usatisfying
°5u
°5u<ul>
°5u<li><pre><a>toLazyText</a> (<a>fromLazyText</a> t) = t</pre></li>
°5u</ul>
fromLazyText :: Text -> Builder

-- | <i>O(1).</i> A Builder taking a <tt>String</tt>, satisfying
°5u
°5u<ul>
°5u<li><pre><a>toLazyText</a> (<a>fromString</a> s) = <a>fromChunks</a>
°5u[S.pack s]</pre></li>
°5u</ul>
fromString :: String -> Builder

-- | <i>O(1).</i> Pop the strict <tt>Text</tt> we have constructed so far,
°5uif any, yielding a new chunk in the result lazy <tt>Text</tt>.
flush :: Builder
append' :: Builder -> Builder -> Builder

-- | Ensure that there are at least <tt>n</tt> many elements available.
ensureFree :: Int -> Builder

-- | Ensure that <tt>n</tt> many elements are available, and then use
°5u<tt>f</tt> to write some elements into the memory.
writeN :: Int -> (forall s. MArray s -> Int -> ST s ()) -> Builder
instance GHC.Base.Semigroup Data.Text.Internal.Builder.Builder
instance GHC.Base.Monoid Data.Text.Internal.Builder.Builder
instance Data.String.IsString Data.Text.Internal.Builder.Builder
instance GHC.Show.Show Data.Text.Internal.Builder.Builder
instance GHC.Classes.Eq Data.Text.Internal.Builder.Builder
instance GHC.Classes.Ord Data.Text.Internal.Builder.Builder


-- | Efficient construction of lazy <tt>Text</tt> values. The principal
°5uoperations on a <tt>Builder</tt> are <tt>singleton</tt>,
°5u<tt>fromText</tt>, and <tt>fromLazyText</tt>, which construct new
°5ubuilders, and <a>mappend</a>, which concatenates two builders.
°5u
°5uTo get maximum performance when building lazy <tt>Text</tt> values
°5uusing a builder, associate <tt>mappend</tt> calls to the right. For
°5uexample, prefer
°5u
°5u<pre>
°5usingleton 'a' `mappend` (singleton 'b' `mappend` singleton 'c')
°5u</pre>
°5u
°5uto
°5u
°5u<pre>
°5usingleton 'a' `mappend` singleton 'b' `mappend` singleton 'c'
°5u</pre>
°5u
°5uas the latter associates <tt>mappend</tt> to the left. Or,
°5uequivalently, prefer
°5u
°5u<pre>
°5usingleton 'a' &lt;&gt; singleton 'b' &lt;&gt; singleton 'c'
°5u</pre>
°5u
°5usince the <a>&lt;&gt;</a> from recent versions of <a>Monoid</a>
°5uassociates to the right.
module Data.Text.Lazy.Builder

-- | A <tt>Builder</tt> is an efficient way to build lazy <tt>Text</tt>
°5uvalues. There are several functions for constructing builders, but
°5uonly one to inspect them: to extract any data, you have to turn them
°5uinto lazy <tt>Text</tt> values using <tt>toLazyText</tt>.
°5u
°5uInternally, a builder constructs a lazy <tt>Text</tt> by filling
°5uarrays piece by piece. As each buffer is filled, it is 'popped' off,
°5uto become a new chunk of the resulting lazy <tt>Text</tt>. All this is
°5uhidden from the user of the <tt>Builder</tt>.
data Builder

-- | <i>O(n).</i> Extract a lazy <tt>Text</tt> from a <tt>Builder</tt> with
°5ua default buffer size. The construction work takes place if and when
°5uthe relevant part of the lazy <tt>Text</tt> is demanded.
toLazyText :: Builder -> Text

-- | <i>O(n).</i> Extract a lazy <tt>Text</tt> from a <tt>Builder</tt>,
°5uusing the given size for the initial buffer. The construction work
°5utakes place if and when the relevant part of the lazy <tt>Text</tt> is
°5udemanded.
°5u
°5uIf the initial buffer is too small to hold all data, subsequent
°5ubuffers will be the default buffer size.
toLazyTextWith :: Int -> Builder -> Text

-- | <i>O(1).</i> A <tt>Builder</tt> taking a single character, satisfying
°5u
°5u<ul>
°5u<li><pre><a>toLazyText</a> (<a>singleton</a> c) = <a>singleton</a>
°5uc</pre></li>
°5u</ul>
singleton :: Char -> Builder

-- | <i>O(1).</i> A <tt>Builder</tt> taking a <a>Text</a>, satisfying
°5u
°5u<ul>
°5u<li><pre><a>toLazyText</a> (<a>fromText</a> t) = <a>fromChunks</a>
°5u[t]</pre></li>
°5u</ul>
fromText :: Text -> Builder

-- | <i>O(1).</i> A <tt>Builder</tt> taking a lazy <tt>Text</tt>,
°5usatisfying
°5u
°5u<ul>
°5u<li><pre><a>toLazyText</a> (<a>fromLazyText</a> t) = t</pre></li>
°5u</ul>
fromLazyText :: Text -> Builder

-- | <i>O(1).</i> A Builder taking a <tt>String</tt>, satisfying
°5u
°5u<ul>
°5u<li><pre><a>toLazyText</a> (<a>fromString</a> s) = <a>fromChunks</a>
°5u[S.pack s]</pre></li>
°5u</ul>
fromString :: String -> Builder

-- | <i>O(1).</i> Pop the strict <tt>Text</tt> we have constructed so far,
°5uif any, yielding a new chunk in the result lazy <tt>Text</tt>.
flush :: Builder


-- | <i>Warning</i>: this is an internal module, and does not have a stable
°5uAPI or name. Functions in this module may not check or enforce
°5upreconditions expected by public modules. Use at your own risk!
°5u
°5uUseful functions and combinators.
module Data.Text.Internal.Builder.Functions

-- | The normal <a>mappend</a> function with right associativity instead of
°5uleft.
(<>) :: Builder -> Builder -> Builder
infixr 4 <>

-- | Unsafe conversion for decimal digits.
i2d :: Int -> Char

module Data.Text.Lazy.Builder.Int
decimal :: Integral a => a -> Builder
hexadecimal :: Integral a => a -> Builder


-- | Write a floating point value to a <a>Builder</a>.
module Data.Text.Lazy.Builder.RealFloat

-- | Control the rendering of floating point numbers.
data FPFormat

-- | Scientific notation (e.g. <tt>2.3e123</tt>).
Exponent :: FPFormat

-- | Standard decimal notation.
Fixed :: FPFormat

-- | Use decimal notation for values between <tt>0.1</tt> and
°5u<tt>9,999,999</tt>, and scientific notation otherwise.
Generic :: FPFormat

-- | Show a signed <a>RealFloat</a> value to full precision, using standard
°5udecimal notation for arguments whose absolute value lies between
°5u<tt>0.1</tt> and <tt>9,999,999</tt>, and scientific notation
°5uotherwise.
realFloat :: (RealFloat a) => a -> Builder
formatRealFloat :: (RealFloat a) => FPFormat -> Maybe Int -> a -> Builder
instance GHC.Show.Show Data.Text.Lazy.Builder.RealFloat.FPFormat
instance GHC.Read.Read Data.Text.Lazy.Builder.RealFloat.FPFormat
instance GHC.Enum.Enum Data.Text.Lazy.Builder.RealFloat.FPFormat


-- | Efficient locale-sensitive support for text I/O.
°5u
°5uSkip past the synopsis for some important notes on performance and
°5uportability across different versions of GHC.
module Data.Text.IO

-- | The <a>readFile</a> function reads a file and returns the contents of
°5uthe file as a string. The entire file is read strictly, as with
°5u<a>getContents</a>.
readFile :: FilePath -> IO Text

-- | Write a string to a file. The file is truncated to zero length before
°5uwriting begins.
writeFile :: FilePath -> Text -> IO ()

-- | Write a string the end of a file.
appendFile :: FilePath -> Text -> IO ()

-- | Read the remaining contents of a <a>Handle</a> as a string. The
°5u<a>Handle</a> is closed once the contents have been read, or if an
°5uexception is thrown.
°5u
°5uInternally, this function reads a chunk at a time from the lower-level
°5ubuffering abstraction, and concatenates the chunks into a single
°5ustring once the entire file has been read.
°5u
°5uAs a result, it requires approximately twice as much memory as its
°5uresult to construct its result. For files more than a half of
°5uavailable RAM in size, this may result in memory exhaustion.
hGetContents :: Handle -> IO Text

-- | <i>Experimental.</i> Read a single chunk of strict text from a
°5u<a>Handle</a>. The size of the chunk depends on the amount of input
°5ucurrently buffered.
°5u
°5uThis function blocks only if there is no data available, and EOF has
°5unot yet been reached. Once EOF is reached, this function returns an
°5uempty string instead of throwing an exception.
hGetChunk :: Handle -> IO Text

-- | Read a single line from a handle.
hGetLine :: Handle -> IO Text

-- | Write a string to a handle.
hPutStr :: Handle -> Text -> IO ()

-- | Write a string to a handle, followed by a newline.
hPutStrLn :: Handle -> Text -> IO ()

-- | The <a>interact</a> function takes a function of type <tt>Text -&gt;
°5uText</tt> as its argument. The entire input from the standard input
°5udevice is passed to this function as its argument, and the resulting
°5ustring is output on the standard output device.
interact :: (Text -> Text) -> IO ()

-- | Read all user input on <a>stdin</a> as a single string.
getContents :: IO Text

-- | Read a single line of user input from <a>stdin</a>.
getLine :: IO Text

-- | Write a string to <a>stdout</a>.
putStr :: Text -> IO ()

-- | Write a string to <a>stdout</a>, followed by a newline.
putStrLn :: Text -> IO ()


-- | Efficient locale-sensitive support for lazy text I/O.
°5u
°5uSkip past the synopsis for some important notes on performance and
°5uportability across different versions of GHC.
module Data.Text.Lazy.IO

-- | Read a file and return its contents as a string. The file is read
°5ulazily, as with <a>getContents</a>.
readFile :: FilePath -> IO Text

-- | Write a string to a file. The file is truncated to zero length before
°5uwriting begins.
writeFile :: FilePath -> Text -> IO ()

-- | Write a string the end of a file.
appendFile :: FilePath -> Text -> IO ()

-- | Lazily read the remaining contents of a <a>Handle</a>. The
°5u<a>Handle</a> will be closed after the read completes, or on error.
hGetContents :: Handle -> IO Text

-- | Read a single line from a handle.
hGetLine :: Handle -> IO Text

-- | Write a string to a handle.
hPutStr :: Handle -> Text -> IO ()

-- | Write a string to a handle, followed by a newline.
hPutStrLn :: Handle -> Text -> IO ()

-- | The <a>interact</a> function takes a function of type <tt>Text -&gt;
°5uText</tt> as its argument. The entire input from the standard input
°5udevice is passed (lazily) to this function as its argument, and the
°5uresulting string is output on the standard output device.
interact :: (Text -> Text) -> IO ()

-- | Lazily read all user input on <a>stdin</a> as a single string.
getContents :: IO Text

-- | Read a single line of user input from <a>stdin</a>.
getLine :: IO Text

-- | Write a string to <a>stdout</a>.
putStr :: Text -> IO ()

-- | Write a string to <a>stdout</a>, followed by a newline.
putStrLn :: Text -> IO ()
