Vector Labs

Arra — Overview

Arra is an array-functional language organized around subject-first, left-to-right mapping, structural function valence, and compile-time hook selection. Essential Arra is the normative semantic specification; this page is the short map.

One direction

Evaluation, construction, type formation, and deconstruction all read from left to right:

value transform consume
x Some
a Option
x Some → x use

Unary adjacency is subject-first app; there is no conventional function-first call direction. Multivalent application centers a pure mapping between primary and secondary arguments:

x f y                 // equivalent to ⟦x; y⟧ f

Tuple-unary (A, B) → C, dyadic ⟦A; B⟧ → C, nullary ⟦⟧ → C, and curried A → (B → C) functions are distinct. Invocation vectors expose complete domains and residual mappings:

⟦a; _; c⟧ f
⟦_; 1⟧ +
⟦_⟧ 'map parse

All symbolic operators have equal precedence and associate left-to-right:

a + b * c             // (a + b) * c

One conditional form

Every function literal is a UCS conditional function. A single irrefutable clause is an ordinary lambda; ordered clauses combine matching and control flow:

square ← x → x * x

unwrap ←
  x Some → x
  None   → default

⇒ introduces conditional evidence and ∧ sequences successful path parts:

consume ←
  safeHead ⇒ x Some ∧ x valid → x process
  _ → fallback

The compiler checks structural totality over finite constructors, Booleans, products, and exact arrays. A conservative uncovered path retains its explicit Fail effect.

One hook kernel

Head Surface role
app adjacency and ordinary application
op unary postfix or binary infix symbolic operation
fun statically selected named function family
pat named postfix deconstruction
project field read
assign field replacement
iter structure-consuming traversal
gen output-directed generation
to one-step output-directed conversion

Hook signatures are type-like:

app (a → b) : a → b
op + : ⟦I64; I64⟧ → I64
fun ∀ (n : Nat) ⇒ sum : I64[n] → I64
iter ∀ (n : Nat) a b ⇒ 'map (a → b) : a[n] → b[n]

Hooks are resolved statically against a lexical request view. Local declarations appear sequentially; selected opens contribute selected candidates; qualified requests use exactly the closed exported view of the named module. Aliases rekey declarations. Ambiguity is diagnosed only when an actual request has several incomparable maximal candidates.

Direct complete hooks are final. Only their absence permits the compiler-owned function, exact-record, and equal-frame structural schemas. Those schemas never insert conversions, cross nominal boundaries, open rows, broadcast, search ranks, or backtrack. Effects are accumulated after selection and never rank candidates.

Compile-time evidence

A theory is a nominal relation containing labelled hook requirements, prerequisites, directional determinations, and semantic laws. A model certifies the exact hooks selected for one theory assignment:

theory a Equality
  require equal
    op = : ⟦a; a⟧ → Bool
  law reflexive
    ⟦x : a⟧ ⇒ x equal x ≡ True

model I64 Equality
  certify Equality.equal with equalI64
  assume reflexive

Generic values, hooks, and model constructors carry flat theory constraints. Evidence fixes specialization and law authority but never adds or ranks hook candidates. Theories, models, laws, and evidence are erased before checked Core.

Products, names, and arrays

Tuple and unit syntax elaborate to the same structural product calculus as records. Name classifies static label or ordinal identities; Fields classifies finite field maps:

∀ (name : Name) a (rest : Fields)
| name ⟂ rest
⇒ {⟦name⟧: a | rest} → a

Rows are permutation-insensitive disjoint maps. Record + is disjoint concatenation, record - name removes a field, and project/assign accept literal or quantified static names. Static names specialize before Core and never become runtime strings or symbols.

Array types expose shape:

I64[n]
F64[n; m]
a[_]

iter uses a unique prefix-frame/suffix-cell split. A mapper’s input shape identifies the cell; leading dimensions form the frame, and the output cell replaces the input suffix. Regular arrays remain regular; segmented 'flatMap represents variable-length results explicitly.

Arrays of records use canonical column storage. Field projection selects a column without a row-by-row copy; indexing presents a logical scalar record. Dense U8, Char, and Symbol arrays retain specialized flat storage.

Explicit lazy and keyed collections

Map is an opaque insertion-ordered source-library type. Construction requires an Equality model, rejects duplicate equivalent keys, and stores the selected equality mapping as ordinary executable data.

Seq is an opaque pure, replayable, non-memoizing lazy sequence. Lazy transformations pull only on demand; immediate consumers preserve ordered effects; collect explicitly materializes an existentially sized array. characters, bytes, and lines are non-materializing String views. Effectful, resource-owning, memoized, and parallel streams require distinct future types.

Effects, modules, and execution

Function types carry effect rows. Effects and their operations are ordinary source declarations; Fail and IO are Prelude policy, not compiler exceptions. Handlers are non-resumable and cover one exact instantiated effect.

Every file declares one dotted module. Interfaces expose public declarations; implementations own definitions. An interface-only forwarding module may omit its implementation. import is qualified-only, open adds an unqualified view, and export forwards from an interface. exposing and except select values, types, constructors, effects, theories, model groups, exact models, hook families, or exact hooks.

The source Prelude is an installed module graph rather than compiler magic. Surface programs resolve and specialize to immutable monomorphic Typed IR, lower structurally to a small Core, pass an independent Core checker, and then execute in the deterministic reference treewalk. Optimizing backends may follow without changing that semantic boundary.