:: Text -> Text
O(1) Returns all characters after the head of a
Text,
which must be non-empty. This is a partial function, consider using
uncons instead.
O(1) Returns all but the last character of a
Text, which
must be non-empty. This is a partial function, consider using
unsnoc instead.
O(n) Convert a string to folded case.
This function is mainly useful for performing caseless (also known as
case insensitive) string comparisons.
A string
x is a caseless match for a string
y if and
only if:
toCaseFold x == toCaseFold y
The result string may be longer than the input string, and may differ
from applying
toLower to the input string. For instance, the
Armenian small ligature "ﬓ" (men now, U+FB13) is case folded to the
sequence "մ" (men, U+0574) followed by "ն" (now, U+0576), while the
Greek "µ" (micro sign, U+00B5) is case folded to "μ" (small letter mu,
U+03BC) instead of itself.
O(n) Convert a string to lower case, using simple case
conversion.
The result string may be longer than the input string. For instance,
"İ" (Latin capital letter I with dot above, U+0130) maps to the
sequence "i" (Latin small letter i, U+0069) followed by " ̇"
(combining dot above, U+0307).
O(n) Convert a string to upper case, using simple case
conversion.
The result string may be longer than the input string. For instance,
the German "ß" (eszett, U+00DF) maps to the two-letter sequence "SS".
O(n) Convert a string to title case, using simple case
conversion.
The first letter (as determined by
isLetter) of the input is
converted to title case, as is every subsequent letter that
immediately follows a non-letter. Every letter that immediately
follows another letter is converted to lower case.
This function is not idempotent. Consider lower-case letter
ʼn
(U+0149 LATIN SMALL LETTER N PRECEDED BY APOSTROPHE). Then
toTitle "ʼn" =
"ʼN": the first (and the only)
letter of the input is converted to title case, becoming two letters.
Now
ʼ (U+02BC MODIFIER LETTER APOSTROPHE) is a modifier
letter and as such is recognised as a letter by
isLetter, so
toTitle "ʼN" =
"'n".
The result string may be longer than the input string. For example,
the Latin small ligature fl (U+FB02) is converted to the sequence Latin
capital letter F (U+0046) followed by Latin small letter l (U+006C).
Note: this function does not take language or culture specific
rules into account. For instance, in English, different style guides
disagree on whether the book name "The Hill of the Red Fox" is
correctly title cased—but this function will capitalize
every
word.
O(n) Remove leading and trailing white space from a string.
Equivalent to:
dropAround isSpace
O(n) Remove leading white space from a string. Equivalent to:
dropWhile isSpace
O(n) Remove trailing white space from a string. Equivalent to:
dropWhileEnd isSpace
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.
Check the invariant lazily.
O(n/c) Returns all but the last character of a
Text,
which must be non-empty. This is a partial function, consider using
unsnoc instead.
O(n) reverse t returns the elements of
t in reverse order.
O(n) Convert a string to folded case.
This function is mainly useful for performing caseless (or case
insensitive) string comparisons.
A string
x is a caseless match for a string
y if and
only if:
toCaseFold x == toCaseFold y
The result string may be longer than the input string, and may differ
from applying
toLower to the input string. For instance, the
Armenian small ligature men now (U+FB13) is case folded to the bigram
men now (U+0574 U+0576), while the micro sign (U+00B5) is case folded
to the Greek small letter letter mu (U+03BC) instead of itself.
O(n) Convert a string to lower case, using simple case
conversion.
The result string may be longer than the input string. For instance,
the Latin capital letter I with dot above (U+0130) maps to the
sequence Latin small letter i (U+0069) followed by combining dot above
(U+0307).
O(n) Convert a string to upper case, using simple case
conversion.
The result string may be longer than the input string. For instance,
the German eszett (U+00DF) maps to the two-letter sequence SS.
O(n) Convert a string to title case, using simple case
conversion.
The first letter (as determined by
isLetter) of the input is
converted to title case, as is every subsequent letter that
immediately follows a non-letter. Every letter that immediately
follows another letter is converted to lower case.
The result string may be longer than the input string. For example,
the Latin small ligature fl (U+FB02) is converted to the sequence Latin
capital letter F (U+0046) followed by Latin small letter l (U+006C).
This function is not idempotent. Consider lower-case letter
ʼn
(U+0149 LATIN SMALL LETTER N PRECEDED BY APOSTROPHE). Then
toTitle "ʼn" =
"ʼN": the first (and the only)
letter of the input is converted to title case, becoming two letters.
Now
ʼ (U+02BC MODIFIER LETTER APOSTROPHE) is a modifier
letter and as such is recognised as a letter by
isLetter, so
toTitle "ʼN" =
"'n".
Note: this function does not take language or culture specific
rules into account. For instance, in English, different style guides
disagree on whether the book name "The Hill of the Red Fox" is
correctly title cased—but this function will capitalize
every
word.
cycle ties a finite, non-empty
Text into a circular one,
or equivalently, the infinite repetition of the original
Text.
O(1) A variant of
tail for non-empty
Text.
unsafeTail omits the check for the empty case, so there is an
obligation on the programmer to provide a proof that the
Text
is non-empty.
Wrap double quotes around a Text
Strip trailing newlines from string.
Remove leading and trailing space (including newlines) from string.