Issue Type
Feature Proposal
Description
Lift an arbitrary unary predicate into a first-class pattern, evaluated during the match phase rather than as a post-bind guard.
match(x) | on(
pred([](int v) { return v % 2 == 0; }) >> "even",
_ >> "odd"
);
Rationale / Motivation
Currently, evaluating a predicate requires a post-bind guard (e.g., using PTN_WHERE or operator []). A first-class predicate pattern reads more naturally and allows the matching engine to evaluate the condition earlier in the pipeline. It also enables native composition within combinators like any(...) or all(...) without requiring intermediate bindings. This is tracked under the WIP section of the roadmap.md.
Alternatives Considered
Using standard guards (pattern[guard]), but pred(...) offers better ergonomics for simple unary callables and integrates seamlessly with other pattern combinators.
Checklist
Issue Type
Feature Proposal
Description
Lift an arbitrary unary predicate into a first-class pattern, evaluated during the match phase rather than as a post-bind guard.
Rationale / Motivation
Currently, evaluating a predicate requires a post-bind guard (e.g., using
PTN_WHEREor operator[]). A first-class predicate pattern reads more naturally and allows the matching engine to evaluate the condition earlier in the pipeline. It also enables native composition within combinators likeany(...)orall(...)without requiring intermediate bindings. This is tracked under the WIP section of theroadmap.md.Alternatives Considered
Using standard guards (
pattern[guard]), butpred(...)offers better ergonomics for simple unary callables and integrates seamlessly with other pattern combinators.Checklist