Skip to content

release/2.0.2

Latest

Choose a tag to compare

@github-actions github-actions released this 22 Nov 03:50
5d21b6e

2.0.0 is a major release of Unison. Here’s an overview of what’s new, and see fast follow 2.0.1 and 2.0.2 notes at the end:

  1. An LLVM-based JIT compiler for the runtime (#6317, follow-up optimizations and fixes in #6330) and optimizations for the interpreter too. It's opt-in with ucm --jit on and is typically 5–10× faster than the interpreter, and up to 200× faster on hot loops.
  2. Anonymous records (#6143, follow-up in #6305) are a major new language feature.
  3. Standalone binaries (#6336): ucm bundle or the new bundle command in UCM emits a self-contained executable (~25 MB) that runs without ucm or a codebase.
  4. A revamped MCP server (#6328) that can now do "anything you can do in a UCM transcript" and includes a lazily-loaded encyclopedia of Unison know-how (learn).

Also: Unison → C callbacks in the FFI (#6306), file permission builtins (#6329), significant typechecker speedups (#6322, #6323), share.search, share.source, and other share.* commands for Share navigation from UCM (#6328).

The new builtin functions are in 7.21.0 release of @unison/base.

1. Anonymous records

{ x: 1, y: 2 } is term syntax for an anonymous record. It has type { x: Nat, y: Nat }.

pt@x picks the field of a record, pt. You can nest them person@name@lastName.

Here's an example:

pt : { x : Float, y : Float }
pt = { x : 1.0, y : 2.0 }
x : Float
x = pt@x
y = pt@y
pt' = pt@{x : @x + @y, y: 14.0 }

The last line shows syntax for setting or modifying one or more fields of a record.

You can also pattern match on records:

addUpRec : { x: Nat, y: Nat, z: Nat } -> Nat
addUpRec = cases
  { x: x, y: y, z: z } -> x + y + z

And you can put them in data types. The old style of records still exists, but is considered deprecated.

-- A type with a single constructor that takes
-- a record type as its argument.
type Person = Person { name : Text, age : Nat }

example = 
  p = Person { name : "Bob", age : 29 }
  (Person r) = p
  r@name

Official docs here

2. The LLVM-based JIT compiler

Initially introduced in #6317, the JIT is enabled with ucm --jit on or UNISON_JIT=on. It compiles batches of functions in the background using LLVM.

Performance improvements (from the PR's benchmark suites):

Speedup vs interpreter
Counting to a million 209× (66.5 ms → 318 µs)
fib 20 38×
Binary tree inserts / lookups 19× / 47×
Mutable byte array ops 131×
Ability requests (affine handlers) 4.4–6×
Typical code often 5–10×

If enabled, you'll see this on startup:

JIT compilation activated ⚡🚀

If LLVM isn't present, startup prints the reason instead (for example no LLVM 20 or newer found; the JIT is off) and everything runs on the interpreter.

Nothing about language semantics or the serialized code format changes when the JIT is enabled.

Design and usage docs live under unison-runtime/src/Unison/Runtime/JIT/ — see design.md, usage.md, and builtins.md.

Follow-on work since the initial PR:

  • #6330 — Optimization passes for interpreter and JIT. Call-pattern specialization, case-of-case, known-constructor simplification, exploded call results, a "wide" calling convention that skips allocation when a known function returns a 0/1-field constructor (with lightweight escape analysis), and tailcc for cross-module calls. Up to 82× faster on top for contrived cases, big wins on record/tuple loop state. Because the passes are ANF→ANF rewrites, the interpreter benefits as well (up to 5.4×). Includes deoptimization machinery so continuations can still be serialized in unoptimized form. This PR also fixed two intermittent JIT GC bugs, and adds a GC stress test mode.
  • #6331 — Added support for GHC's lower-latency non-moving GC, which needs a different write barrier.
  • #6342 — Fixed quadratic code size at exits: stack write-backs at JIT exit sites now share code.
  • #6335 — Bug fixes for the new wide calling convention, with regression tests.

Related runtime rework, done as part of the original JIT PR: Text and Bytes are now ropes over a strict finger tree (Deque, in the new lib/unison-util-rope package) with a copy-on-write slack buffer; small data constructors are flat closures; dispatch constructors are ordered by measured frequency for pointer tags, resulting in minor interpreter and JIT speedups.

3. Standalone binaries (#6336)

Unison programs can now ship as a single executable, not needing ucm or a codebase:

ucm bundle myproject/main:hello
./hello

The bundle command in ucm does the same thing as compile, but instead of a .uc file plus separate runner it produces the standalone executable. Here's how it works:

  • unisonrt is a minimal dependency runner in unison-runtime which executes a compiled .uc file; it has no parser, typechecker, or pretty-printer. unisonrt bundle prog.uc wraps it into a standalone executable (program embedded in a Mach-O section on macOS, appended with a trailer elsewhere).
  • A new minify tool strips unreachable code from GHC-linked executables and compacts the rest (Mach-O and ELF, arm64 and x86-64). This is applied to unisonrt on mac and linux platforms.
  • ucm finds unisonrt ($UNISONRT, then next to ucm, then on PATH), checks that its version matches its own, copies it, and embeds the compiled program. On mac, it's put in a section of the Mach-O image (re-signed ad hoc), on other platforms it's just appended after the executable with a locating trailer that says where the start of the embedded .uc file is.
  • Sizes: ~25 MB on macOS arm64, ~23 MB Linux arm64, ~27 MB Linux x86-64, ~70 MB Windows (Windows ships unminified for now). Only OS libraries are needed dynamically (plus libgmp on Linux); LLVM is not statically linked — the JIT loads it at runtime only if enabled via the UNISON_JIT=on environment variable.

This feature and the minification process are experimental for now. CI runs a bundle smoke test on all five platforms.

4. Improved coding-agent experience

The MCP server was rebuilt (in #6328) around one idea: tools just run UCM transcripts, so anything a transcript can do is available to an agent. There are now just 5 tools, tiered by how much they're allowed to do:

Tool Allows
transcript-read-only read codebase + Share: find, view, docs, history, diffs
transcript + easy-to-undo edits: typecheck, update, merge, rename, branches, install libraries
transcript-io + run arbitrary code (run, io.test)
transcript-all + externally visible / hard-to-reverse actions (push, delete)
learn lazily-loaded help topics (docs/mcp/learn), hyperlinked and tuned so an unprompted agent can work Unison competently

The learn topic content was iterated against 59 benchmark tasks until a Claude Sonnet agent could do them reliably with no prompting and just access to the MCP server.

Alongside this, there's a number of UCM improvements:

  • New Share commands: share.search, share.source, share.docs, share.render, share.project-search, share.releases, share.releases.detail.
  • undo / redo revamped to use the reflog (undo goes back one step in the reflog, redo goes forward one step). The old one-step-backward undo footgun is gone.
  • docs now shows the signature/type header above the docs.
  • edit.to variants for dumping definitions to a file.
  • rewrite.find/rewrite revamped to be useful for search and refactoring.
  • Failed update/merge/pull produce better instructions and drop output in a fresh scratch file; conflicted merges produce a diff3-marked file automatically, no external merge tool needed.
  • load/typechecking now pulls in definitions a redefinition affects (no more confusing errors when your scratch file has A and C but not B) — fixes #5072.

UCM and LSP polish

  • Clickable error locations (#6326): in watch mode, warnings/errors now emit $file:$line:$column, which IDEs render as clickable.
  • fzf restored (#6341): switch, view, upgrade etc. with no args get their fzf typeahead back in interactive mode (the MCP revamp had accidentally disabled it globally).
  • ucm, not unison (#6343): help text, usage lines, and --version finally say ucm — the name users actually have on their PATH.
  • LSP fixes: the server accepts connections again after the first one closes (#6311), and . now triggers completions in editors (#6327).

5. FFI and IO

  • Unison → C callbacks (#6306): you can pass a Unison function to C as a function pointer. New builtins (renamed for clarity in #6321):
    • FFI.functionPtr : FFI.Spec a -> FFI.Type (FFI.FunctionPtr a) — name a function pointer as a C argument type
    • FFI.newCallback : FFI.Spec a -> a ->{IO} FFI.FunctionPtr a / FFI.freeCallback — the lifecycle pair
  • File permission builtins (#6329, closes #2790): IO.getFilePermissions / IO.setFilePermissions builtins, wrapped in base as IO.FilePath.getPermissions / setPermissions (base contribution #167).

6. Typechecker performance improvements

Two PRs addressing slowness reported in #6312 (wide chains of overloaded operators needing TDNR), but the fixes improve typechecking speed generally:

  • #6322: TDNR resolutions now apply in one pass over the term instead of one visit each; ABT.substsInheritAnnotation became a single simultaneous substitution; quadratic list-appending in the parser and ANF contexts switched to Seq.
  • #6323: the typechecker's ordered context was rebuilt. The old finger-tree measure recomputed set unions on every split; the new design keeps per-variable indices keyed by name and "positions" that only need relative ordering (a path of ints, so insertion never touches existing entries). Solving an existential is now three map lookups plus one log-time replacement.

Combined effect on a 2000-term x + y + z + ... chain (the stress case): 29.5 s and 3.7 GB → 1.31 s and 252 MB. Property tests cover the new structure against a reference implementation.

7. CI, build, and housekeeping

  • macOS runners pinned to macos-15 (#6309, #6310): macos-latest moved to a macOS 27 SDK whose arm64e.x1 GHC's linker rejects; test and release paths are pinned.
  • Attestation system overhaul (#6307, #6319, #6338): proofs are now one file per hash (no more merge conflicts between queued PRs), sources hash with comments/formatting normalized, partial transcript attestations exist for quick PR checks, a 🤖 run full verification comment triggers a from-scratch run, trunk caches are warmed after every push (merge-queue builds were spending 20–48 min on cold dependency builds), and the merge queue no longer trusts attestations — it runs every transcript itself.
  • Transcript coverage across platforms: io.md now runs on macOS and Windows too, not just Linux (#6339).
  • Platform-independent transcript output, transcripts on every platform in the merge queue (#6347): rewritten-file paths always print with / separators regardless of platform, and Windows/macOS transcripts now run in the merge queue — so the Windows-only output mismatch that briefly failed this release's cut is caught at merge time from now on.
  • minify fix for Linux arm64 (#6340): the linker's Cortex-A53 workaround fooled minify's reference-crawling, crashing minified unisonrt with the JIT on.
  • Branch preloads can't outlive the codebase (#6337): branch preloading threads now run in a ki scope tied to the codebase's lifetime, fixing a flaky Windows failure where a stray SQLite connection raced directory deletion.
  • Portable shebangs (#6324): bash scripts use #!/usr/bin/env bash (NixOS-friendly).
  • Stale-bot (#6346): issues/PRs inactive for 180 days are now closed automatically with an explanatory comment.

Trying it

# JIT (falls back to the interpreter if LLVM is missing)
ucm --jit on            # or UNISON_JIT=on

# Standalone binaries (experimental)
ucm bundle myproject/main:hello && ./hello
  • Records: read new-records.md for the full tour.
  • MCP: point your agent at the ucm MCP server. For instance, try asking it how to use structural rewrites to add a new parameter to a function in an automated fashion.
  • JIT internals: design.md and usage.md.

Currently, optimization passes are turned on by default, but if you encounter any issues with them, please report, and you can switch off optimizations by setting this environment variable:

UNISON_OPTIMIZATIONS=none

or see usage.md for additional controls.

Install or upgrade

macOS or Linux with Homebrew:

brew upgrade unisonweb/unison/unison-language

Manual install — download the archive for your platform, then curl -L <url> | tar -xz (.zip and extract on Windows) and run ./ucm (ucm.exe on Windows):

Platform Download
macOS (Apple silicon) ucm-macos-arm64.tar.gz
macOS (Intel) ucm-macos-x64.tar.gz
Linux (arm64) ucm-linux-arm64.tar.gz
Linux (x86-64) ucm-linux-x64.tar.gz
Windows (x86-64) ucm-windows-x64.zip

Upgrading from 1.x: existing codebases migrate automatically to the new codebase schema on first launch — nothing to do by hand. The JIT is off by default; using it needs an LLVM 20+ shared library (ucm --jit on), and everything runs interpreted otherwise.

New contributors

Welcome, and thank you, to everyone whose first Unison PR landed in this release series:

Full changelog: release/1.5.0...release/2.0.0

Appendix: every PR, in merge order

Date PR Title
2026-10-14 #6143 Anonymous Records
2026-10-15 #6305 Nicer inferred and displayed record types
2026-10-17 #6309 Pin macOS CI runners to a supported SDK
2026-10-17 #6307 Add schema migration for record types, improve tests and CI
2026-10-17 #6310 Pin the release path's macOS runners to macos-15
2026-10-22 #6306 Unison → C callbacks (FFI function pointers)
2026-10-22 #6319 The merge queue runs all transcripts regardless of attestations
2026-10-22 #6321 Rename FFI callback builtins to avoid abbreviations
2026-10-25 #6317 LLVM-based JIT compiler
2026-10-26 #6322 Typechecker performance improvements
2026-10-28 #6323 More efficient data structure for typechecker context
2026-11-03 #6328 Revamp MCP server and related commands
2026-11-06 #6330 Optimizations for interpreter and JIT
2026-11-06 #6331 JIT support for lower latency non-moving GC
2026-11-08 #6335 Fix bug related to wide calling convention
2026-11-09 #6336 Standalone binaries
2026-11-10 #6311 Fix LSP not allowing multiple connections
2026-11-10 #6327 LSP: trigger completions after a '.'
2026-11-10 #6338 Tweak to CI attestation system to prevent needless conflicts
2026-11-10 #6337 Branch preloads never outlive the codebase
2026-11-10 #6339 Run io.md on macOS and Windows too
2026-11-11 #6326 Add clickable error locations to UCM-emitted warnings/errors
2026-11-11 #6324 Make the shebang in various bash scripts more portable
2026-11-11 #6340 minify: fix a crash in minified unisonrt on Linux arm64
2026-11-11 #6329 File permission builtins
2026-11-11 #6341 Restore FZF for interactive mode UCM
2026-11-11 #6342 JIT: fix quadratic code size at exits
2026-11-13 #6343 Show ucm, not unison, as the program name in help and messages
2026-11-16 #6346 Close inactive issues and pull requests
2026-11-19 #6347 Use forward slashes for rewritten file paths; run transcripts on all platforms in the merge queue

2.0.1

  • Allow issue authors to reopen auto-closed inactive issues by @pchiusano in #6351
  • Decode compiled programs strictly, so a loaded program holds values instead of thunks by @conikeec in #6348
  • Fix pretty-printing of record sections by @pchiusano in #6353
  • Fix deoptimization of lets removed as dead by the optimizer by @pchiusano in #6355

Full Changelog: release/2.0.0...release/2.0.1

2.0.2

  • Revert the rename of FFI.Func built-in type to FFI.FunctionPtr by @Baccata in #6356

Full Changelog: release/2.0.1...release/2.0.2