Data.String
String operations, byte-oriented and ASCII-accurate.
Built over the primitive UTF-8 string operations. The prelude opens this module.
Functions and Values
str_join
str_join : (String, List(String)) -> String
Join a list of strings, placing sep between adjacent elements.
str_repeat
str_repeat : (String, Int) -> String
s repeated n times (the empty string when n <= 0).
pad_left
pad_left : (String, Int) -> String
Right-align s to width w by prepending spaces (unchanged if already wider).
pad_right
pad_right : (String, Int) -> String
Left-align s to width w by appending spaces (unchanged if already wider).
lines_of
lines_of : (List(String)) -> String
Join a list of strings with newlines between them.
occurs_at
occurs_at : (String, String, Int, Int) -> Bool
Helper for the substring queries: whether needle sits at byte offset j in s, comparing from position k.
starts_with
starts_with : (String, String) -> Bool
True when s begins with prefix.
ends_with
ends_with : (String, String) -> Bool
True when s ends with suffix.
index_of_go
index_of_go : (String, String, Int) -> Int
Helper for index_of: search for needle in s from byte offset j.
index_of
index_of : (String, String) -> Int
The byte offset of the first occurrence of needle in s, or -1 if absent.
contains
contains : (String, String) -> Bool
True when needle occurs anywhere in s.
map_case
map_case : (String, Int, Buf, Bool) -> Buf
Helper for to_upper/to_lower: fold ASCII case mapping over s into a byte buffer (up selects upper- vs lower-casing).
to_upper
to_upper : (String) -> String
ASCII upper-case of s (non-letters unchanged).
to_lower
to_lower : (String) -> String
ASCII lower-case of s (non-letters unchanged).
ltrim_idx
ltrim_idx : (String, Int) -> Int
Helper for trim: the first non-whitespace byte index at or after i.
rtrim_idx
rtrim_idx : (String, Int) -> Int
Helper for trim: the index just past the last non-whitespace byte before i.
slice_bytes
slice_bytes : (String, Int, Int, Buf) -> Buf
Helper for trim: collect the bytes of s in [lo, hi) into buf.
trim
trim : (String) -> String
Strip leading and trailing ASCII whitespace.
index_of_from
index_of_from : (Int, String, Int) -> Int
The index of character c in s at or after position i, or -1 if absent.
split_from
split_from : (Int, String, Int) -> List(String)
Helper for split: split s on c, starting from position i.
split
split : (Int, String) -> List(String)
Split s into the pieces between each occurrence of character c.
str_of_char
str_of_char : (Char) -> String
The single-character string containing c.
chars_from
chars_from : (String, Int) -> List(Char)
Helper for chars: the characters of s from position i onward.
chars
chars : (String) -> List(Char)
The list of characters in s.