Preliminary work on data and holes
This commit is contained in:
@@ -3,14 +3,30 @@ module Lib.Check
|
||||
import Control.Monad.Error.Interface
|
||||
import Control.Monad.Identity
|
||||
import Lib.Parser.Impl
|
||||
import Lib.Prettier
|
||||
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 Error m} (top : TopContext)
|
||||
|
||||
|
||||
|
||||
-- IORef for metas needs IO
|
||||
parameters {0 m : Type -> Type} {auto _ : HasIO m} {auto _ : MonadError Error m} (top : TopContext)
|
||||
|
||||
-- unify : Nat -> Val -> Val -> m ()
|
||||
-- unify l (VLam _ _ t) (VLam _ _ u) = unify (l + 1) (t $$ VVar l) (u $$ VVar l)
|
||||
-- unify l t (VLam _ _ u) = unify (l + 1) (vapp t (VVar l)) (u $$ VVar l)
|
||||
-- unify l (VVar k) u = ?unify_rhs_0
|
||||
-- unify l (VRef str mt) u = ?unify_rhs_1
|
||||
-- unify l (VMeta k) u = ?unify_rhs_2
|
||||
-- unify l (VApp x y) u = ?unify_rhs_3
|
||||
-- unify l (VPi str icit x y) u = ?unify_rhs_5
|
||||
-- unify l VU u = ?unify_rhs_6
|
||||
|
||||
|
||||
export
|
||||
infer : Context -> Raw -> m (Tm, Val)
|
||||
|
||||
@@ -20,7 +36,7 @@ parameters {0 m : Type -> Type} {auto _ : MonadError Error m} (top : TopContext)
|
||||
check ctx (RLam nm icit tm) ty = case ty of
|
||||
(VPi pinm icit a b) => do
|
||||
-- TODO icit
|
||||
let var = VVar (length ctx.env)
|
||||
let var = VVar (length ctx.env) []
|
||||
let ctx' = extend ctx nm a
|
||||
tm' <- check ctx' tm (b $$ var)
|
||||
pure $ Lam nm icit tm'
|
||||
@@ -32,8 +48,10 @@ parameters {0 m : Type -> Type} {auto _ : MonadError Error m} (top : TopContext)
|
||||
other => error [(DS "Expected pi type, got \{show $ quote 0 ty}")]
|
||||
check ctx tm ty = do
|
||||
(tm', ty') <- infer ctx tm
|
||||
-- This is where the conversion check / pattern unification go
|
||||
-- unify ctx.lvl ty' ty
|
||||
if quote 0 ty /= quote 0 ty' then
|
||||
error [DS "type mismatch"]
|
||||
error [DS "type mismatch got", DD (quote 0 ty'), DS "expected", DD (quote 0 ty)]
|
||||
else pure tm'
|
||||
|
||||
infer ctx (RVar nm) = go 0 ctx.types
|
||||
@@ -70,8 +88,13 @@ parameters {0 m : Type -> Type} {auto _ : MonadError Error m} (top : TopContext)
|
||||
pure (tm, vty)
|
||||
|
||||
infer ctx (RLam str icit tm) = error [DS "can't infer lambda"]
|
||||
|
||||
infer ctx _ = error [DS "TODO"]
|
||||
infer ctx RHole = do
|
||||
ty <- freshMeta ctx
|
||||
let vty = eval ctx.env CBN ty
|
||||
tm <- freshMeta ctx
|
||||
pure (tm, vty)
|
||||
|
||||
infer ctx tm = error [DS "Implement infer \{show tm}"]
|
||||
|
||||
-- I don't have types for these yet...
|
||||
-- infer ctx (RLit (LString str)) = ?rhs_10
|
||||
|
||||
Reference in New Issue
Block a user