summaryrefslogtreecommitdiff
path: root/src/Core/Term
diff options
context:
space:
mode:
authorChloe Brown <chloe.brown.00@outlook.com>2023-04-01 13:58:46 +0100
committerChloe Brown <chloe.brown.00@outlook.com>2023-04-01 13:58:46 +0100
commitf19665eac65f9a37dcde85eb58e7d4b5b4a22bcf (patch)
tree0bdae73731c7ec36bac2942d99dba7877ffe723c /src/Core/Term
parent53ff29fda182629b9fd284b196ad67a47c95a777 (diff)
Make environments do weakening lazily.
This is in anticipation for defining well-formed thinnings.
Diffstat (limited to 'src/Core/Term')
-rw-r--r--src/Core/Term/Environment.idr12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/Core/Term/Environment.idr b/src/Core/Term/Environment.idr
index 7b05ec0..62e3b60 100644
--- a/src/Core/Term/Environment.idr
+++ b/src/Core/Term/Environment.idr
@@ -12,10 +12,16 @@ import Core.Var
public export
data Env : Context -> Type where
Lin : Env [<]
- (:<) : Env sx -> Term sx -> Env (sx :< n)
+ Add : Env sx -> sy `Thins` sx -> Term sy -> Env (sx :< n)
%name Env env
+-- Constructors ----------------------------------------------------------------
+
+public export
+(:<) : Env sx -> Term sx -> Env (sx :< n)
+env :< t = Add env (id _) t
+
-- Operations ------------------------------------------------------------------
record IndexResult (sx : Context) where
@@ -25,8 +31,8 @@ record IndexResult (sx : Context) where
thin : sy `Thins` sx
doIndex : Env sx -> {0 i : Var sx} -> View i -> IndexResult sx
-doIndex (env :< t) Here = MkRes t (drop (id _) _)
-doIndex (env :< t) (There i) =
+doIndex (Add env thin t) Here = MkRes t (drop thin _)
+doIndex (Add env thin t) (There i) =
let MkRes val thin = doIndex env $ view i in
MkRes val (drop thin _)