hydra-kernel-0.18.1: hydra-kernel-json/hydra/core/lib/strings.json
{
"name": "hydra.core.lib.strings",
"metadata": {
"description": "Primitives in the hydra.core.lib.strings module.",
"comments": [
"Strings as sequences of Unicode code points: a Hydra string is a sequence of Unicode code points -- not UTF-16 code units and not grapheme clusters -- and length and index positions count code points.",
"The general split/join pair (splitOn and join) is the primary line-and-token machinery; the newline-specific lines and unlines were removed as primitives in its favor, their exact semantics preserved as the non-primitive term helpers hydra.formatting.lines and hydra.formatting.unlines."],
"seeAlso": [],
"provisions": []},
"dependencies": [{"module": "hydra.core.model"}, {"module": "hydra.core.packaging"}, {"module": "hydra.core.typing"}],
"definitions": [
{
"primitive": {
"name": "hydra.core.lib.strings.charAt",
"metadata": {
"description": "Get the Unicode code point of the character at a specific index, returning Nothing if out of bounds.",
"comments": [
"charAt(i, s) returns Just(c) where c is the Unicode code point at position i in s, or Nothing if i is negative or i >= length(s).",
"Total.",
"Renamed from hydra.lib.strings.maybeCharAt."],
"seeAlso": [],
"lifecycle": {"availableSince": "0.17.6"},
"provisions": [
{
"name": "hydra.core.lib.strings.charAt.returnsCodePointAtIndex",
"kind": "requirement",
"statement": "charAt returns the Unicode code point at the given zero-based index, wrapped, indexing by code point (not UTF-16 code unit), so an index after an astral (non-BMP) character is unaffected by that character's surrogate-pair width in UTF-16-based representations."},
{
"name": "hydra.core.lib.strings.charAt.noneWhenOutOfRange",
"kind": "requirement",
"statement": "charAt returns none when the index is negative, at or beyond the string's code-point length, or when the string is empty."}]},
"signature": {
"typeParameters": [],
"parameters": [
{
"name": "i",
"description": "the index of the character to retrieve",
"type": {"literal": {"integer": "int32"}},
"isLazy": false},
{"name": "s", "description": "the string to index into", "type": {"literal": "string"}, "isLazy": false}],
"result": {"type": {"optional": {"literal": {"integer": "int32"}}}}},
"isPure": true,
"isTotal": true}},
{
"primitive": {
"name": "hydra.core.lib.strings.concat",
"metadata": {
"description": "Concatenate a list of strings into a single string.",
"comments": [
"concat(xs) returns the string formed by concatenating every string in xs in order.",
"Total. Corresponds to Haskell's concat :: [String] -> String.",
"Renamed from hydra.lib.strings.cat."],
"seeAlso": [],
"lifecycle": {"availableSince": "0.17.6"},
"provisions": [
{
"name": "hydra.core.lib.strings.concat.flattensPreservingOrderAndContent",
"kind": "requirement",
"statement": "concat concatenates every string in the list in order, preserving all content exactly including control characters, null characters, and multi-code-point Unicode sequences (combining characters) without alteration."},
{
"name": "hydra.core.lib.strings.concat.emptyInputs",
"kind": "requirement",
"statement": "concat of a list containing only empty strings, or of an empty list of strings, is the empty string; empty strings elsewhere in the list contribute nothing to the result."}]},
"signature": {
"typeParameters": [],
"parameters": [
{
"name": "xs",
"description": "the list of strings to concatenate",
"type": {"list": {"literal": "string"}},
"isLazy": false}],
"result": {"type": {"literal": "string"}}},
"isPure": true,
"isTotal": true}},
{
"primitive": {
"name": "hydra.core.lib.strings.concat2",
"metadata": {
"description": "Concatenate two strings.",
"comments": [
"concat2(s, t) returns the concatenation of s and t.",
"Total. Corresponds to Haskell's (++) :: String -> String -> String.",
"Renamed from hydra.lib.strings.cat2."],
"seeAlso": [],
"lifecycle": {"availableSince": "0.17.6"},
"provisions": [
{
"name": "hydra.core.lib.strings.concat2.appendsPreservingContent",
"kind": "requirement",
"statement": "concat2 appends its second string argument to its first, preserving all content exactly including Unicode, control, and null characters."},
{
"name": "hydra.core.lib.strings.concat2.identityOnEmpty",
"kind": "requirement",
"statement": "concat2 with either or both arguments empty returns the other argument unchanged (the empty string is the identity element)."}]},
"signature": {
"typeParameters": [],
"parameters": [
{"name": "s", "description": "the first string", "type": {"literal": "string"}, "isLazy": false},
{"name": "t", "description": "the second string", "type": {"literal": "string"}, "isLazy": false}],
"result": {"type": {"literal": "string"}}},
"isPure": true,
"isTotal": true}},
{
"primitive": {
"name": "hydra.core.lib.strings.fromList",
"metadata": {
"description": "Convert a list of Unicode code points to a string.",
"comments": [
"fromList(cs) returns the string whose characters are the Unicode code points in cs, in order.",
"Code points outside the valid Unicode range [0, 0x10FFFF] yield a host-defined result (typically substitution with U+FFFD or truncation of the bits).",
"Total. The inverse of toList."],
"seeAlso": [],
"lifecycle": {"availableSince": "0.15"},
"provisions": [
{
"name": "hydra.core.lib.strings.fromList.buildsStringFromCodePoints",
"kind": "requirement",
"statement": "fromList constructs a string whose characters are exactly the given Unicode code points, in order, including multi-code-point sequences (combining characters), control characters, and null characters."},
{
"name": "hydra.core.lib.strings.fromList.emptyInput",
"kind": "requirement",
"statement": "fromList of an empty list of code points is the empty string."}]},
"signature": {
"typeParameters": [],
"parameters": [
{
"name": "cs",
"description": "the list of Unicode code points to convert",
"type": {"list": {"literal": {"integer": "int32"}}},
"isLazy": false}],
"result": {"type": {"literal": "string"}}},
"isPure": true,
"isTotal": true}},
{
"primitive": {
"name": "hydra.core.lib.strings.isEmpty",
"metadata": {
"description": "Check whether a string is empty.",
"comments": ["isEmpty(s) returns true iff s is the empty string.", "Total. Corresponds to Haskell's null :: String -> Bool."],
"seeAlso": [],
"lifecycle": {"availableSince": "0.15"},
"provisions": [
{
"name": "hydra.core.lib.strings.isEmpty.testsZeroLength",
"kind": "requirement",
"statement": "isEmpty returns true exactly when the string has no code points; any non-empty content — including whitespace, control characters, or a null character — makes it false."}]},
"signature": {
"typeParameters": [],
"parameters": [{"name": "s", "description": "the string to test for emptiness", "type": {"literal": "string"}, "isLazy": false}],
"result": {"type": {"literal": "boolean"}}},
"isPure": true,
"isTotal": true}},
{
"primitive": {
"name": "hydra.core.lib.strings.join",
"metadata": {
"description": "Join a list of strings with a separator between each element.",
"comments": [
"join(sep, xs) returns the strings in xs concatenated with sep inserted between each pair of adjacent strings; for the empty list the result is the empty string, and for a singleton list the result is the single string.",
"Total. Corresponds to Haskell's Data.List.intercalate :: String -> [String] -> String.",
"Renamed from hydra.lib.strings.intercalate."],
"seeAlso": [],
"lifecycle": {"availableSince": "0.17.6"},
"provisions": [
{
"name": "hydra.core.lib.strings.join.insertsSeparatorBetweenStrings",
"kind": "requirement",
"statement": "join concatenates a list of strings with a copy of the separator inserted between each pair of adjacent strings (not before the first or after the last), for separators of any content including empty, multi-character, and Unicode."},
{
"name": "hydra.core.lib.strings.join.boundaryInputs",
"kind": "requirement",
"statement": "join of an empty list of strings is the empty string, regardless of separator; join of a single-element list returns that element unchanged, regardless of separator."}]},
"signature": {
"typeParameters": [],
"parameters": [
{
"name": "sep",
"description": "the separator to insert between elements",
"type": {"literal": "string"},
"isLazy": false},
{"name": "xs", "description": "the list of strings to join", "type": {"list": {"literal": "string"}}, "isLazy": false}],
"result": {"type": {"literal": "string"}}},
"isPure": true,
"isTotal": true}},
{
"primitive": {
"name": "hydra.core.lib.strings.length",
"metadata": {
"description": "Return the length of a string.",
"comments": [
"length(s) returns the number of Unicode code points in s as an int32.",
"Note: this is the code-point count, not the byte count or the grapheme-cluster count, so a four-byte UTF-8 character counts as one and an emoji built from multiple code points counts as the number of code points it uses.",
"Total on strings shorter than 2^31-1 code points."],
"seeAlso": [],
"lifecycle": {"availableSince": "0.15"},
"provisions": [
{
"name": "hydra.core.lib.strings.length.countsCodePoints",
"kind": "requirement",
"statement": "length returns the number of Unicode code points in the string, not the byte count or grapheme-cluster count — so a multi-byte character counts as one code point and a combining-character sequence counts as multiple."}]},
"signature": {
"typeParameters": [],
"parameters": [{"name": "s", "description": "the string to measure", "type": {"literal": "string"}, "isLazy": false}],
"result": {"type": {"literal": {"integer": "int32"}}}},
"isPure": true,
"isTotal": true}},
{
"primitive": {
"name": "hydra.core.lib.strings.splitOn",
"metadata": {
"description": "Split a string on a delimiter string.",
"comments": [
"splitOn(sep, s) returns the list of substrings of s obtained by splitting on every occurrence of the non-empty delimiter sep. Adjacent or boundary delimiters produce empty-string elements in the result.",
"Behavior when sep is empty is host-defined and should not be relied upon.",
"Total. Corresponds to Haskell's Data.List.Split.splitOn :: String -> String -> [String]."],
"seeAlso": [],
"lifecycle": {"availableSince": "0.15"},
"provisions": [
{
"name": "hydra.core.lib.strings.splitOn.splitsOnEveryOccurrence",
"kind": "requirement",
"statement": "splitOn splits the string into the list of substrings between every occurrence of a non-empty delimiter, including when occurrences are consecutive, overlapping, at a boundary, or span the whole string — boundary and adjacent delimiters produce empty-string elements in the result."},
{
"name": "hydra.core.lib.strings.splitOn.noSplitWhenAbsent",
"kind": "requirement",
"statement": "splitOn returns the single-element list containing the original string when the delimiter does not occur in it."},
{
"name": "hydra.core.lib.strings.splitOn.emptyStringOperands",
"kind": "requirement",
"statement": "splitOn on an empty string (with a non-empty separator) returns the single-element list containing the empty string; splitOn with an empty separator splits between every code point, including around an astral (non-BMP) character without breaking its surrogate-pair encoding apart."}]},
"signature": {
"typeParameters": [],
"parameters": [
{"name": "sep", "description": "the delimiter to split on", "type": {"literal": "string"}, "isLazy": false},
{"name": "s", "description": "the string to split", "type": {"literal": "string"}, "isLazy": false}],
"result": {"type": {"list": {"literal": "string"}}}},
"isPure": true,
"isTotal": true}},
{
"primitive": {
"name": "hydra.core.lib.strings.toList",
"metadata": {
"description": "Convert a string to a list of Unicode code points.",
"comments": [
"toList(s) returns the list of Unicode code points making up s, in order. Each code point is represented as an int32.",
"Total. The inverse of fromList."],
"seeAlso": [],
"lifecycle": {"availableSince": "0.15"},
"provisions": [
{
"name": "hydra.core.lib.strings.toList.decomposesIntoCodePoints",
"kind": "requirement",
"statement": "toList returns the list of Unicode code points making up the string, in order, as the exact inverse of fromList, including for multi-code-point sequences and control/null characters."},
{
"name": "hydra.core.lib.strings.toList.emptyInput",
"kind": "requirement",
"statement": "toList of the empty string is the empty list."}]},
"signature": {
"typeParameters": [],
"parameters": [{"name": "s", "description": "the string to convert", "type": {"literal": "string"}, "isLazy": false}],
"result": {"type": {"list": {"literal": {"integer": "int32"}}}}},
"isPure": true,
"isTotal": true}},
{
"primitive": {
"name": "hydra.core.lib.strings.toLower",
"metadata": {
"description": "Convert a string to lowercase.",
"comments": [
"toLower(s) returns s with each character replaced by its Unicode simple (one-to-one) lowercase mapping, or itself if it has no lowercase mapping.",
"This is a code-point-by-code-point operation, so it does not handle the string-changing match of full Unicode case folding (e.g. U+00DF \"ß\" does not lowercase to \"ss\"; it returns itself).",
"For text intended for human-readable display in locales with non-trivial case mappings, prefer a host-specific full case-folding API.",
"Total."],
"seeAlso": [],
"lifecycle": {"availableSince": "0.15"},
"provisions": [
{
"name": "hydra.core.lib.strings.toLower.appliesSimpleLowercaseMapping",
"kind": "requirement",
"statement": "toLower replaces each character with its Unicode simple (one-to-one) lowercase mapping, leaving a character with no lowercase mapping unchanged — including letters, accented Unicode characters, non-letter characters (numbers, punctuation, control characters), and the empty string."},
{
"name": "hydra.core.lib.strings.toLower.noFullCaseFoldingExpansion",
"kind": "requirement",
"statement": "toLower does not perform full Unicode case folding: a character whose full lowercase mapping would expand to multiple code points (e.g. U+0130) is still mapped to its simple, single-code-point lowercase form, not the multi-code-point expansion."}]},
"signature": {
"typeParameters": [],
"parameters": [{"name": "s", "description": "the string to convert to lowercase", "type": {"literal": "string"}, "isLazy": false}],
"result": {"type": {"literal": "string"}}},
"isPure": true,
"isTotal": true}},
{
"primitive": {
"name": "hydra.core.lib.strings.toUpper",
"metadata": {
"description": "Convert a string to uppercase.",
"comments": [
"toUpper(s) returns s with each character replaced by its Unicode simple (one-to-one) uppercase mapping, or itself if it has no uppercase mapping.",
"This is a code-point-by-code-point operation, so it does not handle the string-changing match of full Unicode case folding (e.g. U+00DF \"ß\" does not uppercase to \"SS\"; it returns itself).",
"For text intended for human-readable display in locales with non-trivial case mappings, prefer a host-specific full case-folding API.",
"Total."],
"seeAlso": [],
"lifecycle": {"availableSince": "0.15"},
"provisions": [
{
"name": "hydra.core.lib.strings.toUpper.appliesSimpleUppercaseMapping",
"kind": "requirement",
"statement": "toUpper replaces each character with its Unicode simple (one-to-one) uppercase mapping, leaving a character with no uppercase mapping unchanged — including letters, accented Unicode characters, non-letter characters, and the empty string."},
{
"name": "hydra.core.lib.strings.toUpper.noFullCaseFoldingExpansion",
"kind": "requirement",
"statement": "toUpper does not perform full Unicode case folding: a character whose full uppercase mapping would expand to multiple code points, or whose simple mapping targets a single precomposed code point rather than a decomposed sequence, is mapped only to its simple, single-code-point uppercase form."}]},
"signature": {
"typeParameters": [],
"parameters": [{"name": "s", "description": "the string to convert to uppercase", "type": {"literal": "string"}, "isLazy": false}],
"result": {"type": {"literal": "string"}}},
"isPure": true,
"isTotal": true}}]}