diff options
author | Greg Brown <greg.brown01@ed.ac.uk> | 2024-02-01 19:25:13 +0000 |
---|---|---|
committer | Greg Brown <greg.brown01@ed.ac.uk> | 2024-02-02 13:33:09 +0000 |
commit | 4b9b6b0211f6fb5691d67ca77ac09be888e569b7 (patch) | |
tree | 33451a63c169a06d0fee67393d0bf081f7e0b1e3 /src/SOAS/Context.idr | |
parent | fa4de437fa3861189b506538f6ca4a39771ecbbb (diff) |
Define generic syntax construction.main
Whilst it works (see `Example`), a generated data type would probably
work better.
Diffstat (limited to 'src/SOAS/Context.idr')
-rw-r--r-- | src/SOAS/Context.idr | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/src/SOAS/Context.idr b/src/SOAS/Context.idr index ef657ae..e2f3c03 100644 --- a/src/SOAS/Context.idr +++ b/src/SOAS/Context.idr @@ -16,7 +16,7 @@ data (.Ctx) : (type : Type) -> Type where public export data (.Erased) : type.Ctx -> Type where Z : [<].Erased - S : ctx.Erased -> (ctx :< x).Erased + S : ctx.Erased -> (ctx :< (n :- ty)).Erased public export (.toNat) : ctx.Erased -> Nat @@ -27,3 +27,27 @@ public export (++) : (ctx1,ctx2 : type.Ctx) -> type.Ctx ctx1 ++ [<] = ctx1 ctx1 ++ (ctx2 :< ty) = (ctx1 ++ ctx2) :< ty + +namespace All + public export + data (.All) : type.Ctx -> (p : (0 n : String) -> type -> Type) -> Type where + Lin : [<].All p + (:<) : ctx.All p -> p n ty -> (ctx :< (n :- ty)).All p + + public export + head : (ctx :< (n :- ty)).All p -> p n ty + head (sx :< px) = px + + public export + tail : (ctx :< (n :- ty)).All p -> ctx.All p + tail (sx :< px) = sx + +public export +(.rename) : (ctx : type.Ctx) -> (0 names : ctx.All (\_,_ => String)) -> type.Ctx +[<].rename names = [<] +(ctx :< (_ :- ty)).rename names = ctx.rename (tail names) :< (head names :- ty) + +export +erasedRename : ctx.Erased -> (ctx.rename names).Erased +erasedRename Z = Z +erasedRename (S length) = S (erasedRename length) |