Skip to content

Types

Atoll's static type system, type forms, inference, and user-defined types.

Updated View as Markdown

Atoll is statically typed. The compiler checks every expression before lowering and infers local types when the surrounding program provides enough information.

count := 3
name := "Nori"
pair: (string, int) = (name, count)
maybe_name: string? = Some(name)

The current spelling rules are important:

  • Scalar and string builtins are lowercase: int, float, bool, char, byte, string, and substring. Owned and borrowed byte sequences are []byte and [..]byte; the older nominal bytes type has been retired.
  • Nominal and composite types are PascalCase: List, Map, Set, Option, Result, and user-defined types.
  • Generic arguments use square brackets: List[int], not List<int>.
  • []T, [..]T, T?, and T ! E are type sugar.

Type forms

Form Meaning
int, string, User Named type
List[T] or []T Growable list
Slice[T] or [..]T Borrowed list view
[N]T Fixed-length array
(A, B) Tuple
fn(A, B) -> R Function value
T? Option[T]
T ! E Result[T, E]
&T Reference type
A | B Anonymous enum
{ name: string, age: int } Anonymous record
impl Trait Opaque value implementing a trait
! Never type

Chapters

  • Inference explains expected types, contextual literals, branch joins, and return inference.
  • Generics covers type parameters, bounds, explicit call arguments, opaque types, and specialization.
  • Structs and Records distinguish nominal and structural product types.
  • Enums and Unions distinguish named and structural sum types.
  • Aliases and Projections name existing or inferred types.
  • Tuples and Sequences cover positional products, lists, arrays, and slices.
  • Traits and Implementations define static behavior and dispatch.
  • Values and References explain copying, sharing, mutation, managed lifetimes, safe references, and raw pointers.

Older documents use names such as Int, Float, Boolean, String, and angle-bracket generics. They are historical spellings and are not used in this guide.

Navigation

Type to search…

↑↓ navigate↵ selectEsc close