# Research Sub-Report: Cluster 9 — Multi-Paradigm Foundation Calculi with Transactional Semantics (Verse)

**Sub-agent dispatch:** Tier 3 Worker (2026-06-12). Read-only research task.
**Sources read:**
- https://verselang.github.io/book/ (Verse book index)
- https://verselang.github.io/book/00_overview/ (overview)
- https://verselang.github.io/book/concept_index/ (concept index)
- https://simon.peytonjones.org/assets/pdfs/verse-icfp23.pdf (ICFP 2023 Distinguished Paper, "The Verse Calculus: A Core Calculus for Deterministic Functional Logic Programming")
- https://youtu.be/OJv8rFap0Nw (YouTube talk — summary via web search for "Simon Peyton Jones Verse ICFP")

---

## Entry: Verse (Simon Peyton Jones + Tim Sweeney, Epic Games, 2021–)

**What it is.** Verse is a multi-paradigm programming language developed by Epic Games (lead: Simon Peyton Jones and Tim Sweeney) for gameplay scripting in Unreal Editor for Fortnite and "metaverse" persistent simulation. Drawing from functional, logic, and imperative traditions, it is built on three explicit principles: "It's Just Code" (no special syntax for complex concepts), "Just One Language" (no preprocessor; the same constructs work at compile-time and run-time), and "Metaverse First" (designed for a single global persistent simulation). Its foundational paper, "The Verse Calculus: A Core Calculus for Deterministic Functional Logic Programming" (Augustsson, Breitner, Claessen, Jhala, Peyton Jones, Shivers, Steele, Sweeney — ICFP 2023, **Distinguished Paper**), defines VC, a deterministic functional logic calculus that extends lambda calculus with unification, choices, tuples, "One" and "All" quantifiers, and a confluent small-step rewrite semantics.

**What we take from it.** The transactional semantics (`<transacts>` with automatic rollback) is the most principled way to formalize the "reads are free, writes are audited" invariant at the *language* level, not at the verb/dispatch level. The DSL's Tier 4 `try { } recover { }` envelope is a tiny step in this direction; Verse's `<transacts>` + `<decides>` + `?T` model is the full system. The two-layer failure model (function-level via `[]` brackets vs value-level via `?T` options) maps to the DSL's two-layer error model: recoverable errors (return `Result[T]` per Cluster 7) vs value-level failures (the verb's success path returns an "empty" value). The effect system (`<reads>`, `<writes>`, `<transacts>`, etc.) is the principled alternative to the DSL's informal "read-verbs vs write-verbs" distinction. The Verse Calculus shows that a "narrow waist" for transactional functional logic programming is possible — VC is to Verse as the lambda calculus is to Haskell; the DSL is a narrow waist for AI-tool invocation, and the question of whether there's a "DSL Calculus" waiting to be formalized is left as Open Question A.7.2.

### 5 Distinctive Design Properties (per sub-agent)

1. **Transactional semantics with speculative execution as a type-system primitive.** A function declared `<transacts>` mutates state provisionally; if any later failable step in the function fails, *all* mutations within the call are automatically rolled back. This is the *default* for stateful operations in Verse, not an opt-in library. (Source: `verselang.github.io/book/08_failure/` §"Speculative Execution": *"When you execute code in a failure context, changes to mutable variables are provisional — they only become permanent if the entire context succeeds... If the check fails, the subtraction is automatically rolled back. You don't need to manually restore the original value or check conditions before modifying state. This transactional behavior makes complex state updates safe and predictable. Either everything succeeds and all changes are committed, or something fails and nothing changes."*)

2. **Failure as first-class control flow (not exceptions).** Failable expressions use `[]` call brackets (e.g., `LookupPlayer[Name]`) and propagate failure through the function body; only functions marked `<decides>` can contain failable expressions. The `?` query operator converts an option into a failable expression; a two-layer failure model distinguishes *function-level failure* ("couldn't complete") from *value-level failure* ("completed but result doesn't meet criteria"), with the latter represented as `?T` option types. No `try`/`catch`, no `null`, no sentinel returns. (Source: `verselang.github.io/book/08_failure/` §"Living with Failure": *"Verse has roots in logic programming, where computations search for solutions rather than executing steps. When a path fails, the computation backtracks and tries alternatives... Verse tames this power by making failure contexts explicit and limiting backtracking to specific constructs. You get the benefits of logic programming — declarative code, automatic search, elegant handling of alternatives — without the complexity of full unification and unbounded backtracking."*)

3. **Effect tracking as part of the function signature.** Every function declares its effect set explicitly: `<computes>` (pure), `<reads>`, `<writes>`, `<transacts>`, `<decides>` (can fail), `<suspends>` (async), `<converges>`/`<diverges>`, `<predicts>` (client-side), `<dictates>` (server-side). Effects compose and propagate; the effect system enables the compiler to reason about transaction boundaries, concurrency safety, and serialization. This is closer to Koka/Leijen's effect typing than to monad transformers. (Source: `verselang.github.io/book/06_failure_handling/` §"Effects"; `verselang.github.io/book/00_overview/` §"Effects".)

4. **A new foundational calculus (Verse Calculus / VC) for deterministic functional logic programming.** VC is presented in the ICFP 2023 paper as a small-step rewrite semantics for the *fusion* of functional and logic programming — an extension of lambda calculus with explicit unification, choice operators, tuples, and One/All quantifiers. Crucially, the authors prove confluence "for well-behaved terms" — a property that earlier functional-logic languages (Curry, Mercury) struggled to give a satisfying semantics for. The "MaxVerse" user-facing syntax elaborates to VC; the calculus is the formal foundation. (Source: `simon.peytonjones.org/assets/pdfs/verse-icfp23.pdf` abstract: *"In this paper we describe the Verse calculus, VC, a new core calculus for deterministic functional logic programming. Our main contribution is to equip VC with a small-step rewrite semantics, so that we can reason about a VC program in the same way as one does with lambda calculus; that is, by applying successive rewrites to it. We also show that the rewrite system is confluent for well-behaved terms."*)

5. **Everything-is-an-expression + live (reactive) variables as language primitives.** Every control construct produces a value (e.g., `Result := if (X > 0) then "yes" else "no"`, `Multiply := for (X : Array) { X * 42 }`). On top of this, "live variables" (declared with `live`) automatically recompute when their dependencies change; reactive constructs `when`, `upon`, `await`, and `batch` turn the language into a hybrid functional/reactive system for the metaverse use case. Combined with `sync`/`race`/`rush`/`branch` concurrency primitives and persistent `weak_map` storage scoped to players/sessions, Verse is a language for a *persistent distributed simulation*, not just a script. (Source: `verselang.github.io/book/00_overview/`; `verselang.github.io/book/12_reactive/`.)

### Anchor Quote

*"In this paper we describe the Verse calculus, VC, a new core calculus for deterministic functional logic programming. Our main contribution is to equip VC with a small-step rewrite semantics, so that we can reason about a VC program in the same way as one does with lambda calculus; that is, by applying successive rewrites to it. We also show that the rewrite system is confluent for well-behaved terms."* — `simon.peytonjones.org/verse-calculus/` (abstract) / ICFP 2023 Distinguished Paper.

*"When you execute code in a failure context, changes to mutable variables are provisional — they only become permanent if the entire context succeeds... If the check fails, the subtraction is automatically rolled back. You don't need to manually restore the original value or check conditions before modifying state... This transactional behavior makes complex state updates safe and predictable. Either everything succeeds and all changes are committed, or something fails and nothing changes."* — `verselang.github.io/book/08_failure/` (Speculative Execution section).

*"Verse has roots in logic programming, where computations search for solutions rather than executing steps. When a path fails, the computation backtracks and tries alternatives... Verse tames this power by making failure contexts explicit and limiting backtracking to specific constructs. You get the benefits of logic programming — declarative code, automatic search, elegant handling of alternatives — without the complexity of full unification and unbounded backtracking."* — `verselang.github.io/book/08_failure/` (Living with Failure section).

---

## Synthesis for the DSL

This section maps Verse's design properties to the DSL's verb tiers, enabling the Tier 1 Orchestrator to write §4 (Tier 4 verb justifications) and §6 (AI-agent properties) of the report.

### Tier 4 (AI-Fuzzing Tolerance) Verb Justification via Verse

| DSL Verb | Verse Analogue | Mapping | Source |
|----------|---------------|---------|--------|
| `try { } recover { }` | `<transacts>` + `<decides>` | The DSL's `try`/`recover` envelope is a tiny surface expression of Verse's transactional+decision effect system. A future v2 of the DSL could adopt `try<transacts><decides> { } recover { }` as the signature. | `verselang.github.io/book/08_failure/` §"Speculative Execution" |
| `sandbox { }` | `<transacts>` boundary | The DSL's `sandbox` block delimits a transaction scope — directly analogous to a Verse function declared `<transacts>`. Mutations within `sandbox { }` are provisional and roll back on failure. | `verselang.github.io/book/08_failure/` §"Speculative Execution" |
| `audit` | `<reads>` effect | The DSL's `audit` verb is a read-only traversal (no writes). Verse's `<reads>` effect formalizes this — a function declared `audit<reads>: T` is statically guaranteed to perform no writes. | `verselang.github.io/book/06_failure_handling/` §"Effects" |
| `fuzzy` | `?T` option type | The DSL's `fuzzy` parse-tolerance is analogous to Verse's `?T` option type — a value-level failure mode that doesn't crash the function. A `fuzzy` verb's "did you mean X?" suggestion is essentially a `?T` return. | `verselang.github.io/book/08_failure/` §"Value-Level Failure" |

### Two-Layer Failure Model Mapping

| Verse Concept | DSL Mapping | Notes |
|---------------|-------------|-------|
| `[]` call brackets (function-level failure) | `try { } recover { }` envelope | Both propagate failure through the function body and require an explicit "can fail" annotation (`<decides>` in Verse, `recover { }` block in DSL). |
| `?T` option type (value-level failure) | `Result[T, list[Suggestion]]` (per Cluster 7) | Both represent "completed but result is not what was asked" — the function succeeded but the value is empty/missing. |
| `<transacts>` rollback | `sandbox { }` rollback (planned) | Both are speculative execution with automatic rollback on failure. |
| `<reads>` / `<writes>` effects | Read-verb / write-verb distinction | Both formalize the "reads are free, writes are audited" invariant — at the language level (Verse) vs at the verb-design level (DSL). |

### File:line References

| Source | Section | Note |
|--------|---------|------|
| `verselang.github.io/book/08_failure/` | §"Speculative Execution" | Anchor quote for transactional semantics |
| `verselang.github.io/book/08_failure/` | §"Living with Failure" | Anchor quote for two-layer failure model |
| `verselang.github.io/book/06_failure_handling/` | §"Effects" | Effect system details |
| `verselang.github.io/book/00_overview/` | §"Effects" | Effect system overview |
| `verselang.github.io/book/00_overview/` | §"Three Principles" | "It's Just Code", "Just One Language", "Metaverse First" |
| `verselang.github.io/book/12_reactive/` | §"Live Variables" | Live reactive variables |
| `simon.peytonjones.org/assets/pdfs/verse-icfp23.pdf` | Abstract | Anchor quote for Verse Calculus / confluent rewrite semantics |
| `verselang.github.io/book/concept_index/` | All | Quick reference for Verse's effect + failure primitives |

---

**Sub-report complete.** This is the evidence base for §2 Cluster 9 in `report_v1.2.md`.
