@@ -487,48 +487,6 @@ reapply2 scope fun fun_ty ((arg,arg_v,arg_ty):args) = do -- Explicit arg (fallth
487487 res_ty -> return res_ty
488488 reapply2 scope (App fun arg) res_ty args
489489
490- {- tcApp scope c t0 t@(App fun (ImplArg arg)) = do -- APP1
491- let (c1,c2,c3,c4) = split4 c
492- (fun,fun_ty) <- tcApp scope c1 t0 fun
493- (bt, x, arg_ty, res_ty) <- unifyFun scope fun_ty
494- if (bt == Implicit)
495- then return ()
496- else evalError (ppTerm Unqualified 0 t <+> "is an implicit argument application, but no implicit argument is expected")
497- (arg,_) <- tcRho scope c2 arg (Just arg_ty)
498- res_ty <- case res_ty of
499- VClosure res_env res_c res_ty -> do g <- globals
500- return (eval g ((x,eval g (scopeEnv scope) c3 arg []):res_env) res_c res_ty [])
501- res_ty -> return res_ty
502- return (App fun (ImplArg arg), res_ty)
503- tcApp scope c t0 (App fun arg) = do -- APP2
504- let (c1,c2,c3,c4) = split4 c
505- (fun,fun_ty) <- tcApp scope c1 t0 fun
506- (fun,fun_ty) <- instantiate scope fun fun_ty
507- (_, x, arg_ty, res_ty) <- unifyFun scope fun_ty
508- (arg,_) <- tcRho scope c2 arg (Just arg_ty)
509- g <- globals
510- let res_ty' = foo g (x,eval g (scopeEnv scope) c3 arg []) res_ty
511- return (App fun arg, res_ty')
512- where
513- foo g arg (VClosure env c res_ty) = eval g (arg:env) c res_ty []
514- foo g arg (VFV c vs) = VFV c (map (foo g arg) vs)
515- foo g arg res_ty = res_ty
516- tcApp scope c t0 (Q id) = getOverloads scope c t0 id -- VAR (global)
517- tcApp scope c t0 (QC id) = getOverloads scope c t0 id -- VAR (global)
518- tcApp scope c t0 t = tcRho scope c t Nothing
519- -}
520- getOverloads :: Scope -> Choice -> Term -> QIdent -> EvalM (Term ,Rho )
521- getOverloads scope c t q = do
522- g@ (Gl gr _) <- globals
523- case lookupOverloadTypes gr q of
524- Bad msg -> evalError (pp msg)
525- Ok [(t,ty)] -> return (t, eval g [] c ty [] )
526- Ok ttys -> do let (c1,c2,c3,c4) = split4 c
527- vs = mapC (\ c (t,ty) -> eval g [] c t [] ) c1 ttys
528- vtys = mapC (\ c (t,ty) -> eval g [] c ty [] ) c2 ttys
529- i <- newBinding (VFV c3 vs)
530- return (Meta i, VFV c3 vtys)
531-
532490tcPatt scope c PW ty0 =
533491 return scope
534492tcPatt scope c (PV x) ty0 =
@@ -669,9 +627,9 @@ subsCheckRho scope t (VMeta i vs1) (VMeta j vs2)
669627 g <- globals
670628 subsCheckRho scope t (VMeta i vs1) (apply g v2 vs2)
671629 Residuation scope2 _
672- | m > n -> do setMeta i (Bound m (VMeta j vs2))
630+ | m > n -> do setMeta i (Bound scope1 (VMeta j vs2))
673631 return t
674- | otherwise -> do setMeta j (Bound n (VMeta i vs2))
632+ | otherwise -> do setMeta j (Bound scope2 (VMeta i vs2))
675633 return t
676634 where
677635 m = length scope1
@@ -895,8 +853,8 @@ unify scope (VMeta i vs1) (VMeta j vs2)
895853 g <- globals
896854 unify scope (VMeta i vs1) (apply g v2 vs2)
897855 Residuation scope2 _
898- | m > n -> setMeta i (Bound m (VMeta j vs2))
899- | otherwise -> setMeta j (Bound n (VMeta i vs2))
856+ | m > n -> setMeta i (Bound scope1 (VMeta j vs2))
857+ | otherwise -> setMeta j (Bound scope2 (VMeta i vs2))
900858 where
901859 m = length scope1
902860 n = length scope2
@@ -937,7 +895,7 @@ unifyVar scope metaid vs ty2 = do -- Check whether i is bound
937895 Bound _ ty1 -> do g <- globals
938896 unify scope (apply g ty1 vs) ty2
939897 Residuation scope' _ -> do occursCheck scope' metaid scope ty2
940- setMeta metaid (Bound ( length scope') ty2)
898+ setMeta metaid (Bound scope' ty2)
941899
942900occursCheck scope' i0 scope v =
943901 let m = length scope'
@@ -1047,11 +1005,11 @@ quantify scope t tvs ty = do
10471005 n = length scope
10481006 (used_bndrs,ty) <- check m n [] ty
10491007 let new_bndrs = take m (allBinders \\ used_bndrs)
1050- mapM_ bind (zip3 [0 .. ] tvs new_bndrs)
1008+ mapM_ ( bind ([(var, VSort cType) | var <- new_bndrs] ++ scope)) (zip3 [0 .. ] tvs new_bndrs)
10511009 let ty' = foldr (\ ty -> VProd Implicit ty vtypeType) ty new_bndrs
10521010 return (foldr (Abs Implicit ) t new_bndrs,ty')
10531011 where
1054- bind (i, meta_id, name) = setMeta meta_id (Bound ( length scope) (VGen i [] ))
1012+ bind scope (i, meta_id, name) = setMeta meta_id (Bound scope (VGen i [] ))
10551013
10561014 check m n xs (VApp f vs) = do
10571015 (xs,vs) <- mapAccumM (check m n) xs vs
0 commit comments