Skip to main content

Prelude

The Prelude is loaded automatically for ordinary compilation and execution. It defines the core capability vocabulary and a small compatibility surface; no import is required.

Ordering

Ordering

data Ordering = LT | EQ | GT.

The result of a three-way comparison.

LT

The left value precedes the right value.

EQ

The values have equal ordering.

GT

The left value follows the right value.

Equality and ordering capabilities

Eq

class Eq(a) { equals :: a -> a -> Bool. }.

Requires an equality operation for a. Built-in implementations cover scalar and numeric types.

equals

equals :: a -> a -> Bool.

Ord

class Ord(a) { compare :: a -> a -> Ordering. }.

Requires a three-way ordering operation for a. Numeric and character values use their ordinary order. Text compares lexicographically by Unicode scalar.

compare

compare :: a -> a -> Ordering.

Numeric capabilities

Num

class Num(a) { }.

Supplies evidence for arithmetic and conversions over Jazz's primitive numeric types. Implementing Num for another type does not extend the set of types accepted by numeric expressions.

Integral

class Integral(a) { }.

Marks integral numeric types. Built-in signed and unsigned integer types implement it.

Fractional

class Fractional(a) { }.

Marks fractional numeric types. Built-in floating types implement it.

Rendering and defaults

Showable

class Showable(a) { show :: a -> Text. }.

Requires stable runtime-value rendering for a. Built-in scalar and numeric types implement it.

show

show :: a -> Text.

Renders a value using its active Showable(a) implementation and stable Jazz value syntax.

Default

class Default(a) { defaultValue :: a. }.

Provides a type-directed default. Built-in numeric defaults are zero, Bool uses False, Char uses '\0', and Text uses "".

defaultValue

defaultValue :: a.

Compatibility list helpers

map

map :: (a -> b) -> [a] -> [b].

Applies a function to every item and preserves order. Prefer listMap in library-oriented code.

filter

filter :: (a -> Bool) -> [a] -> [a].

Keeps the items whose predicate is True, preserving order. Prefer listFilter in library-oriented code.

hd

hd :: [a] -> a.

tl

tl :: [a] -> [a].

hd and tl are partial: an empty list fails fatally with E3009 or E3010, respectively. Prefer listHead and listTail when emptiness is possible.

Effectful compatibility value

print!

print! :: a -> a.

In stub-v1, evaluates and returns its argument without emitting output. Its ! suffix still classifies it as impure. Run-mode rendering of the final expression is separate from print!.

Numeric conversions

Conversion inputs must satisfy Num(a). Integer targets require an in-range integral value. Floating targets use deterministic target-format rounding; non-finite or overflowing conversions fail with a runtime diagnostic.

toInt8

toInt8 :: @{Num(a)}: a -> Int8.

Converts to an 8-bit signed integer and rejects values outside -128 through 127.

toInt16

toInt16 :: @{Num(a)}: a -> Int16.

toInt32

toInt32 :: @{Num(a)}: a -> Int32.

toInt64

toInt64 :: @{Num(a)}: a -> Int64.

toUInt8

toUInt8 :: @{Num(a)}: a -> UInt8.

Converts to an 8-bit unsigned integer and rejects values outside 0 through 255. Example: toUInt8 255 succeeds; toUInt8 256 fails.

toUInt16

toUInt16 :: @{Num(a)}: a -> UInt16.

toUInt32

toUInt32 :: @{Num(a)}: a -> UInt32.

toUInt64

toUInt64 :: @{Num(a)}: a -> UInt64.

toFloat16

toFloat16 :: @{Num(a)}: a -> Float16.

toFloat32

toFloat32 :: @{Num(a)}: a -> Float32.

toFloat64

toFloat64 :: @{Num(a)}: a -> Float64.

toInt

toInt :: @{Num(a)}: a -> Int64.

An alias of toInt64 with the same range and integral-input requirements.

toFloat

toFloat :: @{Num(a)}: a -> Float64.

An alias of toFloat64 with the same rounding and overflow behavior.

Use --no-prelude only for compiler or runtime work. Its low-level support surface is not a user API. See capabilities for constraint syntax and resolution.