Safe Haskell | None |
---|
Compatible API with the text
package.
- data Text
- pack :: String -> Text
- unpack :: Text -> String
- fromString :: String -> Text
- empty :: Text
- showInt :: Int -> Text
- toShortest :: Double -> Text
- putStrLn :: Text -> Fay ()
- splitOn :: Char -> Text -> [Text]
- stripSuffix :: Text -> Text -> Maybe Text
- cons :: Char -> Text -> Text
- snoc :: Text -> Char -> Text
- append :: Text -> Text -> Text
- (<>) :: Text -> Text -> Text
- uncons :: Text -> Maybe (Char, Text)
- head :: Text -> Char
- init :: Text -> Text
- last :: Text -> Char
- tail :: Text -> Text
- null :: Text -> Bool
- length :: Text -> Int
- maximum :: Text -> Char
- all :: (Char -> Bool) -> Text -> Bool
- any :: (Char -> Bool) -> Text -> Bool
- concatMap :: (Char -> Text) -> Text -> Text
- concat :: [Text] -> Text
- minimum :: Text -> Char
- toLower :: Text -> Text
- toUpper :: Text -> Text
- map :: (Char -> Char) -> Text -> Text
- intercalate :: Text -> [Text] -> Text
- intersperse :: Char -> Text -> Text
- reverse :: Text -> Text
- isPrefixOf :: Text -> Text -> Bool
- drop :: Int -> Text -> Text
- take :: Int -> Text -> Text
- unlines :: [Text] -> Text
- lines :: Text -> [Text]
Documentation
A space efficient, packed, unboxed Unicode text type.
Creation and elimination
O(n) Convert a String into a Text. Subject to fusion. Performs replacement on invalid scalar values.
fromString :: String -> TextSource
Convert from a string to text.
Conversions
toShortest :: Double -> TextSource
I/O
Breaking into many substrings
splitOn :: Char -> Text -> [Text]Source
O(m+n) Break a Text into pieces separated by the first Text argument, consuming the delimiter. An empty delimiter is invalid, and will cause an error to be raised.
O(n) Return the prefix of the second string if its suffix matches the entire first string.
Basic interface
cons :: Char -> Text -> TextSource
O(n) Adds a character to the front of a Text. This function is more costly than its List counterpart because it requires copying a new array. Subject to fusion. Performs replacement on invalid scalar values.
snoc :: Text -> Char -> TextSource
O(n) Adds a character to the end of a Text. This copies the entire array in the process, unless fused. Subject to fusion. Performs replacement on invalid scalar values.
append :: Text -> Text -> TextSource
O(n) Appends one Text to the other by copying both of them into a new Text. Subject to fusion.
uncons :: Text -> Maybe (Char, Text)Source
O(1) Returns the first character and rest of a Text, or Nothing if empty. Subject to fusion.
O(1) Returns the first character of a Text, which must be non-empty. Subject to fusion.
O(1) Returns all but the last character of a Text, which must be non-empty. Subject to fusion.
O(1) Returns the last character of a Text, which must be non-empty. Subject to fusion.
O(1) Returns all characters after the head of a Text, which must be non-empty. Subject to fusion.
Special folds
O(n) maximum returns the maximum value from a Text, which must be non-empty. Subject to fusion.
all :: (Char -> Bool) -> Text -> BoolSource
O(n) all p t determines whether all characters in the Text t satisify the predicate p. Subject to fusion.
any :: (Char -> Bool) -> Text -> BoolSource
O(n) any p t determines whether any character in the Text t satisifes the predicate p. Subject to fusion.
concatMap :: (Char -> Text) -> Text -> TextSource
O(n) Map a function over a Text that results in a Text, and concatenate the results.
O(n) minimum returns the minimum value from a Text, which must be non-empty. Subject to fusion.
Case conversion
Transformations
map :: (Char -> Char) -> Text -> TextSource
O(n) map f t is the Text obtained by applying f to each element of t. Subject to fusion. Performs replacement on invalid scalar values.
intercalate :: Text -> [Text] -> TextSource
O(n) The intercalate function takes a Text and a list of Texts and concatenates the list after interspersing the first argument between each element of the list.
intersperse :: Char -> Text -> TextSource
O(n) The intersperse function takes a character and places it between the characters of a Text. Subject to fusion. Performs replacement on invalid scalar values.
Predicates
isPrefixOf :: Text -> Text -> BoolSource
O(n) The isPrefixOf function takes two Texts and returns True iff the first is a prefix of the second. Subject to fusion. http:docs.closure-library.googlecode.comgitclosure_goog_string_string.js.source.html
Substrings
drop :: Int -> Text -> TextSource
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. Subject to fusion.
take :: Int -> Text -> TextSource
O(n) take n, applied to a Text, returns the prefix of the Text of length n, or the Text itself if n is greater than the length of the Text. Subject to fusion.