On this page
Vibe types and annotations
Vibe parameters, results, fields, and collection elements have static types. The compiler can infer many locals, but it does not turn annotations into optional hints. The same program must obey the shared type, range, initialization, and ownership rules before proof or code generation. See the shared type reference for language-wide rules.
Scalar types
| Vibe spelling | Verada meaning | Important distinction |
|---|---|---|
int |
Integer, signed 64-bit |
Finite; overflow must be proved absent |
Natural |
Integer constrained to 0 .. 2**63 - 1 |
Same type identity as int, narrower subtype |
Positive |
Integer constrained to 1 .. 2**63 - 1 |
Excludes zero |
float |
Long_Float |
Floating-point rounding and checks; not an exact real |
bool |
Boolean |
Distinct from integers; no Python bool-is-int arithmetic |
str |
Verada.Strings.Texts.Text |
Immutable copyable text of Unicode code points with managed storage |
None as a return annotation |
No result | Used by procedures |
T | None, Optional[T] |
Verada.Optionals' Optional of T |
A value that may be absent; see below |
Natural, Positive, and other helpers are conventionally imported from verada. Wider named numeric types from the shared environment can be named explicitly when visible, but int never grows automatically into one. Fixed-point and decimal types are declared in a Vada or Varc package and imported. Mathematical big numbers are library types for contracts and ghost code, not a meaning of int.
Annotate a run-time real as float when its type matters. A float literal is the double nearest it, and each float operation rounds to a double, as Python's does, also where the compiler works the value out (0.1 + 0.2 is 0.30000000000000004, as in CPython; Ada would compute such a constant expression exactly and round once).
Aliases and constrained subtypes
Use a type statement at module level:
from verada import Annotated, Interval, Ge, Le, Natural
type Score = Annotated[int, Interval(ge=0, le=100)]
type Nonzero = Annotated[Natural, Ge(1)]
type Small = Annotated[int, Le(10)]These declaration fragments create constrained subtypes of their first argument. Score retains int's type identity and constrains stored/passed values. A one-sided Ge or Le uses the base subtype's other bound. Interval accepts ge= and le=. The bounds must lie within the first argument's range (Annotated[Natural, Ge(-5)] is B2002). Unsupported or duplicated constraint combinations are rejected; Annotated is not an arbitrary metadata interpreter. type Alias = Existing is a plain subtype alias. A type alias joining classes with | declares a union.
Write a constraint once, in a named type declaration, and use its name in profiles. Final marks a module constant; it is not a field or parameter modifier.
Distinct scalar classes
from verada import Modular, RangeInt
from enum import Enum
class Level(RangeInt, ge=0, le=10):
pass
class Byte(Modular, modulus=256):
pass
class Colour(Enum):
RED = 1
GREEN = 2
BLUE = 3These are module-level declaration fragments. Level is a new integer type, not a subtype alias. Its defining bounds must be static and fit the supported signed base widths; values stored as Level must fit the declared range. Byte is a modular type; its supported arithmetic wraps modulo 256, unlike signed int arithmetic. Explicit conversion such as int(level) bridges distinct integer types where required.
An Enum class is an enumeration type whose values are its members, ordered as declared. Name a member as Python does, Colour.RED, also through an import (m.Colour.RED); a bare RED is not a name (B1001). A member's .value is the value written after its = (an int when every member's is an integer, a str when every one's is a string), and its .name is its name as written, a str: Colour.RED.value is 1 and c.name is "RED" when c is Colour.RED. The values are not representations: the members are ordered as declared. print(Colour.RED), str(Colour.RED) and an f-string field give the class's name and the member's, Colour.RED, as Python's do; repr(Colour.RED) is <Colour.RED: 1> (a str value with its quotes, <Mode.ON: 'on'>). Colour.first and Colour.last are the first and last members.
Selected bound properties are T.first and T.last. These correspond to subtype bounds; they are not arbitrary class attributes. The integer reference explains base ranges, conversion placement, and range versus overflow failures.
Optional values
int | None (or Optional[int], from typing) is a value of int that may be absent, for a scalar, a str or a dataclass: the Optional of an implicit instance of Verada.Optionals. A value of int where an int | None is wanted is that value, present; None is the absent one:
def find(xs: list[int], v: int) -> int | None:
for i in range(len(xs)):
if xs[i] == v:
return i
return Nonex is None and x is not None test it. Where the program uses x as its element (x + 1, x.upper(), p.x, an argument of the element's type), it reads the value, whose precondition, that there is one, is proved: after if x is not None:, or wherever the program shows it otherwise; elsewhere the proof fails (B5101) as Python's None + 1 would. print(x), str(x) and an f-string field give the value's text, or None. A dictionary's d.get(key) without a default is such a value. (An owner's Owned[T] | None is an access type instead, see sharing.)
Arrays with a fixed element type
from verada import Array
class Row(Array[int], size=3):
pass
class Board(Array[int], shape=(2, 3)):
pass
class Matrix(Array[int], rank=2):
passAn array class has one component type and one of these bound descriptions:
| Class keyword | Bounds/indexing |
|---|---|
size=N |
One fixed dimension, positions 0 .. N-1 |
index=IndexType |
One dimension whose actual indices are values of that discrete subtype |
shape=(M, N, ...) |
Fixed rectangular dimensions, each indexed from zero |
rank=R |
R >= 1 dimensions whose bounds belong to each value; Vibe indexes by zero-based position in each dimension |
rank=R, index=IndexType |
As rank=R, with each dimension's indices values of that subtype, by which Vibe indexes (index=Positive: from 1) |
Write one bound description per class (rank may add index=). An array is a value, not a growable list. A fixed array is constructed as Row([1, 2, 3]). Multidimensional arrays need rectangular nested input and compatible shape. Detailed indexing, assignment and shape rules are under iteration and matrices.
Collection and tuple annotations
The supported builtin generic forms are list[T], dict[K, V], set[T], and tuple[T0, T1] through tuple[T0, T1, T2, T3]. Their element types must be supported static types; these are nominal instances of Verada library generics. No heterogeneous list, variadic tuple, tuple[T, ...], runtime type parameter substitution, or arbitrary Python generic subscription follows from the syntax. See collections for construction/method restrictions and classes for imported instance identity.
Give a local collection its type, including nonempty literals:
scores: list[int] = [72, 85, 64]
counts: dict[int, int] = {}
seen: set[int] = set()
pair: tuple[int, str] = (7, "seven")These are function-body fragments. A collection local takes its type from its annotation: an unannotated list literal is B2010, as the literal alone does not say whether a list or an array is meant. A collection returned by a typed function has its declared result type.
Record, generic, interface, and owner types
A supported dataclass's name is its record type. A tagged class or Protocol used as an ordinary non-self parameter can accept subclasses through the corresponding class-wide view. This is nominal dispatch, not arbitrary Python duck typing. Box[int] names an instance of a supported generic dataclass. Type arguments and the defining module must resolve according to generic rules.
Owned[Node] and Owned[Node] | None are the owning access types for a class Node the module declares. Owned[Node] is never null: assigning None to it fails its null check (B4109). Owned[Node] | None may be null; test pointer is not None, or require it, before reaching through it. See sharing and ownership.
Inference, conversions, and initialization
Local scalar literals and ordinary function calls can determine a type. A call that changes its arguments and returns a value needs a typed target, as described under subprograms. Reassignment cannot change the object's static type. T(value) is a conversion or a constructor. For int(float_value), Vibe truncates toward zero; the result still must fit Integer. float(integer_value) converts to Long_Float and obeys its rounding.
An uninitialized local must be definitely initialized before reading. A dataclass field with a default can be left out of a construction, which then takes the default; see fields and construction.
Source evidence: type and class lowering, standard types, and surface form resolution.