rio-0.1.18.0: A standard library for Haskell

Safe Haskell | Safe
Language | Haskell2010

RIO.Text

Contents

- Types
- Creation and elimination
- Basic interface
- Transformations
  - Case conversion
  - Justification
- Folds
  - Special folds
- Construction
  - Scans
  - Accumulating maps
  - Generation and unfolding
- Substrings
  - Breaking strings
  - Breaking into many substrings
  - Breaking into lines and words
- Predicates
  - View patterns
- Searching
- Indexing
- Zipping
- Low level operations
- Encoding

Description

Strict `Text`. Import as:

    import qualified RIO.Text as T

This module does not export any partial functions. For those, see RIO.Text.Partial

Synopsis

- data Text
- pack :: String -> Text
- unpack :: Text -> String
- singleton :: Char -> Text
- empty :: Text
- cons :: Char -> Text -> Text
- snoc :: Text -> Char -> Text
- append :: Text -> Text -> Text
- uncons :: Text -> Maybe (Char, Text)
- null :: Text -> Bool
- length :: Text -> Int
- compareLength :: Text -> Int -> Ordering
- map :: (Char -> Char) -> Text -> Text
- intercalate :: Text -> [Text] -> Text
- intersperse :: Char -> Text -> Text
- transpose :: [Text] -> [Text]
- reverse :: Text -> Text
- toCaseFold :: Text -> Text
- toLower :: Text -> Text
- toUpper :: Text -> Text
- toTitle :: Text -> Text
- justifyLeft :: Int -> Char -> Text -> Text
- justifyRight :: Int -> Char -> Text -> Text
- center :: Int -> Char -> Text -> Text
- foldl :: (a -> Char -> a) -> a -> Text -> a
- foldl' :: (a -> Char -> a) -> a -> Text -> a
- foldr :: (Char -> a -> a) -> a -> Text -> a
- concat :: [Text] -> Text
- concatMap :: (Char -> Text) -> Text -> Text
- any :: (Char -> Bool) -> Text -> Bool
- all :: (Char -> Bool) -> Text -> Bool
- scanl :: (Char -> Char -> Char) -> Char -> Text -> Text
- scanl1 :: (Char -> Char -> Char) -> Text -> Text
- scanr :: (Char -> Char -> Char) -> Char -> Text -> Text
- scanr1 :: (Char -> Char -> Char) -> Text -> Text
- mapAccumL :: (a -> Char -> (a, Char)) -> a -> Text -> (a, Text)
- mapAccumR :: (a -> Char -> (a, Char)) -> a -> Text -> (a, Text)
- replicate :: Int -> Text -> Text
- unfoldr :: (a -> Maybe (Char, a)) -> a -> Text
- unfoldrN :: Int -> (a -> Maybe (Char, a)) -> a -> Text
- take :: Int -> Text -> Text
- takeEnd :: Int -> Text -> Text
- drop :: Int -> Text -> Text
- dropEnd :: Int -> Text -> Text
- takeWhile :: (Char -> Bool) -> Text -> Text
- takeWhileEnd :: (Char -> Bool) -> Text -> Text
- dropWhile :: (Char -> Bool) -> Text -> Text
- dropWhileEnd :: (Char -> Bool) -> Text -> Text
- dropAround :: (Char -> Bool) -> Text -> Text
- strip :: Text -> Text
- stripStart :: Text -> Text
- stripEnd :: Text -> Text
- splitAt :: Int -> Text -> (Text, Text)
- break :: (Char -> Bool) -> Text -> (Text, Text)
- span :: (Char -> Bool) -> Text -> (Text, Text)
- group :: Text -> [Text]
- groupBy :: (Char -> Char -> Bool) -> Text -> [Text]
- inits :: Text -> [Text]
- tails :: Text -> [Text]
- split :: (Char -> Bool) -> Text -> [Text]
- chunksOf :: Int -> Text -> [Text]
- lines :: Text -> [Text]
- linesCR :: Text -> [Text]
- words :: Text -> [Text]
- unlines :: [Text] -> Text
- unwords :: [Text] -> Text
- isPrefixOf :: Text -> Text -> Bool
- isSuffixOf :: Text -> Text -> Bool
- isInfixOf :: Text -> Text -> Bool
- stripPrefix :: Text -> Text -> Maybe Text
- stripSuffix :: Text -> Text -> Maybe Text
- dropPrefix :: Text -> Text -> Text
- dropSuffix :: Text -> Text -> Text
- commonPrefixes :: Text -> Text -> Maybe (Text, Text, Text)
- filter :: (Char -> Bool) -> Text -> Text
- find :: (Char -> Bool) -> Text -> Maybe Char
- partition :: (Char -> Bool) -> Text -> (Text, Text)
- index :: Text -> Int -> Char
- findIndex :: (Char -> Bool) -> Text -> Maybe Int
- zip :: Text -> Text -> [(Char, Char)]
- zipWith :: (Char -> Char -> Char) -> Text -> Text -> Text
- copy :: Text -> Text
- unpackCString# :: Addr# -> Text
- encodeUtf8 :: Text -> ByteString
- decodeUtf8With :: OnDecodeError -> ByteString -> Text
- decodeUtf8' :: ByteString -> Either UnicodeException Text
- lenientDecode :: OnDecodeError

# Types

data Text #

#### Instances

Instances details

Hashable Text |
Instance details Defined in Data.Hashable.Class Methods hashWithSalt :: Int -> Text -> Int Source # hash :: Text -> Int Source #
Display Text Source # | Since: 0.1.0.0
Instance details Defined in RIO.Prelude.Display Methods display :: Text -> Utf8Builder Source # textDisplay :: Text -> Text Source #
type Item Text |
Instance details Defined in Data.Text type Item Text = Char

# Creation and elimination

pack :: String -> Text #

unpack :: Text -> String #

singleton :: Char -> Text #

empty :: Text #

# Basic interface

cons :: Char -> Text -> Text #

snoc :: Text -> Char -> Text #

append :: Text -> Text -> Text #

uncons :: Text -> Maybe (Char, Text) #

null :: Text -> Bool #

length :: Text -> Int #

compareLength :: Text -> Int -> Ordering #

# Transformations

map :: (Char -> Char) -> Text -> Text #

intercalate :: Text -> [Text] -> Text #

intersperse :: Char -> Text -> Text #

transpose :: [Text] -> [Text] #

reverse :: Text -> Text #

## Case conversion

toCaseFold :: Text -> Text #

toLower :: Text -> Text #

toUpper :: Text -> Text #

toTitle :: Text -> Text #

## Justification

justifyLeft :: Int -> Char -> Text -> Text #

justifyRight :: Int -> Char -> Text -> Text #

center :: Int -> Char -> Text -> Text #

# Folds

foldl :: (a -> Char -> a) -> a -> Text -> a #

foldl' :: (a -> Char -> a) -> a -> Text -> a #

foldr :: (Char -> a -> a) -> a -> Text -> a #

## Special folds

concat :: [Text] -> Text #

concatMap :: (Char -> Text) -> Text -> Text #

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

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

# Construction

## Scans

scanl :: (Char -> Char -> Char) -> Char -> Text -> Text #

scanl1 :: (Char -> Char -> Char) -> Text -> Text #

scanr :: (Char -> Char -> Char) -> Char -> Text -> Text #

scanr1 :: (Char -> Char -> Char) -> Text -> Text #

## Accumulating maps

mapAccumL :: (a -> Char -> (a, Char)) -> a -> Text -> (a, Text) #

mapAccumR :: (a -> Char -> (a, Char)) -> a -> Text -> (a, Text) #

## Generation and unfolding

replicate :: Int -> Text -> Text #

unfoldr :: (a -> Maybe (Char, a)) -> a -> Text #

unfoldrN :: Int -> (a -> Maybe (Char, a)) -> a -> Text #

# Substrings

## Breaking strings

take :: Int -> Text -> Text #

takeEnd :: Int -> Text -> Text #

drop :: Int -> Text -> Text #

dropEnd :: Int -> Text -> Text #

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

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

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

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

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

strip :: Text -> Text #

stripStart :: Text -> Text #

stripEnd :: Text -> Text #

splitAt :: Int -> Text -> (Text, Text) #

break :: (Char -> Bool) -> Text -> (Text, Text) #

span :: (Char -> Bool) -> Text -> (Text, Text) #

group :: Text -> [Text] #

groupBy :: (Char -> Char -> Bool) -> Text -> [Text] #

inits :: Text -> [Text] #

tails :: Text -> [Text] #

## Breaking into many substrings

split :: (Char -> Bool) -> Text -> [Text] #

chunksOf :: Int -> Text -> [Text] #

## Breaking into lines and words

lines :: Text -> [Text] #

linesCR :: Text -> [Text] Source #

`linesCR` breaks a `Text` up into a list of `Text`s at newline `Char`s. It is very similar to `lines`, but it also removes any trailing `'r'` characters. The resulting `Text` values do not contain newlines or trailing `'r'` characters.

Since: 0.1.0.0

words :: Text -> [Text] #

unlines :: [Text] -> Text #

unwords :: [Text] -> Text #

# Predicates

isPrefixOf :: Text -> Text -> Bool #

isSuffixOf :: Text -> Text -> Bool #

isInfixOf :: Text -> Text -> Bool #

## View patterns

stripPrefix :: Text -> Text -> Maybe Text #

stripSuffix :: Text -> Text -> Maybe Text #

dropPrefix Source #

Arguments

:: Text | prefix
-> Text |
-> Text |

Drop prefix if present, otherwise return original `Text`.

Since: 0.0.0.0

dropSuffix Source #

Arguments

:: Text | suffix
-> Text |
-> Text |

Drop prefix if present, otherwise return original `Text`.

Since: 0.0.0.0

commonPrefixes :: Text -> Text -> Maybe (Text, Text, Text) #

# Searching

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

find :: (Char -> Bool) -> Text -> Maybe Char #

partition :: (Char -> Bool) -> Text -> (Text, Text) #

# Indexing

index :: Text -> Int -> Char #

findIndex :: (Char -> Bool) -> Text -> Maybe Int #

# Zipping

zip :: Text -> Text -> [(Char, Char)] #

zipWith :: (Char -> Char -> Char) -> Text -> Text -> Text #

# Low level operations

copy :: Text -> Text #

unpackCString# :: Addr# -> Text #

# Encoding

encodeUtf8 :: Text -> ByteString #

decodeUtf8With :: OnDecodeError -> ByteString -> Text #

decodeUtf8' :: ByteString -> Either UnicodeException Text #

lenientDecode :: OnDecodeError #