HORIZON HASKELLDocslts/ghc-9.10.xc74966e2026-09-27Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27

Moduleutf8-string-1.0.2Haskell2010

Data.String.UTF8

  • 1 type
  • 1 class
  • 21 values

Representation

7 declarations
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

11 declarations
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.

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

Traverse a bytestring (right biased).

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

5 declarations
valuenull :: UTF8Bytes string index => UTF8 string -> Bool
#

Checks if there are no more bytes in the underlying representation.

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.

valuebyteTake :: UTF8Bytes string index => index -> UTF8 string -> UTF8 string
#

Take only the given number of bytes from the underlying representation. See also take.

valuebyteDrop :: UTF8Bytes string index => index -> UTF8 string -> UTF8 string
#

Drop the given number of bytes from the underlying representation. See also drop.