lean4-htt/src/Lean/Eval.lean
2020-11-27 15:09:30 -08:00

24 lines
860 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, Sebastian Ullrich
-/
import Lean.Environment
namespace Lean
universe u
/-- `Eval` extension that gives access to the current environment & options.
The basic `Eval` class is in the prelude and should not depend on these
types. -/
class MetaEval (α : Type u) where
eval : Environment → Options → α → (hideUnit : Bool) → IO Environment
instance {α : Type u} [Eval α] : MetaEval α :=
⟨fun env opts a hideUnit => do Eval.eval (fun _ => a) hideUnit; pure env⟩
def runMetaEval {α : Type u} [MetaEval α] (env : Environment) (opts : Options) (a : α) : IO (String × Except IO.Error Environment) :=
IO.FS.withIsolatedStreams (MetaEval.eval env opts a false)
end Lean