bricks-internal-0.0.0.4: ...

Safe HaskellSafe
LanguageHaskell2010

Bricks.Internal.Text

Synopsis

Documentation

data Text :: * #

A space efficient, packed, unboxed Unicode text type.

Instances

type Item Text 
type Item Text = Char

all :: (Char -> Bool) -> Text -> Bool #

O(n) all p t determines whether all characters in the Text t satisfy the predicate p. Subject to fusion.

append :: Text -> Text -> Text #

O(n) Appends one Text to the other by copying both of them into a new Text. Subject to fusion.

concatMap :: Foldable f => (a -> Text) -> f a -> Text Source #

intercalateMap :: (Foldable f, Functor f) => Text -> (a -> Text) -> f a -> Text Source #

isPrefixOf :: Text -> Text -> Bool #

O(n) The isPrefixOf function takes two Texts 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 Texts and returns True iff the first is a suffix of the second.

null :: Text -> Bool #

O(1) Tests whether a Text is empty or not. Subject to fusion.

pack :: String -> Text #

O(n) Convert a String into a Text. Subject to fusion. Performs replacement on invalid scalar values.

replace #

Arguments

:: Text

needle to search for. If this string is empty, an error will occur.

-> Text

replacement to replace needle with.

-> Text

haystack in which to search.

-> 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).

replicate :: Int -> Text -> Text #

O(n*m) replicate n t is a Text consisting of the input t repeated n times.

show :: Show a => a -> Text Source #

singleton :: Char -> Text #

O(1) Convert a character into a Text. Subject to fusion. Performs replacement on invalid scalar values.

unpack :: Text -> String #

O(n) Convert a Text into a String. Subject to fusion.

unwords :: [Text] -> Text #

O(n) Joins words using single space characters.