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

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
surroundWithText -> Text -> Text -> TextAlias of surround
withDefaultText -> Text -> TextReplace "" with a fallback
upperText -> TextWrapper around toUpper
lowerText -> TextWrapper around toLower
capitalizeText -> TextUppercase the first character and lowercase the rest
hasMinLengthText -> Int -> BoolCheck a minimum length
hasMaxLengthText -> Int -> BoolCheck a maximum length
includesTextText -> Text -> BoolHelper over contains
stripBlanksText -> TextWrapper around trim
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

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

AIVI Language Manual