use a SnocVect for subN

This commit is contained in:
rhiannon morris 2023-03-26 16:09:47 +02:00
parent 8402da6d5e
commit 84e1cc78cc
4 changed files with 17 additions and 19 deletions

View file

@ -7,7 +7,7 @@ import Quox.Pretty
import Data.Nat
import Data.List
import Data.Vect
import Data.SnocVect
%default total
@ -101,13 +101,13 @@ drop1 (t ::: th) = th
public export
fromVect : Vect s (f n) -> Subst f (s + n) n
fromVect [] = id
fromVect (x :: xs) = x ::: fromVect xs
fromSnocVect : SnocVect s (f n) -> Subst f (s + n) n
fromSnocVect [<] = id
fromSnocVect (xs :< x) = x ::: fromSnocVect xs
public export %inline
one : f n -> Subst f (S n) n
one x = fromVect [x]
one x = fromSnocVect [< x]
||| `prettySubst pr names bnd op cl th` pretty-prints the substitution `th`,

View file

@ -2,7 +2,7 @@ module Quox.Syntax.Term.Subst
import Quox.No
import Quox.Syntax.Term.Base
import Data.Vect
import Data.SnocVect
%default total
@ -172,22 +172,22 @@ parameters {s : Nat}
export %inline
subN : ScopeTermN s q d n -> Vect s (Elim q d n) -> Term q d n
subN (S _ (Y body)) es = body // fromVect es
subN : ScopeTermN s q d n -> SnocVect s (Elim q d n) -> Term q d n
subN (S _ (Y body)) es = body // fromSnocVect es
subN (S _ (N body)) _ = body
export %inline
sub1 : ScopeTerm q d n -> Elim q d n -> Term q d n
sub1 t e = subN t [e]
sub1 t e = subN t [< e]
export %inline
dsubN : DScopeTermN s q d n -> Vect s (Dim d) -> Term q d n
dsubN (S _ (Y body)) ps = body // fromVect ps
dsubN : DScopeTermN s q d n -> SnocVect s (Dim d) -> Term q d n
dsubN (S _ (Y body)) ps = body // fromSnocVect ps
dsubN (S _ (N body)) _ = body
export %inline
dsub1 : DScopeTerm q d n -> Dim d -> Term q d n
dsub1 t p = dsubN t [p]
dsub1 t p = dsubN t [< p]
public export %inline