aboutsummaryrefslogtreecommitdiff
path: root/lib/Eval.ml
diff options
context:
space:
mode:
authorMalte Voos <git@mal.tc>2024-06-23 23:31:59 +0200
committerMalte Voos <git@mal.tc>2024-06-24 00:16:55 +0200
commit5d227bcd0055d02e1d49a3dcd27e80a756923d5b (patch)
treeda468ad3a8f3caf709b731ca2678c86a5a015990 /lib/Eval.ml
parent8d40541003736d5319ec981278338e8c8c66daf6 (diff)
downloadtoytt-5d227bcd0055d02e1d49a3dcd27e80a756923d5b.tar.gz
toytt-5d227bcd0055d02e1d49a3dcd27e80a756923d5b.zip
split code into smaller libraries and make a better repl
Diffstat (limited to 'lib/Eval.ml')
-rw-r--r--lib/Eval.ml56
1 files changed, 0 insertions, 56 deletions
diff --git a/lib/Eval.ml b/lib/Eval.ml
deleted file mode 100644
index bd8326e..0000000
--- a/lib/Eval.ml
+++ /dev/null
@@ -1,56 +0,0 @@
-open Bwd
-open Bwd.Infix
-
-module S = Syntax
-module D = Domain
-
-module Internal =
-struct
- module Eff = Algaeff.Reader.Make (struct type nonrec t = D.env end)
-
- let make_clo body = D.Clo { body; env = Eff.read() }
-
- let rec inst_clo (D.Clo { body; env }) arg =
- let env = env <: arg in
- Eff.run ~env @@ fun () -> eval body
-
- and app v w = match v with
- | D.Lam (_, clo) -> inst_clo clo w
- | D.Neutral (hd, frms) -> D.Neutral (hd, frms <: D.App w)
- | _ -> invalid_arg "Eval.app"
-
- and fst = function
- | D.Pair (v, _) -> v
- | D.Neutral (hd, frms) -> D.Neutral (hd, frms <: D.Fst)
- | _ -> invalid_arg "Eval.fst"
-
- and snd = function
- | D.Pair (_, v) -> v
- | D.Neutral (hd, frms) -> D.Neutral (hd, frms <: D.Snd)
- | _ -> invalid_arg "Eval.snd"
-
- and bool_elim motive_var motive true_case false_case = function
- | D.True -> true_case
- | D.False -> false_case
- | D.Neutral (hd, frms) -> D.Neutral (hd, frms <: D.BoolElim { motive_var; motive; true_case; false_case })
- | _ -> invalid_arg "Eval.bool_elim"
-
- and eval = function
- | S.Var i -> Bwd.nth (Eff.read()) i
- | S.Pi (name, base, fam) -> D.Pi (name, eval base, make_clo fam)
- | S.Lam (name, body) -> D.Lam (name, make_clo body)
- | S.App (a, b) -> app (eval a) (eval b)
- | S.Sg (name, base, fam) -> D.Sg (name, eval base, make_clo fam)
- | S.Pair (a, b) -> D.Pair (eval a, eval b)
- | S.Fst a -> fst (eval a)
- | S.Snd a -> snd (eval a)
- | S.Type -> D.Type
- | S.Bool -> D.Bool
- | S.True -> D.True
- | S.False -> D.False
- | S.BoolElim { motive_var; motive; true_case; false_case; scrut } ->
- bool_elim motive_var (make_clo motive) (eval true_case) (eval false_case) (eval scrut)
-end
-
-let eval ~env tm = Internal.Eff.run ~env @@ fun () -> Internal.eval tm
-let inst_clo = Internal.inst_clo