MatchMaker.jl
Julia-native symbolic pattern matching and rewriting for SymbolicUtils.jl expressions: literals, slots, sequence captures, optional positions, and associative/commutative matching with deterministic enumeration.
using MatchMaker, SymbolicUtilsWhich API should I use?
| I want to… | Use |
|---|---|
| test whether a pattern matches a subject | match |
| get every match as dictionaries | matchall |
| stream matches lazily | matches / boundmatches |
| count or compare matches cheaply | boundmatches / boundmatchall |
| find where a pattern matches inside a subject | boundmatches_at / matches_at |
| substitute bindings into a template | instantiate |
| rewrite a term with rules | mmrule + RuleWorkspace |
| rewrite a whole tree | rewrite |
| rewrite to a fixed point | fixpoint_rewrite |
| customize matching engine internals | MatchEngine + next_match! |
The mental model
- Compile once —
compile_patternbuilds aMatcher(ormmrule/RuleSetfor rewriting); the compiled form is immutable and shareable. - Match at sites — the match functions drive a
MatchEngineover the pattern; results arrive as bindings keyed by variableSym. - Consume results — lazily (
SubstitutionView,BoundMatch) or materialized (MarkersMap), theninstantiateinto a template or feedRuleWorkspacerewrites.
See the Tutorial for a worked end-to-end example and the user guide for the semantics reference.
Module
MatchMaker.MatchMaker — Module
MatchMakerSymbolic pattern matching on top of SymbolicUtils.jl.
The governing design document is DESIGN.md (section references throughout source comments point at it); DEVELOPING.md documents codebase navigation and the implicit contracts between components. This module file only declares dependencies and wires includes together; the file layout is DESIGN.md §6.