summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/top.ur2
-rw-r--r--src/reduce.sml18
2 files changed, 18 insertions, 2 deletions
diff --git a/lib/top.ur b/lib/top.ur
index 4df12ff0..d94f8bf6 100644
--- a/lib/top.ur
+++ b/lib/top.ur
@@ -8,7 +8,7 @@ fun compose (t1 ::: Type) (t2 ::: Type) (t3 ::: Type) (f1 : t2 -> t3) (f2 : t1 -
fun txt (t ::: Type) (ctx ::: {Unit}) (use ::: {Type}) (sh : show t) (v : t) = cdata (show sh v)
-val foldTR2 (tf1 :: Type -> Type) (tf2 :: Type -> Type) (tr :: {Type} -> Type)
+fun foldTR2 (tf1 :: Type -> Type) (tf2 :: Type -> Type) (tr :: {Type} -> Type)
(f : nm :: Name -> t :: Type -> rest :: {Type} -> [nm] ~ rest
-> tf1 t -> tf2 t -> tr rest -> tr ([nm = t] ++ rest))
(i : tr []) =
diff --git a/src/reduce.sml b/src/reduce.sml
index 89b9b30e..9cc57cb2 100644
--- a/src/reduce.sml
+++ b/src/reduce.sml
@@ -148,7 +148,23 @@ fun exp env e =
and reduceExp env = U.Exp.mapB {kind = kind, con = con, exp = exp, bind = bind} env
-fun decl env d = d
+fun decl env d =
+ case d of
+ DValRec [vi as (_, n, _, e, _)] =>
+ let
+ fun kind _ = false
+ fun con _ = false
+ fun exp e =
+ case e of
+ ENamed n' => n' = n
+ | _ => false
+ in
+ if U.Exp.exists {kind = kind, con = con, exp = exp} e then
+ d
+ else
+ DVal vi
+ end
+ | _ => d
val reduce = U.File.mapB {kind = kind, con = con, exp = exp, decl = decl, bind = bind} E.empty