working. checkpoint before messing with parser

This commit is contained in:
2024-06-25 13:27:11 -07:00
parent a9c72d5a6d
commit 968327cdb3
8 changed files with 171 additions and 32 deletions

View File

@@ -6,10 +6,11 @@ import Lib.Parser.Impl
import Data.Vect
import Data.String
import Lib.TT
import Lib.TopContext
import Syntax
-- cribbed this, it avoids MonadError String m => everywhere
parameters {0 m : Type -> Type} {auto _ : MonadError String m}
parameters {0 m : Type -> Type} {auto _ : MonadError String m} (top : TopContext)
export
infer : Context -> Raw -> m (Tm, Val)
@@ -33,7 +34,7 @@ parameters {0 m : Type -> Type} {auto _ : MonadError String m}
infer ctx (RVar nm) = go 0 ctx.types
where
go : Nat -> List (String, Val) -> m (Tm, Val)
go : Nat -> Vect n (String, Val) -> m (Tm, Val)
go i [] = throwError "\{show nm} not in scope \{show $ map fst ctx.types}"
go i ((x, ty) :: xs) = if x == nm then pure $ (Bnd i, ty)
else go (i + 1) xs