p package:text
O(n) Convert a
String into a
Text. Performs
replacement on invalid scalar values, so
unpack .
pack is not
id:
>>> Data.Text.unpack (pack "\55555")
"\65533"
O(n) The
partition function takes a predicate and a
Text, and returns the pair of
Texts with elements which
do and do not satisfy the predicate, respectively; i.e.
partition p t == (filter p t, filter (not . p) t)
O(n) Decode a null-terminated C string, which is assumed to
have been encoded as UTF-8. If decoding fails, a
UnicodeException is thrown.
O(n) Decode a C string with explicit length, which is assumed
to have been encoded as UTF-8. If decoding fails, a
UnicodeException is thrown.
Write a string to
stdout, followed by a newline.
Write a string to stdout.
Write a string to stdout, followed by a newline.
O(n) Convert a
String into a
Text.
Performs replacement on invalid scalar values, so
unpack .
pack is not
id:
>>> Data.Text.Lazy.unpack (Data.Text.Lazy.pack "\55555")
"\65533"
Bidirectional pattern synonym for
empty and
null (both
O(1)), to be used together with
(:<) or
(:>).
O(n) Appends one
Text to the other by copying both of
them into a new
Text.
O(n) Find the longest non-empty common prefix of two strings
and return it, along with the suffixes of each string at which they no
longer match.
If the strings do not have a common prefix or either one is empty,
this function returns
Nothing.
Examples:
>>> commonPrefixes "foobar" "fooquux"
Just ("foo","bar","quux")
>>> commonPrefixes "veeble" "fetzer"
Nothing
>>> commonPrefixes "" "baz"
Nothing
O(min(n,c)) Compare the count of characters in a
Text to
a number.
compareLength t c = compare (length t) c
This function gives the same answer as comparing against the result of
length, but can short circuit if the count of characters is
greater than the number, and hence be more efficient.
O(n) Map a function over a
Text that results in a
Text, and concatenate the results.
O(n) Make a distinct copy of the given string, sharing no
storage with the original string.
As an example, suppose you read a large string, of which you need only
a small portion. If you do not use
copy, the entire original
array will be kept alive in memory by the smaller string. Making a
copy "breaks the link" to the original array, allowing it to be
garbage collected if there are no other live references to it.
O(n) drop n, applied to a
Text, returns
the suffix of the
Text after the first
n characters,
or the empty
Text if
n is greater than the length of
the
Text.
O(n) dropAround p t returns the
substring remaining after dropping characters that satisfy the
predicate
p from both the beginning and end of
t.
O(n) dropEnd n t returns the prefix
remaining after dropping
n characters from the end of
t.
Examples:
>>> dropEnd 3 "foobar"
"foo"
O(n) dropWhileEnd p t returns the
prefix remaining after dropping characters that satisfy the predicate
p from the end of
t.
Examples:
>>> dropWhileEnd (=='.') "foo..."
"foo"