HORIZON HASKELLDocslts/ghc-10.0.x77a86622026-10-31Search packagesCtrl K
Theme: |

GHC 10.0.0.20260917 · lts/ghc-10.0.x · 77a8662 · 2026-10-31

Moduleutf8-string-1.0.2Haskell2010

Data.String.UTF8

Contents
  1. Representation
  2. Character based operations
  3. Representation based operations
Synopsis

Representation

newtypenewtype UTF8 string

The type of strings that are represented using the UTF8 encoding. The parameter is the type of the container for the representation.

Instances4Eq, Ord, Show, IsString
  • Eq string => Eq (UTF8 string)Defined in utf8-string-1.0.2 · Data.String.UTF8
  • Ord string => Ord (UTF8 string)Defined in utf8-string-1.0.2 · Data.String.UTF8
  • UTF8Bytes string index => Show (UTF8 string)Defined in utf8-string-1.0.2 · Data.String.UTF8
  • UTF8Bytes string index => IsString (UTF8 string)Defined in utf8-string-1.0.2 · Data.String.UTF8

Character based operations

valuesplitAt
  1. :: UTF8Bytes string index
  2. => index
  3. -> UTF8 string
  4. -> (UTF8 string, UTF8 string)

Split after a given number of characters. Negative values are treated as if they are 0.

valuetake :: UTF8Bytes string index => index -> UTF8 string -> UTF8 string

take n s returns the first n characters of s. If s has less than n characters, then we return the whole of s.

valuedrop :: UTF8Bytes string index => index -> UTF8 string -> UTF8 string

drop n s returns the s without its first n characters. If s has less than n characters, then we return an empty string.

valuespan
  1. :: UTF8Bytes string index
  2. => Char -> Bool
  3. -> UTF8 string
  4. -> (UTF8 string, UTF8 string)

Split a string into two parts: the first is the longest prefix that contains only characters that satisfy the predicate; the second part is the rest of the string. Invalid characters are passed as '\0xFFFD' to the predicate.

valuebreak
  1. :: UTF8Bytes string index
  2. => Char -> Bool
  3. -> UTF8 string
  4. -> (UTF8 string, UTF8 string)

Split a string into two parts: the first is the longest prefix that contains only characters that do not satisfy the predicate; the second part is the rest of the string. Invalid characters are passed as replacement_char to the predicate.

valuefoldl :: UTF8Bytes string index => (a -> Char -> a) -> a -> UTF8 string -> a

Traverse a bytestring (left biased). This function is strict in the accumulator.

valuelength :: UTF8Bytes string index => UTF8 string -> index

Counts the number of characters encoded in the bytestring. Note that this includes replacement characters. The function is linear in the number of bytes in the representation.

valuelines :: UTF8Bytes string index => UTF8 string -> [UTF8 string]

Split a string into a list of lines. Lines are terminated by '\n' or the end of the string. Empty lines may not be terminated by the end of the string. See also lines'.

valuelines' :: UTF8Bytes string index => UTF8 string -> [UTF8 string]

Split a string into a list of lines. Lines are terminated by '\n' or the end of the string. Empty lines may not be terminated by the end of the string. This function preserves the terminators. See also lines.

Representation based operations

valuedecode :: UTF8Bytes string index => UTF8 string -> Maybe (Char, index)

Extract the first character for the underlying representation, if one is available. It also returns the number of bytes used in the representation of the character. See also uncons.