Skip to content

Add Ord/Hash/Show abilities, ADT auto-derivation, Ordering ADT (v0.0.90)#300

Merged
aallan merged 1 commit into
mainfrom
feat/abilities-codegen
Mar 13, 2026
Merged

Add Ord/Hash/Show abilities, ADT auto-derivation, Ordering ADT (v0.0.90)#300
aallan merged 1 commit into
mainfrom
feat/abilities-codegen

Conversation

@aallan

@aallan aallan commented Mar 13, 2026

Copy link
Copy Markdown
Owner

Summary

  • Four built-in abilities complete: Eq (from PRs 1–3) + Ord, Hash, Show (this PR)
  • Built-in Ordering ADT: data Ordering { Less, Equal, Greater } for compare results
  • ADT auto-derivation for Eq: Simple enums and ADTs with Eq-satisfying fields automatically satisfy the Eq constraint
  • Constrained generics: forall<T where Ability<T>> fully operational across all four abilities
  • Version bump to v0.0.90

Closes #60

What changed

Compiler (8 files, +1862/−129 lines)

File Change
vera/environment.py Register Ordering ADT + Ord/Hash/Show abilities
vera/codegen/registration.py Ordering constructor layouts
vera/codegen/monomorphize.py Constraint satisfaction for all abilities + ADT auto-derivation
vera/codegen/core.py Pass 1.6: compare(a,b) rewriting to nested IfExpr
vera/wasm/calls.py WASM dispatch for show (type-directed) and hash (FNV-1a for strings)
vera/wasm/operators.py String equality + ADT structural equality in WASM
vera/wasm/inference.py IfExpr/Block type inference (needed for rewritten compare)
vera/codegen/modules.py Cross-module ability op recognition

Tests (2 files)

  • 20 new unit tests in TestAbilityConstraints covering all 4 abilities + ADT derivation + unsatisfied constraint
  • 14 new conformance functions in ch09_abilities.vera (6 → 20 total)

Documentation (10 files)

  • Spec §9.8.1–9.8.3: Full ability documentation
  • SKILL.md: Complete ability reference with examples
  • CHANGELOG, ROADMAP, README, docs/index.html updated

Test plan

  • pytest tests/ -v — 2375 tests pass
  • mypy vera/ — clean
  • python scripts/check_conformance.py — 55 conformance programs pass
  • python scripts/check_examples.py — 25 examples pass
  • python scripts/check_version_sync.py — version in sync
  • python scripts/check_doc_counts.py — counts match
  • python scripts/check_limitations_sync.py — tables in sync
  • python scripts/check_spec_examples.py — spec blocks parse
  • python scripts/check_readme_examples.py — README blocks parse
  • python scripts/check_skill_examples.py — SKILL blocks parse
  • python scripts/check_html_examples.py — HTML blocks check + verify

🤖 Generated with Claude Code

Complete the abilities feature (#60) with full codegen for all four
built-in abilities. Register Ordering ADT and Ord/Hash/Show abilities
in the type environment. Extend constraint satisfaction to all abilities
with per-ability type sets. Implement ADT auto-derivation for Eq via
structural equality (tag + field comparison). Add compare rewriting in
Pass 1.6 and WASM-level dispatch for show (to_string routing) and hash
(FNV-1a for strings, identity/extend/reinterpret for primitives). Fix
IfExpr/Block handling in _infer_expr_wasm_type. Add string equality via
byte-by-byte comparison. 20 unit tests, extended conformance test with
20 test functions. Version bump to 0.0.90. Documentation updated across
spec, SKILL.md, README, ROADMAP, CHANGELOG, and docs/index.html.

Closes #60

Co-Authored-By: Claude <noreply@anthropic.invalid>
@aallan aallan merged commit b5c9559 into main Mar 13, 2026
11 checks passed
@aallan aallan deleted the feat/abilities-codegen branch March 13, 2026 15:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Abilities and type constraints

1 participant