lean4-htt/tests/lean/macro_scopes.lean
2018-12-19 15:04:48 +01:00

27 lines
838 B
Text

import init.lean.expander init.io
open lean.expander -- for coercions
open lean.parser
open lean.parser.term
local attribute [reducible] macro_scope
-- TODO(Sebastian): `syntax.to_format` should probably propagate scopes by itself in the end
#eval (do {
let stx := review pi {op := syntax.atom {val := "Π"}, binders := ["a"], range := review sort sort.view.Type},
-- tag root with {1}
let stx := stx.flip_scopes [1],
io.println stx,
-- tag root with {2} and propagate once
let stx := stx.flip_scopes [2],
some n ← pure stx.as_node,
let stx := syntax.mk_node n.kind n.args,
io.println stx,
-- flip {2}
let stx := stx.flip_scopes [2],
io.println stx,
-- propagate once, only {1} remains
some n ← pure stx.as_node,
let stx := syntax.mk_node n.kind n.args,
io.println stx
} : except_t string io unit)