lean4-htt/tests/lean/run/eval_attr_cache.lean
Sebastian Ullrich 3188c4cbcf refactor(library/tactic/user_attribute,init/meta/attribute): merge caching_user_attribute into user_attribute
The inheritance-based approach doesn't scale to a second subclass for parameterized attributes
2017-09-05 23:14:34 +02:00

24 lines
716 B
Text

open tactic
@[user_attribute]
meta def my_attr : user_attribute (name → bool) :=
{ name := "my_attr",
descr := "my attr",
cache_cfg := {
mk_cache := λ ls, do {
let c := `(λ n : name, (name.cases_on n ff (λ _ _, to_bool (n ∈ ls)) (λ _ _, ff) : bool)),
eval_expr (name → bool) c
},
dependencies := []}
}
meta def my_tac : tactic unit :=
do f ← my_attr.get_cache,
trace (f `foo),
return ()
@[my_attr] def bla := 10
run_cmd my_tac
@[my_attr] def foo := 10 -- Cache was invalided
run_cmd my_tac -- Add closure to the cache containing auxiliary function created by eval_expr
run_cmd my_tac -- Cache should be flushed since the auxiliary function is gone