Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
- data Text :: *
- all :: (Char -> Bool) -> Text -> Bool
- append :: Text -> Text -> Text
- concat :: Foldable f => f Text -> Text
- concatMap :: Foldable f => (a -> Text) -> f a -> Text
- intercalate :: Foldable f => Text -> f Text -> Text
- intercalateMap :: (Foldable f, Functor f) => Text -> (a -> Text) -> f a -> Text
- isPrefixOf :: Text -> Text -> Bool
- isSuffixOf :: Text -> Text -> Bool
- null :: Text -> Bool
- pack :: String -> Text
- replace :: Text -> Text -> Text -> Text
- replicate :: Int -> Text -> Text
- show :: Show a => a -> Text
- singleton :: Char -> Text
- unpack :: Text -> String
- unwords :: [Text] -> Text
Documentation
isPrefixOf :: Text -> Text -> Bool #
O(n) The isPrefixOf
function takes two Text
s and returns
True
iff the first is a prefix of the second. Subject to fusion.
isSuffixOf :: Text -> Text -> Bool #
O(n) The isSuffixOf
function takes two Text
s and returns
True
iff the first is a suffix of the second.
:: Text |
|
-> Text |
|
-> Text |
|
-> Text |
O(m+n) Replace every non-overlapping occurrence of needle
in
haystack
with replacement
.
This function behaves as though it was defined as follows:
replace needle replacement haystack =intercalate
replacement (splitOn
needle haystack)
As this suggests, each occurrence is replaced exactly once. So if
needle
occurs in replacement
, that occurrence will not itself
be replaced recursively:
replace "oo" "foo" "oo" == "foo"
In cases where several instances of needle
overlap, only the
first one will be replaced:
replace "ofo" "bar" "ofofo" == "barfo"
In (unlikely) bad cases, this function's time complexity degrades towards O(n*m).
O(1) Convert a character into a Text. Subject to fusion. Performs replacement on invalid scalar values.