Commit 48d1866e authored by Simon Peyton Jones's avatar Simon Peyton Jones

Improve error messages for skolems

In error messages like this
    • Couldn't match type ‘c’ with ‘f0 (a -> b)’
      ‘c’ is a rigid type variable bound by
        the type signature for:
          f :: ((a -> b) -> b) -> forall c. c -> a

we need to take case both to actually show that 'forall c',
and to make sure that its name lines with the 'c' in the
error message.

This has been shaky for some time, and this commit puts it on solid
ground.  See TcRnTypes: Note [SigSkol SkolemInfo]

The main changes are

* SigSkol gets an extra field that records the way in which the
  type signature was skolemised.

* The type in SigSkol is now the /un/-skolemised version

* pprSkolemInfo uses the info to make the tidy type line up
  nicely

Lots of error message wibbles!
parent 7e96526a
......@@ -54,7 +54,7 @@ import Class( Class )
import MkId( mkDictFunId )
import Id
import Name
import Var ( EvVar, mkTyVar, TyVarBndr(..) )
import Var ( EvVar, mkTyVar, tyVarName, TyVarBndr(..) )
import DataCon
import TyCon
import VarEnv
......@@ -129,31 +129,37 @@ ToDo: this eta-abstraction plays fast and loose with termination,
fix this
-}
deeplySkolemise
:: TcSigmaType
-> TcM ( HsWrapper
, [TyVar] -- all skolemised variables
, [EvVar] -- all "given"s
, TcRhoType)
deeplySkolemise :: TcSigmaType
-> TcM ( HsWrapper
, [(Name,TyVar)] -- All skolemised variables
, [EvVar] -- All "given"s
, TcRhoType )
deeplySkolemise ty
| Just (arg_tys, tvs, theta, ty') <- tcDeepSplitSigmaTy_maybe ty
= do { ids1 <- newSysLocalIds (fsLit "dk") arg_tys
; (subst, tvs1) <- tcInstSkolTyVars tvs
; ev_vars1 <- newEvVars (substThetaUnchecked subst theta)
; (wrap, tvs2, ev_vars2, rho) <-
deeplySkolemise (substTyAddInScope subst ty')
; return ( mkWpLams ids1
<.> mkWpTyLams tvs1
<.> mkWpLams ev_vars1
<.> wrap
<.> mkWpEvVarApps ids1
, tvs1 ++ tvs2
, ev_vars1 ++ ev_vars2
, mkFunTys arg_tys rho ) }
= go init_subst ty
where
init_subst = mkEmptyTCvSubst (mkInScopeSet (tyCoVarsOfType ty))
go subst ty
| Just (arg_tys, tvs, theta, ty') <- tcDeepSplitSigmaTy_maybe ty
= do { let arg_tys' = substTys subst arg_tys
; ids1 <- newSysLocalIds (fsLit "dk") arg_tys'
; (subst', tvs1) <- tcInstSkolTyVarsX subst tvs
; ev_vars1 <- newEvVars (substTheta subst' theta)
; (wrap, tvs_prs2, ev_vars2, rho) <- go subst' ty'
; let tv_prs1 = map tyVarName tvs `zip` tvs1
; return ( mkWpLams ids1
<.> mkWpTyLams tvs1
<.> mkWpLams ev_vars1
<.> wrap
<.> mkWpEvVarApps ids1
, tv_prs1 ++ tvs_prs2
, ev_vars1 ++ ev_vars2
, mkFunTys arg_tys' rho ) }
| otherwise
= return (idHsWrapper, [], [], ty)
| otherwise
= return (idHsWrapper, [], [], substTy subst ty)
-- substTy is a quick no-op on an empty substitution
-- | Instantiate all outer type variables
-- and any context. Never looks through arrows.
......
......@@ -687,13 +687,13 @@ tcPolyCheck prag_fn
, fun_matches = matches }))
= setSrcSpan sig_loc $
do { traceTc "tcPolyCheck" (ppr poly_id $$ ppr sig_loc)
; (tv_prs, theta, tau) <- tcInstType (tcInstSigTyVars sig_loc) poly_id
; (tv_prs, theta, tau) <- tcInstType tcInstSkolTyVars poly_id
-- See Note [Instantiate sig with fresh variables]
; mono_name <- newNameAt (nameOccName name) nm_loc
; ev_vars <- newEvVars theta
; let mono_id = mkLocalId mono_name tau
skol_info = SigSkol ctxt (mkPhiTy theta tau)
skol_info = SigSkol ctxt (idType poly_id) tv_prs
skol_tvs = map snd tv_prs
; (ev_binds, (co_fn, matches'))
......
......@@ -2329,7 +2329,7 @@ ctxtFixes has_ambig_tvs pred implics
, isTyVarClassPred pred
, (skol:skols) <- usefulContext implics pred
, let what | null skols
, SigSkol (PatSynCtxt {}) _ <- skol
, SigSkol (PatSynCtxt {}) _ _ <- skol
= text "\"required\""
| otherwise
= empty
......@@ -2351,8 +2351,8 @@ discardProvCtxtGivens orig givens -- See Note [discardProvCtxtGivens]
| otherwise
= givens
where
discard n (Implic { ic_info = SigSkol (PatSynCtxt n') _ }) = n == n'
discard _ _ = False
discard n (Implic { ic_info = SigSkol (PatSynCtxt n') _ _ }) = n == n'
discard _ _ = False
usefulContext :: [Implication] -> PredType -> [SkolemInfo]
-- usefulContext picks out the implications whose context
......@@ -2375,8 +2375,8 @@ usefulContext implics pred
| implausible_info (ic_info ic) = True
| otherwise = False
implausible_info (SigSkol (InfSigCtxt {}) _) = True
implausible_info _ = False
implausible_info (SigSkol (InfSigCtxt {}) _ _) = True
implausible_info _ = False
-- Do not suggest adding constraints to an *inferred* type signature
{- Note [Report candidate instances]
......@@ -2600,13 +2600,10 @@ mkAmbigMsg prepend_msg ct
pprSkol :: [Implication] -> TcTyVar -> SDoc
pprSkol implics tv
= case skol_info of
UnkSkol -> quotes (ppr tv) <+> text "is an unknown type variable"
SigSkol ctxt ty -> ppr_rigid (pprSigSkolInfo ctxt
(mkSpecForAllTys skol_tvs ty))
_ -> ppr_rigid (pprSkolInfo skol_info)
UnkSkol -> quotes (ppr tv) <+> text "is an unknown type variable"
_ -> ppr_rigid (pprSkolInfo skol_info)
where
Implic { ic_skols = skol_tvs, ic_info = skol_info }
= getSkolemInfo implics tv
Implic { ic_info = skol_info } = getSkolemInfo implics tv
ppr_rigid pp_info
= hang (quotes (ppr tv) <+> text "is a rigid type variable bound by")
2 (sep [ pp_info
......
......@@ -1490,9 +1490,9 @@ in the other order, the extra signature in f2 is reqd.
tcExprSig :: LHsExpr Name -> TcIdSigInfo -> TcM (LHsExpr TcId, TcType)
tcExprSig expr (CompleteSig { sig_bndr = poly_id, sig_loc = loc })
= setSrcSpan loc $ -- Sets the location for the implication constraint
do { (tv_prs, theta, tau) <- tcInstType (tcInstSigTyVars loc) poly_id
do { (tv_prs, theta, tau) <- tcInstType tcInstSkolTyVars poly_id
; given <- newEvVars theta
; let skol_info = SigSkol ExprSigCtxt (mkPhiTy theta tau)
; let skol_info = SigSkol ExprSigCtxt (idType poly_id) tv_prs
skol_tvs = map snd tv_prs
; (ev_binds, expr') <- checkConstraints skol_info skol_tvs given $
tcExtendTyVarEnv2 tv_prs $
......
......@@ -57,8 +57,8 @@ module TcMType (
newMetaSigTyVars, newMetaSigTyVarX,
newSigTyVar, newWildCardX,
tcInstType,
tcInstSkolTyVars, tcInstSuperSkolTyVarsX,
tcInstSigTyVars,
tcInstSkolTyVars,tcInstSkolTyVarsX,
tcInstSuperSkolTyVarsX,
tcSkolDFunType, tcSuperSkolTyVars,
instSkolTyCoVars, freshenTyVarBndrs, freshenCoVarBndrsX,
......@@ -108,6 +108,7 @@ import VarSet
import TysWiredIn
import TysPrim
import VarEnv
import NameEnv
import PrelNames
import Util
import Outputable
......@@ -478,7 +479,10 @@ tcSuperSkolTyVar subst tv
-- skolems are non-overlappable; see Note [Overlap and deriving]
-- for an example where this matters.
tcInstSkolTyVars :: [TyVar] -> TcM (TCvSubst, [TcTyVar])
tcInstSkolTyVars = tcInstSkolTyVars' False emptyTCvSubst
tcInstSkolTyVars = tcInstSkolTyVarsX emptyTCvSubst
tcInstSkolTyVarsX :: TCvSubst -> [TyVar] -> TcM (TCvSubst, [TcTyVar])
tcInstSkolTyVarsX = tcInstSkolTyVars' False
tcInstSuperSkolTyVars :: [TyVar] -> TcM (TCvSubst, [TcTyVar])
tcInstSuperSkolTyVars = tcInstSuperSkolTyVarsX emptyTCvSubst
......@@ -503,12 +507,6 @@ mkTcSkolTyVar lvl loc overlappable
details = SkolemTv (pushTcLevel lvl) overlappable
-- NB: skolems bump the level
tcInstSigTyVars :: SrcSpan -> [TyVar]
-> TcM (TCvSubst, [TcTyVar])
tcInstSigTyVars loc tvs
= do { lvl <- getTcLevel
; instSkolTyCoVars (mkTcSkolTyVar lvl loc False) tvs }
------------------
freshenTyVarBndrs :: [TyVar] -> TcRnIf gbl lcl (TCvSubst, [TyVar])
-- ^ Give fresh uniques to a bunch of TyVars, but they stay
......@@ -1417,8 +1415,8 @@ zonkCtEvidence ctev@(CtDerived { ctev_pred = pred })
; return (ctev { ctev_pred = pred' }) }
zonkSkolemInfo :: SkolemInfo -> TcM SkolemInfo
zonkSkolemInfo (SigSkol cx ty) = do { ty' <- zonkTcType ty
; return (SigSkol cx ty') }
zonkSkolemInfo (SigSkol cx ty tv_prs) = do { ty' <- zonkTcType ty
; return (SigSkol cx ty' tv_prs) }
zonkSkolemInfo (InferSkol ntys) = do { ntys' <- mapM do_one ntys
; return (InferSkol ntys') }
where
......@@ -1606,11 +1604,39 @@ tidyEvVar env var = setVarType var (tidyType env (varType var))
----------------
tidySkolemInfo :: TidyEnv -> SkolemInfo -> SkolemInfo
tidySkolemInfo env (DerivSkol ty) = DerivSkol (tidyType env ty)
tidySkolemInfo env (SigSkol cx ty) = SigSkol cx (tidyType env ty)
tidySkolemInfo env (InferSkol ids) = InferSkol (mapSnd (tidyType env) ids)
tidySkolemInfo env (UnifyForAllSkol ty) = UnifyForAllSkol (tidyType env ty)
tidySkolemInfo _ info = info
tidySkolemInfo env (DerivSkol ty) = DerivSkol (tidyType env ty)
tidySkolemInfo env (SigSkol cx ty tv_prs) = tidySigSkol env cx ty tv_prs
tidySkolemInfo env (InferSkol ids) = InferSkol (mapSnd (tidyType env) ids)
tidySkolemInfo env (UnifyForAllSkol ty) = UnifyForAllSkol (tidyType env ty)
tidySkolemInfo _ info = info
tidySigSkol :: TidyEnv -> UserTypeCtxt
-> TcType -> [(Name,TcTyVar)] -> SkolemInfo
-- We need to take special care when tidying SigSkol
-- See Note [SigSkol SkolemInfo] in TcRnTypes
tidySigSkol env cx ty tv_prs
= SigSkol cx (tidy_ty env ty) tv_prs'
where
tv_prs' = mapSnd (tidyTyVarOcc env) tv_prs
inst_env = mkNameEnv tv_prs'
tidy_ty env (ForAllTy (TvBndr tv vis) ty)
= ForAllTy (TvBndr tv' vis) (tidy_ty env' ty)
where
(env', tv') = tidy_tv_bndr env tv
tidy_ty env (FunTy arg res)
= FunTy (tidyType env arg) (tidy_ty env res)
tidy_ty env ty = tidyType env ty
tidy_tv_bndr :: TidyEnv -> TyVar -> (TidyEnv, TyVar)
tidy_tv_bndr env@(occ_env, subst) tv
| Just tv' <- lookupNameEnv inst_env (tyVarName tv)
= ((occ_env, extendVarEnv subst tv tv'), tv')
| otherwise
= tidyTyCoVarBndr env tv
-------------------------------------------------------------------------
{-
......
......@@ -1661,7 +1661,7 @@ check_main dflags tcg_env explicit_mod_hdr
; ioTyCon <- tcLookupTyCon ioTyConName
; res_ty <- newFlexiTyVarTy liftedTypeKind
; let io_ty = mkTyConApp ioTyCon [res_ty]
skol_info = SigSkol (FunSigCtxt main_name False) io_ty
skol_info = SigSkol (FunSigCtxt main_name False) io_ty []
; (ev_binds, main_expr)
<- checkConstraints skol_info [] [] $
addErrCtxt mainCtxt $
......
......@@ -2841,9 +2841,14 @@ pushErrCtxtSameOrigin err loc@(CtLoc { ctl_env = lcl })
-- a) type variables are skolemised
-- b) an implication constraint is generated
data SkolemInfo
= SigSkol UserTypeCtxt -- A skolem that is created by instantiating
TcType -- a programmer-supplied type signature
-- Location of the binding site is on the TyVar
= SigSkol -- A skolem that is created by instantiating
-- a programmer-supplied type signature
-- Location of the binding site is on the TyVar
-- See Note [SigSkol SkolemInfo]
UserTypeCtxt -- What sort of signature
TcType -- Original type signature (before skolemisation)
[(Name,TcTyVar)] -- Maps the original name of the skolemised tyvar
-- to its instantiated version
| ClsSkol Class -- Bound at a class decl
......@@ -2898,9 +2903,9 @@ termEvidenceAllowed _ = True
pprSkolInfo :: SkolemInfo -> SDoc
-- Complete the sentence "is a rigid type variable bound by..."
pprSkolInfo (SigSkol ctxt ty) = pprSigSkolInfo ctxt ty
pprSkolInfo (SigSkol cx ty _) = pprSigSkolInfo cx ty
pprSkolInfo (IPSkol ips) = text "the implicit-parameter binding" <> plural ips <+> text "for"
<+> pprWithCommas ppr ips
<+> pprWithCommas ppr ips
pprSkolInfo (ClsSkol cls) = text "the class declaration for" <+> quotes (ppr cls)
pprSkolInfo (DerivSkol pred) = text "the deriving clause for" <+> quotes (ppr pred)
pprSkolInfo InstSkol = text "the instance declaration"
......@@ -2923,6 +2928,7 @@ pprSkolInfo (UnifyForAllSkol ty) = text "the type" <+> ppr ty
pprSkolInfo UnkSkol = WARN( True, text "pprSkolInfo: UnkSkol" ) text "UnkSkol"
pprSigSkolInfo :: UserTypeCtxt -> TcType -> SDoc
-- The type is already tidied
pprSigSkolInfo ctxt ty
= case ctxt of
FunSigCtxt f _ -> vcat [ text "the type signature for:"
......@@ -2948,13 +2954,38 @@ pprPatSkolInfo (PatSynCon ps)
{- Note [Skolem info for pattern synonyms]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
For pattern synonym SkolemInfo we have
SigSkol (PatSynCtxt p) ty
SigSkol (PatSynCtxt p) ty _
but the type 'ty' is not very helpful. The full pattern-synonym type
is has the provided and required pieces, which it is inconvenient to
has the provided and required pieces, which it is inconvenient to
record and display here. So we simply don't display the type at all,
contenting outselves with just the name of the pattern synonym, which
is fine. We could do more, but it doesn't seem worth it.
Note [SigSkol SkolemInfo]
~~~~~~~~~~~~~~~~~~~~~~~~~
Suppose we (deeply) skolemise a type
f :: forall a. a -> forall b. b -> a
Then we'll instantiate [a :-> a', b :-> b'], and with the instantiated
a' -> b' -> a.
But when, in an error message, we report that "b is a rigid type
variable bound by the type signature for f", we want to show the foralls
in the right place. So we proceed as follows:
* In SigSkol we record
- the original signature forall a. a -> forall b. b -> a
- the instantiation mapping [a :-> a', b :-> b']
* Then when tidying in TcMType.tidySkolemInfo, we first tidy a' to
whatever it tidies to, say a''; and then we walk over the type
replacing the binder a by the tidied version a'', to give
forall a''. a'' -> forall b''. b'' -> a''
We need to do this under function arrows, to match what deeplySkolemise
does.
* Typically a'' will have a nice pretty name like "a", but the point is
that the foral-bound variables of the signature we report line up with
the instantiated skolems lying around in other types.
************************************************************************
* *
......
......@@ -1391,7 +1391,7 @@ setImplicationStatus implic@(Implic { ic_binds = ev_binds_var
= Left ic
warnRedundantGivens :: SkolemInfo -> Bool
warnRedundantGivens (SigSkol ctxt _)
warnRedundantGivens (SigSkol ctxt _ _)
= case ctxt of
FunSigCtxt _ warn_redundant -> warn_redundant
ExprSigCtxt -> True
......
......@@ -719,15 +719,13 @@ tc_sub_type_ds eq_orig inst_orig ctxt ty_actual ty_expected
| not (isPredTy act_arg)
, not (isPredTy exp_arg)
= -- See Note [Co/contra-variance of subsumption checking]
do { res_wrap <- tc_sub_type_ds eq_orig inst_orig ctxt act_res exp_res
; arg_wrap
<- tc_sub_tc_type eq_orig (GivenOrigin
(SigSkol GenSigCtxt exp_arg))
ctxt exp_arg act_arg
do { res_wrap <- tc_sub_type_ds eq_orig inst_orig ctxt act_res exp_res
; arg_wrap <- tc_sub_tc_type eq_orig given_orig ctxt exp_arg act_arg
; return (mkWpFun arg_wrap res_wrap exp_arg exp_res doc) }
-- arg_wrap :: exp_arg ~> act_arg
-- res_wrap :: act-res ~> exp_res
where
given_orig = GivenOrigin (SigSkol GenSigCtxt exp_arg [])
doc = text "When checking that" <+> quotes (ppr ty_actual) <+>
text "is more polymorphic than" <+> quotes (ppr ty_expected)
......@@ -1040,14 +1038,14 @@ tcSkolemise ctxt expected_ty thing_inside
-- We expect expected_ty to be a forall-type
-- If not, the call is a no-op
= do { traceTc "tcSkolemise" Outputable.empty
; (wrap, tvs', given, rho') <- deeplySkolemise expected_ty
; (wrap, tv_prs, given, rho') <- deeplySkolemise expected_ty
; lvl <- getTcLevel
; when debugIsOn $
traceTc "tcSkolemise" $ vcat [
ppr lvl,
text "expected_ty" <+> ppr expected_ty,
text "inst tyvars" <+> ppr tvs',
text "inst tyvars" <+> ppr tv_prs,
text "given" <+> ppr given,
text "inst type" <+> ppr rho' ]
......@@ -1064,9 +1062,8 @@ tcSkolemise ctxt expected_ty thing_inside
-- TcTyVars, all this is handled automatically with no need for
-- extra faffing around
-- Use the *instantiated* type in the SkolemInfo
-- so that the names of displayed type variables line up
; let skol_info = SigSkol ctxt (mkFunTys (map varType given) rho')
; let tvs' = map snd tv_prs
skol_info = SigSkol ctxt expected_ty tv_prs
; (ev_binds, result) <- checkConstraints skol_info tvs' given $
thing_inside tvs' rho'
......
......@@ -2118,7 +2118,8 @@ checkValidSubst subst@(TCvSubst in_scope tenv cenv) tys cos a
substTy :: HasCallStack => TCvSubst -> Type -> Type
substTy subst ty
| isEmptyTCvSubst subst = ty
| otherwise = checkValidSubst subst [ty] [] $ subst_ty subst ty
| otherwise = checkValidSubst subst [ty] [] $
subst_ty subst ty
-- | Substitute within a 'Type' disabling the sanity checks.
-- The problems that the sanity checks in substTy catch are described in
......
ado005.hs:8:3: error:
Could not deduce (Monad f) arising from a do statement
from the context: Applicative f
bound by the type signature for:
test :: Applicative f => (Int -> f Int) -> f Int
at ado005.hs:6:1-48
Possible fix:
add (Monad f) to the context of
the type signature for:
test :: Applicative f => (Int -> f Int) -> f Int
In a stmt of a 'do' block: x <- f 3
In the expression:
do x <- f 3
y <- f x
return (x + y)
In an equation for ‘test’:
test f
= do x <- f 3
y <- f x
return (x + y)
• Could not deduce (Monad f) arising from a do statement
from the context: Applicative f
bound by the type signature for:
test :: forall (f :: * -> *).
Applicative f =>
(Int -> f Int) -> f Int
at ado005.hs:6:1-48
Possible fix:
add (Monad f) to the context of
the type signature for:
test :: forall (f :: * -> *).
Applicative f =>
(Int -> f Int) -> f Int
• In a stmt of a 'do' block: x <- f 3
In the expression:
do x <- f 3
y <- f x
return (x + y)
In an equation for ‘test’:
test f
= do x <- f 3
y <- f x
return (x + y)
......@@ -7,7 +7,7 @@ bkpfail24.bkp:14:15: error:
• Could not deduce: a ~ b
from the context: {H1.T} ~ {H2.T}
bound by the type signature for:
f :: {H1.T} ~ {H2.T} => a -> b
f :: forall a b. {H1.T} ~ {H2.T} => a -> b
at bkpfail24.bkp:13:9-34
‘a’ is a rigid type variable bound by
the type signature for:
......
......@@ -6,7 +6,7 @@ bkpfail44.bkp:10:15: error:
• Could not deduce: a ~ b
from the context: Coercible (T a) (T b)
bound by the type signature for:
f :: Coercible (T a) (T b) => a -> b
f :: forall a b. Coercible (T a) (T b) => a -> b
at bkpfail44.bkp:9:9-44
‘a’ is a rigid type variable bound by
the type signature for:
......
......@@ -3,7 +3,7 @@ T5287.hs:6:10: error:
• Could not deduce (A a oops0)
from the context: A a oops
bound by an instance declaration:
A a oops => Read (D a)
forall a oops. A a oops => Read (D a)
at T5287.hs:6:10-31
The type variable ‘oops0’ is ambiguous
• In the ambiguity check for an instance declaration
......
......@@ -4,7 +4,7 @@ PushedInAsGivens.hs:10:31: error:
because type variable ‘a1’ would escape its scope
This (rigid, skolem) type variable is bound by
the type signature for:
foo :: F Int ~ [a1] => a1 -> Int
foo :: forall a1. F Int ~ [a1] => a1 -> Int
at PushedInAsGivens.hs:9:13-44
• In the expression: y
In the first argument of ‘length’, namely ‘[x, y]’
......
......@@ -4,7 +4,9 @@ T3208b.hs:15:15: error:
arising from a use of ‘apply’
from the context: (OTerm a ~ STerm a, OBJECT a, SUBST a)
bound by the type signature for:
fce' :: (OTerm a ~ STerm a, OBJECT a, SUBST a) => a -> c
fce' :: forall a c.
(OTerm a ~ STerm a, OBJECT a, SUBST a) =>
a -> c
at T3208b.hs:14:1-56
The type variable ‘o0’ is ambiguous
• In the first argument of ‘fce’, namely ‘(apply f)’
......
......@@ -3,7 +3,8 @@ T2664.hs:31:9: error:
• Could not deduce: Dual a ~ Dual b
from the context: ((a :*: b) ~ Dual c, c ~ Dual (a :*: b))
bound by the type signature for:
newPChan :: ((a :*: b) ~ Dual c, c ~ Dual (a :*: b)) =>
newPChan :: forall c.
((a :*: b) ~ Dual c, c ~ Dual (a :*: b)) =>
IO (PChan (a :*: b), PChan c)
at T2664.hs:23:5-12
Expected type: IO (PChan (a :*: b), PChan c)
......
......@@ -3,7 +3,7 @@ T4093a.hs:8:8: error:
• Could not deduce: e ~ ()
from the context: Foo e ~ Maybe e
bound by the type signature for:
hang :: Foo e ~ Maybe e => Foo e
hang :: forall e. Foo e ~ Maybe e => Foo e
at T4093a.hs:7:1-34
‘e’ is a rigid type variable bound by
the type signature for:
......
......@@ -4,7 +4,8 @@ T4093b.hs:31:13: error:
from the context: (EitherCO e (A C O n) (A O O n) ~ A e O n,
EitherCO x (A C C n) (A C O n) ~ A C x n)
bound by the type signature for:
blockToNodeList :: (EitherCO e (A C O n) (A O O n) ~ A e O n,
blockToNodeList :: forall (n :: * -> * -> *) e x.
(EitherCO e (A C O n) (A O O n) ~ A e O n,
EitherCO x (A C C n) (A C O n) ~ A C x n) =>
Block n e x -> A e x n
at T4093b.hs:(19,1)-(22,26)
......
......@@ -4,7 +4,7 @@ T7194.hs:18:35: error:
because type variable ‘a’ would escape its scope
This (rigid, skolem) type variable is bound by
the type signature for:
g :: C (F a) => a -> Int
g :: forall a. C (F a) => a -> Int
at T7194.hs:17:18-41
• In the expression: foo y
In the first argument of ‘length’, namely ‘[x, foo y]’
......
......@@ -5,12 +5,12 @@ MonadFailErrors.hs:16:5: error:
with the failable pattern ‘Just x’
from the context: Monad m
bound by the type signature for:
general :: Monad m => m a
general :: forall (m :: * -> *) a. Monad m => m a
at MonadFailErrors.hs:14:1-25
Possible fix:
add (MonadFail m) to the context of
the type signature for:
general :: Monad m => m a
general :: forall (m :: * -> *) a. Monad m => m a
• In a stmt of a 'do' block: Just x <- undefined
In the expression:
do Just x <- undefined
......
......@@ -5,12 +5,12 @@ MonadFailWarnings.hs:19:5: warning: [-Wmissing-monadfail-instances (in -Wcompat)
(this will become an error in a future GHC release)
from the context: Monad m
bound by the type signature for:
general :: Monad m => m a
general :: forall (m :: * -> *) a. Monad m => m a
at MonadFailWarnings.hs:17:1-25
Possible fix:
add (MonadFail m) to the context of
the type signature for:
general :: Monad m => m a
general :: forall (m :: * -> *) a. Monad m => m a
• In a stmt of a 'do' block: Just x <- undefined
In the expression:
do Just x <- undefined
......
......@@ -16,7 +16,7 @@ overloadedlabelsfail01.hs:14:5: error:
arising from the overloaded label ‘#y’
from the context: IsLabel "x" t
bound by the type signature for:
c :: IsLabel "x" t => t
c :: forall t. IsLabel "x" t => t
at overloadedlabelsfail01.hs:13:1-23
• In the expression: #y
In an equation for ‘c’: c = #y
......@@ -9,7 +9,7 @@ T7848.hs:10:9: error:
because type variable ‘a’ would escape its scope
This (rigid, skolem) type variable is bound by
the type signature for:
(&) :: a
(&) :: forall a. a
at T7848.hs:10:9-35
• In the SPECIALISE pragma {-# SPECIALIZE (&) :: a #-}
In an equation for ‘x’:
......
......@@ -53,7 +53,7 @@ T10403.hs:28:8: warning: [-Wdeferred-type-errors (in -Wdefault)]
because type variable ‘t’ would escape its scope
This (rigid, skolem) type variable is bound by
the type signature for:
app2 :: H (B t)
app2 :: forall t. H (B t)
at T10403.hs:27:1-15
Expected type: H (B t)
Actual type: H f0
......
......@@ -3,7 +3,9 @@ T7230.hs:48:32: error:
• Could not deduce: (x :<<= x1) ~ 'True
from the context: Increasing xs ~ 'True
bound by the type signature for:
crash :: Increasing xs ~ 'True => SList xs -> SBool (Increasing xs)
crash :: forall (xs :: [Nat]).
Increasing xs ~ 'True =>
SList xs -> SBool (Increasing xs)
at T7230.hs:47:1-68
or from: xs ~ (x : xs1)
bound by a pattern with constructor:
......
......@@ -4,7 +4,7 @@ T7594.hs:35:12: error:
‘b’ is untouchable
inside the constraints: (:&:) c0 Real a
bound by a type expected by the context:
(:&:) c0 Real a => a -> b
forall a. (:&:) c0 Real a => a -> b
at T7594.hs:35:8-19
‘b’ is a rigid type variable bound by
the inferred type of bar2 :: b at T7594.hs:35:1-19
......
......@@ -3,13 +3,12 @@ T7220a.hs:17:6: error:
• Could not deduce (C a b)
from the context: (C a0 b, TF b ~ Y)
bound by the type signature for:
f :: (C a0 b, TF b ~ Y) => b
f :: forall b. (C a0 b, TF b ~ Y) => b
at T7220a.hs:17:6-44
Possible fix:
add (C a b) to the context of
the type signature for:
f :: (C a0 b, TF b ~ Y) => b
f :: forall b. (C a0 b, TF b ~ Y) => b
• In the ambiguity check for ‘f’
To defer the ambiguity check to use sites, enable AllowAmbiguousTypes
In the type signature:
f :: (forall b. (C a b, TF b ~ Y) => b) -> X
In the type signature: f :: (forall b. (C a b, TF b ~ Y) => b) -> X
......@@ -30,9 +30,7 @@ T9834.hs:23:10: warning: [-Wdeferred-type-errors (in -Wdefault)]
at T9834.hs:22:11-74
‘a1’ is a rigid type variable bound by
a type expected by the context:
forall (q :: * -> *) a1.
Applicative q =>
Comp p q a1 -> Comp p q a1
forall (q :: * -> *). Applicative q => Nat (Comp p q) (Comp p q)
at T9834.hs:23:10-19
Expected type: Comp p q a1 -> Comp p q a1
Actual type: Comp p q a -> Comp p q a
......
......@@ -2,19 +2,19 @@
T9939.hs:6:1: warning: [-Wredundant-constraints]
• Redundant constraint: Eq a
• In the type signature for:
f1 :: (Eq a, Ord a) => a -> a -> Bool
f1 :: forall a. (Eq a, Ord a) => a -> a -> Bool
T9939.hs:10:1: warning: [-Wredundant-constraints]
• Redundant constraint: Eq a
• In the type signature for:
f2 :: (Eq a, Ord a) => a -> a -> Bool
f2 :: forall a. (Eq a, Ord a) => a -> a -> Bool
T9939.hs:14:1: warning: [-Wredundant-constraints]
• Redundant constraint: Eq b
• In the type signature for:
f3 :: (Eq a, a ~ b, Eq b) => a -> b -> Bool
f3 :: forall a b. (Eq a, a ~ b, Eq b) => a -> b -> Bool
T9939.hs:21:1: warning: [-Wredundant-constraints]
• Redundant constraint: Eq a
• In the type signature for:
f4 :: (Eq a, Eq b) => a -> b -> Equal a b -> Bool
f4 :: forall a b. (Eq a, Eq b) => a -> b -> Equal a b -> Bool
tc168.hs:17:1: error:
• Could not deduce (C a1 (a, b0))
from the context: C a1 (a, b)
• Could not deduce (C a (a1, b0))
from the context: C a (a1, b)
bound by the inferred type for ‘g’:
C a1 (a, b) => a1 -> a
forall a a1 b. C a (a1, b) => a -> a1
at tc168.hs:17:1-16
The type variable ‘b0’ is ambiguous
• In the ambiguity check for the inferred type for ‘g’