Primitives, intrinsics, and representations
Primitives describe machine-level value families. Intrinsics provide checked compiler/target implementations. Representation mappings connect semantic user types to efficient storage without identifying the two types.
Primitive declarations
primitive Int;
primitive Float64;
primitive String;Primitive types have no source constructors. Their operations are ordinary algebra members whose instances may be intrinsic.
Intrinsic implementations
instance Additive(Int) = intrinsic;
value machineEpsilon : Float64 = intrinsic;The registry resolves compiler-provided implementations before RuntimeCore. Backends do not perform semantic instance search.
Representation mappings
repr Nat as Int default where {
function toRepr(item:Nat) : Int = ...;
function fromRepr(item:Int) : Nat = ...
};The mapping supplies checked conversion functions and may state an invariant. default selects the preferred coherent mapping in context; alternatives must not create ambiguity.
Explicit casts
natValue as IntThe compiler determines the direction from the declared repr map. as is not an annotation and not a class downcast.
Semantic type versus storage
A representation can change layout and enable native operations while the source API retains the semantic type. Target-specific mappings may refine a canonical declaration, but they must preserve its checked conversions and invariants.
Floating-point policy
The default --fp-contract=off preserves separate multiply and add operations. --fp-contract=fast permits contraction such as fused multiply-add. It does not permit arbitrary reciprocal replacement, erase NaN/infinity cases, or assert exact field laws for floating arithmetic.
Primitive floating division must preserve direct division semantics rather than observably becoming x * recip(y).
Common mistakes
Do not attach implicit operations to a primitive, treat a representation as type equality, or confuse as with annotation or class casting. A restricted representation needs an invariant that its conversions actually respect.
Recap
Primitives name storage families, intrinsics provide checked implementations, and repr connects a semantic type to storage without erasing its identity.
Normative details: Language Reference §11.