lean4-htt/library/Init/Lean/ToExpr.lean
Leonardo de Moura c341486e28 refactor: avoid Expr constructors
Using `mk*` functions instead.
Reason: preparing to remove `src/kernel/expr.cpp` hack.
2019-11-14 16:32:45 -08:00

30 lines
770 B
Text
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/-
Copyright (c) 2019 Microsoft Corporation. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Leonardo de Moura
-/
prelude
import Init.Lean.Expr
universe u
namespace Lean
class ToExpr (α : Type u) :=
(toExpr : α → Expr)
export ToExpr (toExpr)
instance exprToExpr : ToExpr Expr := ⟨id⟩
instance natToExpr : ToExpr Nat := ⟨mkNatLit⟩
instance strToExpr : ToExpr String := ⟨mkStrLit⟩
def nameToExprAux : Name → Expr
| Name.anonymous => mkConst `Lean.Name.anonymous
| Name.mkString p s => mkCAppB `Lean.Name.mkString (nameToExprAux p) (toExpr s)
| Name.mkNumeral p n => mkCAppB `Lean.Name.mkNumeral (nameToExprAux p) (toExpr n)
instance nameToExpr : ToExpr Name := ⟨nameToExprAux⟩
end Lean