@@ -150,8 +150,7 @@ synifyAxBranch tc (CoAxBranch { cab_tvs = tkvs, cab_lhs = args, cab_rhs = rhs })
150
150
= let name = synifyName tc
151
151
args_types_only = filterOutInvisibleTypes tc args
152
152
typats = map (synifyType WithinType [] ) args_types_only
153
- annot_typats = zipWith3 annotHsType (mkIsPolyTvs fam_tvs)
154
- args_types_only typats
153
+ annot_typats = zipWith3 annotHsType args_poly args_types_only typats
155
154
hs_rhs = synifyType WithinType [] rhs
156
155
in HsIB { hsib_ext = map tyVarName tkvs
157
156
, hsib_body = FamEqn { feqn_ext = noExt
@@ -162,7 +161,7 @@ synifyAxBranch tc (CoAxBranch { cab_tvs = tkvs, cab_lhs = args, cab_rhs = rhs })
162
161
, feqn_fixity = synifyFixity name
163
162
, feqn_rhs = hs_rhs } }
164
163
where
165
- fam_tvs = tyConVisibleTyVars tc
164
+ args_poly = tyConArgsPolyKinded tc
166
165
167
166
synifyAxiom :: CoAxiom br -> Either ErrMsg (HsDecl GhcRn )
168
167
synifyAxiom ax@ (CoAxiom { co_ax_tc = tc })
@@ -472,17 +471,26 @@ annotHsType True ty hs_ty
472
471
in noLoc (HsKindSig noExt hs_ty hs_ki)
473
472
annotHsType _ _ hs_ty = hs_ty
474
473
475
- -- | For every type variable in the input,
476
- -- report whether or not the tv is poly-kinded. This is used to eventually
477
- -- feed into 'annotHsType'.
478
- mkIsPolyTvs :: [TyVar ] -> [Bool ]
479
- mkIsPolyTvs = map is_poly_tv
474
+ -- | For every argument type that a type constructor accepts,
475
+ -- report whether or not the argument is poly-kinded. This is used to
476
+ -- eventually feed into 'annotThType'.
477
+ tyConArgsPolyKinded :: TyCon -> [Bool ]
478
+ tyConArgsPolyKinded tc =
479
+ map (is_poly_ty . tyVarKind) tc_vis_tvs
480
+ ++ map (is_poly_ty . tyCoBinderType) tc_res_kind_vis_bndrs
481
+ ++ repeat True
480
482
where
481
- is_poly_tv tv = not $
483
+ is_poly_ty :: Type -> Bool
484
+ is_poly_ty ty = not $
482
485
isEmptyVarSet $
483
486
filterVarSet isTyVar $
484
- tyCoVarsOfType $
485
- tyVarKind tv
487
+ tyCoVarsOfType ty
488
+
489
+ tc_vis_tvs :: [TyVar ]
490
+ tc_vis_tvs = tyConVisibleTyVars tc
491
+
492
+ tc_res_kind_vis_bndrs :: [TyCoBinder ]
493
+ tc_res_kind_vis_bndrs = filter isVisibleBinder $ fst $ splitPiTys $ tyConResKind tc
486
494
487
495
-- states of what to do with foralls:
488
496
data SynifyTypeState
@@ -787,8 +795,8 @@ synifyInstHead (vs, preds, cls, types) = specializeInstHead $ InstHead
787
795
cls_tycon = classTyCon cls
788
796
ts = filterOutInvisibleTypes cls_tycon types
789
797
ts' = map (synifyType WithinType vs) ts
790
- annot_ts = zipWith3 annotHsType is_poly_tvs ts ts'
791
- is_poly_tvs = mkIsPolyTvs (tyConVisibleTyVars cls_tycon)
798
+ annot_ts = zipWith3 annotHsType args_poly ts ts'
799
+ args_poly = tyConArgsPolyKinded cls_tycon
792
800
synifyClsIdSig = synifyIdSig ShowRuntimeRep DeleteTopLevelQuantification vs
793
801
794
802
-- Convert a family instance, this could be a type family or data family
@@ -827,8 +835,8 @@ synifyFamInst fi opaque = do
827
835
ts = filterOutInvisibleTypes fam_tc eta_expanded_lhs
828
836
synifyTypes = map (synifyType WithinType [] )
829
837
ts' = synifyTypes ts
830
- annot_ts = zipWith3 annotHsType is_poly_tvs ts ts'
831
- is_poly_tvs = mkIsPolyTvs (tyConVisibleTyVars fam_tc)
838
+ annot_ts = zipWith3 annotHsType args_poly ts ts'
839
+ args_poly = tyConArgsPolyKinded fam_tc
832
840
833
841
{-
834
842
Note [Invariant: Never expand type synonyms]
0 commit comments