check (Ter t rho) talpha
rho' <- asks env
checkCompSystem (E.evalSystem rho' ts)
(VPi va@(Ter (Sum _ _ cas) nu) f,Split _ _ ty ces) -> do
check VU ty
rho <- asks env
unlessM (a === E.eval rho ty) $ throwError "check: split annotations"
if map labelName cas == map branchName ces
then sequence_ [ checkBranch (lbl,nu) f brc (Ter t rho) va
| (brc, lbl) <- zip ces cas ]
else throwError "case branches does not match the data type"
(VPi va@(Ter (HSum _ _ cas) nu) f,Split _ _ ty ces) -> do
check VU ty
rho <- asks env
unlessM (a === E.eval rho ty) $ throwError "check: split annotations"
if map labelName cas == map branchName ces
then sequence_ [ checkBranch (lbl,nu) f brc (Ter t rho) va
| (brc, lbl) <- zip ces cas ]
else throwError "case branches does not match the data type"
(VPi a f,Lam x a' t) -> do
check VU a'
ns <- asks names
rho <- asks env
unlessM (a === E.eval rho a') $
throwError $ "check: lam types don't match"
++ "\nlambda type annotation: " ++ show a'
++ "\ndomain of Pi: " ++ show a
++ "\nnormal form of type: " ++ show (E.normal ns a)
let var = mkVarNice ns x a
local (addTypeVal (x,a)) $ check (E.app f var) t
(VSigma a f, Pair t1 t2) -> do
check a t1
v <- evalTyping t1
check (E.app f v) t2
(_,Where e d) -> do
local (\tenv@TEnv{indent=i} -> tenv{indent=i + 2}) $ checkDecls d
local (addDecls d) $ check a e
(VU,PathP a e0 e1) -> do
(a0,a1) <- checkPLam (constPath VU) a
check a0 e0
check a1 e1
(VPathP p a0 a1,PLam _ e) -> do
(u0,u1) <- checkPLam p t
ns <- asks names
unless (E.conv ns a0 u0 && E.conv ns a1 u1) $
throwError $ "path endpoints don't match for " ++ show e ++ ", got " ++
show (u0,u1) ++ ", but expected " ++ show (a0,a1)
(VU,Glue a ts) -> do
check VU a
rho <- asks env
checkGlue (E.eval rho a) ts
(VGlue va ts,GlueElem u us) -> do
check va u
vu <- evalTyping u
checkGlueElem vu ts us
(VCompU va ves,GlueElem u us) -> do
check va u
vu <- evalTyping u
checkGlueElemU vu ves us
(VU,Id a a0 a1) -> do
check VU a
va <- evalTyping a
check va a0
check va a1
(VId va va0 va1,IdPair w ts) -> do
check (VPathP (constPath va) va0 va1) w
vw <- evalTyping w
checkSystemWith ts $ \alpha tAlpha ->
local (faceEnv alpha) $ do
check (va `C.face` alpha) tAlpha
vtAlpha <- evalTyping tAlpha
unlessM (vw `C.face` alpha === constPath vtAlpha) $
throwError "malformed eqC"
rho <- asks env
checkCompSystem (E.evalSystem rho ts)
_ -> do
v <- infer t
unlessM (v === a) $
throwError $ "check conv:\n" ++ show v ++ "\n/=\n" ++ show a