11import lean.extra.attrs.dummy
22import lean.extra.attrs.tag
3+ import lean.extra.attrs.parametric
34/-
45# Attributes
56
@@ -11,7 +12,7 @@ we will bounce between this file and the files in the `attrs/` folder which
1112contain the implementations of the attributes. We'll see you at
1213[ `./attrs/tag.lean` ] (./attrs/tag.lean).
1314
14- ## Using `myTag`
15+ ## Tag attributes with `myTag`
1516
1617see that we've created a tagging infrastructure based on Lean's `TagAttribute`s, which exists
1718explicitly 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
3738-- decl: tag2 | find? OfNat.ofNat.{0} Int 2 (Int.instOfNatInt 2)
3839
3940
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+
4061/-
4162## Using `dummy_attr`
4263
@@ -77,5 +98,11 @@ class bar
7798## Modifying the `value` with the `around` attribute
7899
79100We'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.
80106-/
81107
108+
0 commit comments