Commit 544ac0d2 authored by Gabor Greif's avatar Gabor Greif 💬

rename tcInstBinder(s)X to tcInstBinder(s)

Summary: Simplify naming scheme of tcInstBinder(s)X

Test Plan: Eyeball and compile

Reviewers: austin, goldfire, bgamari

Subscribers: goldfire, rwbarton, thomie

Differential Revision: https://phabricator.haskell.org/D3690
parent 05923183
......@@ -15,7 +15,7 @@ module Inst (
instCall, instDFunType, instStupidTheta,
newWanted, newWanteds,
tcInstBindersX, tcInstBinderX,
tcInstBinders, tcInstBinder,
newOverloadedLit, mkOverLit,
......@@ -380,19 +380,19 @@ instStupidTheta orig theta
-- | This is used to instantiate binders when type-checking *types* only.
-- The @VarEnv Kind@ gives some known instantiations.
-- See also Note [Bidirectional type checking]
tcInstBindersX :: TCvSubst -> Maybe (VarEnv Kind)
tcInstBinders :: TCvSubst -> Maybe (VarEnv Kind)
-> [TyBinder] -> TcM (TCvSubst, [TcType])
tcInstBindersX subst mb_kind_info bndrs
= do { (subst, args) <- mapAccumLM (tcInstBinderX mb_kind_info) subst bndrs
tcInstBinders subst mb_kind_info bndrs
= do { (subst, args) <- mapAccumLM (tcInstBinder mb_kind_info) subst bndrs
; traceTc "instantiating tybinders:"
(vcat $ zipWith (\bndr arg -> ppr bndr <+> text ":=" <+> ppr arg)
bndrs args)
; return (subst, args) }
-- | Used only in *types*
tcInstBinderX :: Maybe (VarEnv Kind)
tcInstBinder :: Maybe (VarEnv Kind)
-> TCvSubst -> TyBinder -> TcM (TCvSubst, TcType)
tcInstBinderX mb_kind_info subst (Named (TvBndr tv _))
tcInstBinder mb_kind_info subst (Named (TvBndr tv _))
= case lookup_tv tv of
Just ki -> return (extendTvSubstAndInScope subst tv ki, ki)
Nothing -> do { (subst', tv') <- newMetaTyVarX subst tv
......@@ -402,7 +402,7 @@ tcInstBinderX mb_kind_info subst (Named (TvBndr tv _))
; lookupVarEnv env tv }
tcInstBinderX _ subst (Anon ty)
tcInstBinder _ subst (Anon ty)
-- This is the *only* constraint currently handled in types.
| Just (mk, role, k1, k2) <- get_pred_tys_maybe substed_ty
= do { let origin = TypeEqOrigin { uo_actual = k1
......@@ -411,7 +411,7 @@ tcInstBinderX _ subst (Anon ty)
; co <- case role of
Nominal -> unifyKind noThing k1 k2
Representational -> emitWantedEq origin KindLevel role k1 k2
Phantom -> pprPanic "tcInstBinderX Phantom" (ppr ty)
Phantom -> pprPanic "tcInstBinder Phantom" (ppr ty)
; arg' <- mk co k1 k2
; return (subst, arg') }
......
......@@ -56,7 +56,7 @@ import TcIface
import TcSimplify ( solveEqualities )
import TcType
import TcHsSyn( zonkSigType )
import Inst ( tcInstBindersX, tcInstBinderX )
import Inst ( tcInstBinders, tcInstBinder )
import Type
import Kind
import RdrName( lookupLocalRdrOcc )
......@@ -422,7 +422,7 @@ metavariable.
In types, however, we're not so lucky, because *we cannot re-generalize*!
There is no lambda. So, we must be careful only to instantiate at the last
possible moment, when we're sure we're never going to want the lost polymorphism
again. This is done in calls to tcInstBindersX.
again. This is done in calls to tcInstBinders.
To implement this behavior, we use bidirectional type checking, where we
explicitly think about whether we know the kind of the type we're checking
......@@ -810,7 +810,7 @@ tcInferArgs fun tc_binders mb_kind_info args
-- now, we need to instantiate any remaining invisible arguments
; let (invis_bndrs, other_binders) = break isVisibleBinder leftover_binders
; (subst', invis_args)
<- tcInstBindersX subst mb_kind_info invis_bndrs
<- tcInstBinders subst mb_kind_info invis_bndrs
; return ( subst'
, other_binders
, args' `chkAppend` invis_args
......@@ -838,7 +838,7 @@ tc_infer_args mode orig_ty binders mb_kind_info orig_args n0
go subst (binder:binders) all_args@(arg:args) n acc
| isInvisibleBinder binder
= do { traceTc "tc_infer_args (invis)" (ppr binder)
; (subst', arg') <- tcInstBinderX mb_kind_info subst binder
; (subst', arg') <- tcInstBinder mb_kind_info subst binder
; go subst' binders all_args n (arg' : acc) }
| otherwise
......@@ -932,7 +932,7 @@ instantiateTyN n ty ki
empty_subst = mkEmptyTCvSubst (mkInScopeSet (tyCoVarsOfType ki))
in
if num_to_inst <= 0 then return (ty, ki) else
do { (subst, inst_args) <- tcInstBindersX empty_subst Nothing inst_bndrs
do { (subst, inst_args) <- tcInstBinders empty_subst Nothing inst_bndrs
; let rebuilt_ki = mkPiTys leftover_bndrs inner_ki
ki' = substTy subst rebuilt_ki
; traceTc "instantiateTyN" (vcat [ ppr ty <+> dcolon <+> ppr ki
......
......@@ -843,7 +843,7 @@ new_meta_tv_x info subst tv
-- is not yet fixed so leaving as unchecked for now.
-- OLD NOTE:
-- Unchecked because we call newMetaTyVarX from
-- tcInstBinderX, which is called from tc_infer_args
-- tcInstBinder, which is called from tc_infer_args
-- which does not yet take enough trouble to ensure
-- the in-scope set is right; e.g. Trac #12785 trips
-- if we use substTy here
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment