Commit d59939a4 authored by Simon Peyton Jones's avatar Simon Peyton Jones

Define TyCoRep.ppSuggestExplicitKinds, and use it

This just defines a useful helper function that was being
duplicated in several places
parent a3c37c3f
......@@ -569,10 +569,7 @@ unusedInjectiveVarsErr (Pair invis_vars vis_vars) errorBuilder tyfamEqn
(True, False) -> text "Type"
(False, True) -> text "Kind"
(False, False) -> pprPanic "mkUnusedInjectiveVarsErr" $ ppr tvs
print_kinds_info = sdocWithDynFlags $ \ dflags ->
if has_kinds && not (gopt Opt_PrintExplicitKinds dflags)
then text "(enabling -fprint-explicit-kinds might help)"
else empty
print_kinds_info = ppWhen has_kinds ppSuggestExplicitKinds
msg = doc $$ print_kinds_info $$
text "In the type family equation:"
......
......@@ -404,7 +404,7 @@ checkInstCoverage be_liberal clas theta inst_taus
, text "Un-determined variable" <> plural undet_list <> colon
<+> pprWithCommas ppr undet_list
, ppWhen (isEmptyVarSet $ pSnd undetermined_tvs) $
text "(Use -fprint-explicit-kinds to see the kind variables in the types)"
ppSuggestExplicitKinds
, ppWhen (not be_liberal &&
and (isEmptyVarSet <$> liberal_undet_tvs)) $
text "Using UndecidableInstances might help" ]
......
......@@ -1452,11 +1452,7 @@ mkEqInfoMsg ct ty1 ty2
invis_msg | Just vis <- tcEqTypeVis act_ty exp_ty
, vis /= Visible
= sdocWithDynFlags $ \dflags ->
if gopt Opt_PrintExplicitKinds dflags
then empty
else text "Use -fprint-explicit-kinds to see the kind arguments"
= ppSuggestExplicitKinds
| otherwise
= empty
......@@ -2427,8 +2423,9 @@ mkAmbigMsg prepend_msg ct
= pp_ambig (text "type") ambig_tvs
| otherwise -- All ambiguous kind variabes; suggest -fprint-explicit-kinds
-- See Note [Suggest -fprint-explicit-kinds]
= vcat [ pp_ambig (text "kind") ambig_kvs
, sdocWithDynFlags suggest_explicit_kinds ]
, ppSuggestExplicitKinds ]
pp_ambig what tkvs
| prepend_msg -- "Ambiguous type variable 't0'"
......@@ -2442,10 +2439,6 @@ mkAmbigMsg prepend_msg ct
is_or_are [_] = text "is"
is_or_are _ = text "are"
suggest_explicit_kinds dflags -- See Note [Suggest -fprint-explicit-kinds]
| gopt Opt_PrintExplicitKinds dflags = empty
| otherwise = text "Use -fprint-explicit-kinds to see the kind arguments"
pprSkol :: [Implication] -> TcTyVar -> SDoc
pprSkol implics tv
| (skol_tvs, skol_info) <- getSkolemInfo implics tv
......
......@@ -58,7 +58,7 @@ module TyCoRep (
pprKind, pprParendKind, pprTyLit,
TyPrec(..), maybeParen, pprTcAppCo, pprTcAppTy,
pprPrefixApp, pprArrowChain, ppr_type,
pprDataCons,
pprDataCons, ppSuggestExplicitKinds,
-- * Free variables
tyCoVarsOfType, tyCoVarsOfTypeDSet, tyCoVarsOfTypes, tyCoVarsOfTypesDSet,
......@@ -3088,6 +3088,14 @@ pprArrowChain _ [] = empty
pprArrowChain p (arg:args) = maybeParen p FunPrec $
sep [arg, sep (map (arrow <+>) args)]
ppSuggestExplicitKinds :: SDoc
-- Print a helpful suggstion about -fprint-explicit-kinds,
-- if it is not already on
ppSuggestExplicitKinds
= sdocWithDynFlags $ \ dflags ->
ppUnless (gopt Opt_PrintExplicitKinds dflags) $
text "Use -fprint-explicit-kinds to see the kind arguments"
{-
%************************************************************************
%* *
......
......@@ -175,7 +175,7 @@ module Type (
-- * Pretty-printing
pprType, pprParendType, pprTypeApp, pprTyThingCategory, pprTyThing,
pprTvBndr, pprTvBndrs, pprForAll, pprForAllImplicit, pprUserForAll,
pprSigmaType,
pprSigmaType, ppSuggestExplicitKinds,
pprTheta, pprThetaArrowTy, pprClassPred,
pprKind, pprParendKind, pprSourceTyCon,
TyPrec(..), maybeParen,
......
......@@ -47,14 +47,14 @@
<interactive>:60:15: error:
Type family equation violates injectivity annotation.
Kind variable ‘k’ cannot be inferred from the right-hand side.
(enabling -fprint-explicit-kinds might help)
Use -fprint-explicit-kinds to see the kind arguments
In the type family equation:
PolyKindVars '[] = '[] -- Defined at <interactive>:60:15
<interactive>:64:15: error:
Type family equation violates injectivity annotation.
Kind variable ‘k’ cannot be inferred from the right-hand side.
(enabling -fprint-explicit-kinds might help)
Use -fprint-explicit-kinds to see the kind arguments
In the type family equation:
forall k (a :: k) (b :: k).
Fc a b = Int -- Defined at <interactive>:64:15
......@@ -63,7 +63,7 @@
Type family equation violates injectivity annotation.
Type and kind variables ‘k’, ‘a’, ‘b’
cannot be inferred from the right-hand side.
(enabling -fprint-explicit-kinds might help)
Use -fprint-explicit-kinds to see the kind arguments
In the type family equation:
forall k (a :: k) (b :: k).
Gc a b = Int -- Defined at <interactive>:68:15
......
......@@ -67,14 +67,14 @@ T6018fail.hs:59:10: error:
T6018fail.hs:62:15: error:
Type family equation violates injectivity annotation.
Kind variable ‘k’ cannot be inferred from the right-hand side.
(enabling -fprint-explicit-kinds might help)
Use -fprint-explicit-kinds to see the kind arguments
In the type family equation:
PolyKindVars '[] = '[] -- Defined at T6018fail.hs:62:15
T6018fail.hs:66:15: error:
Type family equation violates injectivity annotation.
Kind variable ‘k’ cannot be inferred from the right-hand side.
(enabling -fprint-explicit-kinds might help)
Use -fprint-explicit-kinds to see the kind arguments
In the type family equation:
forall k (a :: k) (b :: k).
Fc a b = Int -- Defined at T6018fail.hs:66:15
......@@ -83,7 +83,7 @@ T6018fail.hs:70:15: error:
Type family equation violates injectivity annotation.
Type and kind variables ‘k’, ‘a’, ‘b’
cannot be inferred from the right-hand side.
(enabling -fprint-explicit-kinds might help)
Use -fprint-explicit-kinds to see the kind arguments
In the type family equation:
forall k (a :: k) (b :: k).
Gc a b = Int -- Defined at T6018fail.hs:70:15
......@@ -140,7 +140,7 @@ T6018fail.hs:118:15: error:
Type family equation violates injectivity annotation.
Type and kind variables ‘k’, ‘c’
cannot be inferred from the right-hand side.
(enabling -fprint-explicit-kinds might help)
Use -fprint-explicit-kinds to see the kind arguments
In the type family equation:
forall k a b (c :: k).
G7 a b c = [G7a a b c] -- Defined at T6018fail.hs:118:15
......
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