Skip to content

aivi.prelude ​

aivi.prelude is the carrier-agnostic foundation of AIVI programs. It names the built-in value types, higher-kinded classes, and the generic ordering helpers that work for every Ord type. Use ambient class operations such as map, reduce, apply, and chain across supported carriers. Carrier-specific constructors and helpers live in their owning modules.

The compiler also makes the same core types and class members available ambiently. Explicit prelude imports remain useful when a file wants to show those dependencies.

Built-in types ​

TypeDescription
Int64-bit signed integer
Float64-bit floating-point number
DecimalFixed-precision decimal
BigIntArbitrary-precision integer
BoolTrue or False
TextUnicode text
UnitUnit type
OrderingLess, Equal, or Greater
List AOrdered collection
Option AOptional value
Result E ASuccess or failure
Validation E AValidation that can accumulate errors
Signal AReactive value
Task E ADescription of asynchronous work

Type classes ​

ClassMain operation
Eq A(==) and (!=)
Default Adefault
Functor Fmap
Ord Acompare
Semigroup Aappend
Monoid Aempty
Bifunctor Fbimap
Traversable Ftraverse
Filterable FfilterMap
Apply Fapply
Applicative Fpure
Chain Fchain
Monad Fjoin
Foldable Freduce

The complete hierarchy and current executable carrier support are documented in Typeclasses & Higher-Kinded Support.

Class members are ordinary callable values. Prefer them when an operation has the same meaning across carriers; use names such as mapRight, mapValues, and mapNel when the carrier-specific name makes the code clearer. Importing a carrier's module also brings its exported instances into scope. Explicit imports of a same-named helper still take precedence over ambient class methods.

aivi
use aivi.core.either (
    Either
    Right
)

type Int -> Int
func increment = . + 1

value optional : Option Int = map increment (Some 2)
value right : Either Text Int = Right 2
value mapped : Either Text Int = map increment right

See stdlib instances for carrier behavior and intentional exclusions.

Generic ordering helpers ​

FunctionTypeDescription
minOrd A => A -> A -> AReturn the lesser value
maxOrd A => A -> A -> AReturn the greater value
minOfOrd A => A -> List A -> AFold a list from an explicit first value using min
maxOfOrd A => A -> List A -> AFold a list from an explicit first value using max
clampOrd A => A -> A -> A -> ARestrict a value to the inclusive bounds
aivi
use aivi.prelude (
    Int
    Ord
    min
    max
    clamp
)

value smallest : Int = min 5 3
value greatest : Int = max 5 3
value bounded : Int = clamp 0 100 140

Owning modules ​

traverse sequences a fixed Traversable structure through any available Applicative instance. The source and result carriers are independent: a list can produce an Option, an authored Either E, or a Task E, for example. Generic functions retain the required dictionaries.

aivi
type Traversable F => F Int -> Task Text (F Int)
func incrementAll = values => traverse (n => pure (n + 1)) values

value scheduled : Task Text (List Int) = incrementAll [1, 2]

The task remains a plan until executed. Empty structures use the result instance's pure.

Import carrier-specific functions from these modules:

ValuesModule
Option Aaivi.option
Result E Aaivi.result
Validation E Aaivi.validation
List Aaivi.list
pairsaivi.pair
textaivi.text
booleansaivi.bool
integer helpersaivi.math

This keeps each public function tied to one implementation and one reference page.

Built-in carriers and classes ​

The carrier types re-exported by the prelude are List, Option, Result, Validation, Signal, and Task. Its class interfaces are Eq, Default, Functor, Semigroup, Monoid, Bifunctor, Traversable, Filterable, Applicative, Monad, and Foldable.

(c) 2026 by Andreas Herd