lean4-htt/library/init/lean/toexpr.lean
2019-07-02 13:22:11 -07:00

30 lines
836 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 := ⟨fun n => Expr.lit (Literal.natVal n)⟩
instance strToExpr : ToExpr String := ⟨fun s => Expr.lit (Literal.strVal s)⟩
def nameToExprAux : Name → Expr
| Name.anonymous := mkConst `Lean.Name.anonymous
| (Name.mkString p s) := mkBinCApp `Lean.Name.mkString (nameToExprAux p) (toExpr s)
| (Name.mkNumeral p n) := mkBinCApp `Lean.Name.mkNumeral (nameToExprAux p) (toExpr n)
instance nameToExpr : ToExpr Name := ⟨nameToExprAux⟩
end Lean