Skip to content

Commit 7c7732b

Browse files
committed
document @[match_pattern]
1 parent 964bcad commit 7c7732b

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/Lean/Meta/Match/MatchPatternAttr.lean

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,25 @@ import Lean.Attributes
88

99
namespace Lean
1010

11+
/--
12+
Instructs the pattern matcher to unfold occurrences of this definition.
13+
14+
By default, only constructors and literals can be used for pattern matching. Using
15+
`@[match_pattern]` allows using other definitions, as long as they eventually reduce to
16+
constructors.
17+
18+
Example:
19+
```
20+
@[match_pattern]
21+
def yellowString : String := "yellow"
22+
23+
def isYellow (color : String) : Bool :=
24+
match color with
25+
| yellowString => true
26+
| _ => false
27+
```
28+
-/
29+
@[builtin_doc]
1130
builtin_initialize matchPatternAttr : TagAttribute ←
1231
registerTagAttribute `match_pattern "mark that a definition can be used in a pattern (remark: the dependent pattern matching compiler will unfold the definition)"
1332

0 commit comments

Comments
 (0)