lean4-htt/tests/lean/run/evalconst.lean
Leonardo de Moura 5ffbada3df feat: add Lean.MonadEnv, Lean.MonadError, and Lean.MonadOptions
This is the first set of polymorphic methods. I will add more later,
and keep reducing code duplication.

cc @Kha
2020-08-22 16:00:43 -07:00

21 lines
320 B
Text

import Lean
open Lean
def x := 10
unsafe def tst : CoreM Unit := do
env ← getEnv;
IO.println $ env.evalConst Nat `x;
pure ()
#eval tst
def f (x : Nat) := x + 1
unsafe def tst2 : CoreM Unit := do
env ← getEnv;
f ← liftIO $ IO.ofExcept $ env.evalConst (Nat → Nat) `f;
IO.println $ (f 10);
pure ()
#eval tst2