refactor: move OpenDecl to Data
This commit is contained in:
parent
1ce80d5ba7
commit
c8a4252461
2 changed files with 30 additions and 19 deletions
29
src/Lean/Data/OpenDecl.lean
Normal file
29
src/Lean/Data/OpenDecl.lean
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
/-
|
||||
Copyright (c) 2020 Microsoft Corporation. All rights reserved.
|
||||
Released under Apache 2.0 license as described in the file LICENSE.
|
||||
Authors: Leonardo de Moura
|
||||
-/
|
||||
import Lean.Data.Name
|
||||
|
||||
namespace Lean
|
||||
|
||||
inductive OpenDecl
|
||||
| simple (ns : Name) (except : List Name)
|
||||
| explicit (id : Name) (declName : Name)
|
||||
|
||||
namespace OpenDecl
|
||||
instance : Inhabited OpenDecl := ⟨simple Name.anonymous []⟩
|
||||
|
||||
instance : HasToString OpenDecl :=
|
||||
⟨fun decl => match decl with
|
||||
| explicit id decl => toString id ++ " → " ++ toString decl
|
||||
| simple ns ex => toString ns ++ (if ex == [] then "" else " hiding " ++ toString ex)⟩
|
||||
|
||||
end OpenDecl
|
||||
|
||||
def rootNamespace := `_root_
|
||||
|
||||
def removeRoot (n : Name) : Name :=
|
||||
n.replacePrefix rootNamespace Name.anonymous
|
||||
|
||||
end Lean
|
||||
|
|
@ -3,6 +3,7 @@ Copyright (c) 2019 Microsoft Corporation. All rights reserved.
|
|||
Released under Apache 2.0 license as described in the file LICENSE.
|
||||
Authors: Leonardo de Moura, Sebastian Ullrich
|
||||
-/
|
||||
import Lean.Data.OpenDecl
|
||||
import Lean.Hygiene
|
||||
import Lean.Modifiers
|
||||
import Lean.Elab.Alias
|
||||
|
|
@ -10,25 +11,6 @@ import Lean.Elab.Alias
|
|||
namespace Lean
|
||||
namespace Elab
|
||||
|
||||
inductive OpenDecl
|
||||
| simple (ns : Name) (except : List Name)
|
||||
| explicit (id : Name) (declName : Name)
|
||||
|
||||
namespace OpenDecl
|
||||
instance : Inhabited OpenDecl := ⟨simple Name.anonymous []⟩
|
||||
|
||||
instance : HasToString OpenDecl :=
|
||||
⟨fun decl => match decl with
|
||||
| explicit id decl => toString id ++ " → " ++ toString decl
|
||||
| simple ns ex => toString ns ++ (if ex == [] then "" else " hiding " ++ toString ex)⟩
|
||||
|
||||
end OpenDecl
|
||||
|
||||
def rootNamespace := `_root_
|
||||
|
||||
def removeRoot (n : Name) : Name :=
|
||||
n.replacePrefix rootNamespace Name.anonymous
|
||||
|
||||
/- Global name resolution -/
|
||||
|
||||
/- Check whether `ns ++ id` is a valid namepace name and/or there are aliases names `ns ++ id`. -/
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue