gvwilson / gvwilson/l4py

Metaprogramming & DSL Construction

Open
#2 0 comments 0 reactions 1 assignee Claimed by @gvwilson View on GitHub
add
Dominant language
Lean
Stars
2
Forks
0
PR merge metrics
No merged PRs in 30d

Description

## Metaprogramming & DSL Construction

The biggest gap. Lean 4 was redesigned around extensible syntax — this is its
killer feature for programming.

- **`macro`**: define compile-time syntax transformations. The simplest way to
create custom notation, control-flow constructs, or domain-specific syntax.
- **`syntax` and `elab`**: define entirely new syntactic categories and their
elaborators. This is how `do`-notation and `∑` notation were built — users
can build the same class of extensions.
- **`elab` commands**: create new top-level commands (like `#eval` or `#check`
but for your own domain).
- **`macro_rules`**: extend an existing macro with additional cases without
modifying the original definition.
- **`quote` / `unquote` / `TSyntax`**: manipulate concrete syntax trees
programmatically — `TSyntax` is the AST type, `quote` embeds it back into
code.
- **`Lean.Elab.Command`**: run elaboration steps from within metaprogramming
code (useful for code generators and custom tooling).
- **`deriving` handlers**: write your own `deriving MyClass` generator so users
can auto-derive instances for your type classes.
- **Custom notation**: `infix`, `infixl`, `infixr`, `notation` for defining
operators and symbolic syntax like `x ⊕ y` or `⟦x⟧`.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.