lean4-htt/src/Lean/Data/OpenDecl.lean
Markus Himmel 4deb8d5b50
chore: do not use internal append in ToString instances for basic types (#12885)
This PR shifts some material in `Init` to make sure that the `ToString`
instances of basic types don't rely on `String.Internal.append`.
2026-03-11 15:25:54 +00:00

37 lines
911 B
Text

/-
Copyright (c) 2020 Microsoft Corporation. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Leonardo de Moura
-/
module
prelude
public import Init.Data.ToString.Name
public import Init.Data.ToString.Extra
public section
namespace Lean
/-- Data for representing `open` commands -/
inductive OpenDecl where
| simple (ns : Name) (except : List Name)
| explicit (id : Name) (declName : Name)
deriving BEq
namespace OpenDecl
instance : Inhabited OpenDecl := ⟨simple Name.anonymous []⟩
instance : ToString 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