Skip to content

Add Option/Result combinators (#211)#292

Merged
aallan merged 1 commit into
mainfrom
feature/211-option-result-combinators
Mar 12, 2026
Merged

Add Option/Result combinators (#211)#292
aallan merged 1 commit into
mainfrom
feature/211-option-result-combinators

Conversation

@aallan

@aallan aallan commented Mar 12, 2026

Copy link
Copy Markdown
Owner

Summary

  • Ships 5 combinator functions: option_unwrap_or, option_map, option_and_then, result_unwrap_or, result_map
  • Eliminates 5-line match blocks for every fallible operation — the highest-value Tier 0 roadmap item
  • Implements via source injection: combinators defined as Vera source, parsed to AST, injected into the program before compilation
  • Fixes generic type alias return type inference, AnonFn type variable inference in the monomorphizer, closure signature deduplication
  • Renames map_option to option_map across entire codebase per Built-in function naming consistency audit #288 naming convention
  • Adds spec section 9.3.7, SKILL.md docs, conformance test, 12 unit tests
  • Version bump to v0.0.89

Closes #211

Test plan

  • All 2,330 tests pass (pytest tests/ -v)
  • mypy clean (mypy vera/)
  • All 54 conformance programs pass (check_conformance.py)
  • All 25 examples pass (check_examples.py)
  • Spec, SKILL.md, README, HTML code blocks validate
  • Doc counts consistent
  • Version sync clean
  • Pre-commit hooks pass (17/17)

Generated with Claude Code

Ship 5 combinator functions (option_unwrap_or, option_map,
option_and_then, result_unwrap_or, result_map) that eliminate
5-line match blocks for every fallible operation.

Implementation: define as Vera source, inject into program AST via
prelude, compile through existing monomorphization pipeline.

Key compiler fixes for generic closures:
- Monomorphizer infers type variables from AnonFn arguments
- WASM call rewriter handles AnonFn against type alias FnType params
- Generic type alias return type inference with substitution
- Closure signature deduplication across functions

Also renames map_option → option_map per #288 naming convention.

Closes #211

Co-Authored-By: Claude <noreply@anthropic.invalid>
@aallan aallan merged commit 68195ae into main Mar 12, 2026
11 checks passed
@aallan aallan deleted the feature/211-option-result-combinators branch March 12, 2026 21:08
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.

Option and Result combinators

1 participant