1
1
import lean.extra.attrs.dummy
2
2
import lean.extra.attrs.tag
3
+ import lean.extra.attrs.parametric
3
4
/-
4
5
# Attributes
5
6
@@ -11,7 +12,7 @@ we will bounce between this file and the files in the `attrs/` folder which
11
12
contain the implementations of the attributes. We'll see you at
12
13
[ `./attrs/tag.lean` ] (./attrs/tag.lean).
13
14
14
- ## Using `myTag`
15
+ ## Tag attributes with `myTag`
15
16
16
17
see that we've created a tagging infrastructure based on Lean's `TagAttribute`s, which exists
17
18
explicitly to allow us to create 'simple' attributes that wish to keep track of
@@ -37,6 +38,26 @@ This simplified mechanism exists to allow us to easily tag definitions of intere
37
38
-- decl: tag2 | find? OfNat.ofNat.{0} Int 2 (Int.instOfNatInt 2)
38
39
39
40
41
+ /-
42
+ ## Parametric attributes with `myParam`
43
+
44
+ A parametric attribute is like a tag attribute, while adding support for
45
+ parameters in the attribute.
46
+
47
+ We shall add an attribute called `myParam`, which recieves two parameters,
48
+ a priority, denoted by a natural number, and an optional tag `important`.
49
+
50
+
51
+ We'll see you at [ `./attrs/parametric.lean` ] (./attrs/dummy.lean).
52
+
53
+ -/
54
+
55
+
56
+
57
+ @[myParam 10 ] def h1 (x : Nat) := 2 *x + 1
58
+ @[myParam 20 important] def h2 (x : Nat) := 2 *x + 1
59
+
60
+
40
61
/-
41
62
## Using `dummy_attr`
42
63
@@ -77,5 +98,11 @@ class bar
77
98
## Modifying the `value` with the `around` attribute
78
99
79
100
We're going to write an attribute that will modify a given definition
101
+
102
+
103
+ ## Implementing `sym`:
104
+ Scoped environment extension maintains scoping information, so it keeps track of
105
+ whether the tag is local or not.
80
106
-/
81
107
108
+
0 commit comments