-tcArg :: LHsExpr Name -- The function (for error messages)
- -> (LHsExpr Name, BoxySigmaType, Int) -- Actual argument and expected arg type
- -> TcM (LHsExpr TcId) -- Resulting argument
-tcArg fun (arg, ty, arg_no) = addErrCtxt (funAppCtxt fun arg arg_no) $
- tcPolyExprNC arg ty
+tcArgs fun args qtvs qtys arg_tys
+ = go 1 qtys args arg_tys
+ where
+ go n qtys [] [] = return (qtys, [])
+ go n qtys (arg:args) (arg_ty:arg_tys)
+ = do { arg' <- tcArg fun n arg qtvs qtys arg_ty
+ ; qtys' <- mapM refineBox qtys -- Exploit new info
+ ; (qtys'', args') <- go (n+1) qtys' args arg_tys
+ ; return (qtys'', arg':args') }
+ go n qtys args arg_tys = panic "tcArgs"
+
+tcArg :: LHsExpr Name -- The function
+ -> Int -- and arg number (for error messages)
+ -> LHsExpr Name
+ -> [TyVar] -> [TcSigmaType] -- Instantiate the arg type like this
+ -> BoxySigmaType
+ -> TcM (LHsExpr TcId) -- Resulting argument
+tcArg fun arg_no arg qtvs qtys ty
+ = addErrCtxt (funAppCtxt fun arg arg_no) $
+ tcPolyExprNC arg (substTyWith qtvs qtys ty)