Skip to content

aivi.text ​

Utilities for working with Text values.

The module combines low-level text intrinsics with higher-level helpers built in stdlib code. The current surface is broader than the older docs suggested, even though it is still a helper module rather than a richer text domain.

Representative import ​

aivi
use aivi.text (
    isEmpty
    nonEmpty
    join
    surround
    trim
    split
    replaceAll
    capitalize
    padStart
    lines
)

Core operations ​

NameTypeDescription
lengthText -> IntLength of a text value
byteLenText -> IntByte length of a text value
sliceInt -> Int -> Text -> TextSlice text by start/end indexes
findText -> Text -> Option IntFind one text inside another
containsText -> Text -> BoolTest whether text contains a substring
startsWithText -> Text -> BoolTest the start of a text value
endsWithText -> Text -> BoolTest the end of a text value
toUpperText -> TextUppercase conversion
toLowerText -> TextLowercase conversion
trimText -> TextTrim both ends
trimStartText -> TextTrim leading whitespace
trimEndText -> TextTrim trailing whitespace
replaceText -> Text -> Text -> TextReplace the first match
replaceAllText -> Text -> Text -> TextReplace every match
splitText -> Text -> List TextSplit text on a separator
repeatInt -> Text -> TextRepeat a chunk of text
fromIntInt -> TextConvert an integer to text
parseIntText -> Option IntParse text as an integer
fromBoolBool -> TextConvert a boolean to text
parseBoolText -> Option BoolParse text as a boolean
concatList Text -> TextConcatenate several text values

trim removes Unicode whitespace from both ends. toLower performs Unicode lowercase conversion; it is not locale-sensitive case folding or Unicode normalization. contains needle haystack searches for an exact substring and accepts the empty needle. These three operations are supported in native compiled execution as well as the development runtime. Text ordering is lexicographic and does not apply locale-specific collation.

Stdlib helpers ​

NameTypeDescription
isEmptyText -> BoolTrue for ""
nonEmptyText -> BoolTrue when text is not empty
joinText -> List Text -> TextJoin text values with a separator
surroundText -> Text -> Text -> TextWrap text with prefix/suffix
withDefaultText -> Text -> TextReplace "" with a fallback
capitalizeText -> TextUppercase the first character and lowercase the rest
hasMinLengthText -> Int -> BoolCheck a minimum length
hasMaxLengthText -> Int -> BoolCheck a maximum length
padStartInt -> Text -> Text -> TextLeft-pad text to a target length
padEndInt -> Text -> Text -> TextRight-pad text to a target length
parseIntOrElseInt -> Text -> IntParse an int or use a fallback
linesText -> List TextSplit on newline characters
wordsText -> List TextSplit on spaces
unlinesList Text -> TextJoin with newline separators; no trailing newline is added

Example ​

aivi
use aivi.text (
    join
    trim
    capitalize
    lines
    parseIntOrElse
)

value title : Text = capitalize (trim "  aivi  ")

value csv : Text =
    join "," [
        "Ada",
        "Grace",
        "Linus"
    ]

value count : Int = parseIntOrElse 0 "42"
value rows : List Text = lines "a\nb\nc"

Current limits ​

aivi.text is still a helper-oriented module:

  • no richer text domain with structured patch/algebra support
  • no dedicated interpolation, formatting, or template surface here
  • no explicit grapheme-aware or locale-aware text model in the public stdlib page yet

Text interpolation in native kernels reads the committed payload of a Signal Text, Signal Int, Signal Float, Signal Bool, or Signal Unit, using the same formatting as development execution. Arbitrary ADTs and aggregate interpolation still require an explicit formatter; aivi check --runnable checks this before packaging an application.

(c) 2026 by Andreas Herd