module Minilang.Lambda where import Minilang.Lambda.DeBruijn (eval, fromDeBruijn, toDeBruijn) import Minilang.Lambda.Eval (Env, Term) import Minilang.Lambda.Infer (Context, TypeError, infer) import Minilang.Lambda.Parser (AST, desugar) import Minilang.Lambda.Unify (Type) -- | Top-level evaluator -- Load an AST into given `Env` and `Context`, returning an extended -- `Env` and `Context` with declarations bound loadProgram :: AST -> Env -> Context -> Either TypeError (Term, Type, Env, Context) -- loadProgram (Let d r) ρ γ = do -- (ρ', γ') <- checkD 0 d ρ γ -- loadProgram r ρ' γ' loadProgram expr env context = let term = desugar expr in case infer term of Left typeError -> Left typeError Right typ -> Right (fromDeBruijn $ eval (toDeBruijn term), typ, env, context)