lean4-htt/library/Init/Lean/ToExpr.lean
Leonardo de Moura c768a24735 chore: mkApp => mkAppN
We are goint to use `mkApp` for creating unary applications
2019-11-14 15:44:17 -08:00

30 lines
826 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 => 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