A type and functions for single characters.
newtype CharA unicode character.
charString :: Char -> StringReturns the string of length 1 containing only the given character.
toCharCode :: Char -> NumberReturns the numeric Unicode value of the character.
fromCharCode :: Number -> CharConstructs a character from the given Unicode numeric value.
instance eqChar :: Eq CharCharacters can be compared for equality with == and /=.
instance ordChar :: Ord CharCharacters can be compared with compare, >, >=, < and <=.
instance showChar :: Show CharCharacters can be rendered as a string with show.
Wraps the functions of Javascript's String object.
A String represents a sequence of characters.
For details of the underlying implementation, see String Reference at MDN.
charAt :: Number -> String -> Maybe CharReturns the character at the given index, if the index is within bounds.
fromChar :: Char -> StringReturns a string of length 1 containing the given character.
singleton :: Char -> StringReturns a string of length 1 containing the given character.
Same as fromChar.
charCodeAt :: Number -> String -> Maybe NumberReturns the numeric Unicode value of the character at the given index, if the index is within bounds.
null :: String -> BooleanReturns true if the given string is empty.
uncons :: String -> Maybe { tail :: String, head :: Char }Returns the first character and the rest of the string, if the string is not empty.
takeWhile :: (Char -> Boolean) -> String -> StringReturns the longest prefix (possibly empty) of characters that satisfy the predicate:
dropWhile :: (Char -> Boolean) -> String -> StringReturns the suffix remaining after takeWhile.
fromCharArray :: [Char] -> StringConverts an array of characters into a string.
indexOf :: String -> String -> NumberReturns the index of the first occurrence of the first string in the
second string. Returns -1 if there is no match.
indexOf' :: String -> Number -> String -> NumberReturns the index of the first occurrence of the first string in the
second string, starting at the given index. Returns -1 if there is
no match.
lastIndexOf :: String -> String -> NumberReturns the index of the last occurrence of the first string in the
second string. Returns -1 if there is no match.
lastIndexOf' :: String -> Number -> String -> NumberReturns the index of the first occurrence of the last string in the
second string, starting at the given index. Returns -1 if there is
no match.
length :: String -> NumberReturns the number of characters the string is composed of.
localeCompare :: String -> String -> NumberLocale-aware sort order comparison. Returns a negative number if the
first string occurs before the second in a sort, a positive number
if the first string occurs after the second, and 0 if their sort order
is equal.
replace :: String -> String -> String -> StringReplaces the first occurence of the first argument with the second argument.
take :: Number -> String -> StringReturns the first n characters of the string.
drop :: Number -> String -> StringReturns the string without the first n characters.
count :: (Char -> Boolean) -> String -> NumberReturns the number of characters in the string for which the predicate holds.
split :: String -> String -> [String]Returns the substrings of the first string separated along occurences of the second string.
toCharArray :: String -> [Char]Converts the string into an array of characters.
toLower :: String -> StringReturns the argument converted to lowercase.
toUpper :: String -> StringReturns the argument converted to uppercase.
trim :: String -> StringRemoves whitespace from the beginning and end of a string, including whitespace characters and line terminators.
joinWith :: String -> [String] -> StringJoins the strings in the array together, inserting the first argument as separator between them.
Wraps Javascript's RegExp object that enables matching strings with
patternes defined by regular expressions.
For details of the underlying implementation, see RegExp Reference at MDN.
data Regex :: *Wraps Javascript RegExp objects.
instance showRegex :: Show Regextype RegexFlags = { unicode :: Boolean, sticky :: Boolean, multiline :: Boolean, ignoreCase :: Boolean, global :: Boolean }Flags that control matching.
noFlags :: RegexFlagsAll flags set to false.
regex :: String -> RegexFlags -> RegexConstructs a Regex from a pattern string and flags.
source :: Regex -> StringReturns the pattern string used to construct the given Regex.
flags :: Regex -> RegexFlagsReturns the RegexFlags used to construct the given Regex.
renderFlags :: RegexFlags -> StringReturns the string representation of the given RegexFlags.
parseFlags :: String -> RegexFlagsParses the string representation of RegexFlags.
test :: Regex -> String -> BooleanReturns true if the Regex matches the string.
match :: Regex -> String -> Maybe [String]Matches the string against the Regex and returns an array of matches
if there were any.
See reference.
replace :: Regex -> String -> String -> StringReplaces occurences of the Regex with the first string. The replacement
string can include special replacement patterns escaped with "$".
See reference.
replace' :: Regex -> (String -> [String] -> String) -> String -> StringTransforms occurences of the Regex using a function of the matched
substring and a list of submatch strings.
See the reference.
search :: Regex -> String -> NumberReturns the index of the first match of the Regex in the string, or
-1 if there is no match.
split :: Regex -> String -> [String]Split the string into an array of substrings along occurences of the Regex.
Unsafe string and character functions.
charCodeAt :: Number -> String -> NumberReturns the numeric Unicode value of the character at the given index.
Unsafe: returns NaN if the index is out of bounds.
charAt :: Number -> String -> CharReturns the character at the given index.
Unsafe: returns an illegal value if the index is out of bounds.