summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Peyton Jones <simonpj@microsoft.com>2016-06-11 23:49:27 +0100
committerSimon Peyton Jones <simonpj@microsoft.com>2016-06-13 10:57:03 +0100
commit15b9bf4ba4ab47e6809bf2b3b36ec16e502aea72 (patch)
treee2e7336c63e9b7130ba70f3551ff290d4a25184b
parentd25cb61a1c2a135a2564143a332f8b2962f134bc (diff)
downloadhaskell-15b9bf4ba4ab47e6809bf2b3b36ec16e502aea72.tar.gz
Improve typechecking of let-bindings
This major commit was initially triggered by #11339, but it spiraled into a major review of the way in which type signatures for bindings are handled, especially partial type signatures. On the way I fixed a number of other bugs, namely #12069 #12033 #11700 #11339 #11670 The main change is that I completely reorganised the way in which type signatures in bindings are handled. The new story is in TcSigs Note [Overview of type signatures]. Some specific: * Changes in the data types for signatures in TcRnTypes: TcIdSigInfo and new TcIdSigInst * New module TcSigs deals with typechecking type signatures and pragmas. It contains code mostly moved from TcBinds, which is already too big * HsTypes: I swapped the nesting of HsWildCardBndrs and HsImplicitBndsrs, so that the wildcards are on the oustide not the insidde in a LHsSigWcType. This is just a matter of convenient, nothing deep. There are a host of other changes as knock-on effects, and it all took FAR longer than I anticipated :-). But it is a significant improvement, I think. Lots of error messages changed slightly, some just variants but some modest improvements. New tests * typecheck/should_compile * SigTyVars: a scoped-tyvar test * ExPat, ExPatFail: existential pattern bindings * T12069 * T11700 * T11339 * partial-sigs/should_compile * T12033 * T11339a * T11670 One thing to check: * Small change to output from ghc-api/landmines. Need to check with Alan Zimmerman
-rw-r--r--compiler/deSugar/DsMeta.hs14
-rw-r--r--compiler/deSugar/DsMonad.hs1
-rw-r--r--compiler/ghc.cabal.in1
-rw-r--r--compiler/hsSyn/HsTypes.hs34
-rw-r--r--compiler/hsSyn/HsUtils.hs2
-rw-r--r--compiler/rename/RnTypes.hs184
-rw-r--r--compiler/typecheck/TcBinds.hs1041
-rw-r--r--compiler/typecheck/TcClassDcl.hs45
-rw-r--r--compiler/typecheck/TcEnv.hs2
-rw-r--r--compiler/typecheck/TcErrors.hs20
-rw-r--r--compiler/typecheck/TcExpr.hs88
-rw-r--r--compiler/typecheck/TcHsType.hs306
-rw-r--r--compiler/typecheck/TcInstDcls.hs26
-rw-r--r--compiler/typecheck/TcMType.hs59
-rw-r--r--compiler/typecheck/TcPat.hs174
-rw-r--r--compiler/typecheck/TcPatSyn.hs204
-rw-r--r--compiler/typecheck/TcPatSyn.hs-boot10
-rw-r--r--compiler/typecheck/TcRnDriver.hs8
-rw-r--r--compiler/typecheck/TcRnMonad.hs41
-rw-r--r--compiler/typecheck/TcRnTypes.hs280
-rw-r--r--compiler/typecheck/TcRules.hs2
-rw-r--r--compiler/typecheck/TcSigs.hs763
-rw-r--r--compiler/typecheck/TcSimplify.hs66
-rw-r--r--compiler/typecheck/TcType.hs16
-rw-r--r--compiler/vectorise/Vectorise/Generic/PData.hs2
-rw-r--r--testsuite/tests/arrows/should_fail/T5380.stderr64
-rw-r--r--testsuite/tests/dependent/should_compile/T11241.stderr10
-rw-r--r--testsuite/tests/deriving/should_fail/T7148.stderr36
-rw-r--r--testsuite/tests/deriving/should_fail/T7148a.stderr22
-rw-r--r--testsuite/tests/gadt/T3169.stderr38
-rw-r--r--testsuite/tests/gadt/T7558.stderr30
-rw-r--r--testsuite/tests/gadt/gadt-escape1.stderr38
-rw-r--r--testsuite/tests/gadt/gadt13.stderr34
-rw-r--r--testsuite/tests/gadt/gadt7.stderr40
-rw-r--r--testsuite/tests/gadt/rw.stderr60
-rw-r--r--testsuite/tests/ghc-api/landmines/landmines.stdout8
-rw-r--r--testsuite/tests/ghci/scripts/Defer02.stderr395
-rw-r--r--testsuite/tests/ghci/scripts/T10248.stderr28
-rw-r--r--testsuite/tests/ghci/scripts/ghci050.stderr28
-rw-r--r--testsuite/tests/indexed-types/should_compile/Simple14.stderr35
-rw-r--r--testsuite/tests/indexed-types/should_fail/GADTwrong1.stderr34
-rw-r--r--testsuite/tests/indexed-types/should_fail/Overlap6.stderr28
-rw-r--r--testsuite/tests/indexed-types/should_fail/SimpleFail5a.stderr26
-rw-r--r--testsuite/tests/indexed-types/should_fail/T2664.stderr38
-rw-r--r--testsuite/tests/indexed-types/should_fail/T3330a.hs7
-rw-r--r--testsuite/tests/indexed-types/should_fail/T3330a.stderr74
-rw-r--r--testsuite/tests/indexed-types/should_fail/T3440.stderr48
-rw-r--r--testsuite/tests/indexed-types/should_fail/T4093a.stderr32
-rw-r--r--testsuite/tests/indexed-types/should_fail/T4093b.stderr84
-rw-r--r--testsuite/tests/indexed-types/should_fail/T4174.stderr32
-rw-r--r--testsuite/tests/indexed-types/should_fail/T4272.stderr34
-rw-r--r--testsuite/tests/indexed-types/should_fail/T7786.stderr86
-rw-r--r--testsuite/tests/indexed-types/should_fail/T9662.stderr70
-rw-r--r--testsuite/tests/module/mod71.stderr24
-rw-r--r--testsuite/tests/partial-sigs/should_compile/Defaulting2MROff.stderr14
-rw-r--r--testsuite/tests/partial-sigs/should_compile/Defaulting2MROn.stderr14
-rw-r--r--testsuite/tests/partial-sigs/should_compile/Either.stderr14
-rw-r--r--testsuite/tests/partial-sigs/should_compile/EveryNamed.stderr14
-rw-r--r--testsuite/tests/partial-sigs/should_compile/ExprSigLocal.stderr36
-rw-r--r--testsuite/tests/partial-sigs/should_compile/ExtraConstraints3.stderr8
-rw-r--r--testsuite/tests/partial-sigs/should_compile/SimpleGen.stderr14
-rw-r--r--testsuite/tests/partial-sigs/should_compile/SplicesUsed.stderr179
-rw-r--r--testsuite/tests/partial-sigs/should_compile/SuperCls.stderr8
-rw-r--r--testsuite/tests/partial-sigs/should_compile/T10403.stderr158
-rw-r--r--testsuite/tests/partial-sigs/should_compile/T10438.stderr54
-rw-r--r--testsuite/tests/partial-sigs/should_compile/T10519.stderr12
-rw-r--r--testsuite/tests/partial-sigs/should_compile/T11016.stderr19
-rw-r--r--testsuite/tests/partial-sigs/should_compile/T11192.stderr82
-rw-r--r--testsuite/tests/partial-sigs/should_compile/T11339a.hs6
-rw-r--r--testsuite/tests/partial-sigs/should_compile/T11339a.stderr6
-rw-r--r--testsuite/tests/partial-sigs/should_compile/T11670.hs16
-rw-r--r--testsuite/tests/partial-sigs/should_compile/T11670.stderr36
-rw-r--r--testsuite/tests/partial-sigs/should_compile/T12033.hs13
-rw-r--r--testsuite/tests/partial-sigs/should_compile/T12033.stderr24
-rw-r--r--testsuite/tests/partial-sigs/should_compile/Uncurry.stderr2
-rw-r--r--testsuite/tests/partial-sigs/should_compile/UncurryNamed.stderr2
-rw-r--r--testsuite/tests/partial-sigs/should_compile/WarningWildcardInstantiations.stderr110
-rw-r--r--testsuite/tests/partial-sigs/should_compile/all.T5
-rw-r--r--testsuite/tests/partial-sigs/should_fail/Defaulting1MROff.stderr11
-rw-r--r--testsuite/tests/partial-sigs/should_fail/ExtraConstraintsWildcardInExpressionSignature.hs2
-rw-r--r--testsuite/tests/partial-sigs/should_fail/ExtraConstraintsWildcardInExpressionSignature.stderr36
-rw-r--r--testsuite/tests/partial-sigs/should_fail/ExtraConstraintsWildcardNotEnabled.stderr14
-rw-r--r--testsuite/tests/partial-sigs/should_fail/InstantiatedNamedWildcardsInConstraints.stderr34
-rw-r--r--testsuite/tests/partial-sigs/should_fail/NamedExtraConstraintsWildcard.stderr8
-rw-r--r--testsuite/tests/partial-sigs/should_fail/NamedWildcardExplicitForall.stderr93
-rw-r--r--testsuite/tests/partial-sigs/should_fail/NamedWildcardsEnabled.stderr26
-rw-r--r--testsuite/tests/partial-sigs/should_fail/NamedWildcardsNotEnabled.stderr48
-rw-r--r--testsuite/tests/partial-sigs/should_fail/NamedWildcardsNotInMonotype.stderr24
-rw-r--r--testsuite/tests/partial-sigs/should_fail/PartialTypeSignaturesDisabled.stderr26
-rw-r--r--testsuite/tests/partial-sigs/should_fail/PatBind3.stderr8
-rw-r--r--testsuite/tests/partial-sigs/should_fail/T10045.stderr48
-rw-r--r--testsuite/tests/partial-sigs/should_fail/T10615.stderr68
-rw-r--r--testsuite/tests/partial-sigs/should_fail/T10999.stderr50
-rw-r--r--testsuite/tests/partial-sigs/should_fail/T11122.stderr11
-rw-r--r--testsuite/tests/partial-sigs/should_fail/T11976.stderr14
-rw-r--r--testsuite/tests/partial-sigs/should_fail/TidyClash.stderr18
-rw-r--r--testsuite/tests/partial-sigs/should_fail/TidyClash2.stderr46
-rw-r--r--testsuite/tests/partial-sigs/should_fail/WildcardInstantiations.stderr106
-rw-r--r--testsuite/tests/partial-sigs/should_fail/WildcardsInPatternAndExprSig.stderr148
-rw-r--r--testsuite/tests/partial-sigs/should_fail/all.T3
-rw-r--r--testsuite/tests/patsyn/should_fail/T11010.stderr28
-rw-r--r--testsuite/tests/patsyn/should_fail/T11039.stderr18
-rw-r--r--testsuite/tests/patsyn/should_fail/T11667.stderr82
-rw-r--r--testsuite/tests/polykinds/T10503.stderr32
-rw-r--r--testsuite/tests/polykinds/T11399.hs5
-rw-r--r--testsuite/tests/polykinds/T11399.stderr18
-rw-r--r--testsuite/tests/polykinds/T7438.stderr40
-rw-r--r--testsuite/tests/polykinds/T7594.stderr34
-rw-r--r--testsuite/tests/polykinds/T9017.stderr26
-rw-r--r--testsuite/tests/rename/should_fail/rnfail026.stderr21
-rw-r--r--testsuite/tests/th/T10267.stderr92
-rw-r--r--testsuite/tests/typecheck/should_compile/ExPat.hs17
-rw-r--r--testsuite/tests/typecheck/should_compile/ExPatFail.hs13
-rw-r--r--testsuite/tests/typecheck/should_compile/ExPatFail.stderr14
-rw-r--r--testsuite/tests/typecheck/should_compile/FD1.stderr20
-rw-r--r--testsuite/tests/typecheck/should_compile/FD2.stderr40
-rw-r--r--testsuite/tests/typecheck/should_compile/FD3.stderr30
-rw-r--r--testsuite/tests/typecheck/should_compile/SigTyVars.hs12
-rw-r--r--testsuite/tests/typecheck/should_compile/T10072.stderr16
-rw-r--r--testsuite/tests/typecheck/should_compile/T10632.stderr10
-rw-r--r--testsuite/tests/typecheck/should_compile/T11339.hs32
-rw-r--r--testsuite/tests/typecheck/should_compile/T11339.stderr15
-rw-r--r--testsuite/tests/typecheck/should_compile/T11339b.hs32
-rw-r--r--testsuite/tests/typecheck/should_compile/T11339c.hs32
-rw-r--r--testsuite/tests/typecheck/should_compile/T11339d.hs15
-rw-r--r--testsuite/tests/typecheck/should_compile/T11700.hs18
-rw-r--r--testsuite/tests/typecheck/should_compile/T12069.hs4
-rw-r--r--testsuite/tests/typecheck/should_compile/T2357.hs10
-rw-r--r--testsuite/tests/typecheck/should_compile/T2494.stderr72
-rw-r--r--testsuite/tests/typecheck/should_compile/T9834.stderr92
-rw-r--r--testsuite/tests/typecheck/should_compile/T9939.stderr40
-rw-r--r--testsuite/tests/typecheck/should_compile/all.T9
-rw-r--r--testsuite/tests/typecheck/should_compile/holes.stderr66
-rw-r--r--testsuite/tests/typecheck/should_compile/holes3.stderr72
-rw-r--r--testsuite/tests/typecheck/should_compile/tc141.stderr108
-rw-r--r--testsuite/tests/typecheck/should_fail/T10285.stderr44
-rw-r--r--testsuite/tests/typecheck/should_fail/T10534.stderr38
-rw-r--r--testsuite/tests/typecheck/should_fail/T10715.stderr27
-rw-r--r--testsuite/tests/typecheck/should_fail/T11347.stderr22
-rw-r--r--testsuite/tests/typecheck/should_fail/T1899.stderr30
-rw-r--r--testsuite/tests/typecheck/should_fail/T2714.stderr26
-rw-r--r--testsuite/tests/typecheck/should_fail/T3102.stderr24
-rw-r--r--testsuite/tests/typecheck/should_fail/T5691.stderr38
-rw-r--r--testsuite/tests/typecheck/should_fail/T7264.stderr26
-rw-r--r--testsuite/tests/typecheck/should_fail/T7748a.stderr40
-rw-r--r--testsuite/tests/typecheck/should_fail/T7869.stderr28
-rw-r--r--testsuite/tests/typecheck/should_fail/T8450.stderr22
-rw-r--r--testsuite/tests/typecheck/should_fail/T9109.stderr30
-rw-r--r--testsuite/tests/typecheck/should_fail/mc19.stderr24
-rw-r--r--testsuite/tests/typecheck/should_fail/mc21.stderr26
-rw-r--r--testsuite/tests/typecheck/should_fail/mc22.stderr30
-rw-r--r--testsuite/tests/typecheck/should_fail/tcfail032.stderr26
-rw-r--r--testsuite/tests/typecheck/should_fail/tcfail065.stderr34
-rw-r--r--testsuite/tests/typecheck/should_fail/tcfail068.stderr284
-rw-r--r--testsuite/tests/typecheck/should_fail/tcfail076.stderr38
-rw-r--r--testsuite/tests/typecheck/should_fail/tcfail103.stderr48
-rw-r--r--testsuite/tests/typecheck/should_fail/tcfail131.stderr26
-rw-r--r--testsuite/tests/typecheck/should_fail/tcfail153.stderr34
-rw-r--r--testsuite/tests/typecheck/should_fail/tcfail174.stderr60
-rw-r--r--testsuite/tests/typecheck/should_fail/tcfail175.stderr24
-rw-r--r--testsuite/tests/typecheck/should_fail/tcfail179.stderr44
-rw-r--r--testsuite/tests/typecheck/should_fail/tcfail191.stderr26
-rw-r--r--testsuite/tests/typecheck/should_fail/tcfail193.stderr24
-rw-r--r--testsuite/tests/typecheck/should_fail/tcfail198.stderr2
-rw-r--r--testsuite/tests/typecheck/should_fail/tcfail201.stderr38
-rw-r--r--testsuite/tests/typecheck/should_fail/tcfail206.stderr110
166 files changed, 4762 insertions, 4276 deletions
diff --git a/compiler/deSugar/DsMeta.hs b/compiler/deSugar/DsMeta.hs
index 91489b7bc7..9e13b8665c 100644
--- a/compiler/deSugar/DsMeta.hs
+++ b/compiler/deSugar/DsMeta.hs
@@ -189,8 +189,8 @@ hsSigTvBinders binds
-- here 'k' scopes too
get_scoped_tvs (L _ (TypeSig _ sig))
| HsIB { hsib_vars = implicit_vars
- , hsib_body = sig1 } <- sig
- , (explicit_vars, _) <- splitLHsForAllTy (hswc_body sig1)
+ , hsib_body = hs_ty } <- hswc_body sig
+ , (explicit_vars, _) <- splitLHsForAllTy hs_ty
= implicit_vars ++ map hsLTyVarName explicit_vars
get_scoped_tvs _ = []
@@ -567,7 +567,7 @@ repRuleD (L loc (HsRule n act bndrs lhs _ rhs _))
ruleBndrNames :: LRuleBndr Name -> [Name]
ruleBndrNames (L _ (RuleBndr n)) = [unLoc n]
ruleBndrNames (L _ (RuleBndrSig n sig))
- | HsIB { hsib_vars = vars } <- sig
+ | HsWC { hswc_body = HsIB { hsib_vars = vars }} <- sig
= unLoc n : vars
repRuleBndr :: LRuleBndr Name -> DsM (Core TH.RuleBndrQ)
@@ -735,8 +735,8 @@ rep_wc_ty_sig :: Name -> SrcSpan -> LHsSigWcType Name -> Located Name
-- We must special-case the top-level explicit for-all of a TypeSig
-- See Note [Scoped type variables in bindings]
rep_wc_ty_sig mk_sig loc sig_ty nm
- | HsIB { hsib_vars = implicit_tvs, hsib_body = sig1 } <- sig_ty
- , (explicit_tvs, ctxt, ty) <- splitLHsSigmaTy (hswc_body sig1)
+ | HsIB { hsib_vars = implicit_tvs, hsib_body = hs_ty } <- hswc_body sig_ty
+ , (explicit_tvs, ctxt, ty) <- splitLHsSigmaTy hs_ty
= do { nm1 <- lookupLOcc nm
; let rep_in_scope_tv tv = do { name <- lookupBinder (hsLTyVarName tv)
; repTyVarBndrWithKind tv name }
@@ -917,8 +917,8 @@ repHsPatSynSigType (HsIB { hsib_vars = implicit_tvs
(univs, reqs, exis, provs, ty) = splitLHsPatSynTy body
repHsSigWcType :: LHsSigWcType Name -> DsM (Core TH.TypeQ)
-repHsSigWcType ib_ty@(HsIB { hsib_body = sig1 })
- = repHsSigType (ib_ty { hsib_body = hswc_body sig1 })
+repHsSigWcType (HsWC { hswc_body = sig1 })
+ = repHsSigType sig1
-- yield the representation of a list of types
repLTys :: [LHsType Name] -> DsM [Core TH.TypeQ]
diff --git a/compiler/deSugar/DsMonad.hs b/compiler/deSugar/DsMonad.hs
index 69aa0f9648..0320cdf3a2 100644
--- a/compiler/deSugar/DsMonad.hs
+++ b/compiler/deSugar/DsMonad.hs
@@ -15,7 +15,6 @@ module DsMonad (
foldlM, foldrM, whenGOptM, unsetGOptM, unsetWOptM,
Applicative(..),(<$>),
- newLocalName,
duplicateLocalDs, newSysLocalDs, newSysLocalsDs, newUniqueId,
newFailLocalDs, newPredVarDs,
getSrcSpanDs, putSrcSpanDs,
diff --git a/compiler/ghc.cabal.in b/compiler/ghc.cabal.in
index 24764933c9..cfe350fa8f 100644
--- a/compiler/ghc.cabal.in
+++ b/compiler/ghc.cabal.in
@@ -399,6 +399,7 @@ Library
TcAnnotations
TcArrows
TcBinds
+ TcSigs
TcClassDcl
TcDefaults
TcDeriv
diff --git a/compiler/hsSyn/HsTypes.hs b/compiler/hsSyn/HsTypes.hs
index e5f0f9cde5..a0676c98d6 100644
--- a/compiler/hsSyn/HsTypes.hs
+++ b/compiler/hsSyn/HsTypes.hs
@@ -288,16 +288,12 @@ data HsWildCardBndrs name thing
-- See Note [The wildcard story for types]
= HsWC { hswc_wcs :: PostRn name [Name]
-- Wild cards, both named and anonymous
+ -- after the renamer
- , hswc_ctx :: Maybe SrcSpan
- -- Indicates whether hswc_body has an
- -- extra-constraint wildcard, and if so where
- -- e.g. (Eq a, _) => a -> a
- -- NB: the wildcard stays in HsQualTy inside the type!
- -- So for pretty printing purposes you can ignore
- -- hswc_ctx
-
- , hswc_body :: thing -- Main payload (type or list of types)
+ , hswc_body :: thing
+ -- Main payload (type or list of types)
+ -- If there is an extra-constraints wildcard,
+ -- it's still there in the hsc_body.
}
deriving instance (Data name, Data thing, Data (PostRn name [Name]))
@@ -308,7 +304,7 @@ deriving instance (Data name, Data thing, Data (PostRn name [Name]))
type LHsSigType name = HsImplicitBndrs name (LHsType name) -- Implicit only
type LHsWcType name = HsWildCardBndrs name (LHsType name) -- Wildcard only
-type LHsSigWcType name = HsImplicitBndrs name (LHsWcType name) -- Both
+type LHsSigWcType name = HsWildCardBndrs name (LHsSigType name) -- Both
-- See Note [Representing type signatures]
@@ -319,11 +315,11 @@ hsSigType :: LHsSigType name -> LHsType name
hsSigType = hsImplicitBody
hsSigWcType :: LHsSigWcType name -> LHsType name
-hsSigWcType sig_ty = hswc_body (hsib_body sig_ty)
+hsSigWcType sig_ty = hsib_body (hswc_body sig_ty)
dropWildCards :: LHsSigWcType name -> LHsSigType name
-- Drop the wildcard part of a LHsSigWcType
-dropWildCards sig_ty = sig_ty { hsib_body = hsSigWcType sig_ty }
+dropWildCards sig_ty = hswc_body sig_ty
{- Note [Representing type signatures]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -351,8 +347,7 @@ mkHsImplicitBndrs x = HsIB { hsib_body = x
mkHsWildCardBndrs :: thing -> HsWildCardBndrs RdrName thing
mkHsWildCardBndrs x = HsWC { hswc_body = x
- , hswc_wcs = PlaceHolder
- , hswc_ctx = Nothing }
+ , hswc_wcs = PlaceHolder }
-- Add empty binders. This is a bit suspicious; what if
-- the wrapped thing had free type variables?
@@ -362,8 +357,7 @@ mkEmptyImplicitBndrs x = HsIB { hsib_body = x
mkEmptyWildCardBndrs :: thing -> HsWildCardBndrs Name thing
mkEmptyWildCardBndrs x = HsWC { hswc_body = x
- , hswc_wcs = []
- , hswc_ctx = Nothing }
+ , hswc_wcs = [] }
--------------------------------------------------
@@ -789,8 +783,8 @@ hsWcScopedTvs :: LHsSigWcType Name -> [Name]
-- - the named wildcars; see Note [Scoping of named wildcards]
-- because they scope in the same way
hsWcScopedTvs sig_ty
- | HsIB { hsib_vars = vars, hsib_body = sig_ty1 } <- sig_ty
- , HsWC { hswc_wcs = nwcs, hswc_body = sig_ty2 } <- sig_ty1
+ | HsWC { hswc_wcs = nwcs, hswc_body = sig_ty1 } <- sig_ty
+ , HsIB { hsib_vars = vars, hsib_body = sig_ty2 } <- sig_ty1
= case sig_ty2 of
L _ (HsForAllTy { hst_bndrs = tvs }) -> vars ++ nwcs ++
map hsLTyVarName tvs
@@ -1237,10 +1231,10 @@ ppr_mono_ty _ (HsPArrTy ty) = paBrackets (ppr_mono_lty TopPrec ty)
ppr_mono_ty prec (HsIParamTy n ty) = maybeParen prec FunPrec (ppr n <+> dcolon <+> ppr_mono_lty TopPrec ty)
ppr_mono_ty _ (HsSpliceTy s _) = pprSplice s
ppr_mono_ty _ (HsCoreTy ty) = ppr ty
-ppr_mono_ty _ (HsExplicitListTy _ tys) = quote $ brackets (interpp'SP tys)
+ppr_mono_ty _ (HsExplicitListTy _ tys) = quote $ brackets (interpp'SP tys)
ppr_mono_ty _ (HsExplicitTupleTy _ tys) = quote $ parens (interpp'SP tys)
ppr_mono_ty _ (HsTyLit t) = ppr_tylit t
-ppr_mono_ty _ (HsWildCardTy (AnonWildCard _)) = char '_'
+ppr_mono_ty _ (HsWildCardTy {}) = char '_'
ppr_mono_ty ctxt_prec (HsEqTy ty1 ty2)
= maybeParen ctxt_prec TyOpPrec $
diff --git a/compiler/hsSyn/HsUtils.hs b/compiler/hsSyn/HsUtils.hs
index 43d60a3667..23c8d911ad 100644
--- a/compiler/hsSyn/HsUtils.hs
+++ b/compiler/hsSyn/HsUtils.hs
@@ -564,7 +564,7 @@ mkLHsSigType :: LHsType RdrName -> LHsSigType RdrName
mkLHsSigType ty = mkHsImplicitBndrs ty
mkLHsSigWcType :: LHsType RdrName -> LHsSigWcType RdrName
-mkLHsSigWcType ty = mkHsImplicitBndrs (mkHsWildCardBndrs ty)
+mkLHsSigWcType ty = mkHsWildCardBndrs (mkHsImplicitBndrs ty)
mkClassOpSigs :: [LSig RdrName] -> [LSig RdrName]
-- Convert TypeSig to ClassOpSig
diff --git a/compiler/rename/RnTypes.hs b/compiler/rename/RnTypes.hs
index 08c157163f..d8a58777f9 100644
--- a/compiler/rename/RnTypes.hs
+++ b/compiler/rename/RnTypes.hs
@@ -103,100 +103,95 @@ rn_hs_sig_wc_type :: Bool -- see rnImplicitBndrs
-> RnM (a, FreeVars)
-- rn_hs_sig_wc_type is used for source-language type signatures
rn_hs_sig_wc_type no_implicit_if_forall ctxt
- (HsIB { hsib_body = wc_ty }) thing_inside
- = do { let hs_ty = hswc_body wc_ty
- ; free_vars <- extractFilteredRdrTyVars hs_ty
- ; (free_vars', nwc_rdrs) <- partition_nwcs free_vars
- ; rnImplicitBndrs no_implicit_if_forall free_vars' hs_ty $ \ vars ->
- do { rn_hs_wc_type ctxt wc_ty nwc_rdrs $ \ wc_ty' ->
- thing_inside (HsIB { hsib_vars = vars
- , hsib_body = wc_ty' }) } }
+ (HsWC { hswc_body = HsIB { hsib_body = hs_ty }})
+ thing_inside
+ = do { free_vars <- extractFilteredRdrTyVars hs_ty
+ ; (tv_rdrs, nwc_rdrs) <- partition_nwcs free_vars
+ ; rnImplicitBndrs no_implicit_if_forall tv_rdrs hs_ty $ \ vars ->
+ do { (wcs, hs_ty', fvs1) <- rnWcBody ctxt nwc_rdrs hs_ty
+ ; let sig_ty' = HsWC { hswc_wcs = wcs, hswc_body = ib_ty' }
+ ib_ty' = HsIB { hsib_vars = vars, hsib_body = hs_ty' }
+ ; (res, fvs2) <- thing_inside sig_ty'
+ ; return (res, fvs1 `plusFV` fvs2) } }
rnHsWcType :: HsDocContext -> LHsWcType RdrName -> RnM (LHsWcType Name, FreeVars)
-rnHsWcType ctxt wc_ty@(HsWC { hswc_body = hs_ty })
+rnHsWcType ctxt (HsWC { hswc_body = hs_ty })
= do { free_vars <- extractFilteredRdrTyVars hs_ty
; (_, nwc_rdrs) <- partition_nwcs free_vars
- ; rn_hs_wc_type ctxt wc_ty nwc_rdrs $ \ wc_ty' ->
- return (wc_ty', emptyFVs) }
-
--- | Renames a type with wild card binders.
--- Expects a list of names of type variables that should be replaced with
--- named wild cards. (See Note [Renaming named wild cards])
--- Although the parser does not create named wild cards, it is possible to find
--- them in declaration splices, so the function tries to collect them.
-rn_hs_wc_type :: HsDocContext -> LHsWcType RdrName
- -> [Located RdrName] -- Named wildcards
- -> (LHsWcType Name -> RnM (a, FreeVars))
- -> RnM (a, FreeVars)
-rn_hs_wc_type ctxt (HsWC { hswc_body = hs_ty }) nwc_rdrs thing_inside
+ ; (wcs, hs_ty', fvs) <- rnWcBody ctxt nwc_rdrs hs_ty
+ ; let sig_ty' = HsWC { hswc_wcs = wcs, hswc_body = hs_ty' }
+ ; return (sig_ty', fvs) }
+
+rnWcBody :: HsDocContext -> [Located RdrName] -> LHsType RdrName
+ -> RnM ([Name], LHsType Name, FreeVars)
+rnWcBody ctxt nwc_rdrs hs_ty
= do { nwcs <- mapM newLocalBndrRn nwc_rdrs
- ; bindLocalNamesFV nwcs $
- do { let env = RTKE { rtke_level = TypeLevel
+ ; let env = RTKE { rtke_level = TypeLevel
, rtke_what = RnTypeBody
, rtke_nwcs = mkNameSet nwcs
, rtke_ctxt = ctxt }
- ; (wc_ty, fvs1) <- rnWcSigTy env hs_ty
- ; let wc_ty' :: HsWildCardBndrs Name (LHsType Name)
- wc_ty' = wc_ty { hswc_wcs = nwcs ++ hswc_wcs wc_ty }
- ; (res, fvs2) <- thing_inside wc_ty'
- ; return (res, fvs1 `plusFV` fvs2) } }
+ ; (hs_ty', fvs) <- bindLocalNamesFV nwcs $
+ rn_lty env hs_ty
+ ; let awcs = collectAnonWildCards hs_ty'
+ ; return (nwcs ++ awcs, hs_ty', fvs) }
+ where
+ rn_lty env (L loc hs_ty)
+ = setSrcSpan loc $
+ do { (hs_ty', fvs) <- rn_ty env hs_ty
+ ; return (L loc hs_ty', fvs) }
+
+ rn_ty :: RnTyKiEnv -> HsType RdrName -> RnM (HsType Name, FreeVars)
+ -- A lot of faff just to allow the extra-constraints wildcard to appear
+ rn_ty env hs_ty@(HsForAllTy { hst_bndrs = tvs, hst_body = hs_body })
+ = bindLHsTyVarBndrs (rtke_ctxt env) (Just $ inTypeDoc hs_ty)
+ Nothing [] tvs $ \ _ tvs' _ _ ->
+ do { (hs_body', fvs) <- rn_lty env hs_body
+ ; return (HsForAllTy { hst_bndrs = tvs', hst_body = hs_body' }, fvs) }
+
+ rn_ty env (HsQualTy { hst_ctxt = L cx hs_ctxt, hst_body = hs_ty })
+ | Just (hs_ctxt1, hs_ctxt_last) <- snocView hs_ctxt
+ , L lx (HsWildCardTy wc) <- ignoreParens hs_ctxt_last
+ = do { (hs_ctxt1', fvs1) <- mapFvRn (rn_top_constraint env) hs_ctxt1
+ ; wc' <- setSrcSpan lx $
+ do { checkExtraConstraintWildCard env wc
+ ; rnAnonWildCard wc }
+ ; let hs_ctxt' = hs_ctxt1' ++ [L lx (HsWildCardTy wc')]
+ ; (hs_ty', fvs2) <- rnLHsTyKi env hs_ty
+ ; return (HsQualTy { hst_ctxt = L cx hs_ctxt', hst_body = hs_ty' }
+ , fvs1 `plusFV` fvs2) }
+
+ | otherwise
+ = do { (hs_ctxt', fvs1) <- mapFvRn (rn_top_constraint env) hs_ctxt
+ ; (hs_ty', fvs2) <- rnLHsTyKi env hs_ty
+ ; return (HsQualTy { hst_ctxt = L cx hs_ctxt', hst_body = hs_ty' }
+ , fvs1 `plusFV` fvs2) }
+
+ rn_ty env hs_ty = rnHsTyKi env hs_ty
+
+ rn_top_constraint env = rnLHsTyKi (env { rtke_what = RnTopConstraint })
-rnWcSigTy :: RnTyKiEnv -> LHsType RdrName
- -> RnM (LHsWcType Name, FreeVars)
--- ^ Renames just the top level of a type signature
--- It's exactly like rnHsTyKi, except that it uses rnWcSigContext
--- on a qualified type, and return info on any extra-constraints
--- wildcard. Some code duplication, but no big deal.
-rnWcSigTy env (L loc hs_ty@(HsForAllTy { hst_bndrs = tvs, hst_body = hs_tau }))
- = bindLHsTyVarBndrs (rtke_ctxt env) (Just $ inTypeDoc hs_ty)
- Nothing [] tvs $ \ _ tvs' _ _ ->
- do { (hs_tau', fvs) <- rnWcSigTy env hs_tau
- ; let hs_ty' = HsForAllTy { hst_bndrs = tvs', hst_body = hswc_body hs_tau' }
- awcs_bndrs = collectAnonWildCardsBndrs tvs'
- ; return ( hs_tau' { hswc_wcs = hswc_wcs hs_tau' ++ awcs_bndrs
- , hswc_body = L loc hs_ty' }, fvs) }
-
-rnWcSigTy env (L loc (HsQualTy { hst_ctxt = hs_ctxt, hst_body = tau }))
- = do { (hs_ctxt', fvs1) <- rnWcSigContext env hs_ctxt
- ; (tau', fvs2) <- rnLHsTyKi env tau
- ; let awcs_tau = collectAnonWildCards tau'
- hs_ty' = HsQualTy { hst_ctxt = hswc_body hs_ctxt'
- , hst_body = tau' }
- ; return ( HsWC { hswc_wcs = hswc_wcs hs_ctxt' ++ awcs_tau
- , hswc_ctx = hswc_ctx hs_ctxt'
- , hswc_body = L loc hs_ty' }
- , fvs1 `plusFV` fvs2) }
-rnWcSigTy env hs_ty
- = do { (hs_ty', fvs) <- rnLHsTyKi env hs_ty
- ; return (HsWC { hswc_wcs = collectAnonWildCards hs_ty'
- , hswc_ctx = Nothing
- , hswc_body = hs_ty' }
- , fvs) }
-
-rnWcSigContext :: RnTyKiEnv -> LHsContext RdrName
- -> RnM (HsWildCardBndrs Name (LHsContext Name), FreeVars)
-rnWcSigContext env (L loc hs_ctxt)
- | Just (hs_ctxt1, hs_ctxt_last) <- snocView hs_ctxt
- , L lx (HsWildCardTy wc) <- ignoreParens hs_ctxt_last
- = do { (hs_ctxt1', fvs) <- mapFvRn rn_top_constraint hs_ctxt1
- ; setSrcSpan lx $ checkExtraConstraintWildCard env wc
- ; wc' <- rnAnonWildCard wc
- ; let hs_ctxt' = hs_ctxt1' ++ [L lx (HsWildCardTy wc')]
- awcs = concatMap collectAnonWildCards hs_ctxt1'
- -- NB: *not* including the extra-constraint wildcard
- ; return ( HsWC { hswc_wcs = awcs
- , hswc_ctx = Just lx
- , hswc_body = L loc hs_ctxt' }
- , fvs ) }
- | otherwise
- = do { (hs_ctxt', fvs) <- mapFvRn rn_top_constraint hs_ctxt
- ; return (HsWC { hswc_wcs = concatMap collectAnonWildCards hs_ctxt'
- , hswc_ctx = Nothing
- , hswc_body = L loc hs_ctxt' }, fvs) }
+checkExtraConstraintWildCard :: RnTyKiEnv -> HsWildCardInfo RdrName
+ -> RnM ()
+-- Rename the extra-constraint spot in a type signature
+-- (blah, _) => type
+-- Check that extra-constraints are allowed at all, and
+-- if so that it's an anonymous wildcard
+checkExtraConstraintWildCard env wc
+ = checkWildCard env mb_bad
where
- rn_top_constraint = rnLHsTyKi (env { rtke_what = RnTopConstraint })
+ mb_bad | not (extraConstraintWildCardsAllowed env)
+ = Just (text "Extra-constraint wildcard" <+> quotes (ppr wc)
+ <+> text "not allowed")
+ | otherwise
+ = Nothing
+extraConstraintWildCardsAllowed :: RnTyKiEnv -> Bool
+extraConstraintWildCardsAllowed env
+ = case rtke_ctxt env of
+ TypeSigCtx {} -> True
+ ExprWithTySigCtx {} -> True
+ _ -> False
-- | Finds free type and kind variables in a type,
-- without duplicates, and
@@ -736,27 +731,6 @@ checkNamedWildCard env name
RnConstraint -> Just constraint_msg
constraint_msg = notAllowed (ppr name) <+> text "in a constraint"
-checkExtraConstraintWildCard :: RnTyKiEnv -> HsWildCardInfo RdrName
- -> RnM ()
--- Rename the extra-constraint spot in a type signature
--- (blah, _) => type
--- Check that extra-constraints are allowed at all, and
--- if so that it's an anonymous wildcard
-checkExtraConstraintWildCard env wc
- = checkWildCard env mb_bad
- where
- mb_bad | not (extraConstraintWildCardsAllowed env)
- = Just (text "Extra-constraint wildcard" <+> quotes (ppr wc)
- <+> text "not allowed")
- | otherwise
- = Nothing
-
-extraConstraintWildCardsAllowed :: RnTyKiEnv -> Bool
-extraConstraintWildCardsAllowed env
- = case rtke_ctxt env of
- TypeSigCtx {} -> True
- _ -> False
-
wildCardsAllowed :: RnTyKiEnv -> Bool
-- ^ In what contexts are wildcards permitted
wildCardsAllowed env
@@ -1052,7 +1026,9 @@ collectAnonWildCards lty = go lty
HsRecTy flds -> gos $ map (cd_fld_type . unLoc) flds
HsExplicitListTy _ tys -> gos tys
HsExplicitTupleTy _ tys -> gos tys
- HsForAllTy { hst_body = ty } -> go ty
+ HsForAllTy { hst_bndrs = bndrs
+ , hst_body = ty } -> collectAnonWildCardsBndrs bndrs
+ `mappend` go ty
HsQualTy { hst_ctxt = L _ ctxt
, hst_body = ty } -> gos ctxt `mappend` go ty
-- HsQuasiQuoteTy, HsSpliceTy, HsCoreTy, HsTyLit
diff --git a/compiler/typecheck/TcBinds.hs b/compiler/typecheck/TcBinds.hs
index 8cfd5551ca..10d5901b19 100644
--- a/compiler/typecheck/TcBinds.hs
+++ b/compiler/typecheck/TcBinds.hs
@@ -10,21 +10,18 @@
module TcBinds ( tcLocalBinds, tcTopBinds, tcRecSelBinds,
tcValBinds, tcHsBootSigs, tcPolyCheck,
- tcSpecPrags, tcSpecWrapper,
tcVectDecls, addTypecheckedBinds,
- TcSigInfo(..), TcSigFun,
- TcPragEnv, mkPragEnv,
- tcUserTypeSig, instTcTySig, chooseInferredQuantifiers,
- instTcTySigFromId, tcExtendTyVarEnvFromSig,
- badBootDeclErr) where
+ chooseInferredQuantifiers,
+ badBootDeclErr ) where
import {-# SOURCE #-} TcMatches ( tcGRHSsPat, tcMatchesFun )
import {-# SOURCE #-} TcExpr ( tcMonoExpr )
import {-# SOURCE #-} TcPatSyn ( tcInferPatSynDecl, tcCheckPatSynDecl
- , tcPatSynBuilderBind, tcPatSynSig )
+ , tcPatSynBuilderBind )
import DynFlags
import HsSyn
import HscTypes( isHsBootOrSig )
+import TcSigs
import TcRnMonad
import TcEnv
import TcUnify
@@ -33,12 +30,13 @@ import TcEvidence
import TcHsType
import TcPat
import TcMType
-import Inst( topInstantiate, deeplyInstantiate )
+import Inst( deeplyInstantiate )
import FamInstEnv( normaliseType )
import FamInst( tcGetFamInstEnvs )
import TyCon
import TcType
import TysPrim
+import TysWiredIn( cTupleTyConName )
import Id
import Var
import VarSet
@@ -57,7 +55,7 @@ import Util
import BasicTypes
import Outputable
import Type(mkStrLitTy, tidyOpenType)
-import PrelNames( mkUnboundName, gHC_PRIM, ipClassName )
+import PrelNames( gHC_PRIM, ipClassName )
import TcValidity (checkValidType)
import UniqFM
import qualified GHC.LanguageExtensions as LangExt
@@ -360,7 +358,7 @@ tcValBinds top_lvl binds sigs thing_inside
{ (binds', (extra_binds', thing)) <- tcBindGroups top_lvl sig_fn prag_fn binds $ do
{ thing <- thing_inside
-- See Note [Pattern synonym builders don't yield dependencies]
- ; patsyn_builders <- mapM (tcPatSynBuilderBind sig_fn) patsyns
+ ; patsyn_builders <- mapM tcPatSynBuilderBind patsyns
; let extra_binds = [ (NonRecursive, builder) | builder <- patsyn_builders ]
; return (extra_binds, thing) }
; return (binds' ++ extra_binds', thing) }}
@@ -550,7 +548,7 @@ tcPolyBinds top_lvl sig_fn prag_fn rec_group rec_tc closed bind_list
; result@(tc_binds, poly_ids) <- case plan of
NoGen -> tcPolyNoGen rec_tc prag_fn sig_fn bind_list
InferGen mn -> tcPolyInfer rec_tc prag_fn sig_fn mn bind_list
- CheckGen lbind sig -> tcPolyCheck rec_tc prag_fn sig lbind
+ CheckGen lbind sig -> tcPolyCheck prag_fn sig lbind
-- Check whether strict bindings are ok
-- These must be non-recursive etc, and are not generalised
@@ -568,7 +566,32 @@ tcPolyBinds top_lvl sig_fn prag_fn rec_group rec_tc closed bind_list
-- may no longer be adjacent; so find the narrowest
-- span that includes them all
-------------------
+--------------
+-- If typechecking the binds fails, then return with each
+-- signature-less binder given type (forall a.a), to minimise
+-- subsequent error messages
+recoveryCode :: [Name] -> TcSigFun -> TcM (LHsBinds TcId, [Id])
+recoveryCode binder_names sig_fn
+ = do { traceTc "tcBindsWithSigs: error recovery" (ppr binder_names)
+ ; let poly_ids = map mk_dummy binder_names
+ ; return (emptyBag, poly_ids) }
+ where
+ mk_dummy name
+ | Just sig <- sig_fn name
+ , Just poly_id <- completeSigPolyId_maybe sig
+ = poly_id
+ | otherwise
+ = mkLocalId name forall_a_a
+
+forall_a_a :: TcType
+forall_a_a = mkSpecForAllTys [runtimeRep1TyVar, openAlphaTyVar] openAlphaTy
+
+{- *********************************************************************
+* *
+ tcPolyNoGen
+* *
+********************************************************************* -}
+
tcPolyNoGen -- No generalisation whatsoever
:: RecFlag -- Whether it's recursive after breaking
-- dependencies based on type signatures
@@ -594,57 +617,87 @@ tcPolyNoGen rec_tc prag_fn tc_sig_fn bind_list
-- Indeed that is why we call it here!
-- So we can safely ignore _specs
-------------------
-tcPolyCheck :: RecFlag -- Whether it's recursive after breaking
- -- dependencies based on type signatures
- -> TcPragEnv
- -> TcIdSigInfo
- -> LHsBind Name
+
+{- *********************************************************************
+* *
+ tcPolyCheck
+* *
+********************************************************************* -}
+
+tcPolyCheck :: TcPragEnv
+ -> TcIdSigInfo -- Must be a complete signature
+ -> LHsBind Name -- Must be a FunBind
-> TcM (LHsBinds TcId, [TcId])
-- There is just one binding,
--- it binds a single variable,
+-- it is a Funbind
-- it has a complete type signature,
-tcPolyCheck rec_tc prag_fn
- sig@(TISI { sig_bndr = CompleteSig poly_id
- , sig_skols = skol_prs
- , sig_theta = theta
- , sig_tau = tau
- , sig_ctxt = ctxt
- , sig_loc = loc })
- bind
- = do { ev_vars <- newEvVars theta
- ; let skol_info = SigSkol ctxt (mkPhiTy theta tau)
- prag_sigs = lookupPragEnv prag_fn name
- skol_tvs = map snd skol_prs
- -- Find the location of the original source type sig, if
- -- there is was one. This will appear in messages like
- -- "type variable x is bound by .. at <loc>"
- name = idName poly_id
- ; (ev_binds, (binds', _))
- <- setSrcSpan loc $
- checkConstraints skol_info skol_tvs ev_vars $
- tcMonoBinds rec_tc (\_ -> Just (TcIdSig sig)) LetLclBndr [bind]
-
+tcPolyCheck prag_fn
+ (CompleteSig { sig_bndr = poly_id
+ , sig_ctxt = ctxt
+ , sig_loc = sig_loc })
+ (L loc (FunBind { fun_id = L nm_loc name
+ , 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
+ -- 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_tvs = map snd tv_prs
+
+ ; (ev_binds, (co_fn, matches'))
+ <- checkConstraints skol_info skol_tvs ev_vars $
+ tcExtendIdBndrs [TcIdBndr mono_id NotTopLevel] $
+ tcExtendTyVarEnv2 tv_prs $
+ setSrcSpan loc $
+ tcMatchesFun (L nm_loc mono_name) matches (mkCheckExpType tau)
+
+ ; let prag_sigs = lookupPragEnv prag_fn name
; spec_prags <- tcSpecPrags poly_id prag_sigs
; poly_id <- addInlinePrags poly_id prag_sigs
- ; let bind' = case bagToList binds' of
- [b] -> b
- _ -> pprPanic "tcPolyCheck" (ppr binds')
+ ; let bind' = FunBind { fun_id = L nm_loc mono_id
+ , fun_matches = matches'
+ , fun_co_fn = co_fn
+ , bind_fvs = placeHolderNamesTc
+ , fun_tick = [] }
+
abs_bind = L loc $ AbsBindsSig
- { abs_tvs = skol_tvs
- , abs_ev_vars = ev_vars
- , abs_sig_export = poly_id
- , abs_sig_prags = SpecPrags spec_prags
+ { abs_sig_export = poly_id
+ , abs_tvs = skol_tvs
+ , abs_ev_vars = ev_vars
+ , abs_sig_prags = SpecPrags spec_prags
, abs_sig_ev_bind = ev_binds
- , abs_sig_bind = bind' }
+ , abs_sig_bind = L loc bind' }
; return (unitBag abs_bind, [poly_id]) }
-tcPolyCheck _rec_tc _prag_fn sig _bind
- = pprPanic "tcPolyCheck" (ppr sig)
+tcPolyCheck _prag_fn sig bind
+ = pprPanic "tcPolyCheck" (ppr sig $$ ppr bind)
+
+{- Note [Instantiate sig with fresh variables]
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+It's vital to instantiate a type signature with fresh variables.
+For example:
+ type T = forall a. [a] -> [a]
+ f :: T;
+ f = g where { g :: T; g = <rhs> }
+
+ We must not use the same 'a' from the defn of T at both places!!
+(Instantiation is only necessary because of type synonyms. Otherwise,
+it's all cool; each signature has distinct type variables from the renamer.)
+-}
+
+
+{- *********************************************************************
+* *
+ tcPolyInfer
+* *
+********************************************************************* -}
-------------------
tcPolyInfer
:: RecFlag -- Whether it's recursive after breaking
-- dependencies based on type signatures
@@ -661,6 +714,8 @@ tcPolyInfer rec_tc prag_fn tc_sig_fn mono bind_list
| info <- mono_infos ]
sigs = [ sig | MBI { mbi_sig = Just sig } <- mono_infos ]
+ ; mapM_ (checkOverloadedSig mono) sigs
+
; traceTc "simplifyInfer call" (ppr tclvl $$ ppr name_taus $$ ppr wanted)
; (qtvs, givens, ev_binds)
<- simplifyInfer tclvl mono sigs name_taus wanted
@@ -713,11 +768,11 @@ mkExport prag_fn qtvs theta
-- See Note [Impedence matching]
-- NB: we have already done checkValidType, including an ambiguity check,
-- on the type; either when we checked the sig or in mkInferredPolyId
- ; let sel_poly_ty = mkInvSigmaTy qtvs theta mono_ty
- -- this type is just going into tcSubType, so Inv vs. Spec doesn't
- -- matter
+ ; let poly_ty = idType poly_id
+ sel_poly_ty = mkInvSigmaTy qtvs theta mono_ty
+ -- This type is just going into tcSubType,
+ -- so Inv vs. Spec doesn't matter
- poly_ty = idType poly_id
; wrap <- if sel_poly_ty `eqType` poly_ty -- NB: eqType ignores visibility
then return idHsWrapper -- Fast path; also avoids complaint when we infer
-- an ambiguouse type and have AllowAmbiguousType
@@ -739,11 +794,11 @@ mkExport prag_fn qtvs theta
sig_ctxt = InfSigCtxt poly_name
mkInferredPolyId :: [TyVar] -> TcThetaType
- -> Name -> Maybe TcIdSigInfo -> TcType
+ -> Name -> Maybe TcIdSigInst -> TcType
-> TcM TcId
-mkInferredPolyId qtvs inferred_theta poly_name mb_sig mono_ty
- | Just sig <- mb_sig
- , Just poly_id <- completeIdSigPolyId_maybe sig
+mkInferredPolyId qtvs inferred_theta poly_name mb_sig_inst mono_ty
+ | Just (TISI { sig_inst_sig = sig }) <- mb_sig_inst
+ , CompleteSig { sig_bndr = poly_id } <- sig
= return poly_id
| otherwise -- Either no type sig or partial type sig
@@ -763,7 +818,7 @@ mkInferredPolyId qtvs inferred_theta poly_name mb_sig mono_ty
-- it in the call to tcSubType below
; (binders, theta') <- chooseInferredQuantifiers inferred_theta
- (tyCoVarsOfType mono_ty') qtvs mb_sig
+ (tyCoVarsOfType mono_ty') qtvs mb_sig_inst
; let inferred_poly_ty = mkForAllTys binders (mkPhiTy theta' mono_ty')
@@ -779,7 +834,7 @@ mkInferredPolyId qtvs inferred_theta poly_name mb_sig mono_ty
chooseInferredQuantifiers :: TcThetaType -- inferred
-> TcTyVarSet -- tvs free in tau type
-> [TcTyVar] -- inferred quantified tvs
- -> Maybe TcIdSigInfo
+ -> Maybe TcIdSigInst
-> TcM ([TcTyBinder], TcThetaType)
chooseInferredQuantifiers inferred_theta tau_tvs qtvs Nothing
= -- No type signature (partial or complete) for this binder,
@@ -792,20 +847,18 @@ chooseInferredQuantifiers inferred_theta tau_tvs qtvs Nothing
; return (binders, my_theta) }
chooseInferredQuantifiers inferred_theta tau_tvs qtvs
- (Just (TISI { sig_bndr = bndr_info -- Always PartialSig
- , sig_ctxt = ctxt
- , sig_theta = annotated_theta
- , sig_skols = annotated_tvs }))
- | PartialSig { sig_cts = extra } <- bndr_info
- , Nothing <- extra
+ (Just (TISI { sig_inst_sig = sig -- Always PartialSig
+ , sig_inst_wcx = wcx
+ , sig_inst_theta = annotated_theta
+ , sig_inst_skols = annotated_tvs }))
+ | Nothing <- wcx
= do { annotated_theta <- zonkTcTypes annotated_theta
; let free_tvs = closeOverKinds (tyCoVarsOfTypes annotated_theta
`unionVarSet` tau_tvs)
- ; traceTc "ciq" (vcat [ ppr bndr_info, ppr annotated_theta, ppr free_tvs])
+ ; traceTc "ciq" (vcat [ ppr sig, ppr annotated_theta, ppr free_tvs])
; return (mk_binders free_tvs, annotated_theta) }
- | PartialSig { sig_cts = extra, sig_hs_ty = hs_ty } <- bndr_info
- , Just loc <- extra
+ | Just wc_var <- wcx
= do { annotated_theta <- zonkTcTypes annotated_theta
; let free_tvs = closeOverKinds (tyCoVarsOfTypes annotated_theta
`unionVarSet` tau_tvs)
@@ -818,32 +871,19 @@ chooseInferredQuantifiers inferred_theta tau_tvs qtvs
inferred_diff = [ pred
| pred <- my_theta
, all (not . (`eqType` pred)) annotated_theta ]
- ; partial_sigs <- xoptM LangExt.PartialTypeSignatures
- ; warn_partial_sigs <- woptM Opt_WarnPartialTypeSignatures
- ; msg <- mkLongErrAt loc (mk_msg inferred_diff partial_sigs hs_ty) empty
+ ; ctuple <- mk_ctuple inferred_diff
+ ; writeMetaTyVar wc_var ctuple
; traceTc "completeTheta" $
- vcat [ ppr bndr_info
+ vcat [ ppr sig
, ppr annotated_theta, ppr inferred_theta
, ppr inferred_diff ]
- ; case partial_sigs of
- True | warn_partial_sigs ->
- reportWarning (Reason Opt_WarnPartialTypeSignatures) msg
- | otherwise -> return ()
- False -> reportError msg
; return (mk_binders free_tvs, my_theta) }
| otherwise -- A complete type signature is dealt with in mkInferredPolyId
- = pprPanic "chooseInferredQuantifiers" (ppr bndr_info)
+ = pprPanic "chooseInferredQuantifiers" (ppr sig)
where
- pts_hint = text "To use the inferred type, enable PartialTypeSignatures"
- mk_msg inferred_diff suppress_hint hs_ty
- = vcat [ hang ((text "Found constraint wildcard") <+> quotes (char '_'))
- 2 (text "standing for") <+> quotes (pprTheta inferred_diff)
- , if suppress_hint then empty else pts_hint
- , pprSigCtxt ctxt (ppr hs_ty) ]
-
spec_tv_set = mkVarSet $ map snd annotated_tvs
mk_binders free_tvs
= [ mkNamedBinder vis tv
@@ -853,6 +893,10 @@ chooseInferredQuantifiers inferred_theta tau_tvs qtvs
| otherwise = Invisible ]
-- Pulling from qtvs maintains original order
+ mk_ctuple [pred] = return pred
+ mk_ctuple preds = do { tc <- tcLookupTyCon (cTupleTyConName (length preds))
+ ; return (mkTyConApp tc preds) }
+
mk_impedence_match_msg :: MonoBindInfo
-> TcType -> TcType
-> TidyEnv -> TcM (TidyEnv, SDoc)
@@ -882,7 +926,7 @@ mk_inf_msg poly_name poly_ty tidy_env
-- | Warn the user about polymorphic local binders that lack type signatures.
-localSigWarn :: WarningFlag -> Id -> Maybe TcIdSigInfo -> TcM ()
+localSigWarn :: WarningFlag -> Id -> Maybe TcIdSigInst -> TcM ()
localSigWarn flag id mb_sig
| Just _ <- mb_sig = return ()
| not (isSigmaTy (idType id)) = return ()
@@ -898,13 +942,32 @@ warnMissingSignatures flag msg id
where
mk_msg ty = sep [ msg, nest 2 $ pprPrefixName (idName id) <+> dcolon <+> ppr ty ]
-{-
-Note [Partial type signatures and generalisation]
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-When we have a partial type signature, like
+checkOverloadedSig :: Bool -> TcIdSigInst -> TcM ()
+-- Example:
+-- f :: Eq a => a -> a
+-- K f = e
+-- The MR applies, but the signature is overloaded, and it's
+-- best to complain about this directly
+-- c.f Trac #11339
+checkOverloadedSig monomorphism_restriction_applies sig
+ | not (null (sig_inst_theta sig))
+ , monomorphism_restriction_applies
+ , let orig_sig = sig_inst_sig sig
+ = setSrcSpan (sig_loc orig_sig) $
+ failWith $
+ hang (text "Illegal overloaded signature conflicts with monomorphism restriction")
+ 2 (ppr orig_sig)
+ | otherwise
+ = return ()
+
+{- Note [Partial type signatures and generalisation]
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+If /any/ of the signatures in the gropu is a partial type signature
f :: _ -> Int
then we *always* use the InferGen plan, and hence tcPolyInfer.
-We do this even for a local binding with -XMonoLocalBinds.
+We do this even for a local binding with -XMonoLocalBinds, when
+we normally use NoGen.
+
Reasons:
* The TcSigInfo for 'f' has a unification variable for the '_',
whose TcLevel is one level deeper than the current level.
@@ -922,6 +985,14 @@ It might be possible to fix these difficulties somehow, but there
doesn't seem much point. Indeed, adding a partial type signature is a
way to get per-binding inferred generalisation.
+We apply the MR if /all/ of the partial signatures lack a context.
+In particular (Trac #11016):
+ f2 :: (?loc :: Int) => _
+ f2 = ?loc
+It's stupid to apply the MR here. This test includes an extra-constraints
+wildcard; that is, we don't apply the MR if you write
+ f3 :: _ => blah
+
Note [Validity of inferred types]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
We need to check inferred type for validity, in case it uses language
@@ -976,282 +1047,6 @@ It also cleverly does an ambiguity check; for example, rejecting
where F is a non-injective type function.
-}
---------------
--- If typechecking the binds fails, then return with each
--- signature-less binder given type (forall a.a), to minimise
--- subsequent error messages
-recoveryCode :: [Name] -> TcSigFun -> TcM (LHsBinds TcId, [Id])
-recoveryCode binder_names sig_fn
- = do { traceTc "tcBindsWithSigs: error recovery" (ppr binder_names)
- ; let poly_ids = map mk_dummy binder_names
- ; return (emptyBag, poly_ids) }
- where
- mk_dummy name
- | Just sig <- sig_fn name
- , Just poly_id <- completeSigPolyId_maybe sig
- = poly_id
- | otherwise
- = mkLocalId name forall_a_a
-
-forall_a_a :: TcType
-forall_a_a = mkSpecForAllTys [runtimeRep1TyVar, openAlphaTyVar] openAlphaTy
-
-{- *********************************************************************
-* *
- Pragmas, including SPECIALISE
-* *
-************************************************************************
-
-Note [Handling SPECIALISE pragmas]
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-The basic idea is this:
-
- foo :: Num a => a -> b -> a
- {-# SPECIALISE foo :: Int -> b -> Int #-}
-
-We check that
- (forall a b. Num a => a -> b -> a)
- is more polymorphic than
- forall b. Int -> b -> Int
-(for which we could use tcSubType, but see below), generating a HsWrapper
-to connect the two, something like
- wrap = /\b. <hole> Int b dNumInt
-This wrapper is put in the TcSpecPrag, in the ABExport record of
-the AbsBinds.
-
-
- f :: (Eq a, Ix b) => a -> b -> Bool
- {-# SPECIALISE f :: (Ix p, Ix q) => Int -> (p,q) -> Bool #-}
- f = <poly_rhs>
-
-From this the typechecker generates
-
- AbsBinds [ab] [d1,d2] [([ab], f, f_mono, prags)] binds
-
- SpecPrag (wrap_fn :: forall a b. (Eq a, Ix b) => XXX
- -> forall p q. (Ix p, Ix q) => XXX[ Int/a, (p,q)/b ])
-
-From these we generate:
-
- Rule: forall p, q, (dp:Ix p), (dq:Ix q).
- f Int (p,q) dInt ($dfInPair dp dq) = f_spec p q dp dq
-
- Spec bind: f_spec = wrap_fn <poly_rhs>
-
-Note that
-
- * The LHS of the rule may mention dictionary *expressions* (eg
- $dfIxPair dp dq), and that is essential because the dp, dq are
- needed on the RHS.
-
- * The RHS of f_spec, <poly_rhs> has a *copy* of 'binds', so that it
- can fully specialise it.
-
-
-
-From the TcSpecPrag, in DsBinds we generate a binding for f_spec and a RULE:
-
- f_spec :: Int -> b -> Int
- f_spec = wrap<f rhs>
-
- RULE: forall b (d:Num b). f b d = f_spec b
-
-The RULE is generated by taking apart the HsWrapper, which is a little
-delicate, but works.
-
-Some wrinkles
-
-1. We don't use full-on tcSubType, because that does co and contra
- variance and that in turn will generate too complex a LHS for the
- RULE. So we use a single invocation of skolemise /
- topInstantiate in tcSpecWrapper. (Actually I think that even
- the "deeply" stuff may be too much, because it introduces lambdas,
- though I think it can be made to work without too much trouble.)
-
-2. We need to take care with type families (Trac #5821). Consider
- type instance F Int = Bool
- f :: Num a => a -> F a
- {-# SPECIALISE foo :: Int -> Bool #-}
-
- We *could* try to generate an f_spec with precisely the declared type:
- f_spec :: Int -> Bool
- f_spec = <f rhs> Int dNumInt |> co
-
- RULE: forall d. f Int d = f_spec |> sym co
-
- but the 'co' and 'sym co' are (a) playing no useful role, and (b) are
- hard to generate. At all costs we must avoid this:
- RULE: forall d. f Int d |> co = f_spec
- because the LHS will never match (indeed it's rejected in
- decomposeRuleLhs).
-
- So we simply do this:
- - Generate a constraint to check that the specialised type (after
- skolemiseation) is equal to the instantiated function type.
- - But *discard* the evidence (coercion) for that constraint,
- so that we ultimately generate the simpler code
- f_spec :: Int -> F Int
- f_spec = <f rhs> Int dNumInt
-
- RULE: forall d. f Int d = f_spec
- You can see this discarding happening in
-
-3. Note that the HsWrapper can transform *any* function with the right
- type prefix
- forall ab. (Eq a, Ix b) => XXX
- regardless of XXX. It's sort of polymorphic in XXX. This is
- useful: we use the same wrapper to transform each of the class ops, as
- well as the dict. That's what goes on in TcInstDcls.mk_meth_spec_prags
--}
-
-mkPragEnv :: [LSig Name] -> LHsBinds Name -> TcPragEnv
-mkPragEnv sigs binds
- = foldl extendPragEnv emptyNameEnv prs
- where
- prs = mapMaybe get_sig sigs
-
- get_sig :: LSig Name -> Maybe (Name, LSig Name)
- get_sig (L l (SpecSig lnm@(L _ nm) ty inl)) = Just (nm, L l $ SpecSig lnm ty (add_arity nm inl))
- get_sig (L l (InlineSig lnm@(L _ nm) inl)) = Just (nm, L l $ InlineSig lnm (add_arity nm inl))
- get_sig _ = Nothing
-
- add_arity n inl_prag -- Adjust inl_sat field to match visible arity of function
- | Inline <- inl_inline inl_prag
- -- add arity only for real INLINE pragmas, not INLINABLE
- = case lookupNameEnv ar_env n of
- Just ar -> inl_prag { inl_sat = Just ar }
- Nothing -> WARN( True, text "mkPragEnv no arity" <+> ppr n )
- -- There really should be a binding for every INLINE pragma
- inl_prag
- | otherwise
- = inl_prag
-
- -- ar_env maps a local to the arity of its definition
- ar_env :: NameEnv Arity
- ar_env = foldrBag lhsBindArity emptyNameEnv binds
-
-extendPragEnv :: TcPragEnv -> (Name, LSig Name) -> TcPragEnv
-extendPragEnv prag_fn (n, sig) = extendNameEnv_Acc (:) singleton prag_fn n sig
-
-lhsBindArity :: LHsBind Name -> NameEnv Arity -> NameEnv Arity
-lhsBindArity (L _ (FunBind { fun_id = id, fun_matches = ms })) env
- = extendNameEnv env (unLoc id) (matchGroupArity ms)
-lhsBindArity _ env = env -- PatBind/VarBind
-
-------------------
-tcSpecPrags :: Id -> [LSig Name]
- -> TcM [LTcSpecPrag]
--- Add INLINE and SPECIALSE pragmas
--- INLINE prags are added to the (polymorphic) Id directly
--- SPECIALISE prags are passed to the desugarer via TcSpecPrags
--- Pre-condition: the poly_id is zonked
--- Reason: required by tcSubExp
-tcSpecPrags poly_id prag_sigs
- = do { traceTc "tcSpecPrags" (ppr poly_id <+> ppr spec_sigs)
- ; unless (null bad_sigs) warn_discarded_sigs
- ; pss <- mapAndRecoverM (wrapLocM (tcSpecPrag poly_id)) spec_sigs
- ; return $ concatMap (\(L l ps) -> map (L l) ps) pss }
- where
- spec_sigs = filter isSpecLSig prag_sigs
- bad_sigs = filter is_bad_sig prag_sigs
- is_bad_sig s = not (isSpecLSig s || isInlineLSig s)
-
- warn_discarded_sigs
- = addWarnTc NoReason
- (hang (text "Discarding unexpected pragmas for" <+> ppr poly_id)
- 2 (vcat (map (ppr . getLoc) bad_sigs)))
-
---------------
-tcSpecPrag :: TcId -> Sig Name -> TcM [TcSpecPrag]
-tcSpecPrag poly_id prag@(SpecSig fun_name hs_tys inl)
--- See Note [Handling SPECIALISE pragmas]
---
--- The Name fun_name in the SpecSig may not be the same as that of the poly_id
--- Example: SPECIALISE for a class method: the Name in the SpecSig is
--- for the selector Id, but the poly_id is something like $cop
--- However we want to use fun_name in the error message, since that is
--- what the user wrote (Trac #8537)
- = addErrCtxt (spec_ctxt prag) $
- do { warnIf NoReason (not (isOverloadedTy poly_ty || isInlinePragma inl))
- (text "SPECIALISE pragma for non-overloaded function"
- <+> quotes (ppr fun_name))
- -- Note [SPECIALISE pragmas]
- ; spec_prags <- mapM tc_one hs_tys
- ; traceTc "tcSpecPrag" (ppr poly_id $$ nest 2 (vcat (map ppr spec_prags)))
- ; return spec_prags }
- where
- name = idName poly_id
- poly_ty = idType poly_id
- spec_ctxt prag = hang (text "In the SPECIALISE pragma") 2 (ppr prag)
-
- tc_one hs_ty
- = do { spec_ty <- tcHsSigType (FunSigCtxt name False) hs_ty
- ; wrap <- tcSpecWrapper (FunSigCtxt name True) poly_ty spec_ty
- ; return (SpecPrag poly_id wrap inl) }
-
-tcSpecPrag _ prag = pprPanic "tcSpecPrag" (ppr prag)
-
---------------
-tcSpecWrapper :: UserTypeCtxt -> TcType -> TcType -> TcM HsWrapper
--- A simpler variant of tcSubType, used for SPECIALISE pragmas
--- See Note [Handling SPECIALISE pragmas], wrinkle 1
-tcSpecWrapper ctxt poly_ty spec_ty
- = do { (sk_wrap, inst_wrap)
- <- tcSkolemise ctxt spec_ty $ \ _ spec_tau ->
- do { (inst_wrap, tau) <- topInstantiate orig poly_ty
- ; _ <- unifyType noThing spec_tau tau
- -- Deliberately ignore the evidence
- -- See Note [Handling SPECIALISE pragmas],
- -- wrinkle (2)
- ; return inst_wrap }
- ; return (sk_wrap <.> inst_wrap) }
- where
- orig = SpecPragOrigin ctxt
-
---------------
-tcImpPrags :: [LSig Name] -> TcM [LTcSpecPrag]
--- SPECIALISE pragmas for imported things
-tcImpPrags prags
- = do { this_mod <- getModule
- ; dflags <- getDynFlags
- ; if (not_specialising dflags) then
- return []
- else do
- { pss <- mapAndRecoverM (wrapLocM tcImpSpec)
- [L loc (name,prag)
- | (L loc prag@(SpecSig (L _ name) _ _)) <- prags
- , not (nameIsLocalOrFrom this_mod name) ]
- ; return $ concatMap (\(L l ps) -> map (L l) ps) pss } }
- where
- -- Ignore SPECIALISE pragmas for imported things
- -- when we aren't specialising, or when we aren't generating
- -- code. The latter happens when Haddocking the base library;
- -- we don't wnat complaints about lack of INLINABLE pragmas
- not_specialising dflags
- | not (gopt Opt_Specialise dflags) = True
- | otherwise = case hscTarget dflags of
- HscNothing -> True
- HscInterpreted -> True
- _other -> False
-
-tcImpSpec :: (Name, Sig Name) -> TcM [TcSpecPrag]
-tcImpSpec (name, prag)
- = do { id <- tcLookupId name
- ; unless (isAnyInlinePragma (idInlinePragma id))
- (addWarnTc NoReason (impSpecErr name))
- ; tcSpecPrag id prag }
-
-impSpecErr :: Name -> SDoc
-impSpecErr name
- = hang (text "You cannot SPECIALISE" <+> quotes (ppr name))
- 2 (vcat [ text "because its definition has no INLINE/INLINABLE pragma"
- , parens $ sep
- [ text "or its defining module" <+> quotes (ppr mod)
- , text "was compiled without -O"]])
- where
- mod = nameModule name
-
-
{- *********************************************************************
* *
Vectorisation
@@ -1288,32 +1083,6 @@ tcVect (HsVect s name rhs)
; return $ HsVect s var (L rhs_loc (HsVar (L lv rhs_id)))
}
-{- OLD CODE:
- -- turn the vectorisation declaration into a single non-recursive binding
- ; let bind = L loc $ mkTopFunBind name [mkSimpleMatch [] rhs]
- sigFun = const Nothing
- pragFun = emptyPragEnv
-
- -- perform type inference (including generalisation)
- ; (binds, [id'], _) <- tcPolyInfer False True sigFun pragFun NonRecursive [bind]
-
- ; traceTc "tcVect inferred type" $ ppr (varType id')
- ; traceTc "tcVect bindings" $ ppr binds
-
- -- add all bindings, including the type variable and dictionary bindings produced by type
- -- generalisation to the right-hand side of the vectorisation declaration
- ; let [AbsBinds tvs evs _ evBinds actualBinds] = (map unLoc . bagToList) binds
- ; let [bind'] = bagToList actualBinds
- MatchGroup
- [L _ (Match _ _ (GRHSs [L _ (GRHS _ rhs')] _))]
- _ = (fun_matches . unLoc) bind'
- rhsWrapped = mkHsLams tvs evs (mkHsDictLet evBinds rhs')
-
- -- We return the type-checked 'Id', to propagate the inferred signature
- -- to the vectoriser - see "Note [Typechecked vectorisation pragmas]" in HsDecls
- ; return $ HsVect (L loc id') (Just rhsWrapped)
- }
- -}
tcVect (HsNoVect s name)
= addErrCtxt (vectCtxt name) $
do { var <- wrapLocM tcLookupId name
@@ -1439,6 +1208,10 @@ We do not need to do this
* for FunBinds where we have a signature, bucause we aren't doing inference
-}
+data MonoBindInfo = MBI { mbi_poly_name :: Name
+ , mbi_sig :: Maybe TcIdSigInst
+ , mbi_mono_id :: TcId }
+
tcMonoBinds :: RecFlag -- Whether the binding is recursive for typechecking purposes
-- i.e. the binders are mentioned in their RHSs, and
-- we are not rescued by a type signature
@@ -1473,7 +1246,7 @@ tcMonoBinds is_rec sig_fn no_gen
; (inst_wrap, rhs_ty) <- addErrCtxtM (instErrCtxt name rhs_ty) $
deeplyInstantiate orig rhs_ty
- ; mono_id <- newNoSigLetBndr no_gen name rhs_ty
+ ; mono_id <- newLetBndr no_gen name rhs_ty
; return (unitBag $ L b_loc $
FunBind { fun_id = L nm_loc mono_id,
fun_matches = matches', bind_fvs = fvs,
@@ -1505,15 +1278,6 @@ tcMonoBinds _ sig_fn no_gen binds
; return (listToBag binds', mono_infos) }
-emitWildCardHoles :: MonoBindInfo -> TcM ()
-emitWildCardHoles (MBI { mbi_sig = Just sig })
- | TISI { sig_bndr = bndr, sig_ctxt = ctxt } <- sig
- , PartialSig { sig_wcs = wc_prs, sig_hs_ty = hs_ty } <- bndr
- = addErrCtxt (pprSigCtxt ctxt (ppr hs_ty)) $
- emitWildCardHoleConstraints wc_prs
-emitWildCardHoles _
- = return ()
-
------------------------
-- tcLhs typechecks the LHS of the bindings, to construct the environment in which
-- we typecheck the RHSs. Basically what we are doing is this: for each binder:
@@ -1534,76 +1298,109 @@ data TcMonoBind -- Half completed; LHS done, RHS not done
= TcFunBind MonoBindInfo SrcSpan (MatchGroup Name (LHsExpr Name))
| TcPatBind [MonoBindInfo] (LPat TcId) (GRHSs Name (LHsExpr Name)) TcSigmaType
-data MonoBindInfo = MBI { mbi_poly_name :: Name
- , mbi_sig :: Maybe TcIdSigInfo
- , mbi_mono_id :: TcId }
-
tcLhs :: TcSigFun -> LetBndrSpec -> HsBind Name -> TcM TcMonoBind
tcLhs sig_fn no_gen (FunBind { fun_id = L nm_loc name, fun_matches = matches })
- | Just (TcIdSig sig) <- sig_fn name
- , TISI { sig_tau = tau } <- sig
- = ASSERT2( case no_gen of { LetLclBndr -> True; LetGblBndr {} -> False }
- , ppr name )
- -- { f :: ty; f x = e } is always done via CheckGen (full signature)
- -- or InferGen (partial signature)
- -- see Note [Partial type signatures and generalisation]
- -- Both InferGen and CheckGen gives rise to LetLclBndr
- do { mono_name <- newLocalName name
- ; let mono_id = mkLocalIdOrCoVar mono_name tau
- ; return (TcFunBind (MBI { mbi_poly_name = name
- , mbi_sig = Just sig
- , mbi_mono_id = mono_id })
- nm_loc matches) }
-
- | otherwise
- = do { mono_ty <- newOpenFlexiTyVarTy
- ; mono_id <- newNoSigLetBndr no_gen name mono_ty
- ; return (TcFunBind (MBI { mbi_poly_name = name
- , mbi_sig = Nothing
- , mbi_mono_id = mono_id })
- nm_loc matches) }
+ = do { mono_info <- tcLhsId sig_fn no_gen name
+ ; return (TcFunBind mono_info nm_loc matches) }
tcLhs sig_fn no_gen (PatBind { pat_lhs = pat, pat_rhs = grhss })
- = do { let tc_pat exp_ty = tcLetPat sig_fn no_gen pat exp_ty $
- mapM lookup_info (collectPatBinders pat)
-
- -- After typechecking the pattern, look up the binder
- -- names, which the pattern has brought into scope.
- lookup_info :: Name -> TcM MonoBindInfo
- lookup_info name
- = do { mono_id <- tcLookupId name
- ; let mb_sig = case sig_fn name of
- Just (TcIdSig sig) -> Just sig
- _ -> Nothing
- ; return (MBI { mbi_poly_name = name
- , mbi_sig = mb_sig
- , mbi_mono_id = mono_id }) }
-
- ; ((pat', infos), pat_ty) <- addErrCtxt (patMonoBindsCtxt pat grhss) $
- tcInfer tc_pat
-
- ; return (TcPatBind infos pat' grhss pat_ty) }
+ = do { let bndr_names = collectPatBinders pat
+ ; mbis <- mapM (tcLhsId sig_fn no_gen) bndr_names
+ -- See Note [Existentials in pattern bindings]
+
+ ; let inst_sig_fun = lookupNameEnv $ mkNameEnv $
+ bndr_names `zip` map mbi_mono_id mbis
+
+ ; traceTc "tcLhs" (vcat [ ppr id <+> dcolon <+> ppr (idType id)
+ | mbi <- mbis, let id = mbi_mono_id mbi ]
+ $$ ppr no_gen)
+
+ ; ((pat', _), pat_ty) <- addErrCtxt (patMonoBindsCtxt pat grhss) $
+ tcInfer $ \ exp_ty ->
+ tcLetPat inst_sig_fun pat exp_ty $
+ return () -- mapM (lookup_info inst_sig_fun) bndr_names
+
+ ; return (TcPatBind mbis pat' grhss pat_ty) }
tcLhs _ _ other_bind = pprPanic "tcLhs" (ppr other_bind)
-- AbsBind, VarBind impossible
-------------------
+data LetBndrSpec
+ = LetLclBndr -- We are going to generalise, and wrap in an AbsBinds
+ -- so clone a fresh binder for the local monomorphic Id
+
+ | LetGblBndr TcPragEnv -- Generalisation plan is NoGen, so there isn't going
+ -- to be an AbsBinds; So we must bind the global version
+ -- of the binder right away.
+ -- And here is the inline-pragma information
+
+instance Outputable LetBndrSpec where
+ ppr LetLclBndr = text "LetLclBndr"
+ ppr (LetGblBndr {}) = text "LetGblBndr"
+
+tcLhsId :: TcSigFun -> LetBndrSpec -> Name -> TcM MonoBindInfo
+tcLhsId sig_fn no_gen name
+ | Just (TcIdSig sig) <- sig_fn name
+ = -- A partial type signature on a FunBind, in a mixed group
+ -- e.g. f :: _ -> _
+ -- f x = ...g...
+ -- Just g = ...f...
+ -- Hence always typechecked with InferGen; hence LetLclBndr
+ --
+ -- A compelete type sig on a FunBind is checked with CheckGen
+ -- and does not go via tcLhsId
+ do { inst_sig <- tcInstSig sig
+ ; the_id <- newSigLetBndr no_gen name inst_sig
+ ; return (MBI { mbi_poly_name = name
+ , mbi_sig = Just inst_sig
+ , mbi_mono_id = the_id }) }
+
+ | otherwise
+ = -- No type signature, plan InferGen (LetLclBndr) or NoGen (LetGblBndr)
+ do { mono_ty <- newOpenFlexiTyVarTy
+ ; mono_id <- newLetBndr no_gen name mono_ty
+ ; return (MBI { mbi_poly_name = name
+ , mbi_sig = Nothing
+ , mbi_mono_id = mono_id }) }
+
+------------
+newSigLetBndr :: LetBndrSpec -> Name -> TcIdSigInst -> TcM TcId
+newSigLetBndr (LetGblBndr prags) name (TISI { sig_inst_sig = id_sig })
+ | CompleteSig { sig_bndr = poly_id } <- id_sig
+ = addInlinePrags poly_id (lookupPragEnv prags name)
+newSigLetBndr no_gen name (TISI { sig_inst_tau = tau })
+ = newLetBndr no_gen name tau
+
+newLetBndr :: LetBndrSpec -> Name -> TcType -> TcM TcId
+-- In the polymorphic case when we are going to generalise
+-- (plan InferGen, no_gen = LetLclBndr), generate a "monomorphic version"
+-- of the Id; the original name will be bound to the polymorphic version
+-- by the AbsBinds
+-- In the monomorphic case when we are not going to generalise
+-- (plan NoGen, no_gen = LetGblBndr) there is no AbsBinds,
+-- and we use the original name directly
+newLetBndr LetLclBndr name ty
+ = do { mono_name <- cloneLocalName name
+ ; return (mkLocalId mono_name ty) }
+newLetBndr (LetGblBndr prags) name ty
+ = addInlinePrags (mkLocalId name ty) (lookupPragEnv prags name)
+
+-------------------
tcRhs :: TcMonoBind -> TcM (HsBind TcId)
tcRhs (TcFunBind info@(MBI { mbi_sig = mb_sig, mbi_mono_id = mono_id })
loc matches)
= tcExtendIdBinderStackForRhs [info] $
tcExtendTyVarEnvForRhs mb_sig $
do { traceTc "tcRhs: fun bind" (ppr mono_id $$ ppr (idType mono_id))
- ; (co_fn, matches') <- tcMatchesFun (noLoc $ idName mono_id)
+ ; (co_fn, matches') <- tcMatchesFun (L loc (idName mono_id))
matches (mkCheckExpType $ idType mono_id)
- ; emitWildCardHoles info
; return ( FunBind { fun_id = L loc mono_id
, fun_matches = matches'
, fun_co_fn = co_fn
, bind_fvs = placeHolderNamesTc
, fun_tick = [] } ) }
--- TODO: emit Hole Constraints for wildcards
tcRhs (TcPatBind infos pat' grhss pat_ty)
= -- When we are doing pattern bindings we *don't* bring any scoped
-- type variables into scope unlike function bindings
@@ -1613,26 +1410,23 @@ tcRhs (TcPatBind infos pat' grhss pat_ty)
do { traceTc "tcRhs: pat bind" (ppr pat' $$ ppr pat_ty)
; grhss' <- addErrCtxt (patMonoBindsCtxt pat' grhss) $
tcGRHSsPat grhss pat_ty
- ; mapM_ emitWildCardHoles infos
; return ( PatBind { pat_lhs = pat', pat_rhs = grhss'
, pat_rhs_ty = pat_ty
, bind_fvs = placeHolderNamesTc
, pat_ticks = ([],[]) } )}
-tcExtendTyVarEnvForRhs :: Maybe TcIdSigInfo -> TcM a -> TcM a
+tcExtendTyVarEnvForRhs :: Maybe TcIdSigInst -> TcM a -> TcM a
tcExtendTyVarEnvForRhs Nothing thing_inside
= thing_inside
tcExtendTyVarEnvForRhs (Just sig) thing_inside
= tcExtendTyVarEnvFromSig sig thing_inside
-tcExtendTyVarEnvFromSig :: TcIdSigInfo -> TcM a -> TcM a
-tcExtendTyVarEnvFromSig sig thing_inside
- | TISI { sig_bndr = s_bndr, sig_skols = skol_prs } <- sig
- = tcExtendTyVarEnv2 skol_prs $
- case s_bndr of
- CompleteSig {} -> thing_inside
- PartialSig { sig_wcs = wc_prs } -- Extend the env ad emit the holes
- -> tcExtendTyVarEnv2 wc_prs thing_inside
+tcExtendTyVarEnvFromSig :: TcIdSigInst -> TcM a -> TcM a
+tcExtendTyVarEnvFromSig sig_inst thing_inside
+ | TISI { sig_inst_skols = skol_prs, sig_inst_wcs = wcs } <- sig_inst
+ = tcExtendTyVarEnv2 wcs $
+ tcExtendTyVarEnv2 skol_prs $
+ thing_inside
tcExtendIdBinderStackForRhs :: [MonoBindInfo] -> TcM a -> TcM a
-- Extend the TcIdBinderStack for the RHS of the binding, with
@@ -1657,243 +1451,72 @@ getMonoBindInfo :: [Located TcMonoBind] -> [MonoBindInfo]
getMonoBindInfo tc_binds
= foldr (get_info . unLoc) [] tc_binds
where
- get_info (TcFunBind info _ _) rest = info : rest
+ get_info (TcFunBind info _ _) rest = info : rest
get_info (TcPatBind infos _ _ _) rest = infos ++ rest
-{-
-************************************************************************
-* *
- Signatures
-* *
-************************************************************************
+{- Note [Existentials in pattern bindings]
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+Consider (typecheck/should_compile/ExPat):
+ data T where
+ MkT :: Integral a => a -> Int -> T
-Type signatures are tricky. See Note [Signature skolems] in TcType
-
-@tcSigs@ checks the signatures for validity, and returns a list of
-{\em freshly-instantiated} signatures. That is, the types are already
-split up, and have fresh type variables installed. All non-type-signature
-"RenamedSigs" are ignored.
-
-The @TcSigInfo@ contains @TcTypes@ because they are unified with
-the variable's type, and after that checked to see whether they've
-been instantiated.
-
-Note [Scoped tyvars]
-~~~~~~~~~~~~~~~~~~~~
-The -XScopedTypeVariables flag brings lexically-scoped type variables
-into scope for any explicitly forall-quantified type variables:
- f :: forall a. a -> a
- f x = e
-Then 'a' is in scope inside 'e'.
-
-However, we do *not* support this
- - For pattern bindings e.g
- f :: forall a. a->a
- (f,g) = e
-
-Note [Signature skolems]
-~~~~~~~~~~~~~~~~~~~~~~~~
-When instantiating a type signature, we do so with either skolems or
-SigTv meta-type variables depending on the use_skols boolean. This
-variable is set True when we are typechecking a single function
-binding; and False for pattern bindings and a group of several
-function bindings.
-
-Reason: in the latter cases, the "skolems" can be unified together,
- so they aren't properly rigid in the type-refinement sense.
-NB: unless we are doing H98, each function with a sig will be done
- separately, even if it's mutually recursive, so use_skols will be True
-
-
-Note [Only scoped tyvars are in the TyVarEnv]
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-We are careful to keep only the *lexically scoped* type variables in
-the type environment. Why? After all, the renamer has ensured
-that only legal occurrences occur, so we could put all type variables
-into the type env.
-
-But we want to check that two distinct lexically scoped type variables
-do not map to the same internal type variable. So we need to know which
-the lexically-scoped ones are... and at the moment we do that by putting
-only the lexically scoped ones into the environment.
-
-Note [Instantiate sig with fresh variables]
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-It's vital to instantiate a type signature with fresh variables.
-For example:
- type T = forall a. [a] -> [a]
- f :: T;
- f = g where { g :: T; g = <rhs> }
+and suppose t :: T. Which of these pattern bindings are ok?
- We must not use the same 'a' from the defn of T at both places!!
-(Instantiation is only necessary because of type synonyms. Otherwise,
-it's all cool; each signature has distinct type variables from the renamer.)
+ E1. let { MkT p _ = t } in <body>
-Note [Fail eagerly on bad signatures]
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-If a type signaure is wrong, fail immediately:
+ E2. let { MkT _ q = t } in <body>
- * the type sigs may bind type variables, so proceeding without them
- can lead to a cascade of errors
+ E3. let { MkT (toInteger -> r) _ = t } in <body>
- * the type signature might be ambiguous, in which case checking
- the code against the signature will give a very similar error
- to the ambiguity error.
+Well (E1) is clearly wrong becuase the existential 'a' escapes.
+What type could 'p' possibly have?
-ToDo: this means we fall over if any type sig
-is wrong (eg at the top level of the module),
-which is over-conservative
--}
+But (E2) is fine, despite the existential pattern, because
+q::Int, and nothing escapes.
+
+Even (E3) is fine. The existential pattern binds a dictionary
+for (Integral a) which the view pattern can use to convert the
+a-valued field to an Integer, so r :: Integer.
+
+An easy way to see all three is to imagine the desugaring.
+For (2) it would look like
+ let q = case t of MkT _ q' -> q'
+ in <body>
+
+We typecheck pattern bindings as follows:
+ 1. In tcLhs we bind q'::alpha, for each varibable q bound by the
+ pattern, where q' is a fresh name, and alpha is a fresh
+ unification variable; it will be the monomorphic verion of q that
+ we later generalise
+
+ It's very important that these fresh unification variables
+ alpha are born here, not deep under implications as would happen
+ if we allocated them when we encountered q during tcPat.
+
+ 2. Still in tcLhs, we build a little environment mappting "q" ->
+ q':alpha, and pass that to tcLetPet.
+
+ 3. Then tcLhs invokes tcLetPat to typecheck the patter as usual:
+ - When tcLetPat finds an existential constructor, it binds fresh
+ type variables and dictionaries as usual, and emits an
+ implication constraint.
+
+ - When tcLetPat finds a variable (TcPat.tcPatBndr) it looks it up
+ in the little environment, which should always succeed. And
+ uses tcSubTypeET to connect the type of that variable with the
+ expected type of the pattern.
+
+And that's it! The implication constraints check for the skolem
+escape. It's quite simple and neat, and more exressive than before
+e.g. GHC 8.0 rejects (E2) and (E3).
+
+
+************************************************************************
+* *
+ Generalisation
+* *
+********************************************************************* -}
-tcTySigs :: [LSig Name] -> TcM ([TcId], TcSigFun)
-tcTySigs hs_sigs
- = checkNoErrs $ -- See Note [Fail eagerly on bad signatures]
- do { ty_sigs_s <- mapAndRecoverM tcTySig hs_sigs
- ; let ty_sigs = concat ty_sigs_s
- poly_ids = mapMaybe completeSigPolyId_maybe ty_sigs
- -- The returned [TcId] are the ones for which we have
- -- a complete type signature.
- -- See Note [Complete and partial type signatures]
- env = mkNameEnv [(tcSigInfoName sig, sig) | sig <- ty_sigs]
- ; return (poly_ids, lookupNameEnv env) }
-
-tcTySig :: LSig Name -> TcM [TcSigInfo]
-tcTySig (L _ (IdSig id))
- = do { sig <- instTcTySigFromId id
- ; return [TcIdSig sig] }
-
-tcTySig (L loc (TypeSig names sig_ty))
- = setSrcSpan loc $
- do { sigs <- sequence [ tcUserTypeSig sig_ty (Just name)
- | L _ name <- names ]
- ; return (map TcIdSig sigs) }
-
-tcTySig (L loc (PatSynSig (L _ name) sig_ty))
- = setSrcSpan loc $
- do { tpsi <- tcPatSynSig name sig_ty
- ; return [TcPatSynSig tpsi] }
-
-tcTySig _ = return []
-
-isCompleteHsSig :: LHsSigWcType Name -> Bool
--- ^ If there are no wildcards, return a LHsSigType
-isCompleteHsSig sig_ty
- | HsWC { hswc_wcs = wcs, hswc_ctx = extra } <- hsib_body sig_ty
- , null wcs
- , Nothing <- extra
- = True
- | otherwise
- = False
-
-tcUserTypeSig :: LHsSigWcType Name -> Maybe Name -> TcM TcIdSigInfo
--- Just n => Function type signatre name :: type
--- Nothing => Expression type signature <expr> :: type
-tcUserTypeSig hs_sig_ty mb_name
- | isCompleteHsSig hs_sig_ty
- = pushTcLevelM_ $ -- When instantiating the signature, do so "one level in"
- -- so that they can be unified under the forall
- do { sigma_ty <- tcHsSigWcType ctxt_F hs_sig_ty
- ; (inst_tvs, theta, tau) <- tcInstType tcInstSigTyVars sigma_ty
- ; loc <- getSrcSpanM
- ; return $
- TISI { sig_bndr = CompleteSig (mkLocalId name sigma_ty)
- , sig_skols = findScopedTyVars sigma_ty inst_tvs
- , sig_theta = theta
- , sig_tau = tau
- , sig_ctxt = ctxt_T
- , sig_loc = loc } }
-
- -- Partial sig with wildcards
- | HsIB { hsib_vars = vars, hsib_body = wc_ty } <- hs_sig_ty
- , HsWC { hswc_wcs = wcs, hswc_ctx = extra, hswc_body = hs_ty } <- wc_ty
- , (hs_tvs, L _ hs_ctxt, hs_tau) <- splitLHsSigmaTy hs_ty
- = do { (vars1, (wcs, tvs2, theta, tau))
- <- pushTcLevelM_ $
- -- When instantiating the signature, do so "one level in"
- -- so that they can be unified under the forall
- solveEqualities $
- tcImplicitTKBndrs vars $
- tcWildCardBinders wcs $ \ wcs ->
- tcExplicitTKBndrs hs_tvs $ \ tvs2 ->
- do { -- Instantiate the type-class context; but if there
- -- is an extra-constraints wildcard, just discard it here
- traceTc "tcPartial" (ppr name $$ ppr vars $$ ppr wcs)
- ; theta <- mapM tcLHsPredType $
- case extra of
- Nothing -> hs_ctxt
- Just _ -> dropTail 1 hs_ctxt
-
- ; tau <- tcHsOpenType hs_tau
-
- -- zonking is necessary to establish type representation
- -- invariants
- ; theta <- zonkTcTypes theta
- ; tau <- zonkTcType tau
-
- ; let bound_tvs
- = unionVarSets [ allBoundVariabless theta
- , allBoundVariables tau
- , mkVarSet (map snd wcs) ]
- ; return ((wcs, tvs2, theta, tau), bound_tvs) }
-
- -- NB: checkValidType on the final inferred type will
- -- be done later by checkInferredPolyId
- ; loc <- getSrcSpanM
- ; return $
- TISI { sig_bndr = PartialSig { sig_name = name, sig_hs_ty = hs_ty
- , sig_cts = extra, sig_wcs = wcs }
- , sig_skols = [ (tyVarName tv, tv) | tv <- vars1 ++ tvs2 ]
- , sig_theta = theta
- , sig_tau = tau
- , sig_ctxt = ctxt_F
- , sig_loc = loc } }
- where
- name = case mb_name of
- Just n -> n
- Nothing -> mkUnboundName (mkVarOcc "<expression>")
- ctxt_F = case mb_name of
- Just n -> FunSigCtxt n False
- Nothing -> ExprSigCtxt
- ctxt_T = case mb_name of
- Just n -> FunSigCtxt n True
- Nothing -> ExprSigCtxt
-
-instTcTySigFromId :: Id -> TcM TcIdSigInfo
--- Used for instance methods and record selectors
-instTcTySigFromId id
- = do { let name = idName id
- loc = getSrcSpan name
- ; (tvs, theta, tau) <- tcInstType (tcInstSigTyVarsLoc loc)
- (idType id)
- ; return $ TISI { sig_bndr = CompleteSig id
- , sig_skols = [(tyVarName tv, tv) | tv <- tvs]
- -- These are freshly instantiated, so although
- -- we put them in the type envt, doing so has
- -- no effect
- , sig_theta = theta
- , sig_tau = tau
- , sig_ctxt = FunSigCtxt name False
- -- False: do not report redundant constraints
- -- The user has no control over the signature!
- , sig_loc = loc } }
-
-instTcTySig :: UserTypeCtxt
- -> LHsSigType Name -- Used to get the scoped type variables
- -> TcType
- -> Name -- Name of the function
- -> TcM TcIdSigInfo
-instTcTySig ctxt hs_ty sigma_ty name
- = do { (inst_tvs, theta, tau) <- tcInstType tcInstSigTyVars sigma_ty
- ; return (TISI { sig_bndr = CompleteSig (mkLocalIdOrCoVar name sigma_ty)
- , sig_skols = findScopedTyVars sigma_ty inst_tvs
- , sig_theta = theta
- , sig_tau = tau
- , sig_ctxt = ctxt
- , sig_loc = getLoc (hsSigType hs_ty)
- -- SrcSpan from the signature
- }) }
-
--------------------------------
data GeneralisationPlan
= NoGen -- No generalisation, no AbsBinds
@@ -1916,28 +1539,26 @@ decideGeneralisationPlan
:: DynFlags -> [LHsBind Name] -> IsGroupClosed -> TcSigFun
-> GeneralisationPlan
decideGeneralisationPlan dflags lbinds closed sig_fn
- | unlifted_pat_binds = NoGen
- | Just bind_sig <- one_funbind_with_sig = sig_plan bind_sig
- | mono_local_binds closed = NoGen
- | otherwise = InferGen mono_restriction
+ | unlifted_pat_binds = NoGen
+ | has_partial_sigs = InferGen (and partial_sig_mrs)
+ | Just (bind, sig) <- one_funbind_with_sig = CheckGen bind sig
+ | mono_local_binds closed = NoGen
+ | otherwise = InferGen mono_restriction
where
binds = map unLoc lbinds
- sig_plan :: (LHsBind Name, TcIdSigInfo) -> GeneralisationPlan
+ partial_sig_mrs :: [Bool]
+ -- One for each parital signature (so empty => no partial sigs)
+ -- The Bool is True if the signature has no constraint context
+ -- so we should apply the MR
-- See Note [Partial type signatures and generalisation]
- -- We use InferGen False to say "do inference, but do not apply
- -- the MR". It's stupid to apply the MR when we are given a
- -- signature! C.f Trac #11016, function f2
- sig_plan (lbind, sig@(TISI { sig_bndr = s_bndr, sig_theta = theta }))
- = case s_bndr of
- CompleteSig {} -> CheckGen lbind sig
- PartialSig { sig_cts = extra_constraints }
- | Nothing <- extra_constraints
- , [] <- theta
- -> InferGen True -- No signature constraints: apply the MR
- | otherwise
- -> InferGen False -- Don't apply the MR
+ partial_sig_mrs
+ = [ null theta
+ | TcIdSig (PartialSig { psig_hs_ty = hs_ty })
+ <- mapMaybe sig_fn (collectHsBindListBinders lbinds)
+ , let (_, L _ theta, _) = splitLHsSigmaTy (hsSigWcType hs_ty) ]
+ has_partial_sigs = not (null partial_sig_mrs)
unlifted_pat_binds = any isUnliftedHsBind binds
-- Unlifted patterns (unboxed tuple) must not
-- be polymorphic, because we are going to force them
@@ -1949,8 +1570,6 @@ decideGeneralisationPlan dflags lbinds closed sig_fn
mono_local_binds ClosedGroup = False
mono_local_binds _ = xopt LangExt.MonoLocalBinds dflags
- no_sig n = noCompleteSig (sig_fn n)
-
-- With OutsideIn, all nested bindings are monomorphic
-- except a single function binding with a signature
one_funbind_with_sig
@@ -1974,6 +1593,8 @@ decideGeneralisationPlan dflags lbinds closed sig_fn
-- No args => like a pattern binding
-- Some args => a function binding
+ no_sig n = noCompleteSig (sig_fn n)
+
isClosedBndrGroup :: Bag (LHsBind Name) -> TcM IsGroupClosed
isClosedBndrGroup binds = do
type_env <- getLclTypeEnv
diff --git a/compiler/typecheck/TcClassDcl.hs b/compiler/typecheck/TcClassDcl.hs
index 48b0e56baf..d0978fb5d4 100644
--- a/compiler/typecheck/TcClassDcl.hs
+++ b/compiler/typecheck/TcClassDcl.hs
@@ -20,8 +20,8 @@ module TcClassDcl ( tcClassSigs, tcClassDecl2,
import HsSyn
import TcEnv
-import TcPat( addInlinePrags, lookupPragEnv, emptyPragEnv )
-import TcEvidence( idHsWrapper )
+import TcSigs
+import TcEvidence ( idHsWrapper )
import TcBinds
import TcUnify
import TcHsType
@@ -152,10 +152,10 @@ tcClassSigs clas sigs def_methods
tcClassDecl2 :: LTyClDecl Name -- The class declaration
-> TcM (LHsBinds Id)
-tcClassDecl2 (L loc (ClassDecl {tcdLName = class_name, tcdSigs = sigs,
+tcClassDecl2 (L _ (ClassDecl {tcdLName = class_name, tcdSigs = sigs,
tcdMeths = default_binds}))
= recoverM (return emptyLHsBinds) $
- setSrcSpan loc $
+ setSrcSpan (getLoc class_name) $
do { clas <- tcLookupLocatedClass class_name
-- We make a separate binding for each default method.
@@ -203,7 +203,7 @@ tcDefMeth clas tyvars this_dict binds_in hs_sig_fn prag_fn
= do { -- First look up the default method -- It should be there!
global_dm_id <- tcLookupId dm_name
; global_dm_id <- addInlinePrags global_dm_id prags
- ; local_dm_name <- setSrcSpan bndr_loc (newLocalName sel_name)
+ ; local_dm_name <- newNameAt (getOccName sel_name) bndr_loc
-- Base the local_dm_name on the selector name, because
-- type errors from tcInstanceMethodBody come from here
@@ -241,26 +241,27 @@ tcDefMeth clas tyvars this_dict binds_in hs_sig_fn prag_fn
ctxt = FunSigCtxt sel_name warn_redundant
- ; local_dm_sig <- instTcTySig ctxt hs_ty local_dm_ty local_dm_name
- ; (ev_binds, (tc_bind, _))
+ ; let local_dm_id = mkLocalId local_dm_name local_dm_ty
+ local_dm_sig = CompleteSig { sig_bndr = local_dm_id
+ , sig_ctxt = ctxt
+ , sig_loc = getLoc (hsSigType hs_ty) }
+
+ ; (ev_binds, (tc_bind, _))
<- checkConstraints (ClsSkol clas) tyvars [this_dict] $
- tcPolyCheck NonRecursive no_prag_fn local_dm_sig
+ tcPolyCheck no_prag_fn local_dm_sig
(L bind_loc lm_bind)
- ; let export = ABE { abe_poly = global_dm_id
- -- We have created a complete type signature in
- -- instTcTySig, hence it is safe to call
- -- completeSigPolyId
- , abe_mono = completeIdSigPolyId local_dm_sig
- , abe_wrap = idHsWrapper
- , abe_prags = IsDefaultMethod }
- full_bind = AbsBinds { abs_tvs = tyvars
- , abs_ev_vars = [this_dict]
- , abs_exports = [export]
- , abs_ev_binds = [ev_binds]
- , abs_binds = tc_bind }
-
- ; return (unitBag (L bind_loc full_bind)) }
+ ; let export = ABE { abe_poly = global_dm_id
+ , abe_mono = local_dm_id
+ , abe_wrap = idHsWrapper
+ , abe_prags = IsDefaultMethod }
+ full_bind = AbsBinds { abs_tvs = tyvars
+ , abs_ev_vars = [this_dict]
+ , abs_exports = [export]
+ , abs_ev_binds = [ev_binds]
+ , abs_binds = tc_bind }
+
+ ; return (unitBag (L bind_loc full_bind)) }
| otherwise = pprPanic "tcDefMeth" (ppr sel_id)
where
diff --git a/compiler/typecheck/TcEnv.hs b/compiler/typecheck/TcEnv.hs
index 525e834393..be301f3ba1 100644
--- a/compiler/typecheck/TcEnv.hs
+++ b/compiler/typecheck/TcEnv.hs
@@ -60,7 +60,7 @@ module TcEnv(
topIdLvl, isBrackStage,
-- New Ids
- newLocalName, newDFunName, newDFunName', newFamInstTyConName,
+ newDFunName, newDFunName', newFamInstTyConName,
newFamInstAxiomName,
mkStableIdFromString, mkStableIdFromName,
mkWrapperName
diff --git a/compiler/typecheck/TcErrors.hs b/compiler/typecheck/TcErrors.hs
index e7fb82757b..d5b003b3c5 100644
--- a/compiler/typecheck/TcErrors.hs
+++ b/compiler/typecheck/TcErrors.hs
@@ -1545,7 +1545,7 @@ suggestAddSig ctxt ty1 ty2
inferred_bndrs = nub (get_inf ty1 ++ get_inf ty2)
get_inf ty | Just tv <- tcGetTyVar_maybe ty
, isSkolemTyVar tv
- , (_, InferSkol prs) <- getSkolemInfo (cec_encl ctxt) tv
+ , InferSkol prs <- ic_info (getSkolemInfo (cec_encl ctxt) tv)
= map fst prs
| otherwise
= []
@@ -2477,17 +2477,18 @@ mkAmbigMsg prepend_msg ct
pprSkol :: [Implication] -> TcTyVar -> SDoc
pprSkol implics tv
- | (skol_tvs, skol_info) <- getSkolemInfo implics tv
= case skol_info of
- UnkSkol -> pp_tv <+> text "is an unknown type variable"
+ 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)
where
- pp_tv = quotes (ppr tv)
- ppr_rigid pp_info = hang (pp_tv <+> text "is a rigid type variable bound by")
- 2 (sep [ pp_info
- , text "at" <+> ppr (getSrcLoc tv) ])
+ Implic { ic_skols = skol_tvs, 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
+ , text "at" <+> ppr (getSrcSpan tv) ])
getAmbigTkvs :: Ct -> ([Var],[Var])
getAmbigTkvs ct
@@ -2497,15 +2498,14 @@ getAmbigTkvs ct
ambig_tkvs = filter isAmbiguousTyVar tkvs
dep_tkv_set = tyCoVarsOfTypes (map tyVarKind tkvs)
-getSkolemInfo :: [Implication] -> TcTyVar -> ([TcTyVar], SkolemInfo)
+getSkolemInfo :: [Implication] -> TcTyVar -> Implication
-- Get the skolem info for a type variable
-- from the implication constraint that binds it
getSkolemInfo [] tv
= pprPanic "No skolem info:" (ppr tv)
getSkolemInfo (implic:implics) tv
- | let skols = ic_skols implic
- , tv `elem` ic_skols implic = (skols, ic_info implic)
+ | tv `elem` ic_skols implic = implic
| otherwise = getSkolemInfo implics tv
-----------------------
diff --git a/compiler/typecheck/TcExpr.hs b/compiler/typecheck/TcExpr.hs
index f078ba4da8..816fd9b031 100644
--- a/compiler/typecheck/TcExpr.hs
+++ b/compiler/typecheck/TcExpr.hs
@@ -27,8 +27,8 @@ import TcRnMonad
import TcUnify
import BasicTypes
import Inst
-import TcBinds ( chooseInferredQuantifiers, tcLocalBinds
- , tcUserTypeSig, tcExtendTyVarEnvFromSig )
+import TcBinds ( chooseInferredQuantifiers, tcLocalBinds )
+import TcSigs ( tcUserTypeSig, tcInstSig )
import TcSimplify ( simplifyInfer )
import FamInst ( tcGetFamInstEnvs, tcLookupDataFamInst )
import FamInstEnv ( FamInstEnvs )
@@ -256,8 +256,9 @@ tcExpr e@(HsLamCase matches) res_ty
match_ctxt = MC { mc_what = CaseAlt, mc_body = tcBody }
tcExpr e@(ExprWithTySig expr sig_ty) res_ty
- = do { sig_info <- checkNoErrs $ -- Avoid error cascade
- tcUserTypeSig sig_ty Nothing
+ = do { let loc = getLoc (hsSigWcType sig_ty)
+ ; sig_info <- checkNoErrs $ -- Avoid error cascade
+ tcUserTypeSig loc sig_ty Nothing
; (expr', poly_ty) <- tcExprSig expr sig_info
; let expr'' = ExprWithTySigOut expr' sig_ty
; tcWrapResult e expr'' poly_ty res_ty }
@@ -880,12 +881,13 @@ tcExpr expr@(RecordUpd { rupd_expr = record_expr, rupd_flds = rbnds }) res_ty
; (result_subst, con1_tvs') <- newMetaTyVars con1_tvs
; let result_inst_tys = mkTyVarTys con1_tvs'
+ init_subst = mkEmptyTCvSubst (getTCvInScope result_subst)
- ; (scrut_subst, scrut_inst_tys) <- mapAccumLM mk_inst_ty emptyTCvSubst
+ ; (scrut_subst, scrut_inst_tys) <- mapAccumLM mk_inst_ty init_subst
(con1_tvs `zip` result_inst_tys)
; let rec_res_ty = TcType.substTy result_subst con1_res_ty
- scrut_ty = TcType.substTyUnchecked scrut_subst con1_res_ty
+ scrut_ty = TcType.substTy scrut_subst con1_res_ty
con1_arg_tys' = map (TcType.substTy result_subst) con1_arg_tys
; wrap_res <- tcSubTypeHR (exprCtOrigin expr)
@@ -1443,20 +1445,14 @@ in the other order, the extra signature in f2 is reqd.
********************************************************************* -}
tcExprSig :: LHsExpr Name -> TcIdSigInfo -> TcM (LHsExpr TcId, TcType)
-tcExprSig expr sig@(TISI { sig_bndr = s_bndr
- , sig_skols = skol_prs
- , sig_theta = theta
- , sig_tau = tau })
- | null skol_prs -- Fast path when there is no quantification at all
- , null theta
- , CompleteSig {} <- s_bndr
- = do { expr' <- tcPolyExprNC expr tau
- ; return (expr', tau) }
-
- | CompleteSig poly_id <- s_bndr
- = do { given <- newEvVars theta
+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
+ ; given <- newEvVars theta
+ ; let skol_info = SigSkol ExprSigCtxt (mkPhiTy theta tau)
+ skol_tvs = map snd tv_prs
; (ev_binds, expr') <- checkConstraints skol_info skol_tvs given $
- tcExtendTyVarEnvFromSig sig $
+ tcExtendTyVarEnv2 tv_prs $
tcPolyExprNC expr tau
; let poly_wrap = mkWpTyLams skol_tvs
@@ -1464,20 +1460,26 @@ tcExprSig expr sig@(TISI { sig_bndr = s_bndr
<.> mkWpLet ev_binds
; return (mkLHsWrap poly_wrap expr', idType poly_id) }
- | PartialSig { sig_name = name, sig_wcs = wc_prs, sig_hs_ty = hs_ty } <- s_bndr
- = do { (tclvl, wanted, expr')
+tcExprSig expr sig@(PartialSig { psig_name = name, sig_loc = loc })
+ = setSrcSpan loc $ -- Sets the location for the implication constraint
+ do { (tclvl, wanted, (expr', sig_inst))
<- pushLevelAndCaptureConstraints $
- tcExtendTyVarEnvFromSig sig $
- do { addErrCtxt (pprSigCtxt ExprSigCtxt (ppr hs_ty)) $
- emitWildCardHoleConstraints wc_prs
- ; tcPolyExprNC expr tau }
+ do { sig_inst <- tcInstSig sig
+ ; expr' <- tcExtendTyVarEnv2 (sig_inst_skols sig_inst) $
+ tcExtendTyVarEnv2 (sig_inst_wcs sig_inst) $
+ tcPolyExprNC expr (sig_inst_tau sig_inst)
+ ; return (expr', sig_inst) }
+ -- See Note [Partial expression signatures]
+ ; let tau = sig_inst_tau sig_inst
+ mr = null (sig_inst_theta sig_inst) &&
+ isNothing (sig_inst_wcx sig_inst)
; (qtvs, givens, ev_binds)
- <- simplifyInfer tclvl False [sig] [(name, tau)] wanted
+ <- simplifyInfer tclvl mr [sig_inst] [(name, tau)] wanted
; tau <- zonkTcType tau
; let inferred_theta = map evVarPred givens
tau_tvs = tyCoVarsOfType tau
; (binders, my_theta) <- chooseInferredQuantifiers inferred_theta
- tau_tvs qtvs (Just sig)
+ tau_tvs qtvs (Just sig_inst)
; let inferred_sigma = mkInvSigmaTy qtvs inferred_theta tau
my_sigma = mkForAllTys binders (mkPhiTy my_theta tau)
; wrap <- if inferred_sigma `eqType` my_sigma -- NB: eqType ignores vis.
@@ -1494,10 +1496,34 @@ tcExprSig expr sig@(TISI { sig_bndr = s_bndr
<.> mkWpLet ev_binds
; return (mkLHsWrap poly_wrap expr', my_sigma) }
- | otherwise = panic "tcExprSig" -- Can't happen
- where
- skol_info = SigSkol ExprSigCtxt (mkPhiTy theta tau)
- skol_tvs = map snd skol_prs
+
+{- Note [Partial expression signatures]
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+Partial type signatures on expressions are easy to get wrong. But
+here is a guiding principile
+ e :: ty
+should behave like
+ let x :: ty
+ x = e
+ in x
+
+So for partial signatures we apply the MR if no context is given. So
+ e :: IO _ apply the MR
+ e :: _ => IO _ do not apply the MR
+just like in TcBinds.decideGeneralisationPlan
+
+This makes a difference (Trac #11670):
+ peek :: Ptr a -> IO CLong
+ peek ptr = peekElemOff undefined 0 :: _
+from (peekElemOff undefined 0) we get
+ type: IO w
+ constraints: Storable w
+
+We must NOT try to generalise over 'w' because the signature specifies
+no constraints so we'll complain about not being able to solve
+Storable w. Instead, don't generalise; then _ gets instantiated to
+CLong, as it should.
+-}
{- *********************************************************************
* *
diff --git a/compiler/typecheck/TcHsType.hs b/compiler/typecheck/TcHsType.hs
index f09bde5443..5492a8acd5 100644
--- a/compiler/typecheck/TcHsType.hs
+++ b/compiler/typecheck/TcHsType.hs
@@ -11,7 +11,8 @@ module TcHsType (
-- Type signatures
kcHsSigType, tcClassSigType,
tcHsSigType, tcHsSigWcType,
- funsSigCtxt, addSigCtxt,
+ tcHsPartialSigType,
+ funsSigCtxt, addSigCtxt, pprSigCtxt,
tcHsClsInstType,
tcHsDeriv, tcHsVectInst,
@@ -151,11 +152,25 @@ funsSigCtxt (L _ name1 : _) = FunSigCtxt name1 False
funsSigCtxt [] = panic "funSigCtxt"
addSigCtxt :: UserTypeCtxt -> LHsType Name -> TcM a -> TcM a
-addSigCtxt ctxt sig_ty thing_inside
- = setSrcSpan (getLoc sig_ty) $
- addErrCtxt (pprSigCtxt ctxt (ppr sig_ty)) $
+addSigCtxt ctxt hs_ty thing_inside
+ = setSrcSpan (getLoc hs_ty) $
+ addErrCtxt (pprSigCtxt ctxt hs_ty) $
thing_inside
+pprSigCtxt :: UserTypeCtxt -> LHsType Name -> SDoc
+-- (pprSigCtxt ctxt <extra> <type>)
+-- prints In the type signature for 'f':
+-- f :: <type>
+-- The <extra> is either empty or "the ambiguity check for"
+pprSigCtxt ctxt hs_ty
+ | Just n <- isSigMaybe ctxt
+ = hang (text "In the type signature:")
+ 2 (pprPrefixOcc n <+> dcolon <+> ppr hs_ty)
+
+ | otherwise
+ = hang (text "In" <+> pprUserTypeCtxt ctxt <> colon)
+ 2 (ppr hs_ty)
+
tcHsSigWcType :: UserTypeCtxt -> LHsSigWcType Name -> TcM Type
-- This one is used when we have a LHsSigWcType, but in
-- a place where wildards aren't allowed. The renamer has
@@ -262,10 +277,10 @@ tcHsVectInst ty
-- | Type-check a visible type application
tcHsTypeApp :: LHsWcType Name -> Kind -> TcM Type
tcHsTypeApp wc_ty kind
- | HsWC { hswc_wcs = sig_wcs, hswc_ctx = extra, hswc_body = hs_ty } <- wc_ty
- = ASSERT( isNothing extra ) -- handled in RnTypes.rnExtraConstraintWildCard
- tcWildCardBinders sig_wcs $ \ _ ->
- do { ty <- tcCheckLHsType hs_ty kind
+ | HsWC { hswc_wcs = sig_wcs, hswc_body = hs_ty } <- wc_ty
+ = do { ty <- solveEqualities $
+ tcWildCardBindersX newWildTyVar sig_wcs $ \ _ ->
+ tcCheckLHsType hs_ty kind
; ty <- zonkTcType ty
; checkValidType TypeAppCtxt ty
; return ty }
@@ -274,11 +289,6 @@ tcHsTypeApp wc_ty kind
-- without fuss. No errors, warnings, extensions, etc.
{-
- These functions are used during knot-tying in
- type and class declarations, when we have to
- separate kind-checking, desugaring, and validity checking
-
-
************************************************************************
* *
The main kind checker: no validity checks here
@@ -419,14 +429,15 @@ we have a bunch of repetitive code just so that we get warnings if we're
missing any patterns.
-}
+------------------------------------------
-- | Check and desugar a type, returning the core type and its
-- possibly-polymorphic kind. Much like 'tcInferRho' at the expression
-- level.
tc_infer_lhs_type :: TcTyMode -> LHsType Name -> TcM (TcType, TcKind)
tc_infer_lhs_type mode (L span ty)
= setSrcSpan span $
- do { traceTc "tc_infer_lhs_type:" (ppr ty)
- ; tc_infer_hs_type mode ty }
+ do { (ty', kind) <- tc_infer_hs_type mode ty
+ ; return (ty', kind) }
-- | Infer the kind of a type and desugar. This is the "up" type-checker,
-- as described in Note [Bidirectional type checking]
@@ -454,11 +465,12 @@ tc_infer_hs_type mode other_ty
; ty' <- tc_hs_type mode other_ty kv
; return (ty', kv) }
+------------------------------------------
tc_lhs_type :: TcTyMode -> LHsType Name -> TcKind -> TcM TcType
tc_lhs_type mode (L span ty) exp_kind
= setSrcSpan span $
- do { traceTc "tc_lhs_type:" (ppr ty $$ ppr exp_kind)
- ; tc_hs_type mode ty exp_kind }
+ do { ty' <- tc_hs_type mode ty exp_kind
+ ; return ty' }
------------------------------------------
tc_fun_type :: TcTyMode -> LHsType Name -> LHsType Name -> TcKind -> TcM TcType
@@ -638,14 +650,21 @@ tc_hs_type mode ty@(HsKindSig {}) ek = tc_infer_hs_type_ek mode ty ek
tc_hs_type mode ty@(HsCoreTy {}) ek = tc_infer_hs_type_ek mode ty ek
tc_hs_type _ (HsWildCardTy wc) exp_kind
- = do { let name = wildCardName wc
- ; tv <- tcLookupTyVar name
- ; checkExpectedKind (mkTyVarTy tv) (tyVarKind tv) exp_kind }
+ = do { wc_tv <- tcWildCardOcc wc exp_kind
+ ; return (mkTyVarTy wc_tv) }
-- disposed of by renamer
tc_hs_type _ ty@(HsAppsTy {}) _
= pprPanic "tc_hs_tyep HsAppsTy" (ppr ty)
+tcWildCardOcc :: HsWildCardInfo Name -> Kind -> TcM TcTyVar
+tcWildCardOcc wc_info exp_kind
+ = do { wc_tv <- tcLookupTyVar (wildCardName wc_info)
+ -- The wildcard's kind should be an un-filled-in meta tyvar
+ ; let Just wc_kind_var = tcGetTyVar_maybe (tyVarKind wc_tv)
+ ; writeMetaTyVar wc_kind_var exp_kind
+ ; return wc_tv }
+
---------------------------
-- | Call 'tc_infer_hs_type' and check its result against an expected kind.
tc_infer_hs_type_ek :: TcTyMode -> HsType Name -> TcKind -> TcM TcType
@@ -750,8 +769,10 @@ tc_infer_args :: Outputable fun
-> Int -- ^ number to start arg counter at
-> TcM (TCvSubst, [TyBinder], [TcType], [LHsType Name], Int)
tc_infer_args mode orig_ty binders mb_kind_info orig_args n0
- = do { traceTc "tcInferApps" (ppr binders $$ ppr orig_args)
- ; go emptyTCvSubst binders orig_args n0 [] }
+ = do { traceTc "tc_infer_args {" (ppr binders $$ ppr orig_args)
+ ; stuff <- go emptyTCvSubst binders orig_args n0 []
+ ; traceTc "tc_infer_args }" (ppr stuff)
+ ; return stuff }
where
go subst binders [] n acc
= return ( subst, binders, reverse acc, [], n )
@@ -762,12 +783,14 @@ tc_infer_args mode orig_ty binders mb_kind_info orig_args n0
go subst binders all_args n acc
| (inv_binders, other_binders) <- span isInvisibleBinder binders
, not (null inv_binders)
- = do { (subst', args') <- tcInstBindersX subst mb_kind_info inv_binders
+ = do { traceTc "tc_infer_args 1" (ppr inv_binders)
+ ; (subst', args') <- tcInstBindersX subst mb_kind_info inv_binders
; go subst' other_binders all_args n (reverse args' ++ acc) }
go subst (binder:binders) (arg:args) n acc
= ASSERT( isVisibleBinder binder )
- do { arg' <- addErrCtxt (funAppCtxt orig_ty arg n) $
+ do { traceTc "tc_infer_args 2" (ppr binder $$ ppr arg)
+ ; arg' <- addErrCtxt (funAppCtxt orig_ty arg n) $
tc_lhs_type mode arg (substTyUnchecked subst $ binderType binder)
; let subst' = case binderVar_maybe binder of
Just tv -> extendTvSubst subst tv arg'
@@ -777,8 +800,9 @@ tc_infer_args mode orig_ty binders mb_kind_info orig_args n0
go subst [] all_args n acc
= return (subst, [], reverse acc, all_args, n)
--- | Applies a type to a list of arguments. Always consumes all the
--- arguments.
+-- | Applies a type to a list of arguments.
+-- Always consumes all the arguments.
+-- Used for types only
tcInferApps :: Outputable fun
=> TcTyMode
-> fun -- ^ Function (for printing only)
@@ -1179,18 +1203,20 @@ all get more permissive.
tcWildCardBinders :: [Name]
-> ([(Name, TcTyVar)] -> TcM a)
-> TcM a
--- Use the Unique form the specified Name; don't clone it. There is
--- no need to clone, and not doing so avoids the need to return a list
--- of pairs to bring into scope.
-tcWildCardBinders wcs thing_inside
- = do { wcs <- mapM new_wildcard wcs
- ; tcExtendTyVarEnv2 wcs $
- thing_inside wcs }
+tcWildCardBinders = tcWildCardBindersX new_tv
where
- new_wildcard :: Name -> TcM (Name, TcTyVar)
- new_wildcard name = do { kind <- newMetaKindVar
- ; tv <- newFlexiTyVar kind
- ; return (name, tv) }
+ new_tv name = do { kind <- newMetaKindVar
+ ; newSkolemTyVar name kind }
+
+tcWildCardBindersX :: (Name -> TcM TcTyVar)
+ -> [Name]
+ -> ([(Name, TcTyVar)] -> TcM a)
+ -> TcM a
+tcWildCardBindersX new_wc wc_names thing_inside
+ = do { wcs <- mapM new_wc wc_names
+ ; let wc_prs = wc_names `zip` wcs
+ ; tcExtendTyVarEnv2 wc_prs $
+ thing_inside wc_prs }
-- | Kind-check a 'LHsQTyVars'. If the decl under consideration has a complete,
-- user-supplied kind signature (CUSK), generalise the result.
@@ -1215,7 +1241,7 @@ kcHsTyVarBndrs name cusk open_fam all_kind_vars
, hsq_dependent = dep_names }) thing_inside
| cusk
= do { kv_kinds <- mk_kv_kinds
- ; let scoped_kvs = zipWith new_skolem_tv kv_ns kv_kinds
+ ; let scoped_kvs = zipWith mk_skolem_tv kv_ns kv_kinds
; tcExtendTyVarEnv2 (kv_ns `zip` scoped_kvs) $
do { (tvs, binders, res_kind, stuff) <- solveEqualities $
bind_telescope hs_tvs thing_inside
@@ -1389,6 +1415,15 @@ tcExplicitTKBndrs :: [LHsTyVarBndr Name]
-> TcM (a, TyVarSet) -- ^ returns augmented bound vars
-- No cloning: returned TyVars have the same Name as the incoming LHsTyVarBndrs
tcExplicitTKBndrs orig_hs_tvs thing_inside
+ = tcExplicitTKBndrsX newSkolemTyVar orig_hs_tvs thing_inside
+
+tcExplicitTKBndrsX :: (Name -> Kind -> TcM TyVar)
+ -> [LHsTyVarBndr Name]
+ -> ([TyVar] -> TcM (a, TyVarSet))
+ -- ^ Thing inside returns the set of variables bound
+ -- in the scope. See Note [Scope-check inferred kinds]
+ -> TcM (a, TyVarSet) -- ^ returns augmented bound vars
+tcExplicitTKBndrsX new_tv orig_hs_tvs thing_inside
= go orig_hs_tvs $ \ tvs ->
do { (result, bound_tvs) <- thing_inside tvs
@@ -1406,12 +1441,13 @@ tcExplicitTKBndrs orig_hs_tvs thing_inside
where
go [] thing = thing []
go (L _ hs_tv : hs_tvs) thing
- = do { tv <- tcHsTyVarBndr hs_tv
+ = do { tv <- tcHsTyVarBndr new_tv hs_tv
; tcExtendTyVarEnv [tv] $
go hs_tvs $ \ tvs ->
thing (tv : tvs) }
-tcHsTyVarBndr :: HsTyVarBndr Name -> TcM TcTyVar
+tcHsTyVarBndr :: (Name -> Kind -> TcM TyVar)
+ -> HsTyVarBndr Name -> TcM TcTyVar
-- Return a SkolemTv TcTyVar, initialised with a kind variable.
-- Typically the Kind inside the HsTyVarBndr will be a tyvar
-- with a mutable kind in it.
@@ -1421,12 +1457,23 @@ tcHsTyVarBndr :: HsTyVarBndr Name -> TcM TcTyVar
-- Returned TcTyVar has the same name; no cloning
--
-- See also Note [Associated type tyvar names] in Class
-tcHsTyVarBndr (UserTyVar (L _ name))
+--
+tcHsTyVarBndr new_tv (UserTyVar (L _ name))
= do { kind <- newMetaKindVar
- ; return (mkTcTyVar name kind (SkolemTv False)) }
-tcHsTyVarBndr (KindedTyVar (L _ name) kind)
+ ; new_tv name kind }
+
+tcHsTyVarBndr new_tv (KindedTyVar (L _ name) kind)
= do { kind <- tcLHsKind kind
- ; return (mkTcTyVar name kind (SkolemTv False)) }
+ ; new_tv name kind }
+
+newWildTyVar :: Name -> TcM TcTyVar
+-- ^ New unification variable for a wildcard
+newWildTyVar _name
+ = do { kind <- newMetaKindVar
+ ; uniq <- newUnique
+ ; details <- newMetaDetails TauTv
+ ; let name = mkSysTvName uniq (fsLit "w")
+ ; return (mkTcTyVar name kind details) }
-- | Produce a tyvar of the given name (with the kind provided, or
-- otherwise a meta-var kind). If
@@ -1443,12 +1490,17 @@ tcHsTyVarName m_kind name
discardResult $
unifyKind (Just (mkTyVarTy tv)) kind (tyVarKind tv)
; return (tv, True) }
- _ -> do { kind <- maybe newMetaKindVar return m_kind
- ; return (mkTcTyVar name kind vanillaSkolemTv, False) }}
+ _ -> do { kind <- case m_kind of
+ Just kind -> return kind
+ Nothing -> newMetaKindVar
+ ; return (mk_skolem_tv name kind, False) }}
-- makes a new skolem tv
-new_skolem_tv :: Name -> Kind -> TcTyVar
-new_skolem_tv n k = mkTcTyVar n k vanillaSkolemTv
+newSkolemTyVar :: Name -> Kind -> TcM TcTyVar
+newSkolemTyVar name kind = return (mk_skolem_tv name kind)
+
+mk_skolem_tv :: Name -> Kind -> TcTyVar
+mk_skolem_tv n k = mkTcTyVar n k vanillaSkolemTv
------------------
kindGeneralizeType :: Type -> TcM Type
@@ -1669,50 +1721,93 @@ It isn't essential for correctness.
************************************************************************
* *
- Scoped type variables
+ Partial signatures and pattern signatures
* *
************************************************************************
-tcAddScopedTyVars is used for scoped type variables added by pattern
-type signatures
- e.g. \ ((x::a), (y::a)) -> x+y
-They never have explicit kinds (because this is source-code only)
-They are mutable (because they can get bound to a more specific type).
-
-Usually we kind-infer and expand type splices, and then
-tupecheck/desugar the type. That doesn't work well for scoped type
-variables, because they scope left-right in patterns. (e.g. in the
-example above, the 'a' in (y::a) is bound by the 'a' in (x::a).
-
-The current not-very-good plan is to
- * find all the types in the patterns
- * find their free tyvars
- * do kind inference
- * bring the kinded type vars into scope
- * BUT throw away the kind-checked type
- (we'll kind-check it again when we type-check the pattern)
-
-This is bad because throwing away the kind checked type throws away
-its splices. But too bad for now. [July 03]
-
-Historical note:
- We no longer specify that these type variables must be universally
- quantified (lots of email on the subject). If you want to put that
- back in, you need to
- a) Do a checkSigTyVars after thing_inside
- b) More insidiously, don't pass in expected_ty, else
- we unify with it too early and checkSigTyVars barfs
- Instead you have to pass in a fresh ty var, and unify
- it with expected_ty afterwards
+Note [Solving equalities in partial type signatures]
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+We treat a partial type signature as a "shape constraint" to impose on
+the term:
+ * We make no attempt to kind-generalise it
+ * We instantiate the explicit and implicit foralls with SigTvs
+ * We instantiate the wildcards with meta tyvars
+
+We /do/ call solveEqualities, and then zonk to propage the result of
+solveEqualities, mainly so that functions like matchExpectedFunTys will
+be able to decompose the type, and hence higher-rank signatures will
+work. Ugh! For example
+ f :: (forall a. a->a) -> _
+ f x = (x True, x 'c')
+
-}
+tcHsPartialSigType
+ :: UserTypeCtxt
+ -> LHsSigWcType Name -- The type signature
+ -> TcM ( [(Name, TcTyVar)] -- Wildcards
+ , Maybe TcTyVar -- Extra-constraints wildcard
+ , [TcTyVar] -- Implicitly and explicitly bound type varialbes
+ , TcThetaType -- Theta part
+ , TcType ) -- Tau part
+tcHsPartialSigType ctxt sig_ty
+ | HsWC { hswc_wcs = sig_wcs, hswc_body = ib_ty } <- sig_ty
+ , HsIB { hsib_vars = implicit_hs_tvs, hsib_body = hs_ty } <- ib_ty
+ , (explicit_hs_tvs, L _ hs_ctxt, hs_tau) <- splitLHsSigmaTy hs_ty
+ = addSigCtxt ctxt hs_ty $
+ do { (implicit_tvs, (wcs, wcx, explicit_tvs, theta, tau))
+ <- -- See Note [Solving equalities in partial type signatures]
+ solveEqualities $
+ tcWildCardBindersX newWildTyVar sig_wcs $ \ wcs ->
+ tcImplicitTKBndrsX new_implicit_tv implicit_hs_tvs $
+ tcExplicitTKBndrsX newSigTyVar explicit_hs_tvs $ \ explicit_tvs ->
+ do { -- Instantiate the type-class context; but if there
+ -- is an extra-constraints wildcard, just discard it here
+ (theta, wcx) <- tcPartialContext hs_ctxt
+
+ ; tau <- tcHsOpenType hs_tau
+
+ ; let bound_tvs = unionVarSets [ allBoundVariables tau
+ , mkVarSet explicit_tvs
+ , mkVarSet (map snd wcs) ]
+
+ ; return ( (wcs, wcx, explicit_tvs, theta, tau)
+ , bound_tvs) }
+
+ ; emitWildCardHoleConstraints wcs
+
+ -- See Note [Solving equalities in partial type signatures]
+ ; all_tvs <- mapM (updateTyVarKindM zonkTcType)
+ (implicit_tvs ++ explicit_tvs)
+ ; theta <- mapM zonkTcType theta
+ ; tau <- zonkTcType tau
+ ; checkValidType ctxt (mkSpecForAllTys all_tvs $ mkPhiTy theta tau)
+
+ ; traceTc "tcHsPatSigType" (ppr all_tvs)
+ ; return (wcs, wcx, all_tvs, theta, tau) }
+ where
+ new_implicit_tv name = do { kind <- newMetaKindVar
+ ; tv <- newSigTyVar name kind
+ ; return (tv, False) }
+
+tcPartialContext :: HsContext Name -> TcM (TcThetaType, Maybe TcTyVar)
+tcPartialContext hs_theta
+ | Just (hs_theta1, hs_ctxt_last) <- snocView hs_theta
+ , L _ (HsWildCardTy wc) <- ignoreParens hs_ctxt_last
+ = do { wc_tv <- tcWildCardOcc wc constraintKind
+ ; theta <- mapM tcLHsPredType hs_theta1
+ ; return (theta, Just wc_tv) }
+ | otherwise
+ = do { theta <- mapM tcLHsPredType hs_theta
+ ; return (theta, Nothing) }
+
tcHsPatSigType :: UserTypeCtxt
-> LHsSigWcType Name -- The type signature
- -> TcM ( Type -- The signature
+ -> TcM ( [(Name, TcTyVar)] -- Wildcards
, [TcTyVar] -- The new bit of type environment, binding
-- the scoped type variables
- , [(Name, TcTyVar)] ) -- The wildcards
+ , TcType) -- The type
-- Used for type-checking type signatures in
-- (a) patterns e.g f (x::Int) = e
-- (b) RULE forall bndrs e.g. forall (x::Int). f x = x
@@ -1720,28 +1815,35 @@ tcHsPatSigType :: UserTypeCtxt
-- This may emit constraints
tcHsPatSigType ctxt sig_ty
- | HsIB { hsib_vars = sig_vars, hsib_body = wc_ty } <- sig_ty
- , HsWC { hswc_wcs = sig_wcs, hswc_ctx = extra, hswc_body = hs_ty } <- wc_ty
- = ASSERT( isNothing extra ) -- No extra-constraint wildcard in pattern sigs
- addSigCtxt ctxt hs_ty $
- tcWildCardBinders sig_wcs $ \ wcs ->
- do { emitWildCardHoleConstraints wcs
- ; (vars, sig_ty) <- tcImplicitTKBndrsX new_tkv sig_vars $
- do { ty <- tcHsLiftedType hs_ty
- ; return (ty, allBoundVariables ty) }
+ | HsWC { hswc_wcs = sig_wcs, hswc_body = ib_ty } <- sig_ty
+ , HsIB { hsib_vars = sig_vars, hsib_body = hs_ty } <- ib_ty
+ = addSigCtxt ctxt hs_ty $
+ do { (implicit_tvs, (wcs, sig_ty))
+ <- -- See Note [Solving equalities in partial type signatures]
+ solveEqualities $
+ tcWildCardBindersX newWildTyVar sig_wcs $ \ wcs ->
+ tcImplicitTKBndrsX new_implicit_tv sig_vars $
+ do { sig_ty <- tcHsOpenType hs_ty
+ ; return ((wcs, sig_ty), allBoundVariables sig_ty) }
+
+ ; emitWildCardHoleConstraints wcs
+
; sig_ty <- zonkTcType sig_ty
- -- don't use zonkTcTypeToType; it mistreats wildcards
; checkValidType ctxt sig_ty
+
; traceTc "tcHsPatSigType" (ppr sig_vars)
- ; return (sig_ty, vars, wcs) }
+ ; return (wcs, implicit_tvs, sig_ty) }
where
- new_tkv name -- See Note [Pattern signature binders]
- = (, False) <$> -- "False" means that these tyvars aren't yet in scope
- do { kind <- newMetaKindVar
- ; case ctxt of
- RuleSigCtxt {} -> return $ new_skolem_tv name kind
- _ -> newSigTyVar name kind }
- -- See Note [Unifying SigTvs]
+ new_implicit_tv name = do { kind <- newMetaKindVar
+ ; tv <- new_tv name kind
+ ; return (tv, False) }
+ -- "False" means that these tyvars aren't yet in scope
+ new_tv = case ctxt of
+ RuleSigCtxt {} -> newSkolemTyVar
+ _ -> newSigTyVar
+ -- See Note [Pattern signature binders]
+ -- See Note [Unifying SigTvs]
+
tcPatSig :: Bool -- True <=> pattern binding
-> LHsSigWcType Name
@@ -1749,11 +1851,11 @@ tcPatSig :: Bool -- True <=> pattern binding
-> TcM (TcType, -- The type to use for "inside" the signature
[TcTyVar], -- The new bit of type environment, binding
-- the scoped type variables
- [(Name, TcTyVar)], -- The wildcards
+ [(Name,TcTyVar)], -- The wildcards
HsWrapper) -- Coercion due to unification with actual ty
-- Of shape: res_ty ~ sig_ty
tcPatSig in_pat_bind sig res_ty
- = do { (sig_ty, sig_tvs, sig_wcs) <- tcHsPatSigType PatSigCtxt sig
+ = do { (sig_wcs, sig_tvs, sig_ty) <- tcHsPatSigType PatSigCtxt sig
-- sig_tvs are the type variables free in 'sig',
-- and not already in scope. These are the ones
-- that should be brought into scope
diff --git a/compiler/typecheck/TcInstDcls.hs b/compiler/typecheck/TcInstDcls.hs
index ffe2d2dd01..d078e2dac5 100644
--- a/compiler/typecheck/TcInstDcls.hs
+++ b/compiler/typecheck/TcInstDcls.hs
@@ -18,7 +18,7 @@ import TcTyClsDecls
import TcClassDcl( tcClassDecl2, tcATDefault,
HsSigFun, lookupHsSig, mkHsSigFun,
findMethodBind, instantiateMethod )
-import TcPat ( addInlinePrags, lookupPragEnv, emptyPragEnv )
+import TcSigs
import TcRnMonad
import TcValidity
import TcHsSyn ( zonkTcTypeToTypes, emptyZonkEnv )
@@ -761,7 +761,7 @@ tcInstDecl2 (InstInfo { iSpec = ispec, iBinds = ibinds })
setSrcSpan loc $
addErrCtxt (instDeclCtxt2 (idType dfun_id)) $
do { -- Instantiate the instance decl with skolem constants
- ; (inst_tyvars, dfun_theta, inst_head) <- tcSkolDFunType (idType dfun_id)
+ ; (inst_tyvars, dfun_theta, inst_head) <- tcSkolDFunType dfun_id
; dfun_ev_vars <- newEvVars dfun_theta
-- We instantiate the dfun_id with superSkolems.
-- See Note [Subtle interaction of recursion and overlap]
@@ -1349,7 +1349,7 @@ tcMethodBody clas tyvars dfun_ev_vars inst_tys
sig_fn (spec_inst_prags, prag_fn)
sel_id (L bind_loc meth_bind) bndr_loc
= add_meth_ctxt $
- do { traceTc "tcMethodBody" (ppr sel_id <+> ppr (idType sel_id))
+ do { traceTc "tcMethodBody" (ppr sel_id <+> ppr (idType sel_id) $$ ppr bndr_loc)
; (global_meth_id, local_meth_id) <- setSrcSpan bndr_loc $
mkMethIds clas tyvars dfun_ev_vars
inst_tys sel_id
@@ -1396,7 +1396,8 @@ tcMethodBodyHelp sig_fn sel_id local_meth_id meth_bind
| Just hs_sig_ty <- lookupHsSig sig_fn sel_name
-- There is a signature in the instance
-- See Note [Instance method signatures]
- = do { (sig_ty, hs_wrap)
+ = do { let ctxt = FunSigCtxt sel_name True
+ ; (sig_ty, hs_wrap)
<- setSrcSpan (getLoc (hsSigType hs_sig_ty)) $
do { inst_sigs <- xoptM LangExt.InstanceSigs
; checkTc inst_sigs (misplacedInstSig sel_name hs_sig_ty)
@@ -1408,8 +1409,13 @@ tcMethodBodyHelp sig_fn sel_id local_meth_id meth_bind
; return (sig_ty, hs_wrap) }
; inner_meth_name <- newName (nameOccName sel_name)
- ; tc_sig <- instTcTySig ctxt hs_sig_ty sig_ty inner_meth_name
- ; (tc_bind, [inner_id]) <- tcPolyCheck NonRecursive no_prag_fn tc_sig meth_bind
+ ; let inner_meth_id = mkLocalId inner_meth_name sig_ty
+ inner_meth_sig = CompleteSig { sig_bndr = inner_meth_id
+ , sig_ctxt = ctxt
+ , sig_loc = getLoc (hsSigType hs_sig_ty) }
+
+
+ ; (tc_bind, [inner_id]) <- tcPolyCheck no_prag_fn inner_meth_sig meth_bind
; let export = ABE { abe_poly = local_meth_id
, abe_mono = inner_id
@@ -1422,7 +1428,10 @@ tcMethodBodyHelp sig_fn sel_id local_meth_id meth_bind
, abs_binds = tc_bind, abs_ev_binds = [] }) }
| otherwise -- No instance signature
- = do { tc_sig <- instTcTySigFromId local_meth_id
+ = do { let ctxt = FunSigCtxt sel_name False
+ -- False <=> don't report redundant constraints
+ -- The signature is not under the users control!
+ tc_sig = completeSigFromId ctxt local_meth_id
-- Absent a type sig, there are no new scoped type variables here
-- Only the ones from the instance decl itself, which are already
-- in scope. Example:
@@ -1430,11 +1439,10 @@ tcMethodBodyHelp sig_fn sel_id local_meth_id meth_bind
-- instance C [c] where { op = <rhs> }
-- In <rhs>, 'c' is scope but 'b' is not!
- ; (tc_bind, _) <- tcPolyCheck NonRecursive no_prag_fn tc_sig meth_bind
+ ; (tc_bind, _) <- tcPolyCheck no_prag_fn tc_sig meth_bind
; return tc_bind }
where
- ctxt = FunSigCtxt sel_name True
sel_name = idName sel_id
no_prag_fn = emptyPragEnv -- No pragmas for local_meth_id;
-- they are all for meth_id
diff --git a/compiler/typecheck/TcMType.hs b/compiler/typecheck/TcMType.hs
index ae5e031f31..8f64594401 100644
--- a/compiler/typecheck/TcMType.hs
+++ b/compiler/typecheck/TcMType.hs
@@ -51,12 +51,12 @@ module TcMType (
--------------------------------
-- Instantiation
- newMetaTyVars, newMetaTyVarX, newMetaSigTyVars,
- newSigTyVar,
+ newMetaTyVars, newMetaTyVarX,
+ newMetaSigTyVars, newMetaSigTyVarX,
+ newSigTyVar, newWildCardX,
tcInstType,
- tcInstSkolTyVars, tcInstSkolTyVarsLoc, tcInstSuperSkolTyVarsX,
- tcInstSigTyVarsLoc, tcInstSigTyVars,
- tcInstSkolType,
+ tcInstSkolTyVars, tcInstSuperSkolTyVarsX,
+ tcInstSigTyVars,
tcSkolDFunType, tcSuperSkolTyVars,
instSkolTyCoVars, freshenTyVarBndrs, freshenCoVarBndrsX,
@@ -433,11 +433,11 @@ inferTypeToType u tc_lvl ki ref
tcInstType :: ([TyVar] -> TcM (TCvSubst, [TcTyVar]))
-- ^ How to instantiate the type variables
- -> TcType -- ^ Type to instantiate
- -> TcM ([TcTyVar], TcThetaType, TcType) -- ^ Result
+ -> Id -- ^ Type to instantiate
+ -> TcM ([(Name, TcTyVar)], TcThetaType, TcType) -- ^ Result
-- (type vars, preds (incl equalities), rho)
-tcInstType inst_tyvars ty
- = case tcSplitForAllTys ty of
+tcInstType inst_tyvars id
+ = case tcSplitForAllTys (idType id) of
([], rho) -> let -- There may be overloading despite no type variables;
-- (?x :: Int) => Int -> Int
(theta, tau) = tcSplitPhiTy rho
@@ -446,12 +446,15 @@ tcInstType inst_tyvars ty
(tyvars, rho) -> do { (subst, tyvars') <- inst_tyvars tyvars
; let (theta, tau) = tcSplitPhiTy (substTyAddInScope subst rho)
- ; return (tyvars', theta, tau) }
+ tv_prs = map tyVarName tyvars `zip` tyvars'
+ ; return (tv_prs, theta, tau) }
-tcSkolDFunType :: Type -> TcM ([TcTyVar], TcThetaType, TcType)
+tcSkolDFunType :: DFunId -> TcM ([TcTyVar], TcThetaType, TcType)
-- Instantiate a type signature with skolem constants.
-- We could give them fresh names, but no need to do so
-tcSkolDFunType ty = tcInstType tcInstSuperSkolTyVars ty
+tcSkolDFunType dfun
+ = do { (tv_prs, theta, tau) <- tcInstType tcInstSuperSkolTyVars dfun
+ ; return (map snd tv_prs, theta, tau) }
tcSuperSkolTyVars :: [TyVar] -> (TCvSubst, [TcTyVar])
-- Make skolem constants, but do *not* give them new names, as above
@@ -467,11 +470,6 @@ tcSuperSkolTyVar subst tv
kind = substTyUnchecked subst (tyVarKind tv)
new_tv = mkTcTyVar (tyVarName tv) kind superSkolemTv
--- Wrappers
--- we need to be able to do this from outside the TcM monad:
-tcInstSkolTyVarsLoc :: SrcSpan -> [TyVar] -> TcRnIf gbl lcl (TCvSubst, [TcTyVar])
-tcInstSkolTyVarsLoc loc = instSkolTyCoVars (mkTcSkolTyVar loc False)
-
-- | Given a list of @['TyVar']@, skolemize the type variables,
-- returning a substitution mapping the original tyvars to the
-- skolems, and the list of newly bound skolems. See also
@@ -501,23 +499,9 @@ mkTcSkolTyVar loc overlappable uniq old_name kind
kind
(SkolemTv overlappable)
-tcInstSigTyVarsLoc :: SrcSpan -> [TyVar]
- -> TcRnIf gbl lcl (TCvSubst, [TcTyVar])
--- We specify the location
-tcInstSigTyVarsLoc loc = instSkolTyCoVars (mkTcSkolTyVar loc False)
-
-tcInstSigTyVars :: [TyVar] -> TcRnIf gbl lcl (TCvSubst, [TcTyVar])
--- Get the location from the TyVar itself, not the monad
-tcInstSigTyVars
- = instSkolTyCoVars mk_tv
- where
- mk_tv uniq old_name kind
- = mkTcTyVar (setNameUnique old_name uniq) kind (SkolemTv False)
-
-tcInstSkolType :: TcType -> TcM ([TcTyVar], TcThetaType, TcType)
--- Instantiate a type with fresh skolem constants
--- Binding location comes from the monad
-tcInstSkolType ty = tcInstType tcInstSkolTyVars ty
+tcInstSigTyVars :: SrcSpan -> [TyVar]
+ -> TcRnIf gbl lcl (TCvSubst, [TcTyVar])
+tcInstSigTyVars loc = instSkolTyCoVars (mkTcSkolTyVar loc False)
------------------
freshenTyVarBndrs :: [TyVar] -> TcRnIf gbl lcl (TCvSubst, [TyVar])
@@ -793,13 +777,18 @@ newMetaSigTyVarX :: TCvSubst -> TyVar -> TcM (TCvSubst, TcTyVar)
-- Just like newMetaTyVarX, but make a SigTv
newMetaSigTyVarX subst tyvar = new_meta_tv_x SigTv subst tyvar
+newWildCardX :: TCvSubst -> TyVar -> TcM (TCvSubst, TcTyVar)
+newWildCardX subst tv
+ = do { new_tv <- newAnonMetaTyVar TauTv (substTy subst (tyVarKind tv))
+ ; return (extendTvSubstWithClone subst tv new_tv, new_tv) }
+
new_meta_tv_x :: MetaInfo -> TCvSubst -> TyVar -> TcM (TCvSubst, TcTyVar)
new_meta_tv_x info subst tyvar
= do { uniq <- newUnique
; details <- newMetaDetails info
; let name = mkSystemName uniq (getOccName tyvar)
-- See Note [Name of an instantiated type variable]
- kind = substTyUnchecked subst (tyVarKind tyvar)
+ kind = substTy subst (tyVarKind tyvar)
new_tv = mkTcTyVar name kind details
subst1 = extendTvSubstWithClone subst tyvar new_tv
; return (subst1, new_tv) }
diff --git a/compiler/typecheck/TcPat.hs b/compiler/typecheck/TcPat.hs
index 35624e7d32..7a210f210d 100644
--- a/compiler/typecheck/TcPat.hs
+++ b/compiler/typecheck/TcPat.hs
@@ -10,9 +10,7 @@ TcPat: Typechecking patterns
{-# LANGUAGE FlexibleContexts #-}
module TcPat ( tcLetPat
- , TcPragEnv, lookupPragEnv, emptyPragEnv
- , LetBndrSpec(..), addInlinePrags
- , tcPat, tcPat_O, tcPats, newNoSigLetBndr
+ , tcPat, tcPat_O, tcPats
, addDataConStupidTheta, badFieldCon, polyPatSig ) where
#include "HsVersions.h"
@@ -26,7 +24,6 @@ import Inst
import Id
import Var
import Name
-import NameEnv
import RdrName
import TcEnv
import TcMType
@@ -47,7 +44,6 @@ import SrcLoc
import VarSet
import Util
import Outputable
-import Maybes( orElse )
import qualified GHC.LanguageExtensions as LangExt
import Control.Monad
import Control.Arrow ( second )
@@ -60,15 +56,15 @@ import Control.Arrow ( second )
************************************************************************
-}
-tcLetPat :: TcSigFun -> LetBndrSpec
+tcLetPat :: (Name -> Maybe TcId)
-> LPat Name -> ExpSigmaType
-> TcM a
-> TcM (LPat TcId, a)
-tcLetPat sig_fn no_gen pat pat_ty thing_inside
+tcLetPat sig_fn pat pat_ty thing_inside
= tc_lpat pat pat_ty penv thing_inside
where
penv = PE { pe_lazy = True
- , pe_ctxt = LetPat sig_fn no_gen
+ , pe_ctxt = LetPat sig_fn
, pe_orig = PatOrigin }
-----------------
@@ -125,17 +121,7 @@ data PatCtxt
| LetPat -- Used only for let(rec) pattern bindings
-- See Note [Typing patterns in pattern bindings]
- TcSigFun -- Tells type sig if any
- LetBndrSpec -- True <=> no generalisation of this let
-
-data LetBndrSpec
- = LetLclBndr -- The binder is just a local one;
- -- an AbsBinds will provide the global version
-
- | LetGblBndr TcPragEnv -- Generalisation plan is NoGen, so there isn't going
- -- to be an AbsBinds; So we must bind the global version
- -- of the binder right away.
- -- Oh, and here is the inline-pragma information
+ (Name -> Maybe TcId) -- Tells the expected type for this binder
makeLazy :: PatEnv -> PatEnv
makeLazy penv = penv { pe_lazy = True }
@@ -144,15 +130,6 @@ inPatBind :: PatEnv -> Bool
inPatBind (PE { pe_ctxt = LetPat {} }) = True
inPatBind (PE { pe_ctxt = LamPat {} }) = False
----------------
-type TcPragEnv = NameEnv [LSig Name]
-
-emptyPragEnv :: TcPragEnv
-emptyPragEnv = emptyNameEnv
-
-lookupPragEnv :: TcPragEnv -> Name -> [LSig Name]
-lookupPragEnv prag_fn n = lookupNameEnv prag_fn n `orElse` []
-
{- *********************************************************************
* *
Binders
@@ -163,83 +140,23 @@ tcPatBndr :: PatEnv -> Name -> ExpSigmaType -> TcM (HsWrapper, TcId)
-- (coi, xp) = tcPatBndr penv x pat_ty
-- Then coi : pat_ty ~ typeof(xp)
--
-tcPatBndr (PE { pe_ctxt = LetPat lookup_sig no_gen
+tcPatBndr (PE { pe_ctxt = LetPat lookup_sig
, pe_orig = orig }) bndr_name pat_ty
-- See Note [Typing patterns in pattern bindings]
- | LetGblBndr prags <- no_gen
- , Just (TcIdSig sig) <- mb_sig
- , Just poly_id <- completeIdSigPolyId_maybe sig
- = do { bndr_id <- addInlinePrags poly_id (lookupPragEnv prags bndr_name)
- ; traceTc "tcPatBndr(gbl,sig)" (ppr bndr_id $$ ppr (idType bndr_id))
- ; co <- unifyPatType bndr_id (idType bndr_id) pat_ty
- ; return (mkWpCastN co, bndr_id) }
-
- -- See Note [Partial signatures for pattern bindings]
- | LetLclBndr <- no_gen
- , Just (TcIdSig sig) <- mb_sig
- = do { mono_name <- newLocalName bndr_name
- ; (subst, _) <- newMetaSigTyVars (map snd (sig_skols sig))
- ; let tau = substTy subst (sig_tau sig)
- mono_id = mkLocalId mono_name tau
- ; wrap <- tcSubTypeET orig pat_ty tau
- ; traceTc "tcPatBndr(lsl,sig)" (ppr mono_id $$ ppr tau $$ ppr pat_ty)
- ; return (wrap, mono_id) }
+ | Just bndr_id <- lookup_sig bndr_name
+ = do { wrap <- tcSubTypeET orig pat_ty (idType bndr_id)
+ ; traceTc "tcPatBndr(lsl,sig)" (ppr bndr_id $$ ppr (idType bndr_id) $$ ppr pat_ty)
+ ; return (wrap, bndr_id) }
- | otherwise
- = do { pat_ty <- expTypeToType pat_ty
- ; bndr_id <- newNoSigLetBndr no_gen bndr_name pat_ty
- ; traceTc "tcPatBndr(no-sig)" (ppr bndr_id $$ ppr (idType bndr_id))
- ; return (idHsWrapper, bndr_id) }
- where
- mb_sig = lookup_sig bndr_name
+ | otherwise -- No signature
+ = pprPanic "tcPatBndr" (ppr bndr_name)
tcPatBndr (PE { pe_ctxt = _lam_or_proc }) bndr_name pat_ty
= do { pat_ty <- expTypeToType pat_ty
+ ; traceTc "tcPatBndr(not let)" (ppr bndr_name $$ ppr pat_ty)
; return (idHsWrapper, mkLocalId bndr_name pat_ty) }
- -- whether or not there is a sig is irrelevant, as this
- -- is local
-
-------------
-newNoSigLetBndr :: LetBndrSpec -> Name -> TcType -> TcM TcId
--- In the polymorphic case (no_gen = LetLclBndr), generate a "monomorphic version"
--- of the Id; the original name will be bound to the polymorphic version
--- by the AbsBinds
--- In the monomorphic case (no_gen = LetBglBndr) there is no AbsBinds, and we
--- use the original name directly
-newNoSigLetBndr LetLclBndr name ty
- =do { mono_name <- newLocalName name
- ; return (mkLocalId mono_name ty) }
-newNoSigLetBndr (LetGblBndr prags) name ty
- = addInlinePrags (mkLocalId name ty) (lookupPragEnv prags name)
-
-----------
-addInlinePrags :: TcId -> [LSig Name] -> TcM TcId
-addInlinePrags poly_id prags
- | inl@(L _ prag) : inls <- inl_prags
- = do { traceTc "addInlinePrag" (ppr poly_id $$ ppr prag)
- ; unless (null inls) (warn_multiple_inlines inl inls)
- ; return (poly_id `setInlinePragma` prag) }
- | otherwise
- = return poly_id
- where
- inl_prags = [L loc prag | L loc (InlineSig _ prag) <- prags]
-
- warn_multiple_inlines _ [] = return ()
-
- warn_multiple_inlines inl1@(L loc prag1) (inl2@(L _ prag2) : inls)
- | inlinePragmaActivation prag1 == inlinePragmaActivation prag2
- , isEmptyInlineSpec (inlinePragmaSpec prag1)
- = -- Tiresome: inl1 is put there by virtue of being in a hs-boot loop
- -- and inl2 is a user NOINLINE pragma; we don't want to complain
- warn_multiple_inlines inl2 inls
- | otherwise
- = setSrcSpan loc $
- addWarnTc NoReason
- (hang (text "Multiple INLINE pragmas for" <+> ppr poly_id)
- 2 (vcat (text "Ignoring all but the first"
- : map pp_inl (inl1:inl2:inls))))
-
- pp_inl (L loc prag) = ppr prag <+> parens (ppr loc)
+ -- Whether or not there is a sig is irrelevant,
+ -- as this is local
{- Note [Partial signatures for pattern bindings]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -276,19 +193,6 @@ Extra notes
Moreover, by feeding in the expected type we do less fruitless
creation of unification variables, and improve error messages.
-* We need to take care with the skolems. Consider
- data T a = MkT a a
- f :: forall a. a->a
- g :: forall b. b->b
- MkT f g = MkT (\x->x) (\y->y)
- Here we'll infer a type from the pattern of 'T a', but if we feed in
- the signature types for f and g, we'll end up unifying 'a' and 'b'.
- So we instantiate the skolems with SigTvs; hence newMetaSigTyVars.
-
- All we are doing here is getting the "shapes" right. In tcExport
- we'll check that the Id really does have the claimed type, with
- the claimed polymorphism.
-
* We need to do a subsumption, not equality, check. If
data T = MkT (forall a. a->a)
f :: forall b. [b]->[b]
@@ -302,7 +206,7 @@ Note [Typing patterns in pattern bindings]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Suppose we are typing a pattern binding
pat = rhs
-Then the PatCtxt will be (LetPat sig_fn let_bndr_spec).
+Then the PatCtxt will be (LetPat sig_fn).
There can still be signatures for the binders:
data T = MkT (forall a. a->a) Int
@@ -324,7 +228,7 @@ Two cases, dealt with by the LetPat case of tcPatBndr
LetBndrSpec will be LetGblBndr. In that case we must bind the
global version of the Id, and do so with precisely the type given
in the signature. (Then we unify with the type from the pattern
- context type.
+ context type.)
************************************************************************
@@ -426,8 +330,16 @@ tc_pat penv lpat@(LazyPat pat) pat_ty thing_inside
-- see Note [Hopping the LIE in lazy patterns]
-- Check there are no unlifted types under the lazy pattern
- ; when (any (isUnliftedType . idType) $ collectPatBinders pat') $
- lazyUnliftedPatErr lpat
+ -- This is a very unsatisfactory test. We have to zonk becuase
+ -- the binder-tys are typically just a unification variable,
+ -- which should by now have been unified... but it might be
+ -- deferred for the constraint solver...Ugh! Also
+ -- collecting the pattern binders again is not very cool.
+ -- But it's all very much a corner case: a lazy pattern with
+ -- unboxed types inside it
+ ; bndr_tys <- mapM (zonkTcType . idType) (collectPatBinders pat')
+ ; when (any isUnliftedType bndr_tys)
+ (lazyUnliftedPatErr lpat)
-- Check that the expected pattern type is itself lifted
; pat_ty <- readExpType pat_ty
@@ -488,8 +400,8 @@ tc_pat penv (ViewPat expr pat _) overall_pat_ty thing_inside
tc_pat penv (SigPatIn pat sig_ty) pat_ty thing_inside
= do { (inner_ty, tv_binds, wcs, wrap) <- tcPatSig (inPatBind penv)
sig_ty pat_ty
- ; (pat', res) <- tcExtendTyVarEnv2 wcs $
- tcExtendTyVarEnv tv_binds $
+ ; (pat', res) <- tcExtendTyVarEnv2 wcs $
+ tcExtendTyVarEnv tv_binds $
tc_lpat pat (mkCheckExpType inner_ty) penv thing_inside
; pat_ty <- readExpType pat_ty
; return (mkHsWrapPat wrap (SigPatOut pat' inner_ty) pat_ty, res) }
@@ -846,9 +758,10 @@ tcDataConPat penv (L con_span con_name) data_con pat_ty arg_pats thing_inside
-- order is *important* as we generate the list of
-- dictionary binders from theta'
no_equalities = not (any isNomEqPred theta')
- skol_info = case pe_ctxt penv of
- LamPat mc -> PatSkol (RealDataCon data_con) mc
- LetPat {} -> UnkSkol -- Doesn't matter
+ skol_info = PatSkol (RealDataCon data_con) mc
+ mc = case pe_ctxt penv of
+ LamPat mc -> mc
+ LetPat {} -> PatBindRhs
; gadts_on <- xoptM LangExt.GADTs
; families_on <- xoptM LangExt.TypeFamilies
@@ -1184,6 +1097,16 @@ Meanwhile, the strategy is:
\subsection{Errors and contexts}
* *
************************************************************************
+
+Note [Existential check]
+~~~~~~~~~~~~~~~~~~~~~~~~
+Lazy patterns can't bind existentials. They arise in two ways:
+ * Let bindings let { C a b = e } in b
+ * Twiddle patterns f ~(C a b) = e
+The pe_lazy field of PatEnv says whether we are inside a lazy
+pattern (perhaps deeply)
+
+See also Note [Existentials in pattern bindings] in TcBinds
-}
maybeWrapPatCtxt :: Pat Name -> (TcM a -> TcM b) -> TcM a -> TcM b
@@ -1203,10 +1126,11 @@ maybeWrapPatCtxt pat tcm thing_inside
checkExistentials :: [TyVar] -- existentials
-> [Type] -- argument types
-> PatEnv -> TcM ()
- -- See Note [Arrows and patterns]
+ -- See Note [Existential check]]
+ -- See Note [Arrows and patterns]
checkExistentials ex_tvs tys _
| all (not . (`elemVarSet` tyCoVarsOfTypes tys)) ex_tvs = return ()
-checkExistentials _ _ (PE { pe_ctxt = LetPat {}}) = failWithTc existentialLetPat
+checkExistentials _ _ (PE { pe_ctxt = LetPat {}}) = return ()
checkExistentials _ _ (PE { pe_ctxt = LamPat ProcExpr }) = failWithTc existentialProcPat
checkExistentials _ _ (PE { pe_lazy = True }) = failWithTc existentialLazyPat
checkExistentials _ _ _ = return ()
@@ -1220,12 +1144,6 @@ existentialProcPat :: SDoc
existentialProcPat
= text "Proc patterns cannot use existential or GADT data constructors"
-existentialLetPat :: SDoc
-existentialLetPat
- = vcat [text "My brain just exploded",
- text "I can't handle pattern bindings for existential or GADT data constructors.",
- text "Instead, use a case-expression, or do-notation, to unpack the constructor."]
-
badFieldCon :: ConLike -> FieldLabelString -> SDoc
badFieldCon con field
= hsep [text "Constructor" <+> quotes (ppr con),
diff --git a/compiler/typecheck/TcPatSyn.hs b/compiler/typecheck/TcPatSyn.hs
index c73da99dce..c5a0c270b4 100644
--- a/compiler/typecheck/TcPatSyn.hs
+++ b/compiler/typecheck/TcPatSyn.hs
@@ -8,17 +8,16 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE FlexibleContexts #-}
-module TcPatSyn ( tcPatSynSig, tcInferPatSynDecl, tcCheckPatSynDecl
+module TcPatSyn ( tcInferPatSynDecl, tcCheckPatSynDecl
, tcPatSynBuilderBind, tcPatSynBuilderOcc, nonBidirectionalErr
) where
import HsSyn
import TcPat
-import TcHsType( tcImplicitTKBndrs, tcExplicitTKBndrs
- , tcHsContext, tcHsOpenType, kindGeneralize )
-import Type( binderVar, mkNamedBinders, binderVisibility
+import Type( binderVar, mkNamedBinders, binderVisibility, mkEmptyTCvSubst
, tidyTyCoVarBndrs, tidyTypes, tidyType )
import TcRnMonad
+import TcSigs( emptyPragEnv, completeSigFromId )
import TcEnv
import TcMType
import TysPrim
@@ -31,7 +30,7 @@ import Panic
import Outputable
import FastString
import Var
-import VarEnv( emptyTidyEnv )
+import VarEnv( emptyTidyEnv, mkInScopeSet )
import Id
import IdInfo( RecSelParent(..))
import TcBinds
@@ -55,144 +54,6 @@ import Data.List( partition )
#include "HsVersions.h"
-{- *********************************************************************
-* *
- Type checking a pattern synonym signature
-* *
-************************************************************************
-
-Note [Pattern synonym signatures]
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-Pattern synonym signatures are surprisingly tricky (see Trac #11224 for example).
-In general they look like this:
-
- pattern P :: forall univ_tvs. req_theta
- => forall ex_tvs. prov_theta
- => arg1 -> .. -> argn -> res_ty
-
-For parsing and renaming we treat the signature as an ordinary LHsSigType.
-
-Once we get to type checking, we decompose it into its parts, in tcPatSynSig.
-
-* Note that 'forall univ_tvs' and 'req_theta =>'
- and 'forall ex_tvs' and 'prov_theta =>'
- are all optional. We gather the pieces at the the top of tcPatSynSig
-
-* Initially the implicitly-bound tyvars (added by the renamer) include both
- universal and existential vars.
-
-* After we kind-check the pieces and convert to Types, we do kind generalisation.
-
-Note [The pattern-synonym signature splitting rule]
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-Given a pattern signature, we must split
- the kind-generalised variables, and
- the implicitly-bound variables
-into universal and existential. The rule is this
-(see discussion on Trac #11224):
-
- The universal tyvars are the ones mentioned in
- - univ_tvs: the user-specified (forall'd) universals
- - req_theta
- - res_ty
- The existential tyvars are all the rest
-
-For example
-
- pattern P :: () => b -> T a
- pattern P x = ...
-
-Here 'a' is universal, and 'b' is existential. But there is a wrinkle:
-how do we split the arg_tys from req_ty? Consider
-
- pattern Q :: () => b -> S c -> T a
- pattern Q x = ...
-
-This is an odd example because Q has only one syntactic argument, and
-so presumably is defined by a view pattern matching a function. But
-it can happen (Trac #11977, #12108).
-
-We don't know Q's arity from the pattern signature, so we have to wait
-until we see the pattern declaration itself before deciding res_ty is,
-and hence which variables are existential and which are universal.
-
-And that in turn is why TcPatSynInfo has a separate field,
-patsig_implicit_bndrs, to capture the implicitly bound type variables,
-because we don't yet know how to split them up.
-
-It's a slight compromise, because it means we don't really know the
-pattern synonym's real signature until we see its declaration. So,
-for example, in hs-boot file, we may need to think what to do...
-(eg don't have any implicitly-bound variables).
--}
-
-tcPatSynSig :: Name -> LHsSigType Name -> TcM TcPatSynInfo
-tcPatSynSig name sig_ty
- | HsIB { hsib_vars = implicit_hs_tvs
- , hsib_body = hs_ty } <- sig_ty
- , (univ_hs_tvs, hs_req, hs_ty1) <- splitLHsSigmaTy hs_ty
- , (ex_hs_tvs, hs_prov, hs_body_ty) <- splitLHsSigmaTy hs_ty1
- = do { (implicit_tvs, (univ_tvs, req, ex_tvs, prov, body_ty))
- <- solveEqualities $
- tcImplicitTKBndrs implicit_hs_tvs $
- tcExplicitTKBndrs univ_hs_tvs $ \ univ_tvs ->
- tcExplicitTKBndrs ex_hs_tvs $ \ ex_tvs ->
- do { req <- tcHsContext hs_req
- ; prov <- tcHsContext hs_prov
- ; body_ty <- tcHsOpenType hs_body_ty
- -- A (literal) pattern can be unlifted;
- -- e.g. pattern Zero <- 0# (Trac #12094)
- ; let bound_tvs
- = unionVarSets [ allBoundVariabless req
- , allBoundVariabless prov
- , allBoundVariables body_ty
- ]
- ; return ( (univ_tvs, req, ex_tvs, prov, body_ty)
- , bound_tvs) }
-
- -- Kind generalisation
- ; kvs <- kindGeneralize $
- mkSpecForAllTys (implicit_tvs ++ univ_tvs) $
- mkFunTys req $
- mkSpecForAllTys ex_tvs $
- mkFunTys prov $
- body_ty
-
- -- These are /signatures/ so we zonk to squeeze out any kind
- -- unification variables. Do this after quantifyTyVars which may
- -- default kind variables to *.
- -- ToDo: checkValidType?
- ; traceTc "about zonk" empty
- ; implicit_tvs <- mapM zonkTcTyCoVarBndr implicit_tvs
- ; univ_tvs <- mapM zonkTcTyCoVarBndr univ_tvs
- ; ex_tvs <- mapM zonkTcTyCoVarBndr ex_tvs
- ; req <- zonkTcTypes req
- ; prov <- zonkTcTypes prov
- ; body_ty <- zonkTcType body_ty
-
- ; traceTc "tcTySig }" $
- vcat [ text "implicit_tvs" <+> ppr_tvs implicit_tvs
- , text "kvs" <+> ppr_tvs kvs
- , text "univ_tvs" <+> ppr_tvs univ_tvs
- , text "req" <+> ppr req
- , text "ex_tvs" <+> ppr_tvs ex_tvs
- , text "prov" <+> ppr prov
- , text "body_ty" <+> ppr body_ty ]
- ; return (TPSI { patsig_name = name
- , patsig_implicit_bndrs = mkNamedBinders Invisible kvs ++
- mkNamedBinders Specified implicit_tvs
- , patsig_univ_bndrs = univ_tvs
- , patsig_req = req
- , patsig_ex_bndrs = ex_tvs
- , patsig_prov = prov
- , patsig_body_ty = body_ty }) }
- where
-
-ppr_tvs :: [TyVar] -> SDoc
-ppr_tvs tvs = braces (vcat [ ppr tv <+> dcolon <+> ppr (tyVarKind tv)
- | tv <- tvs])
-
-
{-
************************************************************************
* *
@@ -288,14 +149,16 @@ tcCheckPatSynDecl psb@PSB{ psb_id = lname@(L _ name), psb_args = details
pushLevelAndCaptureConstraints $
tcExtendTyVarEnv univ_tvs $
tcPat PatSyn lpat (mkCheckExpType pat_ty) $
- do { (subst, ex_tvs') <- if isUnidirectional dir
- then newMetaTyVars ex_tvs
- else newMetaSigTyVars ex_tvs
+ do { let new_tv | isUnidirectional dir = newMetaTyVarX
+ | otherwise = newMetaSigTyVarX
+ in_scope = mkInScopeSet (mkVarSet univ_tvs)
+ empty_subst = mkEmptyTCvSubst in_scope
+ ; (subst, ex_tvs') <- mapAccumLM new_tv empty_subst ex_tvs
-- See the "Existential type variables" part of
-- Note [Checking against a pattern signature]
; traceTc "tcpatsyn1" (vcat [ ppr v <+> dcolon <+> ppr (tyVarKind v) | v <- ex_tvs])
; traceTc "tcpatsyn2" (vcat [ ppr v <+> dcolon <+> ppr (tyVarKind v) | v <- ex_tvs'])
- ; let prov_theta' = substTheta (extendTCvInScopeList subst univ_tvs) prov_theta
+ ; let prov_theta' = substTheta subst prov_theta
-- Add univ_tvs to the in_scope set to
-- satisfy the substition invariant. There's no need to
-- add 'ex_tvs' as they are already in the domain of the
@@ -536,11 +399,9 @@ tcPatSynMatcher (L loc name) lpat
(univ_tvs, req_theta, req_ev_binds, req_dicts)
(ex_tvs, ex_tys, prov_theta, prov_dicts)
(args, arg_tys) pat_ty
- = do { rr_uniq <- newUnique
- ; tv_uniq <- newUnique
- ; let rr_name = mkInternalName rr_uniq (mkTyVarOcc "rep") loc
- tv_name = mkInternalName tv_uniq (mkTyVarOcc "r") loc
- rr_tv = mkTcTyVar rr_name runtimeRepTy (SkolemTv False)
+ = do { rr_name <- newNameAt (mkTyVarOcc "rep") loc
+ ; tv_name <- newNameAt (mkTyVarOcc "r") loc
+ ; let rr_tv = mkTcTyVar rr_name runtimeRepTy (SkolemTv False)
rr = mkTyVarTy rr_tv
res_tv = mkTcTyVar tv_name (tYPE rr) (SkolemTv False)
is_unlifted = null args && null prov_dicts
@@ -660,12 +521,11 @@ mkPatSynBuilderId dir (L _ name)
; return (Just (builder_id, need_dummy_arg)) }
where
-tcPatSynBuilderBind :: TcSigFun
- -> PatSynBind Name Name
+tcPatSynBuilderBind :: PatSynBind Name Name
-> TcM (LHsBinds Id)
-- See Note [Matchers and builders for pattern synonyms] in PatSyn
-tcPatSynBuilderBind sig_fun PSB{ psb_id = L loc name, psb_def = lpat
- , psb_dir = dir, psb_args = details }
+tcPatSynBuilderBind (PSB { psb_id = L loc name, psb_def = lpat
+ , psb_dir = dir, psb_args = details })
| isUnidirectional dir
= return emptyBag
@@ -691,9 +551,9 @@ tcPatSynBuilderBind sig_fun PSB{ psb_id = L loc name, psb_def = lpat
, bind_fvs = placeHolderNamesTc
, fun_tick = [] }
- ; sig <- get_builder_sig sig_fun name builder_id need_dummy_arg
+ sig = completeSigFromId (PatSynCtxt name) builder_id
- ; (builder_binds, _) <- tcPolyCheck NonRecursive emptyPragEnv sig (noLoc bind)
+ ; (builder_binds, _) <- tcPolyCheck emptyPragEnv sig (noLoc bind)
; traceTc "tcPatSynBuilderBind }" $ ppr builder_binds
; return builder_binds }
@@ -725,34 +585,6 @@ tcPatSynBuilderBind sig_fun PSB{ psb_id = L loc name, psb_def = lpat
add_dummy_arg other_mg = pprPanic "add_dummy_arg" $
pprMatches other_mg
-get_builder_sig :: TcSigFun -> Name -> Id -> Bool -> TcM TcIdSigInfo
-get_builder_sig sig_fun name builder_id need_dummy_arg
- | Just (TcPatSynSig sig) <- sig_fun name
- , TPSI { patsig_implicit_bndrs = implicit_bndrs
- , patsig_univ_bndrs = univ_bndrs
- , patsig_req = req
- , patsig_ex_bndrs = ex_bndrs
- , patsig_prov = prov
- , patsig_body_ty = body_ty } <- sig
- = -- Constuct a TcIdSigInfo from a TcPatSynInfo
- -- This does unfortunately mean that we have to know how to
- -- make the builder Id's type from the TcPatSynInfo, which
- -- duplicates the construction in mkPatSynBuilderId
- -- But we really want to use the scoped type variables from
- -- the actual sigature, so this is really the Right Thing
- return (TISI { sig_bndr = CompleteSig builder_id
- , sig_skols = [ (tyVarName tv, tv)
- | tv <- map (binderVar "get_builder_sig") implicit_bndrs
- ++ univ_bndrs ++ ex_bndrs ]
- , sig_theta = req ++ prov
- , sig_tau = add_void need_dummy_arg body_ty
- , sig_ctxt = PatSynCtxt name
- , sig_loc = getSrcSpan name })
- | otherwise
- = -- No signature, so fake up a TcIdSigInfo from the builder Id
- instTcTySigFromId builder_id
- -- See Note [Redundant constraints for builder]
-
tcPatSynBuilderOcc :: PatSyn -> TcM (HsExpr TcId, TcSigmaType)
-- monadic only for failure
tcPatSynBuilderOcc ps
diff --git a/compiler/typecheck/TcPatSyn.hs-boot b/compiler/typecheck/TcPatSyn.hs-boot
index 583abc11c2..18914bc2ec 100644
--- a/compiler/typecheck/TcPatSyn.hs-boot
+++ b/compiler/typecheck/TcPatSyn.hs-boot
@@ -2,14 +2,11 @@ module TcPatSyn where
import Name ( Name )
import Id ( Id )
-import HsSyn ( PatSynBind, LHsBinds, LHsSigType )
-import TcRnTypes ( TcM, TcSigFun, TcPatSynInfo )
+import HsSyn ( PatSynBind, LHsBinds )
+import TcRnTypes ( TcM, TcPatSynInfo )
import TcRnMonad ( TcGblEnv)
import Outputable ( Outputable )
-tcPatSynSig :: Name -> LHsSigType Name
- -> TcM TcPatSynInfo
-
tcInferPatSynDecl :: PatSynBind Name Name
-> TcM (LHsBinds Id, TcGblEnv)
@@ -17,7 +14,6 @@ tcCheckPatSynDecl :: PatSynBind Name Name
-> TcPatSynInfo
-> TcM (LHsBinds Id, TcGblEnv)
-tcPatSynBuilderBind :: TcSigFun -> PatSynBind Name Name
- -> TcM (LHsBinds Id)
+tcPatSynBuilderBind :: PatSynBind Name Name -> TcM (LHsBinds Id)
nonBidirectionalErr :: Outputable name => name -> TcM a
diff --git a/compiler/typecheck/TcRnDriver.hs b/compiler/typecheck/TcRnDriver.hs
index 154b127371..378f17a95c 100644
--- a/compiler/typecheck/TcRnDriver.hs
+++ b/compiler/typecheck/TcRnDriver.hs
@@ -1943,17 +1943,15 @@ tcGhciStmts stmts
getGhciStepIO :: TcM (LHsExpr Name)
getGhciStepIO = do
ghciTy <- getGHCiMonad
- fresh_a <- newUnique
- loc <- getSrcSpanM
- let a_tv = mkInternalName fresh_a (mkTyVarOccFS (fsLit "a")) loc
- ghciM = nlHsAppTy (nlHsTyVar ghciTy) (nlHsTyVar a_tv)
+ a_tv <- newName (mkTyVarOccFS (fsLit "a"))
+ let ghciM = nlHsAppTy (nlHsTyVar ghciTy) (nlHsTyVar a_tv)
ioM = nlHsAppTy (nlHsTyVar ioTyConName) (nlHsTyVar a_tv)
step_ty = noLoc $ HsForAllTy { hst_bndrs = [noLoc $ UserTyVar (noLoc a_tv)]
, hst_body = nlHsFunTy ghciM ioM }
stepTy :: LHsSigWcType Name
- stepTy = mkEmptyImplicitBndrs (mkEmptyWildCardBndrs step_ty)
+ stepTy = mkEmptyWildCardBndrs (mkEmptyImplicitBndrs step_ty)
return (noLoc $ ExprWithTySig (nlHsVar ghciStepIoMName) stepTy)
diff --git a/compiler/typecheck/TcRnMonad.hs b/compiler/typecheck/TcRnMonad.hs
index cd99b7c595..1747ce01a2 100644
--- a/compiler/typecheck/TcRnMonad.hs
+++ b/compiler/typecheck/TcRnMonad.hs
@@ -453,14 +453,18 @@ newUniqueSupply
writeMutVar u_var us1 ;
return us2 }}}
-newLocalName :: Name -> TcM Name
-newLocalName name = newName (nameOccName name)
+cloneLocalName :: Name -> TcM Name
+-- Make a fresh Internal name with the same OccName and SrcSpan
+cloneLocalName name = newNameAt (nameOccName name) (nameSrcSpan name)
newName :: OccName -> TcM Name
-newName occ
+newName occ = do { loc <- getSrcSpanM
+ ; newNameAt occ loc }
+
+newNameAt :: OccName -> SrcSpan -> TcM Name
+newNameAt occ span
= do { uniq <- newUnique
- ; loc <- getSrcSpanM
- ; return (mkInternalName uniq occ loc) }
+ ; return (mkInternalName uniq occ span) }
newSysName :: OccName -> TcRnIf gbl lcl Name
newSysName occ
@@ -1274,6 +1278,13 @@ emitInsoluble ct
v <- readTcRef lie_var ;
traceTc "emitInsoluble" (ppr v) }
+emitInsolubles :: [Ct] -> TcM ()
+emitInsolubles cts
+ = do { lie_var <- getConstraintVar ;
+ updTcRef lie_var (`addInsols` listToBag cts) ;
+ v <- readTcRef lie_var ;
+ traceTc "emitInsoluble" (ppr v) }
+
-- | Throw out any constraints emitted by the thing_inside
discardConstraints :: TcM a -> TcM a
discardConstraints thing_inside = fst <$> captureConstraints thing_inside
@@ -1344,19 +1355,21 @@ traceTcConstraints msg
emitWildCardHoleConstraints :: [(Name, TcTyVar)] -> TcM ()
emitWildCardHoleConstraints wcs
- = do { ctLoc <- getCtLocM HoleOrigin Nothing
- ; forM_ wcs $ \(name, tv) -> do {
- ; let real_span = case nameSrcSpan name of
+ = do { ct_loc <- getCtLocM HoleOrigin Nothing
+ ; emitInsolubles (map (do_one ct_loc) wcs) }
+ where
+ do_one :: CtLoc -> (Name, TcTyVar) -> Ct
+ do_one ct_loc (name, tv)
+ = CHoleCan { cc_ev = CtDerived { ctev_pred = mkTyVarTy tv
+ , ctev_loc = ct_loc' }
+ , cc_hole = TypeHole (occName name) }
+ where
+ real_span = case nameSrcSpan name of
RealSrcSpan span -> span
UnhelpfulSpan str -> pprPanic "emitWildCardHoleConstraints"
(ppr name <+> quotes (ftext str))
-- Wildcards are defined locally, and so have RealSrcSpans
- ctLoc' = setCtLocSpan ctLoc real_span
- ty = mkTyVarTy tv
- can = CHoleCan { cc_ev = CtDerived { ctev_pred = ty
- , ctev_loc = ctLoc' }
- , cc_hole = TypeHole (occName name) }
- ; emitInsoluble can } }
+ ct_loc' = setCtLocSpan ct_loc real_span
{-
************************************************************************
diff --git a/compiler/typecheck/TcRnTypes.hs b/compiler/typecheck/TcRnTypes.hs
index 3978302958..a737067678 100644
--- a/compiler/typecheck/TcRnTypes.hs
+++ b/compiler/typecheck/TcRnTypes.hs
@@ -58,11 +58,9 @@ module TcRnTypes(
ArrowCtxt(..),
-- TcSigInfo
- TcSigFun, TcSigInfo(..), TcIdSigInfo(..),
- TcPatSynInfo(..), TcIdSigBndr(..),
- findScopedTyVars, isPartialSig, noCompleteSig, tcSigInfoName,
- completeIdSigPolyId, completeSigPolyId_maybe,
- completeIdSigPolyId_maybe,
+ TcSigInfo(..), TcIdSigInfo(..),
+ TcIdSigInst(..), TcPatSynInfo(..),
+ isPartialSig,
-- Canonical constraints
Xi, Ct(..), Cts, emptyCts, andCts, andManyCts, pprCts,
@@ -144,7 +142,7 @@ import Coercion ( Coercion, mkHoleCo )
import ConLike ( ConLike(..) )
import DataCon ( DataCon, dataConUserType, dataConOrigArgTys )
import PatSyn ( PatSyn, pprPatSynType )
-import Id ( idName )
+import Id ( idType )
import FieldLabel ( FieldLabel )
import TcType
import Annotations
@@ -1197,62 +1195,111 @@ instance Outputable WhereFrom where
* *
********************************************************************* -}
-type TcSigFun = Name -> Maybe TcSigInfo
+-- These data types need to be here only because
+-- TcSimplify uses them, and TcSimplify is fairly
+-- low down in the module hierarchy
data TcSigInfo = TcIdSig TcIdSigInfo
| TcPatSynSig TcPatSynInfo
-data TcIdSigInfo
- = TISI
- { sig_bndr :: TcIdSigBndr
-
- , sig_skols :: [(Name, TcTyVar)]
- -- Instantiated type and kind variables SKOLEMS
- -- The Name is the Name that the renamer chose;
- -- but the TcTyVar may come from instantiating
- -- the type and hence have a different unique.
- -- No need to keep track of whether they are truly lexically
- -- scoped because the renamer has named them uniquely
- --
- -- For Partial signatures, this list /excludes/ any wildcards
- -- the named wildcards scope over the binding, and hence
- -- their Names may appear in renamed type signatures
- -- in the binding; get them from sig_bndr
- -- See Note [Binding scoped type variables]
-
- , sig_theta :: TcThetaType -- Instantiated theta. In the case of a
- -- PartialSig, sig_theta does not include
- -- the extra-constraints wildcard
-
- , sig_tau :: TcSigmaType -- Instantiated tau
- -- See Note [sig_tau may be polymorphic]
-
- , sig_ctxt :: UserTypeCtxt -- In the case of type-class default methods,
- -- the Name in the FunSigCtxt is not the same
- -- as the TcId; the former is 'op', while the
- -- latter is '$dmop' or some such
-
- , sig_loc :: SrcSpan -- Location of the type signature
- }
-
-data TcIdSigBndr -- See Note [Complete and partial type signatures]
+data TcIdSigInfo -- See Note [Complete and partial type signatures]
= CompleteSig -- A complete signature with no wildcards,
-- so the complete polymorphic type is known.
- TcId -- The polymorphic Id with that type
+ { sig_bndr :: TcId -- The polymorphic Id with that type
+
+ , sig_ctxt :: UserTypeCtxt -- In the case of type-class default methods,
+ -- the Name in the FunSigCtxt is not the same
+ -- as the TcId; the former is 'op', while the
+ -- latter is '$dmop' or some such
+
+ , sig_loc :: SrcSpan -- Location of the type signature
+ }
| PartialSig -- A partial type signature (i.e. includes one or more
-- wildcards). In this case it doesn't make sense to give
-- the polymorphic Id, because we are going to /infer/ its
-- type, so we can't make the polymorphic Id ab-initio
- { sig_name :: Name -- Name of the function; used when report wildcards
- , sig_hs_ty :: LHsType Name -- The original partial signature
- , sig_wcs :: [(Name,TcTyVar)] -- Instantiated wildcard variables (named and anonymous)
- -- The Name is what the user wrote, such as '_',
- -- including SrcSpan for the error message;
- -- The TcTyVar is just an ordinary unification variable
- , sig_cts :: Maybe SrcSpan -- Just loc <=> An extra-constraints wildcard was present
- } -- at location loc
- -- e.g. f :: (Eq a, _) => a -> a
+ { psig_name :: Name -- Name of the function; used when report wildcards
+ , psig_hs_ty :: LHsSigWcType Name -- The original partial signature in HsSyn form
+ , sig_ctxt :: UserTypeCtxt
+ , sig_loc :: SrcSpan -- Location of the type signature
+ }
+
+
+{- Note [Complete and partial type signatures]
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+A type signature is partial when it contains one or more wildcards
+(= type holes). The wildcard can either be:
+* A (type) wildcard occurring in sig_theta or sig_tau. These are
+ stored in sig_wcs.
+ f :: Bool -> _
+ g :: Eq _a => _a -> _a -> Bool
+* Or an extra-constraints wildcard, stored in sig_cts:
+ h :: (Num a, _) => a -> a
+
+A type signature is a complete type signature when there are no
+wildcards in the type signature, i.e. iff sig_wcs is empty and
+sig_extra_cts is Nothing.
+-}
+
+data TcIdSigInst
+ = TISI { sig_inst_sig :: TcIdSigInfo
+
+ , sig_inst_skols :: [(Name, TcTyVar)]
+ -- Instantiated type and kind variables SKOLEMS
+ -- The Name is the Name that the renamer chose;
+ -- but the TcTyVar may come from instantiating
+ -- the type and hence have a different unique.
+ -- No need to keep track of whether they are truly lexically
+ -- scoped because the renamer has named them uniquely
+ -- See Note [Binding scoped type variables] in TcSigs
+
+ , sig_inst_theta :: TcThetaType
+ -- Instantiated theta. In the case of a
+ -- PartialSig, sig_theta does not include
+ -- the extra-constraints wildcard
+
+ , sig_inst_tau :: TcSigmaType -- Instantiated tau
+ -- See Note [sig_inst_tau may be polymorphic]
+
+ -- Relevant for partial signature only
+ , sig_inst_wcs :: [(Name, TcTyVar)]
+ -- Like sig_inst_skols, but for wildcards. The named
+ -- wildcards scope over the binding, and hence their
+ -- Names may appear in type signatures in the binding
+
+ , sig_inst_wcx :: Maybe TcTyVar
+ -- Extra-constraints wildcard to fill in, if any
+ }
+
+{- Note [sig_inst_tau may be polymorphic]
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+Note that "sig_inst_tau" might actually be a polymorphic type,
+if the original function had a signature like
+ forall a. Eq a => forall b. Ord b => ....
+But that's ok: tcMatchesFun (called by tcRhs) can deal with that
+It happens, too! See Note [Polymorphic methods] in TcClassDcl.
+
+Note [Wildcards in partial signatures]
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+The wildcards in psig_wcs may stand for a type mentioning
+the universally-quantified tyvars of psig_ty
+
+E.g. f :: forall a. _ -> a
+ f x = x
+We get sig_inst_skols = [a]
+ sig_inst_tau = _22 -> a
+ sig_inst_wcs = [_22]
+and _22 in the end is unified with the type 'a'
+
+Moreover the kind of a wildcard in sig_inst_wcs may mention
+the universally-quantified tyvars sig_inst_skols
+e.g. f :: t a -> t _
+Here we get
+ sig_inst_skole = [k:*, (t::k ->*), (a::k)]
+ sig_inst_tau = t a -> t _22
+ sig_inst_wcs = [ _22::k ]
+-}
data TcPatSynInfo
= TPSI {
@@ -1267,132 +1314,29 @@ data TcPatSynInfo
patsig_body_ty :: TcSigmaType
}
-findScopedTyVars -- See Note [Binding scoped type variables]
- :: TcType -- The Type: its forall'd variables are a superset
- -- of the lexically scoped variables
- -> [TcTyVar] -- The instantiated forall variables of the TcType
- -> [(Name, TcTyVar)] -- In 1-1 correspondence with the instantiated vars
-findScopedTyVars sig_ty inst_tvs
- = zipWith find sig_tvs inst_tvs
- where
- find sig_tv inst_tv = (tyVarName sig_tv, inst_tv)
- (sig_tvs,_) = tcSplitForAllTys sig_ty
-
instance Outputable TcSigInfo where
ppr (TcIdSig idsi) = ppr idsi
ppr (TcPatSynSig tpsi) = text "TcPatSynInfo" <+> ppr tpsi
instance Outputable TcIdSigInfo where
- ppr (TISI { sig_bndr = bndr, sig_skols = tyvars
- , sig_theta = theta, sig_tau = tau })
- = ppr (tcIdSigBndrName bndr) <+> dcolon <+>
- vcat [ pprSigmaType (mkSpecSigmaTy (map snd tyvars) theta tau)
- , ppr (map fst tyvars) ]
+ ppr (CompleteSig { sig_bndr = bndr })
+ = ppr bndr <+> dcolon <+> ppr (idType bndr)
+ ppr (PartialSig { psig_name = name, psig_hs_ty = hs_ty })
+ = text "psig" <+> ppr name <+> dcolon <+> ppr hs_ty
-instance Outputable TcIdSigBndr where
- ppr (CompleteSig f) = text "CompleteSig" <+> ppr f
- ppr (PartialSig { sig_name = n }) = text "PartialSig" <+> ppr n
+instance Outputable TcIdSigInst where
+ ppr (TISI { sig_inst_sig = sig, sig_inst_skols = skols
+ , sig_inst_theta = theta, sig_inst_tau = tau })
+ = hang (ppr sig) 2 (vcat [ ppr skols, ppr theta <+> darrow <+> ppr tau ])
instance Outputable TcPatSynInfo where
ppr (TPSI{ patsig_name = name}) = ppr name
-isPartialSig :: TcIdSigInfo -> Bool
-isPartialSig (TISI { sig_bndr = PartialSig {} }) = True
-isPartialSig _ = False
-
--- | No signature or a partial signature
-noCompleteSig :: Maybe TcSigInfo -> Bool
-noCompleteSig (Just (TcIdSig sig)) = isPartialSig sig
-noCompleteSig _ = True
-
-tcIdSigBndrName :: TcIdSigBndr -> Name
-tcIdSigBndrName (CompleteSig id) = idName id
-tcIdSigBndrName (PartialSig { sig_name = n }) = n
-
-tcSigInfoName :: TcSigInfo -> Name
-tcSigInfoName (TcIdSig idsi) = tcIdSigBndrName (sig_bndr idsi)
-tcSigInfoName (TcPatSynSig tpsi) = patsig_name tpsi
-
--- Helper for cases when we know for sure we have a complete type
--- signature, e.g. class methods.
-completeIdSigPolyId :: TcIdSigInfo -> TcId
-completeIdSigPolyId (TISI { sig_bndr = CompleteSig id }) = id
-completeIdSigPolyId _ = panic "completeSigPolyId"
-
-completeIdSigPolyId_maybe :: TcIdSigInfo -> Maybe TcId
-completeIdSigPolyId_maybe (TISI { sig_bndr = CompleteSig id }) = Just id
-completeIdSigPolyId_maybe _ = Nothing
-
-completeSigPolyId_maybe :: TcSigInfo -> Maybe TcId
-completeSigPolyId_maybe (TcIdSig sig) = completeIdSigPolyId_maybe sig
-completeSigPolyId_maybe (TcPatSynSig {}) = Nothing
-
-{-
-Note [Binding scoped type variables]
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-The type variables *brought into lexical scope* by a type signature may
-be a subset of the *quantified type variables* of the signatures, for two reasons:
-
-* With kind polymorphism a signature like
- f :: forall f a. f a -> f a
- may actually give rise to
- f :: forall k. forall (f::k -> *) (a:k). f a -> f a
- So the sig_tvs will be [k,f,a], but only f,a are scoped.
- NB: the scoped ones are not necessarily the *inital* ones!
-
-* Even aside from kind polymorphism, there may be more instantiated
- type variables than lexically-scoped ones. For example:
- type T a = forall b. b -> (a,b)
- f :: forall c. T c
- Here, the signature for f will have one scoped type variable, c,
- but two instantiated type variables, c' and b'.
-
-The function findScopedTyVars takes
- * hs_ty: the original HsForAllTy
- * sig_ty: the corresponding Type (which is guaranteed to use the same Names
- as the HsForAllTy)
- * inst_tvs: the skolems instantiated from the forall's in sig_ty
-It returns a [(Maybe Name, TcTyVar)], in 1-1 correspondence with inst_tvs
-but with a (Just n) for the lexically scoped name of each in-scope tyvar.
-
-Note [sig_tau may be polymorphic]
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-Note that "sig_tau" might actually be a polymorphic type,
-if the original function had a signature like
- forall a. Eq a => forall b. Ord b => ....
-But that's ok: tcMatchesFun (called by tcRhs) can deal with that
-It happens, too! See Note [Polymorphic methods] in TcClassDcl.
+isPartialSig :: TcIdSigInst -> Bool
+isPartialSig (TISI { sig_inst_sig = PartialSig {} }) = True
+isPartialSig _ = False
-Note [Existential check]
-~~~~~~~~~~~~~~~~~~~~~~~~
-Lazy patterns can't bind existentials. They arise in two ways:
- * Let bindings let { C a b = e } in b
- * Twiddle patterns f ~(C a b) = e
-The pe_lazy field of PatEnv says whether we are inside a lazy
-pattern (perhaps deeply)
-
-If we aren't inside a lazy pattern then we can bind existentials,
-but we need to be careful about "extra" tyvars. Consider
- (\C x -> d) : pat_ty -> res_ty
-When looking for existential escape we must check that the existential
-bound by C don't unify with the free variables of pat_ty, OR res_ty
-(or of course the environment). Hence we need to keep track of the
-res_ty free vars.
-
-Note [Complete and partial type signatures]
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-A type signature is partial when it contains one or more wildcards
-(= type holes). The wildcard can either be:
-* A (type) wildcard occurring in sig_theta or sig_tau. These are
- stored in sig_wcs.
- f :: Bool -> _
- g :: Eq _a => _a -> _a -> Bool
-* Or an extra-constraints wildcard, stored in sig_cts:
- h :: (Num a, _) => a -> a
-A type signature is a complete type signature when there are no
-wildcards in the type signature, i.e. iff sig_wcs is empty and
-sig_extra_cts is Nothing. -}
{-
************************************************************************
@@ -2751,13 +2695,11 @@ pprSkolInfo UnkSkol = WARN( True, text "pprSkolInfo: UnkSkol" ) text "UnkSkol"
pprSigSkolInfo :: UserTypeCtxt -> TcType -> SDoc
pprSigSkolInfo ctxt ty
= case ctxt of
- FunSigCtxt f _ -> pp_sig f
+ FunSigCtxt f _ -> vcat [ text "the type signature for:"
+ , nest 2 (pprPrefixOcc f <+> dcolon <+> ppr ty) ]
PatSynCtxt {} -> pprUserTypeCtxt ctxt -- See Note [Skolem info for pattern synonyms]
_ -> vcat [ pprUserTypeCtxt ctxt <> colon
, nest 2 (ppr ty) ]
- where
- pp_sig f = vcat [ text "the type signature for:"
- , nest 2 (pprPrefixOcc f <+> dcolon <+> ppr ty) ]
pprPatSkolInfo :: ConLike -> SDoc
pprPatSkolInfo (RealDataCon dc)
diff --git a/compiler/typecheck/TcRules.hs b/compiler/typecheck/TcRules.hs
index 1b4826e1cd..4cfccb6bf0 100644
--- a/compiler/typecheck/TcRules.hs
+++ b/compiler/typecheck/TcRules.hs
@@ -145,7 +145,7 @@ tcRuleBndrs (L _ (RuleBndrSig (L _ name) rn_ty) : rule_bndrs)
-- The tyvar 'a' is brought into scope first, just as if you'd written
-- a::*, x :: a->a
= do { let ctxt = RuleSigCtxt name
- ; (id_ty, tvs, _) <- tcHsPatSigType ctxt rn_ty
+ ; (_ , tvs, id_ty) <- tcHsPatSigType ctxt rn_ty
; let id = mkLocalIdOrCoVar name id_ty
-- See Note [Pattern signature binders] in TcHsType
diff --git a/compiler/typecheck/TcSigs.hs b/compiler/typecheck/TcSigs.hs
new file mode 100644
index 0000000000..8bccc35577
--- /dev/null
+++ b/compiler/typecheck/TcSigs.hs
@@ -0,0 +1,763 @@
+{-
+(c) The University of Glasgow 2006-2012
+(c) The GRASP Project, Glasgow University, 1992-2002
+
+-}
+
+{-# LANGUAGE CPP #-}
+
+module TcSigs(
+ TcSigInfo(..),
+ TcIdSigInfo(..), TcIdSigInst,
+ TcPatSynInfo(..),
+ TcSigFun,
+
+ isPartialSig, noCompleteSig, tcIdSigName, tcSigInfoName,
+ completeSigPolyId_maybe,
+
+ tcTySigs, tcUserTypeSig, completeSigFromId,
+ tcInstSig,
+
+ TcPragEnv, emptyPragEnv, lookupPragEnv, extendPragEnv,
+ mkPragEnv, tcSpecPrags, tcSpecWrapper, tcImpPrags, addInlinePrags
+ ) where
+
+#include "HsVersions.h"
+
+import HsSyn
+import TcHsType
+import TcRnTypes
+import TcRnMonad
+import TcType
+import TcMType
+import TcUnify( tcSkolemise, unifyType, noThing )
+import Inst( topInstantiate )
+import TcEnv( tcLookupId )
+import TcEvidence( HsWrapper, (<.>) )
+import Type( mkNamedBinders )
+
+import DynFlags
+import Var ( TyVar, tyVarName, tyVarKind )
+import Id ( Id, idName, idType, idInlinePragma, setInlinePragma, mkLocalId )
+import PrelNames( mkUnboundName )
+import BasicTypes
+import Bag( foldrBag )
+import Module( getModule )
+import Name
+import NameEnv
+import VarSet
+import Outputable
+import SrcLoc
+import Util( singleton )
+import Maybes( orElse )
+import Data.Maybe( mapMaybe )
+import Control.Monad( unless )
+
+
+{- -------------------------------------------------------------
+ Note [Overview of type signatures]
+----------------------------------------------------------------
+Type signatures, including partial signatures, are jolly tricky,
+especially on value bindings. Here's an overview.
+
+ f :: forall a. [a] -> [a]
+ g :: forall b. _ -> b
+
+ f = ...g...
+ g = ...f...
+
+* HsSyn: a signature in a binding starts of as a TypeSig, in
+ type HsBinds.Sig
+
+* When starting a mutually recursive group, like f/g above, we
+ call tcTySig on each signature in the group.
+
+* tcTySig: Sig -> TcIdSigInfo
+ - For a /complete/ signature, like 'f' above, tcTySig kind-checks
+ the HsType, producing a Type, and wraps it in a CompleteSig, and
+ extend the type environment with this polymorphic 'f'.
+
+ - For a /partial/signauture, like 'g' above, tcTySig does nothing
+ Instead it just wraps the pieces in a PartialSig, to be handled
+ later.
+
+* tcInstSig: TcIdSigInfo -> TcIdSigInst
+ In tcMonoBinds, when looking at an individual binding, we use
+ tcInstSig to instantiate the signature forall's in the signature,
+ and attribute that instantiated (monomorphic) type to the
+ binder. You can see this in TcBinds.tcLhsId.
+
+ The instantiation does the obvious thing for complete signatures,
+ but for /partial/ signatures it starts from the HsSyn, so it
+ has to kind-check it etc: tcHsPartialSigType. It's convenient
+ to do this at the same time as instantiation, becuase we can
+ make the wildcards into unification variables right away, raather
+ than somehow quantifying over them. And the "TcLevel" of those
+ unification variables is correct because we are in tcMonoBinds.
+
+
+Note [Scoped tyvars]
+~~~~~~~~~~~~~~~~~~~~
+The -XScopedTypeVariables flag brings lexically-scoped type variables
+into scope for any explicitly forall-quantified type variables:
+ f :: forall a. a -> a
+ f x = e
+Then 'a' is in scope inside 'e'.
+
+However, we do *not* support this
+ - For pattern bindings e.g
+ f :: forall a. a->a
+ (f,g) = e
+
+Note [Binding scoped type variables]
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+The type variables *brought into lexical scope* by a type signature
+may be a subset of the *quantified type variables* of the signatures,
+for two reasons:
+
+* With kind polymorphism a signature like
+ f :: forall f a. f a -> f a
+ may actually give rise to
+ f :: forall k. forall (f::k -> *) (a:k). f a -> f a
+ So the sig_tvs will be [k,f,a], but only f,a are scoped.
+ NB: the scoped ones are not necessarily the *inital* ones!
+
+* Even aside from kind polymorphism, there may be more instantiated
+ type variables than lexically-scoped ones. For example:
+ type T a = forall b. b -> (a,b)
+ f :: forall c. T c
+ Here, the signature for f will have one scoped type variable, c,
+ but two instantiated type variables, c' and b'.
+
+However, all of this only applies to the renamer. The typechecker
+just puts all of them into the type environment; any lexical-scope
+errors were dealt with by the renamer.
+
+-}
+
+
+{- *********************************************************************
+* *
+ Utility functions for TcSigInfo
+* *
+********************************************************************* -}
+
+type TcSigFun = Name -> Maybe TcSigInfo
+
+-- | No signature or a partial signature
+noCompleteSig :: Maybe TcSigInfo -> Bool
+noCompleteSig (Just (TcIdSig (CompleteSig {}))) = False
+noCompleteSig _ = True
+
+tcIdSigName :: TcIdSigInfo -> Name
+tcIdSigName (CompleteSig { sig_bndr = id }) = idName id
+tcIdSigName (PartialSig { psig_name = n }) = n
+
+tcSigInfoName :: TcSigInfo -> Name
+tcSigInfoName (TcIdSig idsi) = tcIdSigName idsi
+tcSigInfoName (TcPatSynSig tpsi) = patsig_name tpsi
+
+completeSigPolyId_maybe :: TcSigInfo -> Maybe TcId
+completeSigPolyId_maybe sig
+ | TcIdSig sig_info <- sig
+ , CompleteSig { sig_bndr = id } <- sig_info = Just id
+ | otherwise = Nothing
+
+
+{- *********************************************************************
+* *
+ Typechecking user signatures
+* *
+********************************************************************* -}
+
+tcTySigs :: [LSig Name] -> TcM ([TcId], TcSigFun)
+tcTySigs hs_sigs
+ = checkNoErrs $ -- See Note [Fail eagerly on bad signatures]
+ do { ty_sigs_s <- mapAndRecoverM tcTySig hs_sigs
+ ; let ty_sigs = concat ty_sigs_s
+ poly_ids = mapMaybe completeSigPolyId_maybe ty_sigs
+ -- The returned [TcId] are the ones for which we have
+ -- a complete type signature.
+ -- See Note [Complete and partial type signatures]
+ env = mkNameEnv [(tcSigInfoName sig, sig) | sig <- ty_sigs]
+ ; return (poly_ids, lookupNameEnv env) }
+
+tcTySig :: LSig Name -> TcM [TcSigInfo]
+tcTySig (L _ (IdSig id))
+ = do { let ctxt = FunSigCtxt (idName id) False
+ -- False: do not report redundant constraints
+ -- The user has no control over the signature!
+ sig = completeSigFromId ctxt id
+ ; return [TcIdSig sig] }
+
+tcTySig (L loc (TypeSig names sig_ty))
+ = setSrcSpan loc $
+ do { sigs <- sequence [ tcUserTypeSig loc sig_ty (Just name)
+ | L _ name <- names ]
+ ; return (map TcIdSig sigs) }
+
+tcTySig (L loc (PatSynSig (L _ name) sig_ty))
+ = setSrcSpan loc $
+ do { tpsi <- tcPatSynSig name sig_ty
+ ; return [TcPatSynSig tpsi] }
+
+tcTySig _ = return []
+
+
+tcUserTypeSig :: SrcSpan -> LHsSigWcType Name -> Maybe Name -> TcM TcIdSigInfo
+-- A function or expression type signature
+-- Returns a fully quantified type signature; even the wildcards
+-- are quantified with ordinary skolems that should be instantiated
+--
+-- The SrcSpan is what to declare as the binding site of the
+-- any skolems in the signature. For function signatures we
+-- use the whole `f :: ty' signature; for expression signatures
+-- just the type part.
+--
+-- Just n => Function type signature name :: type
+-- Nothing => Expression type signature <expr> :: type
+tcUserTypeSig loc hs_sig_ty mb_name
+ | isCompleteHsSig hs_sig_ty
+ = do { sigma_ty <- tcHsSigWcType ctxt_F hs_sig_ty
+ ; return $
+ CompleteSig { sig_bndr = mkLocalId name sigma_ty
+ , sig_ctxt = ctxt_T
+ , sig_loc = loc } }
+ -- Location of the <type> in f :: <type>
+
+ -- Partial sig with wildcards
+ | otherwise
+ = return (PartialSig { psig_name = name, psig_hs_ty = hs_sig_ty
+ , sig_ctxt = ctxt_F, sig_loc = loc })
+ where
+ name = case mb_name of
+ Just n -> n
+ Nothing -> mkUnboundName (mkVarOcc "<expression>")
+ ctxt_F = case mb_name of
+ Just n -> FunSigCtxt n False
+ Nothing -> ExprSigCtxt
+ ctxt_T = case mb_name of
+ Just n -> FunSigCtxt n True
+ Nothing -> ExprSigCtxt
+
+
+
+completeSigFromId :: UserTypeCtxt -> Id -> TcIdSigInfo
+-- Used for instance methods and record selectors
+completeSigFromId ctxt id
+ = CompleteSig { sig_bndr = id
+ , sig_ctxt = ctxt
+ , sig_loc = getSrcSpan id }
+
+isCompleteHsSig :: LHsSigWcType Name -> Bool
+-- ^ If there are no wildcards, return a LHsSigType
+isCompleteHsSig (HsWC { hswc_wcs = wcs }) = null wcs
+
+{- Note [Fail eagerly on bad signatures]
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+If a type signaure is wrong, fail immediately:
+
+ * the type sigs may bind type variables, so proceeding without them
+ can lead to a cascade of errors
+
+ * the type signature might be ambiguous, in which case checking
+ the code against the signature will give a very similar error
+ to the ambiguity error.
+
+ToDo: this means we fall over if any type sig
+is wrong (eg at the top level of the module),
+which is over-conservative
+-}
+
+{- *********************************************************************
+* *
+ Type checking a pattern synonym signature
+* *
+************************************************************************
+
+Note [Pattern synonym signatures]
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+Pattern synonym signatures are surprisingly tricky (see Trac #11224 for example).
+In general they look like this:
+
+ pattern P :: forall univ_tvs. req_theta
+ => forall ex_tvs. prov_theta
+ => arg1 -> .. -> argn -> res_ty
+
+For parsing and renaming we treat the signature as an ordinary LHsSigType.
+
+Once we get to type checking, we decompose it into its parts, in tcPatSynSig.
+
+* Note that 'forall univ_tvs' and 'req_theta =>'
+ and 'forall ex_tvs' and 'prov_theta =>'
+ are all optional. We gather the pieces at the the top of tcPatSynSig
+
+* Initially the implicitly-bound tyvars (added by the renamer) include both
+ universal and existential vars.
+
+* After we kind-check the pieces and convert to Types, we do kind generalisation.
+
+Note [The pattern-synonym signature splitting rule]
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+Given a pattern signature, we must split
+ the kind-generalised variables, and
+ the implicitly-bound variables
+into universal and existential. The rule is this
+(see discussion on Trac #11224):
+
+ The universal tyvars are the ones mentioned in
+ - univ_tvs: the user-specified (forall'd) universals
+ - req_theta
+ - res_ty
+ The existential tyvars are all the rest
+
+For example
+
+ pattern P :: () => b -> T a
+ pattern P x = ...
+
+Here 'a' is universal, and 'b' is existential. But there is a wrinkle:
+how do we split the arg_tys from req_ty? Consider
+
+ pattern Q :: () => b -> S c -> T a
+ pattern Q x = ...
+
+This is an odd example because Q has only one syntactic argument, and
+so presumably is defined by a view pattern matching a function. But
+it can happen (Trac #11977, #12108).
+
+We don't know Q's arity from the pattern signature, so we have to wait
+until we see the pattern declaration itself before deciding res_ty is,
+and hence which variables are existential and which are universal.
+
+And that in turn is why TcPatSynInfo has a separate field,
+patsig_implicit_bndrs, to capture the implicitly bound type variables,
+because we don't yet know how to split them up.
+
+It's a slight compromise, because it means we don't really know the
+pattern synonym's real signature until we see its declaration. So,
+for example, in hs-boot file, we may need to think what to do...
+(eg don't have any implicitly-bound variables).
+-}
+
+tcPatSynSig :: Name -> LHsSigType Name -> TcM TcPatSynInfo
+tcPatSynSig name sig_ty
+ | HsIB { hsib_vars = implicit_hs_tvs
+ , hsib_body = hs_ty } <- sig_ty
+ , (univ_hs_tvs, hs_req, hs_ty1) <- splitLHsSigmaTy hs_ty
+ , (ex_hs_tvs, hs_prov, hs_body_ty) <- splitLHsSigmaTy hs_ty1
+ = do { (implicit_tvs, (univ_tvs, req, ex_tvs, prov, body_ty))
+ <- solveEqualities $
+ tcImplicitTKBndrs implicit_hs_tvs $
+ tcExplicitTKBndrs univ_hs_tvs $ \ univ_tvs ->
+ tcExplicitTKBndrs ex_hs_tvs $ \ ex_tvs ->
+ do { req <- tcHsContext hs_req
+ ; prov <- tcHsContext hs_prov
+ ; body_ty <- tcHsOpenType hs_body_ty
+ -- A (literal) pattern can be unlifted;
+ -- e.g. pattern Zero <- 0# (Trac #12094)
+ ; let bound_tvs
+ = unionVarSets [ allBoundVariabless req
+ , allBoundVariabless prov
+ , allBoundVariables body_ty
+ ]
+ ; return ( (univ_tvs, req, ex_tvs, prov, body_ty)
+ , bound_tvs) }
+
+ -- Kind generalisation
+ ; kvs <- kindGeneralize $
+ mkSpecForAllTys (implicit_tvs ++ univ_tvs) $
+ mkFunTys req $
+ mkSpecForAllTys ex_tvs $
+ mkFunTys prov $
+ body_ty
+
+ -- These are /signatures/ so we zonk to squeeze out any kind
+ -- unification variables. Do this after quantifyTyVars which may
+ -- default kind variables to *.
+ -- ToDo: checkValidType?
+ ; traceTc "about zonk" empty
+ ; implicit_tvs <- mapM zonkTcTyCoVarBndr implicit_tvs
+ ; univ_tvs <- mapM zonkTcTyCoVarBndr univ_tvs
+ ; ex_tvs <- mapM zonkTcTyCoVarBndr ex_tvs
+ ; req <- zonkTcTypes req
+ ; prov <- zonkTcTypes prov
+ ; body_ty <- zonkTcType body_ty
+
+ ; traceTc "tcTySig }" $
+ vcat [ text "implicit_tvs" <+> ppr_tvs implicit_tvs
+ , text "kvs" <+> ppr_tvs kvs
+ , text "univ_tvs" <+> ppr_tvs univ_tvs
+ , text "req" <+> ppr req
+ , text "ex_tvs" <+> ppr_tvs ex_tvs
+ , text "prov" <+> ppr prov
+ , text "body_ty" <+> ppr body_ty ]
+ ; return (TPSI { patsig_name = name
+ , patsig_implicit_bndrs = mkNamedBinders Invisible kvs ++
+ mkNamedBinders Specified implicit_tvs
+ , patsig_univ_bndrs = univ_tvs
+ , patsig_req = req
+ , patsig_ex_bndrs = ex_tvs
+ , patsig_prov = prov
+ , patsig_body_ty = body_ty }) }
+ where
+
+ppr_tvs :: [TyVar] -> SDoc
+ppr_tvs tvs = braces (vcat [ ppr tv <+> dcolon <+> ppr (tyVarKind tv)
+ | tv <- tvs])
+
+
+{- *********************************************************************
+* *
+ Instantiating user signatures
+* *
+********************************************************************* -}
+
+
+tcInstSig :: TcIdSigInfo -> TcM TcIdSigInst
+-- Instantiate a type signature; only used with plan InferGen
+tcInstSig sig@(CompleteSig { sig_bndr = poly_id, sig_loc = loc })
+ = setSrcSpan loc $ -- Set the binding site of the tyvars
+ do { (tv_prs, theta, tau) <- tcInstType newMetaSigTyVars poly_id
+ -- See Note [Pattern bindings and complete signatures]
+
+ ; return (TISI { sig_inst_sig = sig
+ , sig_inst_skols = tv_prs
+ , sig_inst_wcs = []
+ , sig_inst_wcx = Nothing
+ , sig_inst_theta = theta
+ , sig_inst_tau = tau }) }
+
+tcInstSig sig@(PartialSig { psig_hs_ty = hs_ty
+ , sig_ctxt = ctxt
+ , sig_loc = loc })
+ = setSrcSpan loc $ -- Set the binding site of the tyvars
+ do { (wcs, wcx, tvs, theta, tau) <- tcHsPartialSigType ctxt hs_ty
+ ; return (TISI { sig_inst_sig = sig
+ , sig_inst_skols = map (\tv -> (tyVarName tv, tv)) tvs
+ , sig_inst_wcs = wcs
+ , sig_inst_wcx = wcx
+ , sig_inst_theta = theta
+ , sig_inst_tau = tau }) }
+
+
+{- Note [Pattern bindings and complete signatures]
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+Consider
+ data T a = MkT a a
+ f :: forall a. a->a
+ g :: forall b. b->b
+ MkT f g = MkT (\x->x) (\y->y)
+Here we'll infer a type from the pattern of 'T a', but if we feed in
+the signature types for f and g, we'll end up unifying 'a' and 'b'
+
+So we instantiate f and g's signature with SigTv skolems
+(newMetaSigTyVars) that can unify with each other. If too much
+unification takes place, we'll find out when we do the final
+impedence-matching check in TcBinds.mkExport
+
+See Note [Signature skolems] in TcType
+
+None of this applies to a function binding with a complete
+signature, which doesn't use tcInstSig. See TcBinds.tcPolyCheck.
+-}
+
+{- *********************************************************************
+* *
+ Pragmas and PragEnv
+* *
+********************************************************************* -}
+
+type TcPragEnv = NameEnv [LSig Name]
+
+emptyPragEnv :: TcPragEnv
+emptyPragEnv = emptyNameEnv
+
+lookupPragEnv :: TcPragEnv -> Name -> [LSig Name]
+lookupPragEnv prag_fn n = lookupNameEnv prag_fn n `orElse` []
+
+extendPragEnv :: TcPragEnv -> (Name, LSig Name) -> TcPragEnv
+extendPragEnv prag_fn (n, sig) = extendNameEnv_Acc (:) singleton prag_fn n sig
+
+---------------
+mkPragEnv :: [LSig Name] -> LHsBinds Name -> TcPragEnv
+mkPragEnv sigs binds
+ = foldl extendPragEnv emptyNameEnv prs
+ where
+ prs = mapMaybe get_sig sigs
+
+ get_sig :: LSig Name -> Maybe (Name, LSig Name)
+ get_sig (L l (SpecSig lnm@(L _ nm) ty inl)) = Just (nm, L l $ SpecSig lnm ty (add_arity nm inl))
+ get_sig (L l (InlineSig lnm@(L _ nm) inl)) = Just (nm, L l $ InlineSig lnm (add_arity nm inl))
+ get_sig _ = Nothing
+
+ add_arity n inl_prag -- Adjust inl_sat field to match visible arity of function
+ | Inline <- inl_inline inl_prag
+ -- add arity only for real INLINE pragmas, not INLINABLE
+ = case lookupNameEnv ar_env n of
+ Just ar -> inl_prag { inl_sat = Just ar }
+ Nothing -> WARN( True, text "mkPragEnv no arity" <+> ppr n )
+ -- There really should be a binding for every INLINE pragma
+ inl_prag
+ | otherwise
+ = inl_prag
+
+ -- ar_env maps a local to the arity of its definition
+ ar_env :: NameEnv Arity
+ ar_env = foldrBag lhsBindArity emptyNameEnv binds
+
+lhsBindArity :: LHsBind Name -> NameEnv Arity -> NameEnv Arity
+lhsBindArity (L _ (FunBind { fun_id = id, fun_matches = ms })) env
+ = extendNameEnv env (unLoc id) (matchGroupArity ms)
+lhsBindArity _ env = env -- PatBind/VarBind
+
+
+-----------------
+addInlinePrags :: TcId -> [LSig Name] -> TcM TcId
+addInlinePrags poly_id prags_for_me
+ | inl@(L _ prag) : inls <- inl_prags
+ = do { traceTc "addInlinePrag" (ppr poly_id $$ ppr prag)
+ ; unless (null inls) (warn_multiple_inlines inl inls)
+ ; return (poly_id `setInlinePragma` prag) }
+ | otherwise
+ = return poly_id
+ where
+ inl_prags = [L loc prag | L loc (InlineSig _ prag) <- prags_for_me]
+
+ warn_multiple_inlines _ [] = return ()
+
+ warn_multiple_inlines inl1@(L loc prag1) (inl2@(L _ prag2) : inls)
+ | inlinePragmaActivation prag1 == inlinePragmaActivation prag2
+ , isEmptyInlineSpec (inlinePragmaSpec prag1)
+ = -- Tiresome: inl1 is put there by virtue of being in a hs-boot loop
+ -- and inl2 is a user NOINLINE pragma; we don't want to complain
+ warn_multiple_inlines inl2 inls
+ | otherwise
+ = setSrcSpan loc $
+ addWarnTc NoReason
+ (hang (text "Multiple INLINE pragmas for" <+> ppr poly_id)
+ 2 (vcat (text "Ignoring all but the first"
+ : map pp_inl (inl1:inl2:inls))))
+
+ pp_inl (L loc prag) = ppr prag <+> parens (ppr loc)
+
+
+{- *********************************************************************
+* *
+ SPECIALISE pragmas
+* *
+************************************************************************
+
+Note [Handling SPECIALISE pragmas]
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+The basic idea is this:
+
+ foo :: Num a => a -> b -> a
+ {-# SPECIALISE foo :: Int -> b -> Int #-}
+
+We check that
+ (forall a b. Num a => a -> b -> a)
+ is more polymorphic than
+ forall b. Int -> b -> Int
+(for which we could use tcSubType, but see below), generating a HsWrapper
+to connect the two, something like
+ wrap = /\b. <hole> Int b dNumInt
+This wrapper is put in the TcSpecPrag, in the ABExport record of
+the AbsBinds.
+
+
+ f :: (Eq a, Ix b) => a -> b -> Bool
+ {-# SPECIALISE f :: (Ix p, Ix q) => Int -> (p,q) -> Bool #-}
+ f = <poly_rhs>
+
+From this the typechecker generates
+
+ AbsBinds [ab] [d1,d2] [([ab], f, f_mono, prags)] binds
+
+ SpecPrag (wrap_fn :: forall a b. (Eq a, Ix b) => XXX
+ -> forall p q. (Ix p, Ix q) => XXX[ Int/a, (p,q)/b ])
+
+From these we generate:
+
+ Rule: forall p, q, (dp:Ix p), (dq:Ix q).
+ f Int (p,q) dInt ($dfInPair dp dq) = f_spec p q dp dq
+
+ Spec bind: f_spec = wrap_fn <poly_rhs>
+
+Note that
+
+ * The LHS of the rule may mention dictionary *expressions* (eg
+ $dfIxPair dp dq), and that is essential because the dp, dq are
+ needed on the RHS.
+
+ * The RHS of f_spec, <poly_rhs> has a *copy* of 'binds', so that it
+ can fully specialise it.
+
+
+
+From the TcSpecPrag, in DsBinds we generate a binding for f_spec and a RULE:
+
+ f_spec :: Int -> b -> Int
+ f_spec = wrap<f rhs>
+
+ RULE: forall b (d:Num b). f b d = f_spec b
+
+The RULE is generated by taking apart the HsWrapper, which is a little
+delicate, but works.
+
+Some wrinkles
+
+1. We don't use full-on tcSubType, because that does co and contra
+ variance and that in turn will generate too complex a LHS for the
+ RULE. So we use a single invocation of skolemise /
+ topInstantiate in tcSpecWrapper. (Actually I think that even
+ the "deeply" stuff may be too much, because it introduces lambdas,
+ though I think it can be made to work without too much trouble.)
+
+2. We need to take care with type families (Trac #5821). Consider
+ type instance F Int = Bool
+ f :: Num a => a -> F a
+ {-# SPECIALISE foo :: Int -> Bool #-}
+
+ We *could* try to generate an f_spec with precisely the declared type:
+ f_spec :: Int -> Bool
+ f_spec = <f rhs> Int dNumInt |> co
+
+ RULE: forall d. f Int d = f_spec |> sym co
+
+ but the 'co' and 'sym co' are (a) playing no useful role, and (b) are
+ hard to generate. At all costs we must avoid this:
+ RULE: forall d. f Int d |> co = f_spec
+ because the LHS will never match (indeed it's rejected in
+ decomposeRuleLhs).
+
+ So we simply do this:
+ - Generate a constraint to check that the specialised type (after
+ skolemiseation) is equal to the instantiated function type.
+ - But *discard* the evidence (coercion) for that constraint,
+ so that we ultimately generate the simpler code
+ f_spec :: Int -> F Int
+ f_spec = <f rhs> Int dNumInt
+
+ RULE: forall d. f Int d = f_spec
+ You can see this discarding happening in
+
+3. Note that the HsWrapper can transform *any* function with the right
+ type prefix
+ forall ab. (Eq a, Ix b) => XXX
+ regardless of XXX. It's sort of polymorphic in XXX. This is
+ useful: we use the same wrapper to transform each of the class ops, as
+ well as the dict. That's what goes on in TcInstDcls.mk_meth_spec_prags
+-}
+
+tcSpecPrags :: Id -> [LSig Name]
+ -> TcM [LTcSpecPrag]
+-- Add INLINE and SPECIALSE pragmas
+-- INLINE prags are added to the (polymorphic) Id directly
+-- SPECIALISE prags are passed to the desugarer via TcSpecPrags
+-- Pre-condition: the poly_id is zonked
+-- Reason: required by tcSubExp
+tcSpecPrags poly_id prag_sigs
+ = do { traceTc "tcSpecPrags" (ppr poly_id <+> ppr spec_sigs)
+ ; unless (null bad_sigs) warn_discarded_sigs
+ ; pss <- mapAndRecoverM (wrapLocM (tcSpecPrag poly_id)) spec_sigs
+ ; return $ concatMap (\(L l ps) -> map (L l) ps) pss }
+ where
+ spec_sigs = filter isSpecLSig prag_sigs
+ bad_sigs = filter is_bad_sig prag_sigs
+ is_bad_sig s = not (isSpecLSig s || isInlineLSig s)
+
+ warn_discarded_sigs
+ = addWarnTc NoReason
+ (hang (text "Discarding unexpected pragmas for" <+> ppr poly_id)
+ 2 (vcat (map (ppr . getLoc) bad_sigs)))
+
+--------------
+tcSpecPrag :: TcId -> Sig Name -> TcM [TcSpecPrag]
+tcSpecPrag poly_id prag@(SpecSig fun_name hs_tys inl)
+-- See Note [Handling SPECIALISE pragmas]
+--
+-- The Name fun_name in the SpecSig may not be the same as that of the poly_id
+-- Example: SPECIALISE for a class method: the Name in the SpecSig is
+-- for the selector Id, but the poly_id is something like $cop
+-- However we want to use fun_name in the error message, since that is
+-- what the user wrote (Trac #8537)
+ = addErrCtxt (spec_ctxt prag) $
+ do { warnIf NoReason (not (isOverloadedTy poly_ty || isInlinePragma inl))
+ (text "SPECIALISE pragma for non-overloaded function"
+ <+> quotes (ppr fun_name))
+ -- Note [SPECIALISE pragmas]
+ ; spec_prags <- mapM tc_one hs_tys
+ ; traceTc "tcSpecPrag" (ppr poly_id $$ nest 2 (vcat (map ppr spec_prags)))
+ ; return spec_prags }
+ where
+ name = idName poly_id
+ poly_ty = idType poly_id
+ spec_ctxt prag = hang (text "In the SPECIALISE pragma") 2 (ppr prag)
+
+ tc_one hs_ty
+ = do { spec_ty <- tcHsSigType (FunSigCtxt name False) hs_ty
+ ; wrap <- tcSpecWrapper (FunSigCtxt name True) poly_ty spec_ty
+ ; return (SpecPrag poly_id wrap inl) }
+
+tcSpecPrag _ prag = pprPanic "tcSpecPrag" (ppr prag)
+
+--------------
+tcSpecWrapper :: UserTypeCtxt -> TcType -> TcType -> TcM HsWrapper
+-- A simpler variant of tcSubType, used for SPECIALISE pragmas
+-- See Note [Handling SPECIALISE pragmas], wrinkle 1
+tcSpecWrapper ctxt poly_ty spec_ty
+ = do { (sk_wrap, inst_wrap)
+ <- tcSkolemise ctxt spec_ty $ \ _ spec_tau ->
+ do { (inst_wrap, tau) <- topInstantiate orig poly_ty
+ ; _ <- unifyType noThing spec_tau tau
+ -- Deliberately ignore the evidence
+ -- See Note [Handling SPECIALISE pragmas],
+ -- wrinkle (2)
+ ; return inst_wrap }
+ ; return (sk_wrap <.> inst_wrap) }
+ where
+ orig = SpecPragOrigin ctxt
+
+--------------
+tcImpPrags :: [LSig Name] -> TcM [LTcSpecPrag]
+-- SPECIALISE pragmas for imported things
+tcImpPrags prags
+ = do { this_mod <- getModule
+ ; dflags <- getDynFlags
+ ; if (not_specialising dflags) then
+ return []
+ else do
+ { pss <- mapAndRecoverM (wrapLocM tcImpSpec)
+ [L loc (name,prag)
+ | (L loc prag@(SpecSig (L _ name) _ _)) <- prags
+ , not (nameIsLocalOrFrom this_mod name) ]
+ ; return $ concatMap (\(L l ps) -> map (L l) ps) pss } }
+ where
+ -- Ignore SPECIALISE pragmas for imported things
+ -- when we aren't specialising, or when we aren't generating
+ -- code. The latter happens when Haddocking the base library;
+ -- we don't wnat complaints about lack of INLINABLE pragmas
+ not_specialising dflags
+ | not (gopt Opt_Specialise dflags) = True
+ | otherwise = case hscTarget dflags of
+ HscNothing -> True
+ HscInterpreted -> True
+ _other -> False
+
+tcImpSpec :: (Name, Sig Name) -> TcM [TcSpecPrag]
+tcImpSpec (name, prag)
+ = do { id <- tcLookupId name
+ ; unless (isAnyInlinePragma (idInlinePragma id))
+ (addWarnTc NoReason (impSpecErr name))
+ ; tcSpecPrag id prag }
+
+impSpecErr :: Name -> SDoc
+impSpecErr name
+ = hang (text "You cannot SPECIALISE" <+> quotes (ppr name))
+ 2 (vcat [ text "because its definition has no INLINE/INLINABLE pragma"
+ , parens $ sep
+ [ text "or its defining module" <+> quotes (ppr mod)
+ , text "was compiled without -O"]])
+ where
+ mod = nameModule name
diff --git a/compiler/typecheck/TcSimplify.hs b/compiler/typecheck/TcSimplify.hs
index c889b4b840..5a727a85ed 100644
--- a/compiler/typecheck/TcSimplify.hs
+++ b/compiler/typecheck/TcSimplify.hs
@@ -516,7 +516,7 @@ the let binding.
simplifyInfer :: TcLevel -- Used when generating the constraints
-> Bool -- Apply monomorphism restriction
- -> [TcIdSigInfo] -- Any signatures (possibly partial)
+ -> [TcIdSigInst] -- Any signatures (possibly partial)
-> [(Name, TcTauType)] -- Variables to be generalised,
-- and their tau-types
-> WantedConstraints
@@ -540,8 +540,8 @@ simplifyInfer rhs_tclvl apply_mr sigs name_taus wanteds
, text "(unzonked) wanted =" <+> ppr wanteds
]
- ; let partial_sigs = filter isPartialSig sigs
- psig_theta = concatMap sig_theta partial_sigs
+ ; let partial_sigs = filter isPartialSig sigs
+ psig_theta = concatMap sig_inst_theta partial_sigs
-- First do full-blown solving
-- NB: we must gather up all the bindings from doing
@@ -654,8 +654,13 @@ simplifyInfer rhs_tclvl apply_mr sigs name_taus wanteds
-- Emit an implication constraint for the
-- remaining constraints from the RHS
+ -- extra_qtvs: see Note [Quantification and partial signatures]
; bound_theta_vars <- mapM TcM.newEvVar bound_theta
; psig_theta_vars <- mapM zonkId psig_theta_vars
+ ; all_qtvs <- add_psig_tvs qtvs
+ [ tv | sig <- partial_sigs
+ , (_,tv) <- sig_inst_skols sig ]
+
; let full_theta = psig_theta ++ bound_theta
full_theta_vars = psig_theta_vars ++ bound_theta_vars
skol_info = InferSkol [ (name, mkSigmaTy [] full_theta ty)
@@ -664,13 +669,8 @@ simplifyInfer rhs_tclvl apply_mr sigs name_taus wanteds
-- they are also bound in ic_skols and we want them
-- to be tidied uniformly
- -- extra_qtvs: see Note [Quantification and partial signatures]
- extra_qtvs = [ tv | sig <- partial_sigs
- , (_, tv) <- sig_skols sig
- , not (tv `elem` qtvs) ]
-
implic = Implic { ic_tclvl = rhs_tclvl
- , ic_skols = extra_qtvs ++ qtvs
+ , ic_skols = all_qtvs
, ic_no_eqs = False
, ic_given = full_theta_vars
, ic_wanted = wanted_transformed
@@ -691,6 +691,16 @@ simplifyInfer rhs_tclvl apply_mr sigs name_taus wanteds
, text "implic =" <+> ppr implic ]
; return ( qtvs, full_theta_vars, TcEvBinds ev_binds_var ) }
+ where
+ add_psig_tvs qtvs [] = return qtvs
+ add_psig_tvs qtvs (tv:tvs)
+ = do { tv <- zonkTcTyVarToTyVar tv
+ ; if tv `elem` qtvs
+ then add_psig_tvs qtvs tvs
+ else do { mb_tv <- zonkQuantifiedTyVar False tv
+ ; case mb_tv of
+ Nothing -> add_psig_tvs qtvs tvs
+ Just tv -> add_psig_tvs (tv:qtvs) tvs } }
{- Note [Add signature contexts as givens]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -727,6 +737,7 @@ type signatures.
Note [Deciding quantification]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If the monomorphism restriction does not apply, then we quantify as follows:
+
* Take the global tyvars, and "grow" them using the equality constraints
E.g. if x:alpha is in the environment, and alpha ~ [beta] (which can
happen because alpha is untouchable here) then do not quantify over
@@ -759,7 +770,8 @@ decideQuantification
-> TcM ( [TcTyVar] -- Quantify over these (skolems)
, [PredType] ) -- and this context (fully zonked)
-- See Note [Deciding quantification]
-decideQuantification apply_mr name_taus psig_theta constraints
+decideQuantification apply_mr name_taus psig_theta candidates
+{-
| apply_mr -- Apply the Monomorphism restriction
= do { gbl_tvs <- tcGetGlobalTyCoVars
; zonked_taus <- mapM TcM.zonkTcType (psig_theta ++ taus)
@@ -788,30 +800,51 @@ decideQuantification apply_mr name_taus psig_theta constraints
; return (qtvs, []) }
| otherwise
+-}
= do { gbl_tvs <- tcGetGlobalTyCoVars
; zonked_taus <- mapM TcM.zonkTcType (psig_theta ++ taus)
-- psig_theta: see Note [Quantification and partial signatures]
; let DV { dv_kvs = zkvs, dv_tvs = ztvs} = splitDepVarsOfTypes zonked_taus
- mono_tvs = growThetaTyVars equality_constraints gbl_tvs
- tau_tvs_plus = growThetaTyVarsDSet constraints ztvs
- dvs_plus = DV { dv_kvs = zkvs, dv_tvs = tau_tvs_plus }
+ (gbl_cand, quant_cand) -- gbl_cand = do not quantify me
+ = case apply_mr of -- quant_cand = try to quantify me
+ True -> (candidates, [])
+ False -> ([], candidates)
+ zonked_tkvs = dVarSetToVarSet zkvs `unionVarSet` dVarSetToVarSet ztvs
+ eq_constraints = filter isEqPred quant_cand
+ constrained_tvs = tyCoVarsOfTypes gbl_cand
+ mono_tvs = growThetaTyVars eq_constraints $
+ gbl_tvs `unionVarSet` constrained_tvs
+ tau_tvs_plus = growThetaTyVarsDSet quant_cand ztvs
+ dvs_plus = DV { dv_kvs = zkvs, dv_tvs = tau_tvs_plus }
+
; qtvs <- quantifyZonkedTyVars mono_tvs dvs_plus
-- We don't grow the kvs, as there's no real need to. Recall
-- that quantifyTyVars uses the separation between kvs and tvs
-- only for defaulting, and we don't want (ever) to default a tv
-- to *. So, don't grow the kvs.
- ; constraints <- TcM.zonkTcTypes constraints
+ ; quant_cand <- TcM.zonkTcTypes quant_cand
-- quantifyTyVars turned some meta tyvars into
-- quantified skolems, so we have to zonk again
; let qtv_set = mkVarSet qtvs
- theta = pickQuantifiablePreds qtv_set constraints
+ theta = pickQuantifiablePreds qtv_set quant_cand
min_theta = mkMinimalBySCs theta
-- See Note [Minimize by Superclasses]
+ -- Warn about the monomorphism restriction
+ ; warn_mono <- woptM Opt_WarnMonomorphism
+ ; let mr_bites = constrained_tvs `intersectsVarSet` zonked_tkvs
+ ; warnTc (Reason Opt_WarnMonomorphism) (warn_mono && mr_bites) $
+ hang (text "The Monomorphism Restriction applies to the binding"
+ <> plural bndrs <+> text "for" <+> pp_bndrs)
+ 2 (text "Consider giving a type signature for"
+ <+> if isSingleton bndrs then pp_bndrs
+ else text "these binders")
+
; traceTc "decideQuantification 2"
- (vcat [ text "constraints:" <+> ppr constraints
+ (vcat [ text "gbl_cand:" <+> ppr gbl_cand
+ , text "quant_cand:" <+> ppr quant_cand
, text "gbl_tvs:" <+> ppr gbl_tvs
, text "mono_tvs:" <+> ppr mono_tvs
, text "tau_tvs_plus:" <+> ppr tau_tvs_plus
@@ -820,7 +853,6 @@ decideQuantification apply_mr name_taus psig_theta constraints
; return (qtvs, min_theta) }
where
pp_bndrs = pprWithCommas (quotes . ppr) bndrs
- equality_constraints = filter isEqPred constraints
(bndrs, taus) = unzip name_taus
------------------
diff --git a/compiler/typecheck/TcType.hs b/compiler/typecheck/TcType.hs
index 06f6a45a18..b48a0c1e04 100644
--- a/compiler/typecheck/TcType.hs
+++ b/compiler/typecheck/TcType.hs
@@ -34,7 +34,7 @@ module TcType (
--------------------------------
-- MetaDetails
- UserTypeCtxt(..), pprUserTypeCtxt, pprSigCtxt, isSigMaybe,
+ UserTypeCtxt(..), pprUserTypeCtxt, isSigMaybe,
TcTyVarDetails(..), pprTcTyVarDetails, vanillaSkolemTv, superSkolemTv,
MetaDetails(Flexi, Indirect), MetaInfo(..),
isImmutableTyVar, isSkolemTyVar, isMetaTyVar, isMetaTyVarTy, isTyVarTy,
@@ -564,20 +564,6 @@ pprUserTypeCtxt SigmaCtxt = text "the context of a polymorphic type"
pprUserTypeCtxt (DataTyCtxt tc) = text "the context of the data type declaration for" <+> quotes (ppr tc)
pprUserTypeCtxt (PatSynCtxt n) = text "the signature for pattern synonym" <+> quotes (ppr n)
-pprSigCtxt :: UserTypeCtxt -> SDoc -> SDoc
--- (pprSigCtxt ctxt <extra> <type>)
--- prints In the type signature for 'f':
--- f :: <type>
--- The <extra> is either empty or "the ambiguity check for"
-pprSigCtxt ctxt pp_ty
- | Just n <- isSigMaybe ctxt
- = hang (text "In the type signature:")
- 2 (pprPrefixOcc n <+> dcolon <+> pp_ty)
-
- | otherwise
- = hang (text "In" <+> pprUserTypeCtxt ctxt <> colon)
- 2 pp_ty
-
isSigMaybe :: UserTypeCtxt -> Maybe Name
isSigMaybe (FunSigCtxt n _) = Just n
isSigMaybe (ConArgCtxt n) = Just n
diff --git a/compiler/vectorise/Vectorise/Generic/PData.hs b/compiler/vectorise/Vectorise/Generic/PData.hs
index 54f5ace6e6..2c403bf82a 100644
--- a/compiler/vectorise/Vectorise/Generic/PData.hs
+++ b/compiler/vectorise/Vectorise/Generic/PData.hs
@@ -45,7 +45,7 @@ buildDataFamInst :: Name -> TyCon -> TyCon -> AlgTyConRhs -> VM FamInst
buildDataFamInst name' fam_tc vect_tc rhs
= do { axiom_name <- mkDerivedName mkInstTyCoOcc name'
- ; (_, tyvars') <- liftDs $ tcInstSigTyVarsLoc (getSrcSpan name') tyvars
+ ; (_, tyvars') <- liftDs $ tcInstSigTyVars (getSrcSpan name') tyvars
; let ax = mkSingleCoAxiom Representational axiom_name tyvars' [] fam_tc pat_tys rep_ty
tys' = mkTyVarTys tyvars'
rep_ty = mkTyConApp rep_tc tys'
diff --git a/testsuite/tests/arrows/should_fail/T5380.stderr b/testsuite/tests/arrows/should_fail/T5380.stderr
index 0e258a2c28..6c7caf789d 100644
--- a/testsuite/tests/arrows/should_fail/T5380.stderr
+++ b/testsuite/tests/arrows/should_fail/T5380.stderr
@@ -1,32 +1,32 @@
-
-T5380.hs:7:27: error:
- • Couldn't match expected type ‘Bool’ with actual type ‘not_bool’
- ‘not_bool’ is a rigid type variable bound by
- the type signature for:
- testB :: forall not_bool not_unit.
- not_bool -> (() -> ()) -> () -> not_unit
- at T5380.hs:6:10
- • In the expression: b
- In the expression: proc () -> if b then f -< () else f -< ()
- In an equation for ‘testB’:
- testB b f = proc () -> if b then f -< () else f -< ()
- • Relevant bindings include
- b :: not_bool (bound at T5380.hs:7:7)
- testB :: not_bool -> (() -> ()) -> () -> not_unit
- (bound at T5380.hs:7:1)
-
-T5380.hs:7:34: error:
- • Couldn't match type ‘not_unit’ with ‘()’
- ‘not_unit’ is a rigid type variable bound by
- the type signature for:
- testB :: forall not_bool not_unit.
- not_bool -> (() -> ()) -> () -> not_unit
- at T5380.hs:6:10
- Expected type: () -> not_unit
- Actual type: () -> ()
- • In the expression: f
- In the command: f -< ()
- In the expression: proc () -> if b then f -< () else f -< ()
- • Relevant bindings include
- testB :: not_bool -> (() -> ()) -> () -> not_unit
- (bound at T5380.hs:7:1)
+
+T5380.hs:7:27: error:
+ • Couldn't match expected type ‘Bool’ with actual type ‘not_bool’
+ ‘not_bool’ is a rigid type variable bound by
+ the type signature for:
+ testB :: forall not_bool not_unit.
+ not_bool -> (() -> ()) -> () -> not_unit
+ at T5380.hs:6:1-49
+ • In the expression: b
+ In the expression: proc () -> if b then f -< () else f -< ()
+ In an equation for ‘testB’:
+ testB b f = proc () -> if b then f -< () else f -< ()
+ • Relevant bindings include
+ b :: not_bool (bound at T5380.hs:7:7)
+ testB :: not_bool -> (() -> ()) -> () -> not_unit
+ (bound at T5380.hs:7:1)
+
+T5380.hs:7:34: error:
+ • Couldn't match type ‘not_unit’ with ‘()’
+ ‘not_unit’ is a rigid type variable bound by
+ the type signature for:
+ testB :: forall not_bool not_unit.
+ not_bool -> (() -> ()) -> () -> not_unit
+ at T5380.hs:6:1-49
+ Expected type: () -> not_unit
+ Actual type: () -> ()
+ • In the expression: f
+ In the command: f -< ()
+ In the expression: proc () -> if b then f -< () else f -< ()
+ • Relevant bindings include
+ testB :: not_bool -> (() -> ()) -> () -> not_unit
+ (bound at T5380.hs:7:1)
diff --git a/testsuite/tests/dependent/should_compile/T11241.stderr b/testsuite/tests/dependent/should_compile/T11241.stderr
index f6ec57e03d..fe80b47c3c 100644
--- a/testsuite/tests/dependent/should_compile/T11241.stderr
+++ b/testsuite/tests/dependent/should_compile/T11241.stderr
@@ -1,6 +1,4 @@
-
-T11241.hs:5:21: warning: [-Wpartial-type-signatures (in -Wdefault)]
- • Found type wildcard ‘_’ standing for ‘*’
- • In the type signature:
- foo :: forall (a :: _). a -> a
- • Relevant bindings include foo :: a -> a (bound at T11241.hs:6:1)
+
+T11241.hs:5:21: warning: [-Wpartial-type-signatures (in -Wdefault)]
+ • Found type wildcard ‘_’ standing for ‘*’
+ • In the type signature: foo :: forall (a :: _). a -> a
diff --git a/testsuite/tests/deriving/should_fail/T7148.stderr b/testsuite/tests/deriving/should_fail/T7148.stderr
index afdd1f9d99..a9314f9d64 100644
--- a/testsuite/tests/deriving/should_fail/T7148.stderr
+++ b/testsuite/tests/deriving/should_fail/T7148.stderr
@@ -1,18 +1,18 @@
-
-T7148.hs:27:40: error:
- • Couldn't match type ‘b’ with ‘Tagged a b’
- arising from the coercion of the method ‘iso2’
- from type ‘forall b. SameType b () -> SameType b b’
- to type ‘forall b. SameType b () -> SameType b (Tagged a b)’
- ‘b’ is a rigid type variable bound by
- the deriving clause for ‘IsoUnit (Tagged a b)’ at T7148.hs:27:40
- • When deriving the instance for (IsoUnit (Tagged a b))
-
-T7148.hs:27:40: error:
- • Couldn't match type ‘b’ with ‘Tagged a b’
- arising from the coercion of the method ‘iso1’
- from type ‘forall b. SameType () b -> SameType b b’
- to type ‘forall b. SameType () b -> SameType (Tagged a b) b’
- ‘b’ is a rigid type variable bound by
- the deriving clause for ‘IsoUnit (Tagged a b)’ at T7148.hs:27:40
- • When deriving the instance for (IsoUnit (Tagged a b))
+
+T7148.hs:27:40: error:
+ • Couldn't match type ‘b’ with ‘Tagged a b’
+ arising from the coercion of the method ‘iso2’
+ from type ‘forall b. SameType b () -> SameType b b’
+ to type ‘forall b. SameType b () -> SameType b (Tagged a b)’
+ ‘b’ is a rigid type variable bound by
+ the deriving clause for ‘IsoUnit (Tagged a b)’ at T7148.hs:27:40-46
+ • When deriving the instance for (IsoUnit (Tagged a b))
+
+T7148.hs:27:40: error:
+ • Couldn't match type ‘b’ with ‘Tagged a b’
+ arising from the coercion of the method ‘iso1’
+ from type ‘forall b. SameType () b -> SameType b b’
+ to type ‘forall b. SameType () b -> SameType (Tagged a b) b’
+ ‘b’ is a rigid type variable bound by
+ the deriving clause for ‘IsoUnit (Tagged a b)’ at T7148.hs:27:40-46
+ • When deriving the instance for (IsoUnit (Tagged a b))
diff --git a/testsuite/tests/deriving/should_fail/T7148a.stderr b/testsuite/tests/deriving/should_fail/T7148a.stderr
index 9a6ea41d96..cd1e4db351 100644
--- a/testsuite/tests/deriving/should_fail/T7148a.stderr
+++ b/testsuite/tests/deriving/should_fail/T7148a.stderr
@@ -1,11 +1,11 @@
-
-T7148a.hs:19:50: error:
- • Couldn't match representation of type ‘b’
- with that of ‘Result a b’
- arising from the coercion of the method ‘coerce’
- from type ‘forall b. Proxy b -> a -> Result a b’
- to type ‘forall b.
- Proxy b -> IS_NO_LONGER a -> Result (IS_NO_LONGER a) b’
- ‘b’ is a rigid type variable bound by
- the type Proxy b -> a -> Result a b at T7148a.hs:19:50
- • When deriving the instance for (Convert (IS_NO_LONGER a))
+
+T7148a.hs:19:50: error:
+ • Couldn't match representation of type ‘b’
+ with that of ‘Result a b’
+ arising from the coercion of the method ‘coerce’
+ from type ‘forall b. Proxy b -> a -> Result a b’
+ to type ‘forall b.
+ Proxy b -> IS_NO_LONGER a -> Result (IS_NO_LONGER a) b’
+ ‘b’ is a rigid type variable bound by
+ the type Proxy b -> a -> Result a b at T7148a.hs:19:50-56
+ • When deriving the instance for (Convert (IS_NO_LONGER a))
diff --git a/testsuite/tests/gadt/T3169.stderr b/testsuite/tests/gadt/T3169.stderr
index 4c9097eacd..433333f21d 100644
--- a/testsuite/tests/gadt/T3169.stderr
+++ b/testsuite/tests/gadt/T3169.stderr
@@ -1,19 +1,19 @@
-
-T3169.hs:13:22: error:
- • Couldn't match type ‘elt’ with ‘Map b elt’
- ‘elt’ is a rigid type variable bound by
- the type signature for:
- lookup :: forall elt. (a, b) -> Map (a, b) elt -> Maybe elt
- at T3169.hs:12:3
- Expected type: Map a (Map b elt)
- Actual type: Map (a, b) elt
- • In the second argument of ‘lookup’, namely ‘m’
- In the expression: lookup a m :: Maybe (Map b elt)
- In the expression:
- case lookup a m :: Maybe (Map b elt) of {
- Just (m2 :: Map b elt) -> lookup b m2 :: Maybe elt }
- • Relevant bindings include
- m :: Map (a, b) elt (bound at T3169.hs:12:17)
- b :: b (bound at T3169.hs:12:13)
- lookup :: (a, b) -> Map (a, b) elt -> Maybe elt
- (bound at T3169.hs:12:3)
+
+T3169.hs:13:22: error:
+ • Couldn't match type ‘elt’ with ‘Map b elt’
+ ‘elt’ is a rigid type variable bound by
+ the type signature for:
+ lookup :: forall elt. (a, b) -> Map (a, b) elt -> Maybe elt
+ at T3169.hs:12:3-8
+ Expected type: Map a (Map b elt)
+ Actual type: Map (a, b) elt
+ • In the second argument of ‘lookup’, namely ‘m’
+ In the expression: lookup a m :: Maybe (Map b elt)
+ In the expression:
+ case lookup a m :: Maybe (Map b elt) of {
+ Just (m2 :: Map b elt) -> lookup b m2 :: Maybe elt }
+ • Relevant bindings include
+ m :: Map (a, b) elt (bound at T3169.hs:12:17)
+ b :: b (bound at T3169.hs:12:13)
+ lookup :: (a, b) -> Map (a, b) elt -> Maybe elt
+ (bound at T3169.hs:12:3)
diff --git a/testsuite/tests/gadt/T7558.stderr b/testsuite/tests/gadt/T7558.stderr
index 6618346452..34ade9778e 100644
--- a/testsuite/tests/gadt/T7558.stderr
+++ b/testsuite/tests/gadt/T7558.stderr
@@ -1,15 +1,15 @@
-
-T7558.hs:8:4: error:
- • Couldn't match type ‘a’ with ‘Maybe a’
- ‘a’ is a rigid type variable bound by
- the type signature for:
- f :: forall a. T a a -> Bool
- at T7558.hs:7:6
- Inaccessible code in
- a pattern with constructor:
- MkT :: forall a b. a ~ Maybe b => a -> Maybe b -> T a b,
- in an equation for ‘f’
- • In the pattern: MkT x y
- In an equation for ‘f’: f (MkT x y) = [x, y] `seq` True
- • Relevant bindings include
- f :: T a a -> Bool (bound at T7558.hs:8:1)
+
+T7558.hs:8:4: error:
+ • Couldn't match type ‘a’ with ‘Maybe a’
+ ‘a’ is a rigid type variable bound by
+ the type signature for:
+ f :: forall a. T a a -> Bool
+ at T7558.hs:7:1-18
+ Inaccessible code in
+ a pattern with constructor:
+ MkT :: forall a b. a ~ Maybe b => a -> Maybe b -> T a b,
+ in an equation for ‘f’
+ • In the pattern: MkT x y
+ In an equation for ‘f’: f (MkT x y) = [x, y] `seq` True
+ • Relevant bindings include
+ f :: T a a -> Bool (bound at T7558.hs:8:1)
diff --git a/testsuite/tests/gadt/gadt-escape1.stderr b/testsuite/tests/gadt/gadt-escape1.stderr
index 9bcd99cffe..ccd428f106 100644
--- a/testsuite/tests/gadt/gadt-escape1.stderr
+++ b/testsuite/tests/gadt/gadt-escape1.stderr
@@ -1,19 +1,19 @@
-
-gadt-escape1.hs:19:58: error:
- • Couldn't match type ‘t’ with ‘ExpGADT Int’
- ‘t’ is untouchable
- inside the constraints: t1 ~ Int
- bound by a pattern with constructor: ExpInt :: Int -> ExpGADT Int,
- in a case alternative
- at gadt-escape1.hs:19:43-50
- ‘t’ is a rigid type variable bound by
- the inferred type of weird1 :: t at gadt-escape1.hs:19:1
- Possible fix: add a type signature for ‘weird1’
- Expected type: t
- Actual type: ExpGADT t1
- • In the expression: a
- In a case alternative: Hidden (ExpInt _) a -> a
- In the expression:
- case (hval :: Hidden) of { Hidden (ExpInt _) a -> a }
- • Relevant bindings include
- weird1 :: t (bound at gadt-escape1.hs:19:1)
+
+gadt-escape1.hs:19:58: error:
+ • Couldn't match type ‘t’ with ‘ExpGADT Int’
+ ‘t’ is untouchable
+ inside the constraints: t1 ~ Int
+ bound by a pattern with constructor: ExpInt :: Int -> ExpGADT Int,
+ in a case alternative
+ at gadt-escape1.hs:19:43-50
+ ‘t’ is a rigid type variable bound by
+ the inferred type of weird1 :: t at gadt-escape1.hs:19:1-58
+ Possible fix: add a type signature for ‘weird1’
+ Expected type: t
+ Actual type: ExpGADT t1
+ • In the expression: a
+ In a case alternative: Hidden (ExpInt _) a -> a
+ In the expression:
+ case (hval :: Hidden) of { Hidden (ExpInt _) a -> a }
+ • Relevant bindings include
+ weird1 :: t (bound at gadt-escape1.hs:19:1)
diff --git a/testsuite/tests/gadt/gadt13.stderr b/testsuite/tests/gadt/gadt13.stderr
index 797fd0ba4d..06b1f9c720 100644
--- a/testsuite/tests/gadt/gadt13.stderr
+++ b/testsuite/tests/gadt/gadt13.stderr
@@ -1,17 +1,17 @@
-
-gadt13.hs:15:13: error:
- • Couldn't match expected type ‘t’
- with actual type ‘String -> [Char]’
- ‘t’ is untouchable
- inside the constraints: t1 ~ Int
- bound by a pattern with constructor: I :: Int -> Term Int,
- in an equation for ‘shw’
- at gadt13.hs:15:6-8
- ‘t’ is a rigid type variable bound by
- the inferred type of shw :: Term t1 -> t at gadt13.hs:15:1
- Possible fix: add a type signature for ‘shw’
- • Possible cause: ‘(.)’ is applied to too many arguments
- In the expression: ("I " ++) . shows t
- In an equation for ‘shw’: shw (I t) = ("I " ++) . shows t
- • Relevant bindings include
- shw :: Term t1 -> t (bound at gadt13.hs:15:1)
+
+gadt13.hs:15:13: error:
+ • Couldn't match expected type ‘t’
+ with actual type ‘String -> [Char]’
+ ‘t’ is untouchable
+ inside the constraints: t1 ~ Int
+ bound by a pattern with constructor: I :: Int -> Term Int,
+ in an equation for ‘shw’
+ at gadt13.hs:15:6-8
+ ‘t’ is a rigid type variable bound by
+ the inferred type of shw :: Term t1 -> t at gadt13.hs:15:1-30
+ Possible fix: add a type signature for ‘shw’
+ • Possible cause: ‘(.)’ is applied to too many arguments
+ In the expression: ("I " ++) . shows t
+ In an equation for ‘shw’: shw (I t) = ("I " ++) . shows t
+ • Relevant bindings include
+ shw :: Term t1 -> t (bound at gadt13.hs:15:1)
diff --git a/testsuite/tests/gadt/gadt7.stderr b/testsuite/tests/gadt/gadt7.stderr
index 35c8e10363..6e1effa067 100644
--- a/testsuite/tests/gadt/gadt7.stderr
+++ b/testsuite/tests/gadt/gadt7.stderr
@@ -1,20 +1,20 @@
-
-gadt7.hs:16:38: error:
- • Couldn't match expected type ‘t’ with actual type ‘t1’
- ‘t’ is untouchable
- inside the constraints: t2 ~ Int
- bound by a pattern with constructor: K :: T Int,
- in a case alternative
- at gadt7.hs:16:33
- ‘t’ is a rigid type variable bound by
- the inferred type of i1b :: T t2 -> t1 -> t at gadt7.hs:16:1
- ‘t1’ is a rigid type variable bound by
- the inferred type of i1b :: T t2 -> t1 -> t at gadt7.hs:16:1
- Possible fix: add a type signature for ‘i1b’
- • In the expression: y1
- In a case alternative: K -> y1
- In the expression: case t1 of { K -> y1 }
- • Relevant bindings include
- y1 :: t1 (bound at gadt7.hs:16:16)
- y :: t1 (bound at gadt7.hs:16:7)
- i1b :: T t2 -> t1 -> t (bound at gadt7.hs:16:1)
+
+gadt7.hs:16:38: error:
+ • Couldn't match expected type ‘t’ with actual type ‘t1’
+ ‘t’ is untouchable
+ inside the constraints: t2 ~ Int
+ bound by a pattern with constructor: K :: T Int,
+ in a case alternative
+ at gadt7.hs:16:33
+ ‘t’ is a rigid type variable bound by
+ the inferred type of i1b :: T t2 -> t1 -> t at gadt7.hs:16:1-44
+ ‘t1’ is a rigid type variable bound by
+ the inferred type of i1b :: T t2 -> t1 -> t at gadt7.hs:16:1-44
+ Possible fix: add a type signature for ‘i1b’
+ • In the expression: y1
+ In a case alternative: K -> y1
+ In the expression: case t1 of { K -> y1 }
+ • Relevant bindings include
+ y1 :: t1 (bound at gadt7.hs:16:16)
+ y :: t1 (bound at gadt7.hs:16:7)
+ i1b :: T t2 -> t1 -> t (bound at gadt7.hs:16:1)
diff --git a/testsuite/tests/gadt/rw.stderr b/testsuite/tests/gadt/rw.stderr
index c79bb72b4c..4c53ff2aa1 100644
--- a/testsuite/tests/gadt/rw.stderr
+++ b/testsuite/tests/gadt/rw.stderr
@@ -1,30 +1,30 @@
-
-rw.hs:14:47: error:
- • Couldn't match expected type ‘a’ with actual type ‘Int’
- ‘a’ is a rigid type variable bound by
- the type signature for:
- writeInt :: forall a. T a -> IORef a -> IO ()
- at rw.hs:12:12
- • In the second argument of ‘writeIORef’, namely ‘(1 :: Int)’
- In the expression: writeIORef ref (1 :: Int)
- In a case alternative: ~(Li x) -> writeIORef ref (1 :: Int)
- • Relevant bindings include
- ref :: IORef a (bound at rw.hs:13:12)
- v :: T a (bound at rw.hs:13:10)
- writeInt :: T a -> IORef a -> IO () (bound at rw.hs:13:1)
-
-rw.hs:19:43: error:
- • Couldn't match type ‘a’ with ‘Bool’
- ‘a’ is a rigid type variable bound by
- the type signature for:
- readBool :: forall a. T a -> IORef a -> IO ()
- at rw.hs:16:12
- Expected type: a -> IO ()
- Actual type: Bool -> IO ()
- • In the second argument of ‘(>>=)’, namely ‘(print . not)’
- In the expression: readIORef ref >>= (print . not)
- In a case alternative: ~(Lb x) -> readIORef ref >>= (print . not)
- • Relevant bindings include
- ref :: IORef a (bound at rw.hs:17:12)
- v :: T a (bound at rw.hs:17:10)
- readBool :: T a -> IORef a -> IO () (bound at rw.hs:17:1)
+
+rw.hs:14:47: error:
+ • Couldn't match expected type ‘a’ with actual type ‘Int’
+ ‘a’ is a rigid type variable bound by
+ the type signature for:
+ writeInt :: forall a. T a -> IORef a -> IO ()
+ at rw.hs:12:1-34
+ • In the second argument of ‘writeIORef’, namely ‘(1 :: Int)’
+ In the expression: writeIORef ref (1 :: Int)
+ In a case alternative: ~(Li x) -> writeIORef ref (1 :: Int)
+ • Relevant bindings include
+ ref :: IORef a (bound at rw.hs:13:12)
+ v :: T a (bound at rw.hs:13:10)
+ writeInt :: T a -> IORef a -> IO () (bound at rw.hs:13:1)
+
+rw.hs:19:43: error:
+ • Couldn't match type ‘a’ with ‘Bool’
+ ‘a’ is a rigid type variable bound by
+ the type signature for:
+ readBool :: forall a. T a -> IORef a -> IO ()
+ at rw.hs:16:1-34
+ Expected type: a -> IO ()
+ Actual type: Bool -> IO ()
+ • In the second argument of ‘(>>=)’, namely ‘(print . not)’
+ In the expression: readIORef ref >>= (print . not)
+ In a case alternative: ~(Lb x) -> readIORef ref >>= (print . not)
+ • Relevant bindings include
+ ref :: IORef a (bound at rw.hs:17:12)
+ v :: T a (bound at rw.hs:17:10)
+ readBool :: T a -> IORef a -> IO () (bound at rw.hs:17:1)
diff --git a/testsuite/tests/ghc-api/landmines/landmines.stdout b/testsuite/tests/ghc-api/landmines/landmines.stdout
index 279b92c715..39d6acc353 100644
--- a/testsuite/tests/ghc-api/landmines/landmines.stdout
+++ b/testsuite/tests/ghc-api/landmines/landmines.stdout
@@ -1,4 +1,4 @@
-(12,12,8)
-(93,63,0)
-(15,13,7)
-(10,10,8)
+(12,12,8)
+(93,63,0)
+(15,13,8)
+(10,10,8)
diff --git a/testsuite/tests/ghci/scripts/Defer02.stderr b/testsuite/tests/ghci/scripts/Defer02.stderr
index 7318eb632a..bcc6c5eff5 100644
--- a/testsuite/tests/ghci/scripts/Defer02.stderr
+++ b/testsuite/tests/ghci/scripts/Defer02.stderr
@@ -1,198 +1,197 @@
-
-../../typecheck/should_run/Defer01.hs:11:40: warning: [-Wdeferred-type-errors (in -Wdefault)]
- • Couldn't match type ‘Char’ with ‘[Char]’
- Expected type: String
- Actual type: Char
- • In the first argument of ‘putStr’, namely ‘','’
- In the second argument of ‘(>>)’, namely ‘putStr ','’
- In the expression: putStr "Hello World" >> putStr ','
-
-../../typecheck/should_run/Defer01.hs:14:5: warning: [-Wdeferred-type-errors (in -Wdefault)]
- • Couldn't match expected type ‘Int’ with actual type ‘Char’
- • In the expression: 'p'
- In an equation for ‘a’: a = 'p'
-
-../../typecheck/should_run/Defer01.hs:18:7: warning: [-Wdeferred-type-errors (in -Wdefault)]
- • No instance for (Eq B) arising from a use of ‘==’
- • In the expression: x == x
- In an equation for ‘b’: b x = x == x
-
-../../typecheck/should_run/Defer01.hs:25:1: warning: [-Woverlapping-patterns (in -Wdefault)]
- Pattern match has inaccessible right hand side
- In an equation for ‘c’: c (C2 x) = ...
-
-../../typecheck/should_run/Defer01.hs:25:4: warning: [-Wdeferred-type-errors (in -Wdefault)]
- • Couldn't match type ‘Int’ with ‘Bool’
- Inaccessible code in
- a pattern with constructor: C2 :: Bool -> C Bool,
- in an equation for ‘c’
- • In the pattern: C2 x
- In an equation for ‘c’: c (C2 x) = True
-
-../../typecheck/should_run/Defer01.hs:28:5: warning: [-Wdeferred-type-errors (in -Wdefault)]
- • No instance for (Num (a -> a)) arising from the literal ‘1’
- (maybe you haven't applied a function to enough arguments?)
- • In the expression: 1
- In an equation for ‘d’: d = 1
-
-../../typecheck/should_run/Defer01.hs:31:5: warning: [-Wdeferred-type-errors (in -Wdefault)]
- • Couldn't match expected type ‘Char -> t’ with actual type ‘Char’
- • The function ‘e’ is applied to one argument,
- but its type ‘Char’ has none
- In the expression: e 'q'
- In an equation for ‘f’: f = e 'q'
- • Relevant bindings include
- f :: t (bound at ../../typecheck/should_run/Defer01.hs:31:1)
-
-../../typecheck/should_run/Defer01.hs:34:8: warning: [-Wdeferred-type-errors (in -Wdefault)]
- • Couldn't match expected type ‘Char’ with actual type ‘a’
- ‘a’ is a rigid type variable bound by
- the type signature for:
- h :: forall a. a -> (Char, Char)
- at ../../typecheck/should_run/Defer01.hs:33:6
- • In the expression: x
- In the expression: (x, 'c')
- In an equation for ‘h’: h x = (x, 'c')
- • Relevant bindings include
- x :: a (bound at ../../typecheck/should_run/Defer01.hs:34:3)
- h :: a -> (Char, Char)
- (bound at ../../typecheck/should_run/Defer01.hs:34:1)
-
-../../typecheck/should_run/Defer01.hs:39:17: warning: [-Wdeferred-type-errors (in -Wdefault)]
- • Couldn't match expected type ‘Bool’ with actual type ‘T a’
- • In the first argument of ‘not’, namely ‘(K a)’
- In the expression: (not (K a))
- In the expression: seq (not (K a)) ()
- • Relevant bindings include
- a :: a (bound at ../../typecheck/should_run/Defer01.hs:39:3)
- i :: a -> () (bound at ../../typecheck/should_run/Defer01.hs:39:1)
-
-../../typecheck/should_run/Defer01.hs:43:5: warning: [-Wdeferred-type-errors (in -Wdefault)]
- • No instance for (MyClass a1) arising from a use of ‘myOp’
- • In the expression: myOp 23
- In an equation for ‘j’: j = myOp 23
-
-../../typecheck/should_run/Defer01.hs:43:10: warning: [-Wdeferred-type-errors (in -Wdefault)]
- • Ambiguous type variable ‘a1’ arising from the literal ‘23’
- prevents the constraint ‘(Num a1)’ from being solved.
- Probable fix: use a type annotation to specify what ‘a1’ should be.
- These potential instances exist:
- instance Num Integer -- Defined in ‘GHC.Num’
- instance Num Double -- Defined in ‘GHC.Float’
- instance Num Float -- Defined in ‘GHC.Float’
- ...plus two others
- (use -fprint-potential-instances to see them all)
- • In the first argument of ‘myOp’, namely ‘23’
- In the expression: myOp 23
- In an equation for ‘j’: j = myOp 23
-
-../../typecheck/should_run/Defer01.hs:45:1: warning: [-Wdeferred-type-errors (in -Wdefault)]
- Couldn't match type ‘Int’ with ‘Bool’
- Inaccessible code in
- the type signature for:
- k :: Int ~ Bool => Int -> Bool
-
-../../typecheck/should_run/Defer01.hs:45:6: warning: [-Wdeferred-type-errors (in -Wdefault)]
- • Couldn't match type ‘Int’ with ‘Bool’
- Inaccessible code in
- the type signature for:
- k :: Int ~ Bool => Int -> Bool
- • In the ambiguity check for ‘k’
- To defer the ambiguity check to use sites, enable AllowAmbiguousTypes
- In the type signature:
- k :: (Int ~ Bool) => Int -> Bool
-
-../../typecheck/should_run/Defer01.hs:46:1: warning: [-Woverlapping-patterns (in -Wdefault)]
- Pattern match is redundant
- In an equation for ‘k’: k x = ...
-
-../../typecheck/should_run/Defer01.hs:49:5: warning: [-Wdeferred-type-errors (in -Wdefault)]
- • Couldn't match expected type ‘IO a0’
- with actual type ‘Char -> IO ()’
- • Probable cause: ‘putChar’ is applied to too few arguments
- In the first argument of ‘(>>)’, namely ‘putChar’
- In the expression: putChar >> putChar 'p'
- In an equation for ‘l’: l = putChar >> putChar 'p'
-*** Exception: ../../typecheck/should_run/Defer01.hs:11:40: error:
- • Couldn't match type ‘Char’ with ‘[Char]’
- Expected type: String
- Actual type: Char
- • In the first argument of ‘putStr’, namely ‘','’
- In the second argument of ‘(>>)’, namely ‘putStr ','’
- In the expression: putStr "Hello World" >> putStr ','
-(deferred type error)
-*** Exception: ../../typecheck/should_run/Defer01.hs:14:5: error:
- • Couldn't match expected type ‘Int’ with actual type ‘Char’
- • In the expression: 'p'
- In an equation for ‘a’: a = 'p'
-(deferred type error)
-*** Exception: ../../typecheck/should_run/Defer01.hs:18:7: error:
- • No instance for (Eq B) arising from a use of ‘==’
- • In the expression: x == x
- In an equation for ‘b’: b x = x == x
-(deferred type error)
-
-<interactive>:7:11: error:
- • Couldn't match type ‘Bool’ with ‘Int’
- Expected type: C Int
- Actual type: C Bool
- • In the first argument of ‘c’, namely ‘(C2 True)’
- In the first argument of ‘print’, namely ‘(c (C2 True))’
- In the expression: print (c (C2 True))
-*** Exception: ../../typecheck/should_run/Defer01.hs:28:5: error:
- • No instance for (Num (a -> a)) arising from the literal ‘1’
- (maybe you haven't applied a function to enough arguments?)
- • In the expression: 1
- In an equation for ‘d’: d = 1
-(deferred type error)
-*** Exception: ../../typecheck/should_run/Defer01.hs:31:5: error:
- • Couldn't match expected type ‘Char -> t’ with actual type ‘Char’
- • The function ‘e’ is applied to one argument,
- but its type ‘Char’ has none
- In the expression: e 'q'
- In an equation for ‘f’: f = e 'q'
- • Relevant bindings include
- f :: t (bound at ../../typecheck/should_run/Defer01.hs:31:1)
-(deferred type error)
-*** Exception: ../../typecheck/should_run/Defer01.hs:34:8: error:
- • Couldn't match expected type ‘Char’ with actual type ‘a’
- ‘a’ is a rigid type variable bound by
- the type signature for:
- h :: forall a. a -> (Char, Char)
- at ../../typecheck/should_run/Defer01.hs:33:6
- • In the expression: x
- In the expression: (x, 'c')
- In an equation for ‘h’: h x = (x, 'c')
- • Relevant bindings include
- x :: a (bound at ../../typecheck/should_run/Defer01.hs:34:3)
- h :: a -> (Char, Char)
- (bound at ../../typecheck/should_run/Defer01.hs:34:1)
-(deferred type error)
-*** Exception: ../../typecheck/should_run/Defer01.hs:39:17: error:
- • Couldn't match expected type ‘Bool’ with actual type ‘T a’
- • In the first argument of ‘not’, namely ‘(K a)’
- In the expression: (not (K a))
- In the expression: seq (not (K a)) ()
- • Relevant bindings include
- a :: a (bound at ../../typecheck/should_run/Defer01.hs:39:3)
- i :: a -> () (bound at ../../typecheck/should_run/Defer01.hs:39:1)
-(deferred type error)
-*** Exception: ../../typecheck/should_run/Defer01.hs:43:5: error:
- • No instance for (MyClass a1) arising from a use of ‘myOp’
- • In the expression: myOp 23
- In an equation for ‘j’: j = myOp 23
-(deferred type error)
-
-<interactive>:13:8: error:
- • Couldn't match type ‘Int’ with ‘Bool’ arising from a use of ‘k’
- • In the first argument of ‘print’, namely ‘(k 2)’
- In the expression: print (k 2)
- In an equation for ‘it’: it = print (k 2)
-*** Exception: ../../typecheck/should_run/Defer01.hs:49:5: error:
- • Couldn't match expected type ‘IO a0’
- with actual type ‘Char -> IO ()’
- • Probable cause: ‘putChar’ is applied to too few arguments
- In the first argument of ‘(>>)’, namely ‘putChar’
- In the expression: putChar >> putChar 'p'
- In an equation for ‘l’: l = putChar >> putChar 'p'
-(deferred type error)
+
+..\..\typecheck\should_run\Defer01.hs:11:40: warning: [-Wdeferred-type-errors (in -Wdefault)]
+ • Couldn't match type ‘Char’ with ‘[Char]’
+ Expected type: String
+ Actual type: Char
+ • In the first argument of ‘putStr’, namely ‘','’
+ In the second argument of ‘(>>)’, namely ‘putStr ','’
+ In the expression: putStr "Hello World" >> putStr ','
+
+..\..\typecheck\should_run\Defer01.hs:14:5: warning: [-Wdeferred-type-errors (in -Wdefault)]
+ • Couldn't match expected type ‘Int’ with actual type ‘Char’
+ • In the expression: 'p'
+ In an equation for ‘a’: a = 'p'
+
+..\..\typecheck\should_run\Defer01.hs:18:7: warning: [-Wdeferred-type-errors (in -Wdefault)]
+ • No instance for (Eq B) arising from a use of ‘==’
+ • In the expression: x == x
+ In an equation for ‘b’: b x = x == x
+
+..\..\typecheck\should_run\Defer01.hs:25:1: warning: [-Woverlapping-patterns (in -Wdefault)]
+ Pattern match has inaccessible right hand side
+ In an equation for ‘c’: c (C2 x) = ...
+
+..\..\typecheck\should_run\Defer01.hs:25:4: warning: [-Wdeferred-type-errors (in -Wdefault)]
+ • Couldn't match type ‘Int’ with ‘Bool’
+ Inaccessible code in
+ a pattern with constructor: C2 :: Bool -> C Bool,
+ in an equation for ‘c’
+ • In the pattern: C2 x
+ In an equation for ‘c’: c (C2 x) = True
+
+..\..\typecheck\should_run\Defer01.hs:28:5: warning: [-Wdeferred-type-errors (in -Wdefault)]
+ • No instance for (Num (a -> a)) arising from the literal ‘1’
+ (maybe you haven't applied a function to enough arguments?)
+ • In the expression: 1
+ In an equation for ‘d’: d = 1
+
+..\..\typecheck\should_run\Defer01.hs:31:5: warning: [-Wdeferred-type-errors (in -Wdefault)]
+ • Couldn't match expected type ‘Char -> t’ with actual type ‘Char’
+ • The function ‘e’ is applied to one argument,
+ but its type ‘Char’ has none
+ In the expression: e 'q'
+ In an equation for ‘f’: f = e 'q'
+ • Relevant bindings include
+ f :: t (bound at ..\..\typecheck\should_run\Defer01.hs:31:1)
+
+..\..\typecheck\should_run\Defer01.hs:34:8: warning: [-Wdeferred-type-errors (in -Wdefault)]
+ • Couldn't match expected type ‘Char’ with actual type ‘a’
+ ‘a’ is a rigid type variable bound by
+ the type signature for:
+ h :: forall a. a -> (Char, Char)
+ at ..\..\typecheck\should_run\Defer01.hs:33:1-21
+ • In the expression: x
+ In the expression: (x, 'c')
+ In an equation for ‘h’: h x = (x, 'c')
+ • Relevant bindings include
+ x :: a (bound at ..\..\typecheck\should_run\Defer01.hs:34:3)
+ h :: a -> (Char, Char)
+ (bound at ..\..\typecheck\should_run\Defer01.hs:34:1)
+
+..\..\typecheck\should_run\Defer01.hs:39:17: warning: [-Wdeferred-type-errors (in -Wdefault)]
+ • Couldn't match expected type ‘Bool’ with actual type ‘T a’
+ • In the first argument of ‘not’, namely ‘(K a)’
+ In the expression: (not (K a))
+ In the expression: seq (not (K a)) ()
+ • Relevant bindings include
+ a :: a (bound at ..\..\typecheck\should_run\Defer01.hs:39:3)
+ i :: a -> () (bound at ..\..\typecheck\should_run\Defer01.hs:39:1)
+
+..\..\typecheck\should_run\Defer01.hs:43:5: warning: [-Wdeferred-type-errors (in -Wdefault)]
+ • No instance for (MyClass a1) arising from a use of ‘myOp’
+ • In the expression: myOp 23
+ In an equation for ‘j’: j = myOp 23
+
+..\..\typecheck\should_run\Defer01.hs:43:10: warning: [-Wdeferred-type-errors (in -Wdefault)]
+ • Ambiguous type variable ‘a1’ arising from the literal ‘23’
+ prevents the constraint ‘(Num a1)’ from being solved.
+ Probable fix: use a type annotation to specify what ‘a1’ should be.
+ These potential instances exist:
+ instance Num Integer -- Defined in ‘GHC.Num’
+ instance Num Double -- Defined in ‘GHC.Float’
+ instance Num Float -- Defined in ‘GHC.Float’
+ ...plus two others
+ (use -fprint-potential-instances to see them all)
+ • In the first argument of ‘myOp’, namely ‘23’
+ In the expression: myOp 23
+ In an equation for ‘j’: j = myOp 23
+
+..\..\typecheck\should_run\Defer01.hs:45:1: warning: [-Wdeferred-type-errors (in -Wdefault)]
+ Couldn't match type ‘Int’ with ‘Bool’
+ Inaccessible code in
+ the type signature for:
+ k :: Int ~ Bool => Int -> Bool
+
+..\..\typecheck\should_run\Defer01.hs:45:6: warning: [-Wdeferred-type-errors (in -Wdefault)]
+ • Couldn't match type ‘Int’ with ‘Bool’
+ Inaccessible code in
+ the type signature for:
+ k :: Int ~ Bool => Int -> Bool
+ • In the ambiguity check for ‘k’
+ To defer the ambiguity check to use sites, enable AllowAmbiguousTypes
+ In the type signature: k :: (Int ~ Bool) => Int -> Bool
+
+..\..\typecheck\should_run\Defer01.hs:46:1: warning: [-Woverlapping-patterns (in -Wdefault)]
+ Pattern match is redundant
+ In an equation for ‘k’: k x = ...
+
+..\..\typecheck\should_run\Defer01.hs:49:5: warning: [-Wdeferred-type-errors (in -Wdefault)]
+ • Couldn't match expected type ‘IO a0’
+ with actual type ‘Char -> IO ()’
+ • Probable cause: ‘putChar’ is applied to too few arguments
+ In the first argument of ‘(>>)’, namely ‘putChar’
+ In the expression: putChar >> putChar 'p'
+ In an equation for ‘l’: l = putChar >> putChar 'p'
+*** Exception: ..\..\typecheck\should_run\Defer01.hs:11:40: error:
+ • Couldn't match type ‘Char’ with ‘[Char]’
+ Expected type: String
+ Actual type: Char
+ • In the first argument of ‘putStr’, namely ‘','’
+ In the second argument of ‘(>>)’, namely ‘putStr ','’
+ In the expression: putStr "Hello World" >> putStr ','
+(deferred type error)
+*** Exception: ..\..\typecheck\should_run\Defer01.hs:14:5: error:
+ • Couldn't match expected type ‘Int’ with actual type ‘Char’
+ • In the expression: 'p'
+ In an equation for ‘a’: a = 'p'
+(deferred type error)
+*** Exception: ..\..\typecheck\should_run\Defer01.hs:18:7: error:
+ • No instance for (Eq B) arising from a use of ‘==’
+ • In the expression: x == x
+ In an equation for ‘b’: b x = x == x
+(deferred type error)
+
+<interactive>:7:11: error:
+ • Couldn't match type ‘Bool’ with ‘Int’
+ Expected type: C Int
+ Actual type: C Bool
+ • In the first argument of ‘c’, namely ‘(C2 True)’
+ In the first argument of ‘print’, namely ‘(c (C2 True))’
+ In the expression: print (c (C2 True))
+*** Exception: ..\..\typecheck\should_run\Defer01.hs:28:5: error:
+ • No instance for (Num (a -> a)) arising from the literal ‘1’
+ (maybe you haven't applied a function to enough arguments?)
+ • In the expression: 1
+ In an equation for ‘d’: d = 1
+(deferred type error)
+*** Exception: ..\..\typecheck\should_run\Defer01.hs:31:5: error:
+ • Couldn't match expected type ‘Char -> t’ with actual type ‘Char’
+ • The function ‘e’ is applied to one argument,
+ but its type ‘Char’ has none
+ In the expression: e 'q'
+ In an equation for ‘f’: f = e 'q'
+ • Relevant bindings include
+ f :: t (bound at ..\..\typecheck\should_run\Defer01.hs:31:1)
+(deferred type error)
+*** Exception: ..\..\typecheck\should_run\Defer01.hs:34:8: error:
+ • Couldn't match expected type ‘Char’ with actual type ‘a’
+ ‘a’ is a rigid type variable bound by
+ the type signature for:
+ h :: forall a. a -> (Char, Char)
+ at ..\..\typecheck\should_run\Defer01.hs:33:1-21
+ • In the expression: x
+ In the expression: (x, 'c')
+ In an equation for ‘h’: h x = (x, 'c')
+ • Relevant bindings include
+ x :: a (bound at ..\..\typecheck\should_run\Defer01.hs:34:3)
+ h :: a -> (Char, Char)
+ (bound at ..\..\typecheck\should_run\Defer01.hs:34:1)
+(deferred type error)
+*** Exception: ..\..\typecheck\should_run\Defer01.hs:39:17: error:
+ • Couldn't match expected type ‘Bool’ with actual type ‘T a’
+ • In the first argument of ‘not’, namely ‘(K a)’
+ In the expression: (not (K a))
+ In the expression: seq (not (K a)) ()
+ • Relevant bindings include
+ a :: a (bound at ..\..\typecheck\should_run\Defer01.hs:39:3)
+ i :: a -> () (bound at ..\..\typecheck\should_run\Defer01.hs:39:1)
+(deferred type error)
+*** Exception: ..\..\typecheck\should_run\Defer01.hs:43:5: error:
+ • No instance for (MyClass a1) arising from a use of ‘myOp’
+ • In the expression: myOp 23
+ In an equation for ‘j’: j = myOp 23
+(deferred type error)
+
+<interactive>:13:8: error:
+ • Couldn't match type ‘Int’ with ‘Bool’ arising from a use of ‘k’
+ • In the first argument of ‘print’, namely ‘(k 2)’
+ In the expression: print (k 2)
+ In an equation for ‘it’: it = print (k 2)
+*** Exception: ..\..\typecheck\should_run\Defer01.hs:49:5: error:
+ • Couldn't match expected type ‘IO a0’
+ with actual type ‘Char -> IO ()’
+ • Probable cause: ‘putChar’ is applied to too few arguments
+ In the first argument of ‘(>>)’, namely ‘putChar’
+ In the expression: putChar >> putChar 'p'
+ In an equation for ‘l’: l = putChar >> putChar 'p'
+(deferred type error)
diff --git a/testsuite/tests/ghci/scripts/T10248.stderr b/testsuite/tests/ghci/scripts/T10248.stderr
index c9df22b056..7172d4aa50 100644
--- a/testsuite/tests/ghci/scripts/T10248.stderr
+++ b/testsuite/tests/ghci/scripts/T10248.stderr
@@ -1,14 +1,14 @@
-
-<interactive>:2:10: error:
- • Found hole: _ :: f a
- Where: ‘f’ is a rigid type variable bound by
- the inferred type of it :: Functor f => f (Maybe a)
- at <interactive>:2:1
- ‘a’ is a rigid type variable bound by
- the inferred type of it :: Functor f => f (Maybe a)
- at <interactive>:2:1
- • In the second argument of ‘(<$>)’, namely ‘_’
- In the expression: Just <$> _
- In an equation for ‘it’: it = Just <$> _
- • Relevant bindings include
- it :: f (Maybe a) (bound at <interactive>:2:1)
+
+<interactive>:2:10: error:
+ • Found hole: _ :: f a
+ Where: ‘f’ is a rigid type variable bound by
+ the inferred type of it :: Functor f => f (Maybe a)
+ at <interactive>:2:1-10
+ ‘a’ is a rigid type variable bound by
+ the inferred type of it :: Functor f => f (Maybe a)
+ at <interactive>:2:1-10
+ • In the second argument of ‘(<$>)’, namely ‘_’
+ In the expression: Just <$> _
+ In an equation for ‘it’: it = Just <$> _
+ • Relevant bindings include
+ it :: f (Maybe a) (bound at <interactive>:2:1)
diff --git a/testsuite/tests/ghci/scripts/ghci050.stderr b/testsuite/tests/ghci/scripts/ghci050.stderr
index 588d130172..0ea252e23d 100644
--- a/testsuite/tests/ghci/scripts/ghci050.stderr
+++ b/testsuite/tests/ghci/scripts/ghci050.stderr
@@ -1,14 +1,14 @@
-
-<interactive>:5:49: error:
- • Couldn't match expected type ‘ListableElem (a, a)’
- with actual type ‘a’
- ‘a’ is a rigid type variable bound by
- the instance declaration at <interactive>:5:10
- • In the expression: a
- In the expression: [a, b]
- In an equation for ‘asList’: asList (a, b) = [a, b]
- • Relevant bindings include
- b :: a (bound at <interactive>:5:43)
- a :: a (bound at <interactive>:5:41)
- asList :: (a, a) -> [ListableElem (a, a)]
- (bound at <interactive>:5:33)
+
+<interactive>:5:49: error:
+ • Couldn't match expected type ‘ListableElem (a, a)’
+ with actual type ‘a’
+ ‘a’ is a rigid type variable bound by
+ the instance declaration at <interactive>:5:10-23
+ • In the expression: a
+ In the expression: [a, b]
+ In an equation for ‘asList’: asList (a, b) = [a, b]
+ • Relevant bindings include
+ b :: a (bound at <interactive>:5:43)
+ a :: a (bound at <interactive>:5:41)
+ asList :: (a, a) -> [ListableElem (a, a)]
+ (bound at <interactive>:5:33)
diff --git a/testsuite/tests/indexed-types/should_compile/Simple14.stderr b/testsuite/tests/indexed-types/should_compile/Simple14.stderr
index bbbe0fbc58..eadcfc6953 100644
--- a/testsuite/tests/indexed-types/should_compile/Simple14.stderr
+++ b/testsuite/tests/indexed-types/should_compile/Simple14.stderr
@@ -1,18 +1,17 @@
-
-Simple14.hs:8:8: error:
- • Couldn't match type ‘z0’ with ‘z’
- ‘z0’ is untouchable
- inside the constraints: x ~ y
- bound by the type signature for:
- eqE :: x ~ y => EQ_ z0 z0
- at Simple14.hs:8:8-39
- ‘z’ is a rigid type variable bound by
- the type signature for:
- eqE :: forall x y z p. EQ_ x y -> (x ~ y => EQ_ z z) -> p
- at Simple14.hs:8:8
- Expected type: EQ_ z0 z0
- Actual type: EQ_ z z
- • In the ambiguity check for ‘eqE’
- To defer the ambiguity check to use sites, enable AllowAmbiguousTypes
- In the type signature:
- eqE :: EQ_ x y -> (x ~ y => EQ_ z z) -> p
+
+Simple14.hs:8:8: error:
+ • Couldn't match type ‘z0’ with ‘z’
+ ‘z0’ is untouchable
+ inside the constraints: x ~ y
+ bound by the type signature for:
+ eqE :: x ~ y => EQ_ z0 z0
+ at Simple14.hs:8:8-39
+ ‘z’ is a rigid type variable bound by
+ the type signature for:
+ eqE :: forall x y z p. EQ_ x y -> (x ~ y => EQ_ z z) -> p
+ at Simple14.hs:8:8-39
+ Expected type: EQ_ z0 z0
+ Actual type: EQ_ z z
+ • In the ambiguity check for ‘eqE’
+ To defer the ambiguity check to use sites, enable AllowAmbiguousTypes
+ In the type signature: eqE :: EQ_ x y -> (x ~ y => EQ_ z z) -> p
diff --git a/testsuite/tests/indexed-types/should_fail/GADTwrong1.stderr b/testsuite/tests/indexed-types/should_fail/GADTwrong1.stderr
index 5a0892ed31..f8689f9b8d 100644
--- a/testsuite/tests/indexed-types/should_fail/GADTwrong1.stderr
+++ b/testsuite/tests/indexed-types/should_fail/GADTwrong1.stderr
@@ -1,17 +1,17 @@
-
-GADTwrong1.hs:12:21: error:
- • Couldn't match expected type ‘b’ with actual type ‘c’
- ‘c’ is a rigid type variable bound by
- a pattern with constructor: T :: forall c. c -> T (Const c),
- in a case alternative
- at GADTwrong1.hs:12:14
- ‘b’ is a rigid type variable bound by
- the type signature for:
- coerce :: forall a b. a -> b
- at GADTwrong1.hs:10:20
- • In the expression: y
- In a case alternative: T y -> y
- In the expression: case T x :: T (Const b) of { T y -> y }
- • Relevant bindings include
- y :: c (bound at GADTwrong1.hs:12:16)
- coerce :: a -> b (bound at GADTwrong1.hs:11:1)
+
+GADTwrong1.hs:12:21: error:
+ • Couldn't match expected type ‘b’ with actual type ‘c’
+ ‘c’ is a rigid type variable bound by
+ a pattern with constructor: T :: forall c. c -> T (Const c),
+ in a case alternative
+ at GADTwrong1.hs:12:14-16
+ ‘b’ is a rigid type variable bound by
+ the type signature for:
+ coerce :: forall a b. a -> b
+ at GADTwrong1.hs:10:1-29
+ • In the expression: y
+ In a case alternative: T y -> y
+ In the expression: case T x :: T (Const b) of { T y -> y }
+ • Relevant bindings include
+ y :: c (bound at GADTwrong1.hs:12:16)
+ coerce :: a -> b (bound at GADTwrong1.hs:11:1)
diff --git a/testsuite/tests/indexed-types/should_fail/Overlap6.stderr b/testsuite/tests/indexed-types/should_fail/Overlap6.stderr
index 6ffcda02ce..406ac9d3b6 100644
--- a/testsuite/tests/indexed-types/should_fail/Overlap6.stderr
+++ b/testsuite/tests/indexed-types/should_fail/Overlap6.stderr
@@ -1,14 +1,14 @@
-
-Overlap6.hs:15:7: error:
- • Couldn't match type ‘x’ with ‘And x 'True’
- ‘x’ is a rigid type variable bound by
- the type signature for:
- g :: forall (x :: Bool). Proxy x -> Proxy (And x 'True)
- at Overlap6.hs:14:6
- Expected type: Proxy (And x 'True)
- Actual type: Proxy x
- • In the expression: x
- In an equation for ‘g’: g x = x
- • Relevant bindings include
- x :: Proxy x (bound at Overlap6.hs:15:3)
- g :: Proxy x -> Proxy (And x 'True) (bound at Overlap6.hs:15:1)
+
+Overlap6.hs:15:7: error:
+ • Couldn't match type ‘x’ with ‘And x 'True’
+ ‘x’ is a rigid type variable bound by
+ the type signature for:
+ g :: forall (x :: Bool). Proxy x -> Proxy (And x 'True)
+ at Overlap6.hs:14:1-34
+ Expected type: Proxy (And x 'True)
+ Actual type: Proxy x
+ • In the expression: x
+ In an equation for ‘g’: g x = x
+ • Relevant bindings include
+ x :: Proxy x (bound at Overlap6.hs:15:3)
+ g :: Proxy x -> Proxy (And x 'True) (bound at Overlap6.hs:15:1)
diff --git a/testsuite/tests/indexed-types/should_fail/SimpleFail5a.stderr b/testsuite/tests/indexed-types/should_fail/SimpleFail5a.stderr
index 4b9c3657db..539628c6eb 100644
--- a/testsuite/tests/indexed-types/should_fail/SimpleFail5a.stderr
+++ b/testsuite/tests/indexed-types/should_fail/SimpleFail5a.stderr
@@ -1,13 +1,13 @@
-
-SimpleFail5a.hs:31:11: error:
- • Couldn't match type ‘a’ with ‘Int’
- ‘a’ is a rigid type variable bound by
- the type signature for:
- bar3wrong :: forall a. S3 a -> a
- at SimpleFail5a.hs:30:14
- Expected type: S3 a
- Actual type: S3 Int
- • In the pattern: D3Int
- In an equation for ‘bar3wrong’: bar3wrong D3Int = 1
- • Relevant bindings include
- bar3wrong :: S3 a -> a (bound at SimpleFail5a.hs:31:1)
+
+SimpleFail5a.hs:31:11: error:
+ • Couldn't match type ‘a’ with ‘Int’
+ ‘a’ is a rigid type variable bound by
+ the type signature for:
+ bar3wrong :: forall a. S3 a -> a
+ at SimpleFail5a.hs:30:1-22
+ Expected type: S3 a
+ Actual type: S3 Int
+ • In the pattern: D3Int
+ In an equation for ‘bar3wrong’: bar3wrong D3Int = 1
+ • Relevant bindings include
+ bar3wrong :: S3 a -> a (bound at SimpleFail5a.hs:31:1)
diff --git a/testsuite/tests/indexed-types/should_fail/T2664.stderr b/testsuite/tests/indexed-types/should_fail/T2664.stderr
index 3a84f18272..1409f1f44c 100644
--- a/testsuite/tests/indexed-types/should_fail/T2664.stderr
+++ b/testsuite/tests/indexed-types/should_fail/T2664.stderr
@@ -1,19 +1,19 @@
-
-T2664.hs:31:52: error:
- • Could not deduce: b ~ a arising from a use of ‘newPChan’
- 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)) =>
- IO (PChan (a :*: b), PChan c)
- at T2664.hs:23:5-12
- ‘b’ is a rigid type variable bound by
- the instance declaration at T2664.hs:22:10
- ‘a’ is a rigid type variable bound by
- the instance declaration at T2664.hs:22:10
- • In the third argument of ‘pchoose’, namely ‘newPChan’
- In the first argument of ‘E’, namely ‘(pchoose Right v newPChan)’
- In the expression:
- E (pchoose Right v newPChan) (pchoose Left v newPChan)
- • Relevant bindings include
- v :: MVar (Either (PChan a) (PChan b)) (bound at T2664.hs:24:9)
- newPChan :: IO (PChan (a :*: b), PChan c) (bound at T2664.hs:23:5)
+
+T2664.hs:31:52: error:
+ • Could not deduce: b ~ a arising from a use of ‘newPChan’
+ 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)) =>
+ IO (PChan (a :*: b), PChan c)
+ at T2664.hs:23:5-12
+ ‘b’ is a rigid type variable bound by
+ the instance declaration at T2664.hs:22:10-52
+ ‘a’ is a rigid type variable bound by
+ the instance declaration at T2664.hs:22:10-52
+ • In the third argument of ‘pchoose’, namely ‘newPChan’
+ In the first argument of ‘E’, namely ‘(pchoose Right v newPChan)’
+ In the expression:
+ E (pchoose Right v newPChan) (pchoose Left v newPChan)
+ • Relevant bindings include
+ v :: MVar (Either (PChan a) (PChan b)) (bound at T2664.hs:24:9)
+ newPChan :: IO (PChan (a :*: b), PChan c) (bound at T2664.hs:23:5)
diff --git a/testsuite/tests/indexed-types/should_fail/T3330a.hs b/testsuite/tests/indexed-types/should_fail/T3330a.hs
index 55bf067238..b14a7d0858 100644
--- a/testsuite/tests/indexed-types/should_fail/T3330a.hs
+++ b/testsuite/tests/indexed-types/should_fail/T3330a.hs
@@ -30,12 +30,13 @@ children p x = execWriter (hmapM p collect x)
Hence ix0 := ix
r0 := r
f0 := PF s
- phi0 := s2 ix2
+ phi0 := (->) s2 ix2
m0 := Writer [AnyF s]
a0 : = f0 r'0 ix0
- (forall ixx. (s2 ix2 ixx -> r ixx -> Writer [AnyF s] (r'0 ixx) ~ s ix))
- s2 ix2 ix0 ~ s2 ix2 -> r2 ix2 -> Writer [AnyF s2] (r2 ix2)
+ (forall ixx. ((->) (s2 ix2 -> ixx) (r ixx -> Writer [AnyF s] (r'0 ixx)) ~ s ix))
+
+ s2 ix2 ix0 ~ (->) (s2 ix2) (r2 ix2 -> Writer [AnyF s2] (r2 ix2))
-}
diff --git a/testsuite/tests/indexed-types/should_fail/T3330a.stderr b/testsuite/tests/indexed-types/should_fail/T3330a.stderr
index 0950875229..ffda424227 100644
--- a/testsuite/tests/indexed-types/should_fail/T3330a.stderr
+++ b/testsuite/tests/indexed-types/should_fail/T3330a.stderr
@@ -1,37 +1,37 @@
-
-T3330a.hs:19:34: error:
- • Couldn't match type ‘ix’
- with ‘r ix1 -> Writer [AnyF s] (r'0 ix1)’
- ‘ix’ is a rigid type variable bound by
- the type signature for:
- children :: forall (s :: * -> *) ix (r :: * -> *).
- s ix -> PF s r ix -> [AnyF s]
- at T3330a.hs:18:13
- Expected type: (s0 ix0 -> ix1)
- -> r ix1 -> Writer [AnyF s] (r'0 ix1)
- Actual type: s ix
- • In the first argument of ‘hmapM’, namely ‘p’
- In the first argument of ‘execWriter’, namely ‘(hmapM p collect x)’
- In the expression: execWriter (hmapM p collect x)
- • Relevant bindings include
- x :: PF s r ix (bound at T3330a.hs:19:12)
- p :: s ix (bound at T3330a.hs:19:10)
- children :: s ix -> PF s r ix -> [AnyF s] (bound at T3330a.hs:19:1)
-
-T3330a.hs:19:44: error:
- • Couldn't match type ‘ix’
- with ‘r0 ix0 -> Writer [AnyF s0] (r0 ix0)’
- ‘ix’ is a rigid type variable bound by
- the type signature for:
- children :: forall (s :: * -> *) ix (r :: * -> *).
- s ix -> PF s r ix -> [AnyF s]
- at T3330a.hs:18:13
- Expected type: PF s r (r0 ix0 -> Writer [AnyF s0] (r0 ix0))
- Actual type: PF s r ix
- • In the third argument of ‘hmapM’, namely ‘x’
- In the first argument of ‘execWriter’, namely ‘(hmapM p collect x)’
- In the expression: execWriter (hmapM p collect x)
- • Relevant bindings include
- x :: PF s r ix (bound at T3330a.hs:19:12)
- p :: s ix (bound at T3330a.hs:19:10)
- children :: s ix -> PF s r ix -> [AnyF s] (bound at T3330a.hs:19:1)
+
+T3330a.hs:19:34: error:
+ • Couldn't match type ‘ix’
+ with ‘r ix1 -> Writer [AnyF s] (r'0 ix1)’
+ ‘ix’ is a rigid type variable bound by
+ the type signature for:
+ children :: forall (s :: * -> *) ix (r :: * -> *).
+ s ix -> PF s r ix -> [AnyF s]
+ at T3330a.hs:18:1-43
+ Expected type: (s0 ix0 -> ix1)
+ -> r ix1 -> Writer [AnyF s] (r'0 ix1)
+ Actual type: s ix
+ • In the first argument of ‘hmapM’, namely ‘p’
+ In the first argument of ‘execWriter’, namely ‘(hmapM p collect x)’
+ In the expression: execWriter (hmapM p collect x)
+ • Relevant bindings include
+ x :: PF s r ix (bound at T3330a.hs:19:12)
+ p :: s ix (bound at T3330a.hs:19:10)
+ children :: s ix -> PF s r ix -> [AnyF s] (bound at T3330a.hs:19:1)
+
+T3330a.hs:19:44: error:
+ • Couldn't match type ‘ix’
+ with ‘r0 ix0 -> Writer [AnyF s0] (r0 ix0)’
+ ‘ix’ is a rigid type variable bound by
+ the type signature for:
+ children :: forall (s :: * -> *) ix (r :: * -> *).
+ s ix -> PF s r ix -> [AnyF s]
+ at T3330a.hs:18:1-43
+ Expected type: PF s r (r0 ix0 -> Writer [AnyF s0] (r0 ix0))
+ Actual type: PF s r ix
+ • In the third argument of ‘hmapM’, namely ‘x’
+ In the first argument of ‘execWriter’, namely ‘(hmapM p collect x)’
+ In the expression: execWriter (hmapM p collect x)
+ • Relevant bindings include
+ x :: PF s r ix (bound at T3330a.hs:19:12)
+ p :: s ix (bound at T3330a.hs:19:10)
+ children :: s ix -> PF s r ix -> [AnyF s] (bound at T3330a.hs:19:1)
diff --git a/testsuite/tests/indexed-types/should_fail/T3440.stderr b/testsuite/tests/indexed-types/should_fail/T3440.stderr
index 8289d144c2..84eb475b23 100644
--- a/testsuite/tests/indexed-types/should_fail/T3440.stderr
+++ b/testsuite/tests/indexed-types/should_fail/T3440.stderr
@@ -1,24 +1,24 @@
-
-T3440.hs:11:22: error:
- • Could not deduce: a1 ~ a
- from the context: Fam a ~ Fam a1
- bound by a pattern with constructor:
- GADT :: forall a. a -> Fam a -> GADT (Fam a),
- in an equation for ‘unwrap’
- at T3440.hs:11:9-16
- ‘a1’ is a rigid type variable bound by
- a pattern with constructor:
- GADT :: forall a. a -> Fam a -> GADT (Fam a),
- in an equation for ‘unwrap’
- at T3440.hs:11:9
- ‘a’ is a rigid type variable bound by
- the type signature for:
- unwrap :: forall a. GADT (Fam a) -> (a, Fam a)
- at T3440.hs:10:11
- • In the expression: x
- In the expression: (x, y)
- In an equation for ‘unwrap’: unwrap (GADT x y) = (x, y)
- • Relevant bindings include
- y :: Fam a1 (bound at T3440.hs:11:16)
- x :: a1 (bound at T3440.hs:11:14)
- unwrap :: GADT (Fam a) -> (a, Fam a) (bound at T3440.hs:11:1)
+
+T3440.hs:11:22: error:
+ • Could not deduce: a1 ~ a
+ from the context: Fam a ~ Fam a1
+ bound by a pattern with constructor:
+ GADT :: forall a. a -> Fam a -> GADT (Fam a),
+ in an equation for ‘unwrap’
+ at T3440.hs:11:9-16
+ ‘a1’ is a rigid type variable bound by
+ a pattern with constructor:
+ GADT :: forall a. a -> Fam a -> GADT (Fam a),
+ in an equation for ‘unwrap’
+ at T3440.hs:11:9-16
+ ‘a’ is a rigid type variable bound by
+ the type signature for:
+ unwrap :: forall a. GADT (Fam a) -> (a, Fam a)
+ at T3440.hs:10:1-36
+ • In the expression: x
+ In the expression: (x, y)
+ In an equation for ‘unwrap’: unwrap (GADT x y) = (x, y)
+ • Relevant bindings include
+ y :: Fam a1 (bound at T3440.hs:11:16)
+ x :: a1 (bound at T3440.hs:11:14)
+ unwrap :: GADT (Fam a) -> (a, Fam a) (bound at T3440.hs:11:1)
diff --git a/testsuite/tests/indexed-types/should_fail/T4093a.stderr b/testsuite/tests/indexed-types/should_fail/T4093a.stderr
index d226122614..3ce9158bdc 100644
--- a/testsuite/tests/indexed-types/should_fail/T4093a.stderr
+++ b/testsuite/tests/indexed-types/should_fail/T4093a.stderr
@@ -1,16 +1,16 @@
-
-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
- at T4093a.hs:7:1-34
- ‘e’ is a rigid type variable bound by
- the type signature for:
- hang :: forall e. Foo e ~ Maybe e => Foo e
- at T4093a.hs:7:9
- Expected type: Foo e
- Actual type: Maybe ()
- • In the expression: Just ()
- In an equation for ‘hang’: hang = Just ()
- • Relevant bindings include hang :: Foo e (bound at T4093a.hs:8:1)
+
+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
+ at T4093a.hs:7:1-34
+ ‘e’ is a rigid type variable bound by
+ the type signature for:
+ hang :: forall e. Foo e ~ Maybe e => Foo e
+ at T4093a.hs:7:1-34
+ Expected type: Foo e
+ Actual type: Maybe ()
+ • In the expression: Just ()
+ In an equation for ‘hang’: hang = Just ()
+ • Relevant bindings include hang :: Foo e (bound at T4093a.hs:8:1)
diff --git a/testsuite/tests/indexed-types/should_fail/T4093b.stderr b/testsuite/tests/indexed-types/should_fail/T4093b.stderr
index 0950de8c66..92530d58bf 100644
--- a/testsuite/tests/indexed-types/should_fail/T4093b.stderr
+++ b/testsuite/tests/indexed-types/should_fail/T4093b.stderr
@@ -1,42 +1,42 @@
-
-T4093b.hs:31:13: error:
- • Could not deduce: e ~ C
- 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,
- 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)
- ‘e’ is a rigid type variable bound by
- the type signature for:
- 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:20:12
- Expected type: EitherCO e (A C O n) (A O O n)
- Actual type: (MaybeC C (n C O), MaybeC O (n O C))
- • In the expression: (JustC n, NothingC)
- In an equation for ‘f’: f n _ = (JustC n, NothingC)
- In an equation for ‘blockToNodeList’:
- blockToNodeList b
- = foldBlockNodesF (f, l) b z
- where
- z ::
- EitherCO e (EitherCO e (A C O n) (A O O n)) (EitherCO e (A C O n) (A O O n))
- z = undefined
- f ::
- n C O
- -> EitherCO e (A C O n) (A O O n) -> EitherCO e (A C O n) (A O O n)
- f n _ = (JustC n, NothingC)
- ....
- • Relevant bindings include
- f :: n C O
- -> EitherCO e (A C O n) (A O O n) -> EitherCO e (A C O n) (A O O n)
- (bound at T4093b.hs:31:5)
- l :: n O C
- -> EitherCO e (A C O n) (A O O n) -> EitherCO e (A C C n) (A O C n)
- (bound at T4093b.hs:34:5)
- b :: Block n e x (bound at T4093b.hs:25:17)
- blockToNodeList :: Block n e x -> A e x n (bound at T4093b.hs:25:1)
+
+T4093b.hs:31:13: error:
+ • Could not deduce: e ~ C
+ 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,
+ 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)
+ ‘e’ is a rigid type variable bound by
+ the type signature for:
+ 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)
+ Expected type: EitherCO e (A C O n) (A O O n)
+ Actual type: (MaybeC C (n C O), MaybeC O (n O C))
+ • In the expression: (JustC n, NothingC)
+ In an equation for ‘f’: f n _ = (JustC n, NothingC)
+ In an equation for ‘blockToNodeList’:
+ blockToNodeList b
+ = foldBlockNodesF (f, l) b z
+ where
+ z ::
+ EitherCO e (EitherCO e (A C O n) (A O O n)) (EitherCO e (A C O n) (A O O n))
+ z = undefined
+ f ::
+ n C O
+ -> EitherCO e (A C O n) (A O O n) -> EitherCO e (A C O n) (A O O n)
+ f n _ = (JustC n, NothingC)
+ ....
+ • Relevant bindings include
+ f :: n C O
+ -> EitherCO e (A C O n) (A O O n) -> EitherCO e (A C O n) (A O O n)
+ (bound at T4093b.hs:31:5)
+ l :: n O C
+ -> EitherCO e (A C O n) (A O O n) -> EitherCO e (A C C n) (A O C n)
+ (bound at T4093b.hs:34:5)
+ b :: Block n e x (bound at T4093b.hs:25:17)
+ blockToNodeList :: Block n e x -> A e x n (bound at T4093b.hs:25:1)
diff --git a/testsuite/tests/indexed-types/should_fail/T4174.stderr b/testsuite/tests/indexed-types/should_fail/T4174.stderr
index c932530e5a..7fe8c704b9 100644
--- a/testsuite/tests/indexed-types/should_fail/T4174.stderr
+++ b/testsuite/tests/indexed-types/should_fail/T4174.stderr
@@ -1,16 +1,16 @@
-
-T4174.hs:42:12: error:
- • Couldn't match type ‘b’ with ‘RtsSpinLock’
- ‘b’ is a rigid type variable bound by
- the type signature for:
- testcase :: forall (m :: * -> *) minor n t p a b.
- Monad m =>
- m (Field (Way (GHC6'8 minor) n t p) a b)
- at T4174.hs:41:13
- Expected type: m (Field (Way (GHC6'8 minor) n t p) a b)
- Actual type: m (Field (WayOf m) SmStep RtsSpinLock)
- • In the expression: sync_large_objects
- In an equation for ‘testcase’: testcase = sync_large_objects
- • Relevant bindings include
- testcase :: m (Field (Way (GHC6'8 minor) n t p) a b)
- (bound at T4174.hs:42:1)
+
+T4174.hs:42:12: error:
+ • Couldn't match type ‘b’ with ‘RtsSpinLock’
+ ‘b’ is a rigid type variable bound by
+ the type signature for:
+ testcase :: forall (m :: * -> *) minor n t p a b.
+ Monad m =>
+ m (Field (Way (GHC6'8 minor) n t p) a b)
+ at T4174.hs:41:1-63
+ Expected type: m (Field (Way (GHC6'8 minor) n t p) a b)
+ Actual type: m (Field (WayOf m) SmStep RtsSpinLock)
+ • In the expression: sync_large_objects
+ In an equation for ‘testcase’: testcase = sync_large_objects
+ • Relevant bindings include
+ testcase :: m (Field (Way (GHC6'8 minor) n t p) a b)
+ (bound at T4174.hs:42:1)
diff --git a/testsuite/tests/indexed-types/should_fail/T4272.stderr b/testsuite/tests/indexed-types/should_fail/T4272.stderr
index a3b750a459..49a6e9f6c9 100644
--- a/testsuite/tests/indexed-types/should_fail/T4272.stderr
+++ b/testsuite/tests/indexed-types/should_fail/T4272.stderr
@@ -1,17 +1,17 @@
-
-T4272.hs:15:26: error:
- • Couldn't match type ‘a’ with ‘TermFamily a a’
- ‘a’ is a rigid type variable bound by
- the type signature for:
- laws :: forall a b. TermLike a => TermFamily a a -> b
- at T4272.hs:14:16
- Expected type: TermFamily a (TermFamily a a)
- Actual type: TermFamily a a
- • In the first argument of ‘terms’, namely
- ‘(undefined :: TermFamily a a)’
- In the second argument of ‘prune’, namely
- ‘(terms (undefined :: TermFamily a a))’
- In the expression: prune t (terms (undefined :: TermFamily a a))
- • Relevant bindings include
- t :: TermFamily a a (bound at T4272.hs:15:6)
- laws :: TermFamily a a -> b (bound at T4272.hs:15:1)
+
+T4272.hs:15:26: error:
+ • Couldn't match type ‘a’ with ‘TermFamily a a’
+ ‘a’ is a rigid type variable bound by
+ the type signature for:
+ laws :: forall a b. TermLike a => TermFamily a a -> b
+ at T4272.hs:14:1-53
+ Expected type: TermFamily a (TermFamily a a)
+ Actual type: TermFamily a a
+ • In the first argument of ‘terms’, namely
+ ‘(undefined :: TermFamily a a)’
+ In the second argument of ‘prune’, namely
+ ‘(terms (undefined :: TermFamily a a))’
+ In the expression: prune t (terms (undefined :: TermFamily a a))
+ • Relevant bindings include
+ t :: TermFamily a a (bound at T4272.hs:15:6)
+ laws :: TermFamily a a -> b (bound at T4272.hs:15:1)
diff --git a/testsuite/tests/indexed-types/should_fail/T7786.stderr b/testsuite/tests/indexed-types/should_fail/T7786.stderr
index a58b69e7e7..79230e1555 100644
--- a/testsuite/tests/indexed-types/should_fail/T7786.stderr
+++ b/testsuite/tests/indexed-types/should_fail/T7786.stderr
@@ -1,36 +1,50 @@
-
-T7786.hs:86:22: error:
- • Couldn't match type ‘xxx’ with ‘'Empty’
- Inaccessible code in
- a pattern with constructor: Nil :: forall a. Sing 'Empty,
- in a pattern binding in
- 'do' block
- • In the pattern: Nil
- In the pattern: Nil :: Sing xxx
- In a stmt of a 'do' block:
- Nil :: Sing xxx <- return
- (buryUnder (dbKeys sub) k Nil `intersectPaths` dbKeys db)
-
-T7786.hs:86:49: error:
- • Couldn't match type ‘xxx’
- with ‘Intersect (BuriedUnder sub k 'Empty) inv’
- Expected type: Sing xxx
- Actual type: Sing (Intersect (BuriedUnder sub k 'Empty) inv)
- • In the first argument of ‘return’, namely
- ‘(buryUnder (dbKeys sub) k Nil `intersectPaths` dbKeys db)’
- In a stmt of a 'do' block:
- Nil :: Sing xxx <- return
- (buryUnder (dbKeys sub) k Nil `intersectPaths` dbKeys db)
- In the expression:
- do { Nil :: Sing xxx <- return
- (buryUnder (dbKeys sub) k Nil `intersectPaths` dbKeys db);
- return $ Sub db k sub }
- • Relevant bindings include
- sub :: Database sub (bound at T7786.hs:86:13)
- k :: Sing k (bound at T7786.hs:86:11)
- db :: Database inv (bound at T7786.hs:86:8)
- addSub :: Database inv
- -> Sing k
- -> Database sub
- -> Maybe (Database (BuriedUnder sub k inv))
- (bound at T7786.hs:86:1)
+
+T7786.hs:86:49: error:
+ • Couldn't match type ‘xxx’
+ with ‘Intersect (BuriedUnder sub k 'Empty) inv’
+ Expected type: Sing xxx
+ Actual type: Sing (Intersect (BuriedUnder sub k 'Empty) inv)
+ • In the first argument of ‘return’, namely
+ ‘(buryUnder (dbKeys sub) k Nil `intersectPaths` dbKeys db)’
+ In a stmt of a 'do' block:
+ Nil :: Sing xxx <- return
+ (buryUnder (dbKeys sub) k Nil `intersectPaths` dbKeys db)
+ In the expression:
+ do { Nil :: Sing xxx <- return
+ (buryUnder (dbKeys sub) k Nil `intersectPaths` dbKeys db);
+ return $ Sub db k sub }
+ • Relevant bindings include
+ sub :: Database sub (bound at T7786.hs:86:13)
+ k :: Sing k (bound at T7786.hs:86:11)
+ db :: Database inv (bound at T7786.hs:86:8)
+ addSub :: Database inv
+ -> Sing k
+ -> Database sub
+ -> Maybe (Database (BuriedUnder sub k inv))
+ (bound at T7786.hs:86:1)
+
+T7786.hs:90:31: error:
+ • Could not deduce: Intersect (BuriedUnder sub k 'Empty) inv
+ ~
+ 'Empty
+ arising from a use of ‘Sub’
+ from the context: xxx ~ 'Empty
+ bound by a pattern with constructor: Nil :: forall a. Sing 'Empty,
+ in a pattern binding in
+ 'do' block
+ at T7786.hs:86:22-24
+ • In the second argument of ‘($)’, namely ‘Sub db k sub’
+ In a stmt of a 'do' block: return $ Sub db k sub
+ In the expression:
+ do { Nil :: Sing xxx <- return
+ (buryUnder (dbKeys sub) k Nil `intersectPaths` dbKeys db);
+ return $ Sub db k sub }
+ • Relevant bindings include
+ sub :: Database sub (bound at T7786.hs:86:13)
+ k :: Sing k (bound at T7786.hs:86:11)
+ db :: Database inv (bound at T7786.hs:86:8)
+ addSub :: Database inv
+ -> Sing k
+ -> Database sub
+ -> Maybe (Database (BuriedUnder sub k inv))
+ (bound at T7786.hs:86:1)
diff --git a/testsuite/tests/indexed-types/should_fail/T9662.stderr b/testsuite/tests/indexed-types/should_fail/T9662.stderr
index 04ba4f4dba..403f769dfd 100644
--- a/testsuite/tests/indexed-types/should_fail/T9662.stderr
+++ b/testsuite/tests/indexed-types/should_fail/T9662.stderr
@@ -1,35 +1,35 @@
-
-T9662.hs:47:8: error:
- • Couldn't match type ‘n’ with ‘Int’
- ‘n’ is a rigid type variable bound by
- the type signature for:
- test :: forall sh k m n.
- Shape (((sh :. k) :. m) :. n) -> Shape (((sh :. m) :. n) :. k)
- at T9662.hs:44:9
- Expected type: Exp (((sh :. m) :. n) :. k)
- -> Exp (((sh :. m) :. n) :. k)
- Actual type: Exp
- (Tuple (((Atom a0 :. Atom Int) :. Atom Int) :. Atom Int))
- -> Exp
- (Plain (((Unlifted (Atom a0) :. Exp Int) :. Exp Int) :. Exp Int))
- • In the first argument of ‘backpermute’, namely
- ‘(modify
- (atom :. atom :. atom :. atom)
- (\ (sh :. k :. m :. n) -> (sh :. m :. n :. k)))’
- In the expression:
- backpermute
- (modify
- (atom :. atom :. atom :. atom)
- (\ (sh :. k :. m :. n) -> (sh :. m :. n :. k)))
- id
- In an equation for ‘test’:
- test
- = backpermute
- (modify
- (atom :. atom :. atom :. atom)
- (\ (sh :. k :. m :. n) -> (sh :. m :. n :. k)))
- id
- • Relevant bindings include
- test :: Shape (((sh :. k) :. m) :. n)
- -> Shape (((sh :. m) :. n) :. k)
- (bound at T9662.hs:45:1)
+
+T9662.hs:47:8: error:
+ • Couldn't match type ‘n’ with ‘Int’
+ ‘n’ is a rigid type variable bound by
+ the type signature for:
+ test :: forall sh k m n.
+ Shape (((sh :. k) :. m) :. n) -> Shape (((sh :. m) :. n) :. k)
+ at T9662.hs:44:1-50
+ Expected type: Exp (((sh :. m) :. n) :. k)
+ -> Exp (((sh :. m) :. n) :. k)
+ Actual type: Exp
+ (Tuple (((Atom a0 :. Atom Int) :. Atom Int) :. Atom Int))
+ -> Exp
+ (Plain (((Unlifted (Atom a0) :. Exp Int) :. Exp Int) :. Exp Int))
+ • In the first argument of ‘backpermute’, namely
+ ‘(modify
+ (atom :. atom :. atom :. atom)
+ (\ (sh :. k :. m :. n) -> (sh :. m :. n :. k)))’
+ In the expression:
+ backpermute
+ (modify
+ (atom :. atom :. atom :. atom)
+ (\ (sh :. k :. m :. n) -> (sh :. m :. n :. k)))
+ id
+ In an equation for ‘test’:
+ test
+ = backpermute
+ (modify
+ (atom :. atom :. atom :. atom)
+ (\ (sh :. k :. m :. n) -> (sh :. m :. n :. k)))
+ id
+ • Relevant bindings include
+ test :: Shape (((sh :. k) :. m) :. n)
+ -> Shape (((sh :. m) :. n) :. k)
+ (bound at T9662.hs:45:1)
diff --git a/testsuite/tests/module/mod71.stderr b/testsuite/tests/module/mod71.stderr
index d02aac28fa..f0f43d8df6 100644
--- a/testsuite/tests/module/mod71.stderr
+++ b/testsuite/tests/module/mod71.stderr
@@ -1,12 +1,12 @@
-
-mod71.hs:4:9: error:
- • Found hole: _ :: t1
- Where: ‘t1’ is a rigid type variable bound by
- the inferred type of f :: Num t => (t1 -> t -> t2) -> t2
- at mod71.hs:4:1
- • In the first argument of ‘x’, namely ‘_’
- In the expression: x _ 1
- In an equation for ‘f’: f x = x _ 1
- • Relevant bindings include
- x :: t1 -> t -> t2 (bound at mod71.hs:4:3)
- f :: (t1 -> t -> t2) -> t2 (bound at mod71.hs:4:1)
+
+mod71.hs:4:9: error:
+ • Found hole: _ :: t1
+ Where: ‘t1’ is a rigid type variable bound by
+ the inferred type of f :: Num t => (t1 -> t -> t2) -> t2
+ at mod71.hs:4:1-11
+ • In the first argument of ‘x’, namely ‘_’
+ In the expression: x _ 1
+ In an equation for ‘f’: f x = x _ 1
+ • Relevant bindings include
+ x :: t1 -> t -> t2 (bound at mod71.hs:4:3)
+ f :: (t1 -> t -> t2) -> t2 (bound at mod71.hs:4:1)
diff --git a/testsuite/tests/partial-sigs/should_compile/Defaulting2MROff.stderr b/testsuite/tests/partial-sigs/should_compile/Defaulting2MROff.stderr
index 505e5ae659..097bb88829 100644
--- a/testsuite/tests/partial-sigs/should_compile/Defaulting2MROff.stderr
+++ b/testsuite/tests/partial-sigs/should_compile/Defaulting2MROff.stderr
@@ -1,7 +1,7 @@
-TYPE SIGNATURES
- bravo :: forall t. Num t => t
-TYPE CONSTRUCTORS
-COERCION AXIOMS
-Dependent modules: []
-Dependent packages: [base-4.9.0.0, ghc-prim-0.5.0.0,
- integer-gmp-1.0.0.1]
+TYPE SIGNATURES
+ bravo :: forall w. Num w => w
+TYPE CONSTRUCTORS
+COERCION AXIOMS
+Dependent modules: []
+Dependent packages: [base-4.9.0.0, ghc-prim-0.5.0.0,
+ integer-gmp-1.0.0.1]
diff --git a/testsuite/tests/partial-sigs/should_compile/Defaulting2MROn.stderr b/testsuite/tests/partial-sigs/should_compile/Defaulting2MROn.stderr
index 7e40fd184b..097bb88829 100644
--- a/testsuite/tests/partial-sigs/should_compile/Defaulting2MROn.stderr
+++ b/testsuite/tests/partial-sigs/should_compile/Defaulting2MROn.stderr
@@ -1,7 +1,7 @@
-TYPE SIGNATURES
- bravo :: forall t. Num t => t
-TYPE CONSTRUCTORS
-COERCION AXIOMS
-Dependent modules: []
-Dependent packages: [base-4.9.0.0, ghc-prim-0.5.0.0,
- integer-gmp-1.0.0.0]
+TYPE SIGNATURES
+ bravo :: forall w. Num w => w
+TYPE CONSTRUCTORS
+COERCION AXIOMS
+Dependent modules: []
+Dependent packages: [base-4.9.0.0, ghc-prim-0.5.0.0,
+ integer-gmp-1.0.0.1]
diff --git a/testsuite/tests/partial-sigs/should_compile/Either.stderr b/testsuite/tests/partial-sigs/should_compile/Either.stderr
index 53988619d9..2843775174 100644
--- a/testsuite/tests/partial-sigs/should_compile/Either.stderr
+++ b/testsuite/tests/partial-sigs/should_compile/Either.stderr
@@ -1,7 +1,7 @@
-TYPE SIGNATURES
- barry :: forall t. t -> (Either [Char] t, Either [Char] t)
-TYPE CONSTRUCTORS
-COERCION AXIOMS
-Dependent modules: []
-Dependent packages: [base-4.9.0.0, ghc-prim-0.5.0.0,
- integer-gmp-1.0.0.1]
+TYPE SIGNATURES
+ barry :: forall w. w -> (Either [Char] w, Either [Char] w)
+TYPE CONSTRUCTORS
+COERCION AXIOMS
+Dependent modules: []
+Dependent packages: [base-4.9.0.0, ghc-prim-0.5.0.0,
+ integer-gmp-1.0.0.1]
diff --git a/testsuite/tests/partial-sigs/should_compile/EveryNamed.stderr b/testsuite/tests/partial-sigs/should_compile/EveryNamed.stderr
index 3bb47befd4..29a6506979 100644
--- a/testsuite/tests/partial-sigs/should_compile/EveryNamed.stderr
+++ b/testsuite/tests/partial-sigs/should_compile/EveryNamed.stderr
@@ -1,7 +1,7 @@
-TYPE SIGNATURES
- every :: forall t. (t -> Bool) -> [t] -> Bool
-TYPE CONSTRUCTORS
-COERCION AXIOMS
-Dependent modules: []
-Dependent packages: [base-4.9.0.0, ghc-prim-0.5.0.0,
- integer-gmp-1.0.0.1]
+TYPE SIGNATURES
+ every :: forall w. (w -> Bool) -> [w] -> Bool
+TYPE CONSTRUCTORS
+COERCION AXIOMS
+Dependent modules: []
+Dependent packages: [base-4.9.0.0, ghc-prim-0.5.0.0,
+ integer-gmp-1.0.0.1]
diff --git a/testsuite/tests/partial-sigs/should_compile/ExprSigLocal.stderr b/testsuite/tests/partial-sigs/should_compile/ExprSigLocal.stderr
index 5a3f40f353..b94e0c5c17 100644
--- a/testsuite/tests/partial-sigs/should_compile/ExprSigLocal.stderr
+++ b/testsuite/tests/partial-sigs/should_compile/ExprSigLocal.stderr
@@ -1,19 +1,17 @@
-
-ExprSigLocal.hs:9:35: warning: [-Wpartial-type-signatures (in -Wdefault)]
- • Found type wildcard ‘_’ standing for ‘a’
- Where: ‘a’ is a rigid type variable bound by
- the inferred type of <expression> :: a -> a at ExprSigLocal.hs:9:27
- • In an expression type signature: forall a. a -> _
- In the expression: ((\ x -> x) :: forall a. a -> _)
- In an equation for ‘y’: y = ((\ x -> x) :: forall a. a -> _)
- • Relevant bindings include
- y :: b -> b (bound at ExprSigLocal.hs:9:1)
-
-ExprSigLocal.hs:11:21: warning: [-Wpartial-type-signatures (in -Wdefault)]
- • Found type wildcard ‘_’ standing for ‘a’
- Where: ‘a’ is a rigid type variable bound by
- the inferred type of g :: a -> a at ExprSigLocal.hs:11:13
- • In the type signature:
- g :: forall a. a -> _
- • Relevant bindings include
- g :: a -> a (bound at ExprSigLocal.hs:12:1)
+
+ExprSigLocal.hs:9:35: warning: [-Wpartial-type-signatures (in -Wdefault)]
+ • Found type wildcard ‘_’ standing for ‘a’
+ Where: ‘a’ is a rigid type variable bound by
+ the inferred type of <expression> :: a -> a
+ at ExprSigLocal.hs:9:20-35
+ • In an expression type signature: forall a. a -> _
+ In the expression: ((\ x -> x) :: forall a. a -> _)
+ In an equation for ‘y’: y = ((\ x -> x) :: forall a. a -> _)
+ • Relevant bindings include
+ y :: b -> b (bound at ExprSigLocal.hs:9:1)
+
+ExprSigLocal.hs:11:21: warning: [-Wpartial-type-signatures (in -Wdefault)]
+ • Found type wildcard ‘_’ standing for ‘a’
+ Where: ‘a’ is a rigid type variable bound by
+ the inferred type of g :: a -> a at ExprSigLocal.hs:12:1-7
+ • In the type signature: g :: forall a. a -> _
diff --git a/testsuite/tests/partial-sigs/should_compile/ExtraConstraints3.stderr b/testsuite/tests/partial-sigs/should_compile/ExtraConstraints3.stderr
index 60de114c99..2526f72019 100644
--- a/testsuite/tests/partial-sigs/should_compile/ExtraConstraints3.stderr
+++ b/testsuite/tests/partial-sigs/should_compile/ExtraConstraints3.stderr
@@ -125,12 +125,12 @@ TYPE SIGNATURES
(Monad m, P.Foldable t) =>
(a -> m b) -> t a -> m ()
max :: forall a. Ord a => a -> a -> a
- maxBound :: forall t. Bounded t => t
+ maxBound :: forall w. Bounded w => w
maximum ::
forall (t :: * -> *) a. (Ord a, P.Foldable t) => t a -> a
maybe :: forall a b. b -> (a -> b) -> Maybe a -> b
min :: forall a. Ord a => a -> a -> a
- minBound :: forall t. Bounded t => t
+ minBound :: forall w. Bounded w => w
minimum ::
forall (t :: * -> *) a. (Ord a, P.Foldable t) => t a -> a
mod :: forall a. Integral a => a -> a -> a
@@ -142,7 +142,7 @@ TYPE SIGNATURES
odd :: forall a. Integral a => a -> Bool
or :: forall (t :: * -> *). P.Foldable t => t Bool -> Bool
otherwise :: Bool
- pi :: forall t. Floating t => t
+ pi :: forall w. Floating w => w
pred :: forall a. Enum a => a -> a
print :: forall a. Show a => a -> IO ()
product ::
@@ -212,7 +212,7 @@ TYPE SIGNATURES
toRational :: forall a. Real a => a -> Rational
truncate :: forall b a. (Integral b, RealFrac a) => a -> b
uncurry :: forall c b a. (a -> b -> c) -> (a, b) -> c
- undefined :: forall t. t
+ undefined :: forall w. w
unlines :: [String] -> String
until :: forall a. (a -> Bool) -> (a -> a) -> a -> a
unwords :: [String] -> String
diff --git a/testsuite/tests/partial-sigs/should_compile/SimpleGen.stderr b/testsuite/tests/partial-sigs/should_compile/SimpleGen.stderr
index db0adb2004..1adc0b055c 100644
--- a/testsuite/tests/partial-sigs/should_compile/SimpleGen.stderr
+++ b/testsuite/tests/partial-sigs/should_compile/SimpleGen.stderr
@@ -1,7 +1,7 @@
-TYPE SIGNATURES
- bar :: forall t. t -> Bool
-TYPE CONSTRUCTORS
-COERCION AXIOMS
-Dependent modules: []
-Dependent packages: [base-4.9.0.0, ghc-prim-0.5.0.0,
- integer-gmp-1.0.0.1]
+TYPE SIGNATURES
+ bar :: forall w. w -> Bool
+TYPE CONSTRUCTORS
+COERCION AXIOMS
+Dependent modules: []
+Dependent packages: [base-4.9.0.0, ghc-prim-0.5.0.0,
+ integer-gmp-1.0.0.1]
diff --git a/testsuite/tests/partial-sigs/should_compile/SplicesUsed.stderr b/testsuite/tests/partial-sigs/should_compile/SplicesUsed.stderr
index abc5f44138..2c84971275 100644
--- a/testsuite/tests/partial-sigs/should_compile/SplicesUsed.stderr
+++ b/testsuite/tests/partial-sigs/should_compile/SplicesUsed.stderr
@@ -1,100 +1,79 @@
-[1 of 2] Compiling Splices ( Splices.hs, Splices.o )
-[2 of 2] Compiling SplicesUsed ( SplicesUsed.hs, SplicesUsed.o )
-
-SplicesUsed.hs:7:16: warning: [-Wpartial-type-signatures (in -Wdefault)]
- • Found type wildcard ‘_’ standing for ‘Maybe Bool’
- • In the type signature:
- maybeBool :: _
- • Relevant bindings include
- maybeBool :: Maybe Bool (bound at SplicesUsed.hs:8:1)
-
-SplicesUsed.hs:8:15: warning: [-Wpartial-type-signatures (in -Wdefault)]
- • Found type wildcard ‘_a’ standing for ‘t’
- Where: ‘t’ is a rigid type variable bound by
- the inferred type of <expression> :: t -> t at SplicesUsed.hs:8:15
- • In an expression type signature: _a -> _a
- In the expression: id :: _a -> _a
- In the expression: (id :: _a -> _a) (Just True :: Maybe _)
- • Relevant bindings include
- maybeBool :: Maybe Bool (bound at SplicesUsed.hs:8:1)
-
-SplicesUsed.hs:8:27: warning: [-Wpartial-type-signatures (in -Wdefault)]
- • Found type wildcard ‘_’ standing for ‘Bool’
- • In an expression type signature: Maybe _
- In the first argument of ‘id :: _a -> _a’, namely
- ‘(Just True :: Maybe _)’
- In the expression: (id :: _a -> _a) (Just True :: Maybe _)
- • Relevant bindings include
- maybeBool :: Maybe Bool (bound at SplicesUsed.hs:8:1)
-
-SplicesUsed.hs:10:17: warning: [-Wpartial-type-signatures (in -Wdefault)]
- • Found type wildcard ‘_’ standing for ‘(Char, a)’
- Where: ‘a’ is a rigid type variable bound by
- the inferred type of charA :: a -> (Char, a)
- at SplicesUsed.hs:10:10
- • In the type signature:
- charA :: a -> (_)
- • Relevant bindings include
- charA :: a -> (Char, a) (bound at SplicesUsed.hs:11:1)
-
-SplicesUsed.hs:13:14: warning: [-Wpartial-type-signatures (in -Wdefault)]
- • Found type wildcard ‘_’ standing for ‘a -> Bool’
- Where: ‘a’ is a rigid type variable bound by
- the inferred type of filter' :: (a -> Bool) -> [a] -> [a]
- at SplicesUsed.hs:14:1
- • In the type signature:
- filter' :: _ -> _ -> _
- • Relevant bindings include
- filter' :: (a -> Bool) -> [a] -> [a] (bound at SplicesUsed.hs:14:1)
-
-SplicesUsed.hs:13:14: warning: [-Wpartial-type-signatures (in -Wdefault)]
- • Found type wildcard ‘_’ standing for ‘[a]’
- Where: ‘a’ is a rigid type variable bound by
- the inferred type of filter' :: (a -> Bool) -> [a] -> [a]
- at SplicesUsed.hs:14:1
- • In the type signature:
- filter' :: _ -> _ -> _
- • Relevant bindings include
- filter' :: (a -> Bool) -> [a] -> [a] (bound at SplicesUsed.hs:14:1)
-
-SplicesUsed.hs:13:14: warning: [-Wpartial-type-signatures (in -Wdefault)]
- • Found type wildcard ‘_’ standing for ‘[a]’
- Where: ‘a’ is a rigid type variable bound by
- the inferred type of filter' :: (a -> Bool) -> [a] -> [a]
- at SplicesUsed.hs:14:1
- • In the type signature:
- filter' :: _ -> _ -> _
- • Relevant bindings include
- filter' :: (a -> Bool) -> [a] -> [a] (bound at SplicesUsed.hs:14:1)
-
-SplicesUsed.hs:16:3: warning: [-Wpartial-type-signatures (in -Wdefault)]
- Found constraint wildcard ‘_’ standing for ‘Eq a’
- In the type signature:
- foo :: _ => _
-
-SplicesUsed.hs:16:3: warning: [-Wpartial-type-signatures (in -Wdefault)]
- • Found type wildcard ‘_’ standing for ‘a -> a -> Bool’
- Where: ‘a’ is a rigid type variable bound by
- the inferred type of foo :: Eq a => a -> a -> Bool
- at SplicesUsed.hs:16:3
- • In the type signature:
- foo :: _ => _
- • Relevant bindings include
- foo :: a -> a -> Bool (bound at SplicesUsed.hs:16:3)
-
-SplicesUsed.hs:18:3: warning: [-Wpartial-type-signatures (in -Wdefault)]
- • Found type wildcard ‘_a’ standing for ‘Bool’
- • In the type signature:
- bar :: _a -> _b -> (_a, _b)
- • Relevant bindings include
- bar :: Bool -> t -> (Bool, t) (bound at SplicesUsed.hs:18:3)
-
-SplicesUsed.hs:18:3: warning: [-Wpartial-type-signatures (in -Wdefault)]
- • Found type wildcard ‘_b’ standing for ‘t’
- Where: ‘t’ is a rigid type variable bound by
- the inferred type of bar :: Bool -> t -> (Bool, t)
- at SplicesUsed.hs:18:3
- • In the type signature:
- bar :: _a -> _b -> (_a, _b)
- • Relevant bindings include
- bar :: Bool -> t -> (Bool, t) (bound at SplicesUsed.hs:18:3)
+[1 of 2] Compiling Splices ( Splices.hs, Splices.o )
+[2 of 2] Compiling SplicesUsed ( SplicesUsed.hs, SplicesUsed.o )
+
+SplicesUsed.hs:7:16: warning: [-Wpartial-type-signatures (in -Wdefault)]
+ • Found type wildcard ‘_’ standing for ‘Maybe Bool’
+ • In the type signature: maybeBool :: _
+
+SplicesUsed.hs:8:15: warning: [-Wpartial-type-signatures (in -Wdefault)]
+ • Found type wildcard ‘_a’ standing for ‘w’
+ Where: ‘w’ is a rigid type variable bound by
+ the inferred type of <expression> :: w -> w
+ at SplicesUsed.hs:8:15-22
+ • In an expression type signature: _a -> _a
+ In the expression: id :: _a -> _a
+ In the expression: (id :: _a -> _a) (Just True :: Maybe _)
+ • Relevant bindings include
+ maybeBool :: Maybe Bool (bound at SplicesUsed.hs:8:1)
+
+SplicesUsed.hs:8:27: warning: [-Wpartial-type-signatures (in -Wdefault)]
+ • Found type wildcard ‘_’ standing for ‘Bool’
+ • In an expression type signature: Maybe _
+ In the first argument of ‘id :: _a -> _a’, namely
+ ‘(Just True :: Maybe _)’
+ In the expression: (id :: _a -> _a) (Just True :: Maybe _)
+ • Relevant bindings include
+ maybeBool :: Maybe Bool (bound at SplicesUsed.hs:8:1)
+
+SplicesUsed.hs:10:17: warning: [-Wpartial-type-signatures (in -Wdefault)]
+ • Found type wildcard ‘_’ standing for ‘(Char, a)’
+ Where: ‘a’ is a rigid type variable bound by
+ the inferred type of charA :: a -> (Char, a)
+ at SplicesUsed.hs:11:1-18
+ • In the type signature: charA :: a -> (_)
+
+SplicesUsed.hs:13:14: warning: [-Wpartial-type-signatures (in -Wdefault)]
+ • Found type wildcard ‘_’ standing for ‘a -> Bool’
+ Where: ‘a’ is a rigid type variable bound by
+ the inferred type of filter' :: (a -> Bool) -> [a] -> [a]
+ at SplicesUsed.hs:14:1-16
+ • In the type signature: filter' :: _ -> _ -> _
+
+SplicesUsed.hs:13:14: warning: [-Wpartial-type-signatures (in -Wdefault)]
+ • Found type wildcard ‘_’ standing for ‘[a]’
+ Where: ‘a’ is a rigid type variable bound by
+ the inferred type of filter' :: (a -> Bool) -> [a] -> [a]
+ at SplicesUsed.hs:14:1-16
+ • In the type signature: filter' :: _ -> _ -> _
+
+SplicesUsed.hs:13:14: warning: [-Wpartial-type-signatures (in -Wdefault)]
+ • Found type wildcard ‘_’ standing for ‘[a]’
+ Where: ‘a’ is a rigid type variable bound by
+ the inferred type of filter' :: (a -> Bool) -> [a] -> [a]
+ at SplicesUsed.hs:14:1-16
+ • In the type signature: filter' :: _ -> _ -> _
+
+SplicesUsed.hs:16:3: warning: [-Wpartial-type-signatures (in -Wdefault)]
+ • Found type wildcard ‘_’ standing for ‘Eq a’
+ Where: ‘a’ is a rigid type variable bound by
+ the inferred type of foo :: Eq a => a -> a -> Bool
+ at SplicesUsed.hs:16:3-10
+ • In the type signature: foo :: _ => _
+
+SplicesUsed.hs:16:3: warning: [-Wpartial-type-signatures (in -Wdefault)]
+ • Found type wildcard ‘_’ standing for ‘a -> a -> Bool’
+ Where: ‘a’ is a rigid type variable bound by
+ the inferred type of foo :: Eq a => a -> a -> Bool
+ at SplicesUsed.hs:16:3-10
+ • In the type signature: foo :: _ => _
+
+SplicesUsed.hs:18:3: warning: [-Wpartial-type-signatures (in -Wdefault)]
+ • Found type wildcard ‘_a’ standing for ‘Bool’
+ • In the type signature: bar :: _a -> _b -> (_a, _b)
+
+SplicesUsed.hs:18:3: warning: [-Wpartial-type-signatures (in -Wdefault)]
+ • Found type wildcard ‘_b’ standing for ‘w’
+ Where: ‘w’ is a rigid type variable bound by
+ the inferred type of bar :: Bool -> w -> (Bool, w)
+ at SplicesUsed.hs:18:3-10
+ • In the type signature: bar :: _a -> _b -> (_a, _b)
diff --git a/testsuite/tests/partial-sigs/should_compile/SuperCls.stderr b/testsuite/tests/partial-sigs/should_compile/SuperCls.stderr
index d6fda4e8f5..7811dcb854 100644
--- a/testsuite/tests/partial-sigs/should_compile/SuperCls.stderr
+++ b/testsuite/tests/partial-sigs/should_compile/SuperCls.stderr
@@ -1,4 +1,4 @@
-
-SuperCls.hs:4:14: warning: [-Wpartial-type-signatures (in -Wdefault)]
- Found constraint wildcard ‘_’ standing for ‘()’
- In the type signature: f :: (Ord a, _) => a -> Bool
+
+SuperCls.hs:4:14: warning: [-Wpartial-type-signatures (in -Wdefault)]
+ • Found type wildcard ‘_’ standing for ‘() :: Constraint’
+ • In the type signature: f :: (Ord a, _) => a -> Bool
diff --git a/testsuite/tests/partial-sigs/should_compile/T10403.stderr b/testsuite/tests/partial-sigs/should_compile/T10403.stderr
index 320b28b621..753b983a15 100644
--- a/testsuite/tests/partial-sigs/should_compile/T10403.stderr
+++ b/testsuite/tests/partial-sigs/should_compile/T10403.stderr
@@ -1,81 +1,77 @@
-
-T10403.hs:15:7: warning: [-Wpartial-type-signatures (in -Wdefault)]
- Found constraint wildcard ‘_’ standing for ‘Functor f’
- In the type signature:
- h1 :: _ => _
-
-T10403.hs:15:12: warning: [-Wpartial-type-signatures (in -Wdefault)]
- • Found type wildcard ‘_’ standing for ‘(a -> b) -> f a -> H f’
- Where: ‘f’ is a rigid type variable bound by
- the inferred type of h1 :: Functor f => (a -> b) -> f a -> H f
- at T10403.hs:17:1
- ‘b’ is a rigid type variable bound by
- the inferred type of h1 :: Functor f => (a -> b) -> f a -> H f
- at T10403.hs:17:1
- ‘a’ is a rigid type variable bound by
- the inferred type of h1 :: Functor f => (a -> b) -> f a -> H f
- at T10403.hs:17:1
- • In the type signature:
- h1 :: _ => _
- • Relevant bindings include
- h1 :: (a -> b) -> f a -> H f (bound at T10403.hs:17:1)
-
-T10403.hs:19:7: warning: [-Wpartial-type-signatures (in -Wdefault)]
- • Found type wildcard ‘_’ standing for ‘(a -> b) -> f0 a -> H f0’
- Where: ‘f0’ is an ambiguous type variable
- ‘b’ is a rigid type variable bound by
- the inferred type of h2 :: (a -> b) -> f0 a -> H f0
- at T10403.hs:22:1
- ‘a’ is a rigid type variable bound by
- the inferred type of h2 :: (a -> b) -> f0 a -> H f0
- at T10403.hs:22:1
- • In the type signature:
- h2 :: _
- • Relevant bindings include
- h2 :: (a -> b) -> f0 a -> H f0 (bound at T10403.hs:22:1)
-
-T10403.hs:22:15: warning: [-Wdeferred-type-errors (in -Wdefault)]
- • Ambiguous type variable ‘f0’ arising from a use of ‘fmap’
- prevents the constraint ‘(Functor f0)’ from being solved.
- Relevant bindings include
- b :: f0 a (bound at T10403.hs:22:6)
- h2 :: (a -> b) -> f0 a -> H f0 (bound at T10403.hs:22:1)
- Probable fix: use a type annotation to specify what ‘f0’ should be.
- These potential instances exist:
- instance Functor IO -- Defined in ‘GHC.Base’
- instance Functor (B t) -- Defined at T10403.hs:10:10
- instance Functor I -- Defined at T10403.hs:6:10
- ...plus four others
- (use -fprint-potential-instances to see them all)
- • In the second argument of ‘(.)’, namely ‘fmap (const ())’
- In the expression: H . fmap (const ())
- In the expression: (H . fmap (const ())) (fmap f b)
-
-T10403.hs:28:8: warning: [-Wdeferred-type-errors (in -Wdefault)]
- • Couldn't match type ‘f0’ with ‘B t’
- because type variable ‘t’ would escape its scope
- This (rigid, skolem) type variable is bound by
- the type signature for:
- app2 :: H (B t)
- at T10403.hs:27:1-15
- Expected type: H (B t)
- Actual type: H f0
- • In the expression: h2 (H . I) (B ())
- In an equation for ‘app2’: app2 = h2 (H . I) (B ())
- • Relevant bindings include
- app2 :: H (B t) (bound at T10403.hs:28:1)
-
-T10403.hs:28:20: warning: [-Wdeferred-type-errors (in -Wdefault)]
- • Couldn't match type ‘f0’ with ‘B t’
- because type variable ‘t’ would escape its scope
- This (rigid, skolem) type variable is bound by
- the type signature for:
- app2 :: H (B t)
- at T10403.hs:27:1-15
- Expected type: f0 ()
- Actual type: B t ()
- • In the second argument of ‘h2’, namely ‘(B ())’
- In the expression: h2 (H . I) (B ())
- In an equation for ‘app2’: app2 = h2 (H . I) (B ())
- • Relevant bindings include
- app2 :: H (B t) (bound at T10403.hs:28:1)
+
+T10403.hs:15:7: warning: [-Wpartial-type-signatures (in -Wdefault)]
+ • Found type wildcard ‘_’ standing for ‘Functor f’
+ Where: ‘f’ is a rigid type variable bound by
+ the inferred type of h1 :: Functor f => (a -> b) -> f a -> H f
+ at T10403.hs:17:1-41
+ • In the type signature: h1 :: _ => _
+
+T10403.hs:15:12: warning: [-Wpartial-type-signatures (in -Wdefault)]
+ • Found type wildcard ‘_’ standing for ‘(a -> b) -> f a -> H f’
+ Where: ‘f’ is a rigid type variable bound by
+ the inferred type of h1 :: Functor f => (a -> b) -> f a -> H f
+ at T10403.hs:17:1-41
+ ‘b’ is a rigid type variable bound by
+ the inferred type of h1 :: Functor f => (a -> b) -> f a -> H f
+ at T10403.hs:17:1-41
+ ‘a’ is a rigid type variable bound by
+ the inferred type of h1 :: Functor f => (a -> b) -> f a -> H f
+ at T10403.hs:17:1-41
+ • In the type signature: h1 :: _ => _
+
+T10403.hs:19:7: warning: [-Wpartial-type-signatures (in -Wdefault)]
+ • Found type wildcard ‘_’ standing for ‘(a -> b) -> f0 a -> H f0’
+ Where: ‘f0’ is an ambiguous type variable
+ ‘b’ is a rigid type variable bound by
+ the inferred type of h2 :: (a -> b) -> f0 a -> H f0
+ at T10403.hs:22:1-41
+ ‘a’ is a rigid type variable bound by
+ the inferred type of h2 :: (a -> b) -> f0 a -> H f0
+ at T10403.hs:22:1-41
+ • In the type signature: h2 :: _
+
+T10403.hs:22:15: warning: [-Wdeferred-type-errors (in -Wdefault)]
+ • Ambiguous type variable ‘f0’ arising from a use of ‘fmap’
+ prevents the constraint ‘(Functor f0)’ from being solved.
+ Relevant bindings include
+ b :: f0 a (bound at T10403.hs:22:6)
+ h2 :: (a -> b) -> f0 a -> H f0 (bound at T10403.hs:22:1)
+ Probable fix: use a type annotation to specify what ‘f0’ should be.
+ These potential instances exist:
+ instance Functor IO -- Defined in ‘GHC.Base’
+ instance Functor (B t) -- Defined at T10403.hs:10:10
+ instance Functor I -- Defined at T10403.hs:6:10
+ ...plus four others
+ (use -fprint-potential-instances to see them all)
+ • In the second argument of ‘(.)’, namely ‘fmap (const ())’
+ In the expression: H . fmap (const ())
+ In the expression: (H . fmap (const ())) (fmap f b)
+
+T10403.hs:28:8: warning: [-Wdeferred-type-errors (in -Wdefault)]
+ • Couldn't match type ‘f0’ with ‘B t’
+ because type variable ‘t’ would escape its scope
+ This (rigid, skolem) type variable is bound by
+ the type signature for:
+ app2 :: H (B t)
+ at T10403.hs:27:1-15
+ Expected type: H (B t)
+ Actual type: H f0
+ • In the expression: h2 (H . I) (B ())
+ In an equation for ‘app2’: app2 = h2 (H . I) (B ())
+ • Relevant bindings include
+ app2 :: H (B t) (bound at T10403.hs:28:1)
+
+T10403.hs:28:20: warning: [-Wdeferred-type-errors (in -Wdefault)]
+ • Couldn't match type ‘f0’ with ‘B t’
+ because type variable ‘t’ would escape its scope
+ This (rigid, skolem) type variable is bound by
+ the type signature for:
+ app2 :: H (B t)
+ at T10403.hs:27:1-15
+ Expected type: f0 ()
+ Actual type: B t ()
+ • In the second argument of ‘h2’, namely ‘(B ())’
+ In the expression: h2 (H . I) (B ())
+ In an equation for ‘app2’: app2 = h2 (H . I) (B ())
+ • Relevant bindings include
+ app2 :: H (B t) (bound at T10403.hs:28:1)
diff --git a/testsuite/tests/partial-sigs/should_compile/T10438.stderr b/testsuite/tests/partial-sigs/should_compile/T10438.stderr
index 0742250be3..a3fc19f7aa 100644
--- a/testsuite/tests/partial-sigs/should_compile/T10438.stderr
+++ b/testsuite/tests/partial-sigs/should_compile/T10438.stderr
@@ -1,28 +1,26 @@
-
-T10438.hs:7:22: warning: [-Wpartial-type-signatures (in -Wdefault)]
- • Found type wildcard ‘_’ standing for ‘t2’
- Where: ‘t2’ is a rigid type variable bound by
- the inferred type of g :: t2 -> t2 at T10438.hs:6:9
- • In the type signature:
- x :: _
- In an equation for ‘g’:
- g r
- = x
- where
- x :: _
- x = r
- In an equation for ‘foo’:
- foo f
- = g
- where
- g r
- = x
- where
- x :: _
- x = r
- • Relevant bindings include
- x :: t2 (bound at T10438.hs:8:17)
- r :: t2 (bound at T10438.hs:6:11)
- g :: t2 -> t2 (bound at T10438.hs:6:9)
- f :: t1 (bound at T10438.hs:5:5)
- foo :: t1 -> forall t. t -> t (bound at T10438.hs:5:1)
+
+T10438.hs:7:22: warning: [-Wpartial-type-signatures (in -Wdefault)]
+ • Found type wildcard ‘_’ standing for ‘t2’
+ Where: ‘t2’ is a rigid type variable bound by
+ the inferred type of g :: t2 -> t2 at T10438.hs:(6,9)-(8,21)
+ • In the type signature: x :: _
+ In an equation for ‘g’:
+ g r
+ = x
+ where
+ x :: _
+ x = r
+ In an equation for ‘foo’:
+ foo f
+ = g
+ where
+ g r
+ = x
+ where
+ x :: _
+ x = r
+ • Relevant bindings include
+ r :: t2 (bound at T10438.hs:6:11)
+ g :: t2 -> t2 (bound at T10438.hs:6:9)
+ f :: t1 (bound at T10438.hs:5:5)
+ foo :: t1 -> forall t. t -> t (bound at T10438.hs:5:1)
diff --git a/testsuite/tests/partial-sigs/should_compile/T10519.stderr b/testsuite/tests/partial-sigs/should_compile/T10519.stderr
index ba98d7a3b0..496867bd04 100644
--- a/testsuite/tests/partial-sigs/should_compile/T10519.stderr
+++ b/testsuite/tests/partial-sigs/should_compile/T10519.stderr
@@ -1,5 +1,7 @@
-
-T10519.hs:5:18: warning: [-Wpartial-type-signatures (in -Wdefault)]
- Found constraint wildcard ‘_’ standing for ‘Eq a’
- In the type signature:
- foo :: forall a. _ => a -> a -> Bool
+
+T10519.hs:5:18: warning: [-Wpartial-type-signatures (in -Wdefault)]
+ • Found type wildcard ‘_’ standing for ‘Eq a’
+ Where: ‘a’ is a rigid type variable bound by
+ the inferred type of foo :: Eq a => a -> a -> Bool
+ at T10519.hs:6:1-16
+ • In the type signature: foo :: forall a. _ => a -> a -> Bool
diff --git a/testsuite/tests/partial-sigs/should_compile/T11016.stderr b/testsuite/tests/partial-sigs/should_compile/T11016.stderr
index 5d9ad095c1..faf2124b25 100644
--- a/testsuite/tests/partial-sigs/should_compile/T11016.stderr
+++ b/testsuite/tests/partial-sigs/should_compile/T11016.stderr
@@ -1,11 +1,8 @@
-
-T11016.hs:5:19: warning: [-Wpartial-type-signatures (in -Wdefault)]
- Found constraint wildcard ‘_’ standing for ‘()’
- In the type signature:
- f1 :: (?x :: Int, _) => Int
-
-T11016.hs:8:22: warning: [-Wpartial-type-signatures (in -Wdefault)]
- • Found type wildcard ‘_’ standing for ‘Int’
- • In the type signature:
- f2 :: (?x :: Int) => _
- • Relevant bindings include f2 :: Int (bound at T11016.hs:9:1)
+
+T11016.hs:5:19: warning: [-Wpartial-type-signatures (in -Wdefault)]
+ • Found type wildcard ‘_’ standing for ‘() :: Constraint’
+ • In the type signature: f1 :: (?x :: Int, _) => Int
+
+T11016.hs:8:22: warning: [-Wpartial-type-signatures (in -Wdefault)]
+ • Found type wildcard ‘_’ standing for ‘Int’
+ • In the type signature: f2 :: (?x :: Int) => _
diff --git a/testsuite/tests/partial-sigs/should_compile/T11192.stderr b/testsuite/tests/partial-sigs/should_compile/T11192.stderr
index 558097ca2b..c2a9db5a96 100644
--- a/testsuite/tests/partial-sigs/should_compile/T11192.stderr
+++ b/testsuite/tests/partial-sigs/should_compile/T11192.stderr
@@ -1,44 +1,38 @@
-
-T11192.hs:7:14: warning: [-Wpartial-type-signatures (in -Wdefault)]
- • Found type wildcard ‘_’ standing for ‘Int -> t -> t’
- Where: ‘t’ is a rigid type variable bound by
- the inferred type of go :: Int -> t -> t at T11192.hs:8:8
- • In the type signature:
- go :: _
- In the expression:
- let
- go :: _
- go 0 a = a
- in go (0 :: Int) undefined
- In an equation for ‘fails’:
- fails
- = let
- go :: _
- go 0 a = a
- in go (0 :: Int) undefined
- • Relevant bindings include
- go :: Int -> t -> t (bound at T11192.hs:8:8)
- fails :: a (bound at T11192.hs:6:1)
-
-T11192.hs:13:14: warning: [-Wpartial-type-signatures (in -Wdefault)]
- • Found type wildcard ‘_’ standing for ‘t1 -> t -> t’
- Where: ‘t’ is a rigid type variable bound by
- the inferred type of go :: t1 -> t -> t at T11192.hs:14:8
- ‘t1’ is a rigid type variable bound by
- the inferred type of go :: t1 -> t -> t at T11192.hs:14:8
- • In the type signature:
- go :: _
- In the expression:
- let
- go :: _
- go _ a = a
- in go (0 :: Int) undefined
- In an equation for ‘succeeds’:
- succeeds
- = let
- go :: _
- go _ a = a
- in go (0 :: Int) undefined
- • Relevant bindings include
- go :: t1 -> t -> t (bound at T11192.hs:14:8)
- succeeds :: a (bound at T11192.hs:12:1)
+
+T11192.hs:7:14: warning: [-Wpartial-type-signatures (in -Wdefault)]
+ • Found type wildcard ‘_’ standing for ‘Int -> t -> t’
+ Where: ‘t’ is a rigid type variable bound by
+ the inferred type of go :: Int -> t -> t at T11192.hs:8:8-17
+ • In the type signature: go :: _
+ In the expression:
+ let
+ go :: _
+ go 0 a = a
+ in go (0 :: Int) undefined
+ In an equation for ‘fails’:
+ fails
+ = let
+ go :: _
+ go 0 a = a
+ in go (0 :: Int) undefined
+ • Relevant bindings include fails :: a (bound at T11192.hs:6:1)
+
+T11192.hs:13:14: warning: [-Wpartial-type-signatures (in -Wdefault)]
+ • Found type wildcard ‘_’ standing for ‘t1 -> t -> t’
+ Where: ‘t’ is a rigid type variable bound by
+ the inferred type of go :: t1 -> t -> t at T11192.hs:14:8-17
+ ‘t1’ is a rigid type variable bound by
+ the inferred type of go :: t1 -> t -> t at T11192.hs:14:8-17
+ • In the type signature: go :: _
+ In the expression:
+ let
+ go :: _
+ go _ a = a
+ in go (0 :: Int) undefined
+ In an equation for ‘succeeds’:
+ succeeds
+ = let
+ go :: _
+ go _ a = a
+ in go (0 :: Int) undefined
+ • Relevant bindings include succeeds :: a (bound at T11192.hs:12:1)
diff --git a/testsuite/tests/partial-sigs/should_compile/T11339a.hs b/testsuite/tests/partial-sigs/should_compile/T11339a.hs
new file mode 100644
index 0000000000..de20d93d93
--- /dev/null
+++ b/testsuite/tests/partial-sigs/should_compile/T11339a.hs
@@ -0,0 +1,6 @@
+{-# LANGUAGE PartialTypeSignatures #-}
+
+module T11399a where
+
+bar :: _
+(bar) = id
diff --git a/testsuite/tests/partial-sigs/should_compile/T11339a.stderr b/testsuite/tests/partial-sigs/should_compile/T11339a.stderr
new file mode 100644
index 0000000000..76d15ff356
--- /dev/null
+++ b/testsuite/tests/partial-sigs/should_compile/T11339a.stderr
@@ -0,0 +1,6 @@
+
+T11339a.hs:5:8: warning: [-Wpartial-type-signatures (in -Wdefault)]
+ • Found type wildcard ‘_’ standing for ‘a -> a’
+ Where: ‘a’ is a rigid type variable bound by
+ the inferred type of bar :: a -> a at T11339a.hs:6:1-10
+ • In the type signature: bar :: _
diff --git a/testsuite/tests/partial-sigs/should_compile/T11670.hs b/testsuite/tests/partial-sigs/should_compile/T11670.hs
new file mode 100644
index 0000000000..8b0611fda1
--- /dev/null
+++ b/testsuite/tests/partial-sigs/should_compile/T11670.hs
@@ -0,0 +1,16 @@
+{-# LANGUAGE InstanceSigs, PartialTypeSignatures #-}
+
+module T11670 where
+
+import Foreign.C.Types
+import Foreign.Storable
+import Foreign.Ptr
+
+peek :: Ptr a -> IO CLong
+peek ptr = peekElemOff undefined 0 :: IO _
+
+peek2 :: Ptr a -> IO CLong
+peek2 ptr = peekElemOff undefined 0 :: _ => IO _
+
+-- castPtr :: Ptr a -> Ptr b
+-- peekElemOff :: Storable a => Ptr a -> Int -> IO a
diff --git a/testsuite/tests/partial-sigs/should_compile/T11670.stderr b/testsuite/tests/partial-sigs/should_compile/T11670.stderr
new file mode 100644
index 0000000000..eaa304ca42
--- /dev/null
+++ b/testsuite/tests/partial-sigs/should_compile/T11670.stderr
@@ -0,0 +1,36 @@
+
+T11670.hs:10:42: warning: [-Wpartial-type-signatures (in -Wdefault)]
+ • Found type wildcard ‘_’ standing for ‘CLong’
+ • In an expression type signature: IO _
+ In the expression: peekElemOff undefined 0 :: IO _
+ In an equation for ‘T11670.peek’:
+ T11670.peek ptr = peekElemOff undefined 0 :: IO _
+ • Relevant bindings include
+ ptr :: Ptr a (bound at T11670.hs:10:6)
+ peek :: Ptr a -> IO CLong (bound at T11670.hs:10:1)
+
+T11670.hs:13:40: warning: [-Wpartial-type-signatures (in -Wdefault)]
+ • Found type wildcard ‘_’ standing for ‘Storable w’
+ Where: ‘w’ is a rigid type variable bound by
+ the inferred type of <expression> :: Storable w => IO w
+ at T11670.hs:13:40-48
+ • In an expression type signature: _ => IO _
+ In the expression: peekElemOff undefined 0 :: _ => IO _
+ In an equation for ‘peek2’:
+ peek2 ptr = peekElemOff undefined 0 :: _ => IO _
+ • Relevant bindings include
+ ptr :: Ptr a (bound at T11670.hs:13:7)
+ peek2 :: Ptr a -> IO CLong (bound at T11670.hs:13:1)
+
+T11670.hs:13:48: warning: [-Wpartial-type-signatures (in -Wdefault)]
+ • Found type wildcard ‘_’ standing for ‘w’
+ Where: ‘w’ is a rigid type variable bound by
+ the inferred type of <expression> :: Storable w => IO w
+ at T11670.hs:13:40-48
+ • In an expression type signature: _ => IO _
+ In the expression: peekElemOff undefined 0 :: _ => IO _
+ In an equation for ‘peek2’:
+ peek2 ptr = peekElemOff undefined 0 :: _ => IO _
+ • Relevant bindings include
+ ptr :: Ptr a (bound at T11670.hs:13:7)
+ peek2 :: Ptr a -> IO CLong (bound at T11670.hs:13:1)
diff --git a/testsuite/tests/partial-sigs/should_compile/T12033.hs b/testsuite/tests/partial-sigs/should_compile/T12033.hs
new file mode 100644
index 0000000000..9d47ec6541
--- /dev/null
+++ b/testsuite/tests/partial-sigs/should_compile/T12033.hs
@@ -0,0 +1,13 @@
+{-# LANGUAGE TypeFamilies, PartialTypeSignatures #-}
+
+-- In Trac #12033 this was called HsakellBug.hs
+
+module T12033 where
+tripleStoreToRuleSet :: v -> v
+tripleStoreToRuleSet getAtom
+ = makeTuple getAtom
+ where
+ makeRule v = makeExpression v
+ makeTuple v = makeExpression v
+ makeExpression :: _
+ makeExpression v = makeTuple getAtom
diff --git a/testsuite/tests/partial-sigs/should_compile/T12033.stderr b/testsuite/tests/partial-sigs/should_compile/T12033.stderr
new file mode 100644
index 0000000000..02a1233559
--- /dev/null
+++ b/testsuite/tests/partial-sigs/should_compile/T12033.stderr
@@ -0,0 +1,24 @@
+
+T12033.hs:12:22: warning: [-Wpartial-type-signatures (in -Wdefault)]
+ • Found type wildcard ‘_’ standing for ‘v -> t’
+ Where: ‘t’ is a rigid type variable bound by
+ the inferred type of
+ makeTuple :: v -> t
+ makeExpression :: v -> t
+ at T12033.hs:(11,4)-(13,39)
+ ‘v’ is a rigid type variable bound by
+ the type signature for:
+ tripleStoreToRuleSet :: forall v. v -> v
+ at T12033.hs:6:1-30
+ • In the type signature: makeExpression :: _
+ In an equation for ‘tripleStoreToRuleSet’:
+ tripleStoreToRuleSet getAtom
+ = makeTuple getAtom
+ where
+ makeRule v = makeExpression v
+ makeTuple v = makeExpression v
+ makeExpression :: _
+ makeExpression v = makeTuple getAtom
+ • Relevant bindings include
+ getAtom :: v (bound at T12033.hs:7:22)
+ tripleStoreToRuleSet :: v -> v (bound at T12033.hs:7:1)
diff --git a/testsuite/tests/partial-sigs/should_compile/Uncurry.stderr b/testsuite/tests/partial-sigs/should_compile/Uncurry.stderr
index be6dd3bdf0..bd9ac50bd7 100644
--- a/testsuite/tests/partial-sigs/should_compile/Uncurry.stderr
+++ b/testsuite/tests/partial-sigs/should_compile/Uncurry.stderr
@@ -1,5 +1,5 @@
TYPE SIGNATURES
- unc :: forall t t1 t2. (t2 -> t1 -> t) -> (t2, t1) -> t
+ unc :: forall w w1 w2. (w2 -> w1 -> w) -> (w2, w1) -> w
TYPE CONSTRUCTORS
COERCION AXIOMS
Dependent modules: []
diff --git a/testsuite/tests/partial-sigs/should_compile/UncurryNamed.stderr b/testsuite/tests/partial-sigs/should_compile/UncurryNamed.stderr
index 8951f4490a..b73f5669a0 100644
--- a/testsuite/tests/partial-sigs/should_compile/UncurryNamed.stderr
+++ b/testsuite/tests/partial-sigs/should_compile/UncurryNamed.stderr
@@ -1,5 +1,5 @@
TYPE SIGNATURES
- unc :: forall t b a. (a -> b -> t) -> (a, b) -> t
+ unc :: forall w b a. (a -> b -> w) -> (a, b) -> w
TYPE CONSTRUCTORS
COERCION AXIOMS
Dependent modules: []
diff --git a/testsuite/tests/partial-sigs/should_compile/WarningWildcardInstantiations.stderr b/testsuite/tests/partial-sigs/should_compile/WarningWildcardInstantiations.stderr
index fe80ce4b7b..60b5b11bde 100644
--- a/testsuite/tests/partial-sigs/should_compile/WarningWildcardInstantiations.stderr
+++ b/testsuite/tests/partial-sigs/should_compile/WarningWildcardInstantiations.stderr
@@ -1,60 +1,50 @@
-TYPE SIGNATURES
- bar :: forall t t1. t1 -> (t1 -> t) -> t
- foo :: forall a. (Show a, Enum a) => a -> String
-TYPE CONSTRUCTORS
-COERCION AXIOMS
-Dependent modules: []
-Dependent packages: [base-4.9.0.0, ghc-prim-0.5.0.0,
- integer-gmp-1.0.0.1]
-
-WarningWildcardInstantiations.hs:5:14: warning: [-Wpartial-type-signatures (in -Wdefault)]
- • Found type wildcard ‘_a’ standing for ‘a’
- Where: ‘a’ is a rigid type variable bound by
- the inferred type of foo :: (Show a, Enum a) => a -> String
- at WarningWildcardInstantiations.hs:6:1
- • In the type signature: foo :: (Show _a, _) => _a -> _
- • Relevant bindings include
- foo :: a -> String (bound at WarningWildcardInstantiations.hs:6:1)
-
-WarningWildcardInstantiations.hs:5:18: warning: [-Wpartial-type-signatures (in -Wdefault)]
- Found constraint wildcard ‘_’ standing for ‘Enum a’
- In the type signature: foo :: (Show _a, _) => _a -> _
-
-WarningWildcardInstantiations.hs:5:30: warning: [-Wpartial-type-signatures (in -Wdefault)]
- • Found type wildcard ‘_’ standing for ‘String’
- • In the type signature: foo :: (Show _a, _) => _a -> _
- • Relevant bindings include
- foo :: a -> String (bound at WarningWildcardInstantiations.hs:6:1)
-
-WarningWildcardInstantiations.hs:8:8: warning: [-Wpartial-type-signatures (in -Wdefault)]
- • Found type wildcard ‘_’ standing for ‘t1’
- Where: ‘t1’ is a rigid type variable bound by
- the inferred type of bar :: t1 -> (t1 -> t) -> t
- at WarningWildcardInstantiations.hs:9:1
- • In the type signature: bar :: _ -> _ -> _
- • Relevant bindings include
- bar :: t1 -> (t1 -> t) -> t
- (bound at WarningWildcardInstantiations.hs:9:1)
-
-WarningWildcardInstantiations.hs:8:13: warning: [-Wpartial-type-signatures (in -Wdefault)]
- • Found type wildcard ‘_’ standing for ‘t1 -> t’
- Where: ‘t’ is a rigid type variable bound by
- the inferred type of bar :: t1 -> (t1 -> t) -> t
- at WarningWildcardInstantiations.hs:9:1
- ‘t1’ is a rigid type variable bound by
- the inferred type of bar :: t1 -> (t1 -> t) -> t
- at WarningWildcardInstantiations.hs:9:1
- • In the type signature: bar :: _ -> _ -> _
- • Relevant bindings include
- bar :: t1 -> (t1 -> t) -> t
- (bound at WarningWildcardInstantiations.hs:9:1)
-
-WarningWildcardInstantiations.hs:8:18: warning: [-Wpartial-type-signatures (in -Wdefault)]
- • Found type wildcard ‘_’ standing for ‘t’
- Where: ‘t’ is a rigid type variable bound by
- the inferred type of bar :: t1 -> (t1 -> t) -> t
- at WarningWildcardInstantiations.hs:9:1
- • In the type signature: bar :: _ -> _ -> _
- • Relevant bindings include
- bar :: t1 -> (t1 -> t) -> t
- (bound at WarningWildcardInstantiations.hs:9:1)
+TYPE SIGNATURES
+ bar :: forall w t. t -> (t -> w) -> w
+ foo :: forall a. (Show a, Enum a) => a -> String
+TYPE CONSTRUCTORS
+COERCION AXIOMS
+Dependent modules: []
+Dependent packages: [base-4.9.0.0, ghc-prim-0.5.0.0,
+ integer-gmp-1.0.0.1]
+
+WarningWildcardInstantiations.hs:5:14: warning: [-Wpartial-type-signatures (in -Wdefault)]
+ • Found type wildcard ‘_a’ standing for ‘a’
+ Where: ‘a’ is a rigid type variable bound by
+ the inferred type of foo :: (Show a, Enum a) => a -> String
+ at WarningWildcardInstantiations.hs:6:1-21
+ • In the type signature: foo :: (Show _a, _) => _a -> _
+
+WarningWildcardInstantiations.hs:5:18: warning: [-Wpartial-type-signatures (in -Wdefault)]
+ • Found type wildcard ‘_’ standing for ‘Enum a’
+ Where: ‘a’ is a rigid type variable bound by
+ the inferred type of foo :: (Show a, Enum a) => a -> String
+ at WarningWildcardInstantiations.hs:6:1-21
+ • In the type signature: foo :: (Show _a, _) => _a -> _
+
+WarningWildcardInstantiations.hs:5:30: warning: [-Wpartial-type-signatures (in -Wdefault)]
+ • Found type wildcard ‘_’ standing for ‘String’
+ • In the type signature: foo :: (Show _a, _) => _a -> _
+
+WarningWildcardInstantiations.hs:8:8: warning: [-Wpartial-type-signatures (in -Wdefault)]
+ • Found type wildcard ‘_’ standing for ‘t’
+ Where: ‘t’ is a rigid type variable bound by
+ the inferred type of bar :: t -> (t -> w) -> w
+ at WarningWildcardInstantiations.hs:9:1-13
+ • In the type signature: bar :: _ -> _ -> _
+
+WarningWildcardInstantiations.hs:8:13: warning: [-Wpartial-type-signatures (in -Wdefault)]
+ • Found type wildcard ‘_’ standing for ‘t -> w’
+ Where: ‘w’ is a rigid type variable bound by
+ the inferred type of bar :: t -> (t -> w) -> w
+ at WarningWildcardInstantiations.hs:9:1-13
+ ‘t’ is a rigid type variable bound by
+ the inferred type of bar :: t -> (t -> w) -> w
+ at WarningWildcardInstantiations.hs:9:1-13
+ • In the type signature: bar :: _ -> _ -> _
+
+WarningWildcardInstantiations.hs:8:18: warning: [-Wpartial-type-signatures (in -Wdefault)]
+ • Found type wildcard ‘_’ standing for ‘w’
+ Where: ‘w’ is a rigid type variable bound by
+ the inferred type of bar :: t -> (t -> w) -> w
+ at WarningWildcardInstantiations.hs:9:1-13
+ • In the type signature: bar :: _ -> _ -> _
diff --git a/testsuite/tests/partial-sigs/should_compile/all.T b/testsuite/tests/partial-sigs/should_compile/all.T
index 18895ad551..262bf7e794 100644
--- a/testsuite/tests/partial-sigs/should_compile/all.T
+++ b/testsuite/tests/partial-sigs/should_compile/all.T
@@ -60,4 +60,7 @@ test('T10463', normal, compile, [''])
test('ExprSigLocal', normal, compile, [''])
test('T11016', normal, compile, [''])
test('T11192', normal, compile, [''])
-test('SuperCls', normal, compile, ['']) \ No newline at end of file
+test('SuperCls', normal, compile, [''])
+test('T12033', normal, compile, [''])
+test('T11339a', normal, compile, [''])
+test('T11670', normal, compile, [''])
diff --git a/testsuite/tests/partial-sigs/should_fail/Defaulting1MROff.stderr b/testsuite/tests/partial-sigs/should_fail/Defaulting1MROff.stderr
index 460bc63a44..98fd37770b 100644
--- a/testsuite/tests/partial-sigs/should_fail/Defaulting1MROff.stderr
+++ b/testsuite/tests/partial-sigs/should_fail/Defaulting1MROff.stderr
@@ -1,7 +1,4 @@
-
-Defaulting1MROff.hs:7:10: warning: [-Wpartial-type-signatures (in -Wdefault)]
- • Found type wildcard ‘_’ standing for ‘Integer’
- • In the type signature:
- alpha :: _
- • Relevant bindings include
- alpha :: Integer (bound at Defaulting1MROff.hs:8:1)
+
+Defaulting1MROff.hs:7:10: warning: [-Wpartial-type-signatures (in -Wdefault)]
+ • Found type wildcard ‘_’ standing for ‘Integer’
+ • In the type signature: alpha :: _
diff --git a/testsuite/tests/partial-sigs/should_fail/ExtraConstraintsWildcardInExpressionSignature.hs b/testsuite/tests/partial-sigs/should_fail/ExtraConstraintsWildcardInExpressionSignature.hs
index 8a7ce369e8..ed653c1f64 100644
--- a/testsuite/tests/partial-sigs/should_fail/ExtraConstraintsWildcardInExpressionSignature.hs
+++ b/testsuite/tests/partial-sigs/should_fail/ExtraConstraintsWildcardInExpressionSignature.hs
@@ -1,3 +1,5 @@
+{-# LANGUAGE PartialTypeSignatures #-}
+
module ExtraConstraintsWildcardInExpressionSignature where
foo x y = ((==) :: _ => _) x y
diff --git a/testsuite/tests/partial-sigs/should_fail/ExtraConstraintsWildcardInExpressionSignature.stderr b/testsuite/tests/partial-sigs/should_fail/ExtraConstraintsWildcardInExpressionSignature.stderr
index 9f04fc2cf2..b634ec4eb7 100644
--- a/testsuite/tests/partial-sigs/should_fail/ExtraConstraintsWildcardInExpressionSignature.stderr
+++ b/testsuite/tests/partial-sigs/should_fail/ExtraConstraintsWildcardInExpressionSignature.stderr
@@ -1,4 +1,32 @@
-
-ExtraConstraintsWildcardInExpressionSignature.hs:3:20: error:
- Extra-constraint wildcard ‘_’ not allowed
- in an expression type signature
+
+ExtraConstraintsWildcardInExpressionSignature.hs:5:20: warning: [-Wpartial-type-signatures (in -Wdefault)]
+ • Found type wildcard ‘_’ standing for ‘Eq a1’
+ Where: ‘a1’ is a rigid type variable bound by
+ the inferred type of <expression> :: Eq a1 => a1 -> a1 -> Bool
+ at ExtraConstraintsWildcardInExpressionSignature.hs:5:20-25
+ • In an expression type signature: _ => _
+ In the expression: (==) :: _ => _
+ In the expression: ((==) :: _ => _) x y
+ • Relevant bindings include
+ y :: a
+ (bound at ExtraConstraintsWildcardInExpressionSignature.hs:5:7)
+ x :: a
+ (bound at ExtraConstraintsWildcardInExpressionSignature.hs:5:5)
+ foo :: a -> a -> Bool
+ (bound at ExtraConstraintsWildcardInExpressionSignature.hs:5:1)
+
+ExtraConstraintsWildcardInExpressionSignature.hs:5:25: warning: [-Wpartial-type-signatures (in -Wdefault)]
+ • Found type wildcard ‘_’ standing for ‘a1 -> a1 -> Bool’
+ Where: ‘a1’ is a rigid type variable bound by
+ the inferred type of <expression> :: Eq a1 => a1 -> a1 -> Bool
+ at ExtraConstraintsWildcardInExpressionSignature.hs:5:20-25
+ • In an expression type signature: _ => _
+ In the expression: (==) :: _ => _
+ In the expression: ((==) :: _ => _) x y
+ • Relevant bindings include
+ y :: a
+ (bound at ExtraConstraintsWildcardInExpressionSignature.hs:5:7)
+ x :: a
+ (bound at ExtraConstraintsWildcardInExpressionSignature.hs:5:5)
+ foo :: a -> a -> Bool
+ (bound at ExtraConstraintsWildcardInExpressionSignature.hs:5:1)
diff --git a/testsuite/tests/partial-sigs/should_fail/ExtraConstraintsWildcardNotEnabled.stderr b/testsuite/tests/partial-sigs/should_fail/ExtraConstraintsWildcardNotEnabled.stderr
index d1dee083dd..0790605837 100644
--- a/testsuite/tests/partial-sigs/should_fail/ExtraConstraintsWildcardNotEnabled.stderr
+++ b/testsuite/tests/partial-sigs/should_fail/ExtraConstraintsWildcardNotEnabled.stderr
@@ -1,6 +1,8 @@
-
-ExtraConstraintsWildcardNotEnabled.hs:4:10: error:
- Found constraint wildcard ‘_’ standing for ‘Show a’
- To use the inferred type, enable PartialTypeSignatures
- In the type signature:
- show' :: _ => a -> String
+
+ExtraConstraintsWildcardNotEnabled.hs:4:10: error:
+ • Found type wildcard ‘_’ standing for ‘Show a’
+ Where: ‘a’ is a rigid type variable bound by
+ the inferred type of show' :: Show a => a -> String
+ at ExtraConstraintsWildcardNotEnabled.hs:5:1-16
+ To use the inferred type, enable PartialTypeSignatures
+ • In the type signature: show' :: _ => a -> String
diff --git a/testsuite/tests/partial-sigs/should_fail/InstantiatedNamedWildcardsInConstraints.stderr b/testsuite/tests/partial-sigs/should_fail/InstantiatedNamedWildcardsInConstraints.stderr
index 2df15443c9..ed33f25d47 100644
--- a/testsuite/tests/partial-sigs/should_fail/InstantiatedNamedWildcardsInConstraints.stderr
+++ b/testsuite/tests/partial-sigs/should_fail/InstantiatedNamedWildcardsInConstraints.stderr
@@ -1,18 +1,16 @@
-
-InstantiatedNamedWildcardsInConstraints.hs:4:14: error:
- • Found type wildcard ‘_a’ standing for ‘b’
- Where: ‘b’ is a rigid type variable bound by
- the inferred type of foo :: (Enum b, Show b) => b -> (String, b)
- at InstantiatedNamedWildcardsInConstraints.hs:4:8
- To use the inferred type, enable PartialTypeSignatures
- • In the type signature:
- foo :: (Enum _a, _) => _a -> (String, b)
- • Relevant bindings include
- foo :: b -> (String, b)
- (bound at InstantiatedNamedWildcardsInConstraints.hs:5:1)
-
-InstantiatedNamedWildcardsInConstraints.hs:4:18: error:
- Found constraint wildcard ‘_’ standing for ‘Show b’
- To use the inferred type, enable PartialTypeSignatures
- In the type signature:
- foo :: (Enum _a, _) => _a -> (String, b)
+
+InstantiatedNamedWildcardsInConstraints.hs:4:14: error:
+ • Found type wildcard ‘_a’ standing for ‘b’
+ Where: ‘b’ is a rigid type variable bound by
+ the inferred type of foo :: (Enum b, Show b) => b -> (String, b)
+ at InstantiatedNamedWildcardsInConstraints.hs:5:1-26
+ To use the inferred type, enable PartialTypeSignatures
+ • In the type signature: foo :: (Enum _a, _) => _a -> (String, b)
+
+InstantiatedNamedWildcardsInConstraints.hs:4:18: error:
+ • Found type wildcard ‘_’ standing for ‘Show b’
+ Where: ‘b’ is a rigid type variable bound by
+ the inferred type of foo :: (Enum b, Show b) => b -> (String, b)
+ at InstantiatedNamedWildcardsInConstraints.hs:5:1-26
+ To use the inferred type, enable PartialTypeSignatures
+ • In the type signature: foo :: (Enum _a, _) => _a -> (String, b)
diff --git a/testsuite/tests/partial-sigs/should_fail/NamedExtraConstraintsWildcard.stderr b/testsuite/tests/partial-sigs/should_fail/NamedExtraConstraintsWildcard.stderr
index 5d95186909..0019ec85da 100644
--- a/testsuite/tests/partial-sigs/should_fail/NamedExtraConstraintsWildcard.stderr
+++ b/testsuite/tests/partial-sigs/should_fail/NamedExtraConstraintsWildcard.stderr
@@ -1,11 +1,11 @@
NamedExtraConstraintsWildcard.hs:5:1: error:
- • Could not deduce: t0
- from the context: (Eq a, t)
+ • Could not deduce: w0
+ from the context: (Eq a, w)
bound by the inferred type for ‘foo’:
- (Eq a, t) => a -> a
+ (Eq a, w) => a -> a
at NamedExtraConstraintsWildcard.hs:5:1-15
• In the ambiguity check for the inferred type for ‘foo’
To defer the ambiguity check to use sites, enable AllowAmbiguousTypes
When checking the inferred type
- foo :: forall (t :: Constraint) a. (Eq a, t) => a -> a
+ foo :: forall (w :: Constraint) a. (Eq a, w) => a -> a
diff --git a/testsuite/tests/partial-sigs/should_fail/NamedWildcardExplicitForall.stderr b/testsuite/tests/partial-sigs/should_fail/NamedWildcardExplicitForall.stderr
index 83a9019401..d401382141 100644
--- a/testsuite/tests/partial-sigs/should_fail/NamedWildcardExplicitForall.stderr
+++ b/testsuite/tests/partial-sigs/should_fail/NamedWildcardExplicitForall.stderr
@@ -1,52 +1,41 @@
-
-NamedWildcardExplicitForall.hs:8:7: error:
- • Couldn't match type ‘_a’ with ‘Bool’
- ‘_a’ is a rigid type variable bound by
- the type signature for:
- foo :: forall _a. _a -> _a
- at NamedWildcardExplicitForall.hs:7:15
- Expected type: _a -> _a
- Actual type: Bool -> Bool
- • In the expression: not
- In an equation for ‘foo’: foo = not
- • Relevant bindings include
- foo :: _a -> _a (bound at NamedWildcardExplicitForall.hs:8:1)
-
-NamedWildcardExplicitForall.hs:10:8: error:
- • Found type wildcard ‘_a’ standing for ‘Bool’
- To use the inferred type, enable PartialTypeSignatures
- • In the type signature:
- bar :: _a -> _a
- • Relevant bindings include
- bar :: Bool -> Bool (bound at NamedWildcardExplicitForall.hs:11:1)
-
-NamedWildcardExplicitForall.hs:13:26: error:
- • Found type wildcard ‘_b’ standing for ‘Bool’
- To use the inferred type, enable PartialTypeSignatures
- • In the type signature:
- baz :: forall _a. _a -> _b -> (_a, _b)
- • Relevant bindings include
- baz :: _a -> Bool -> (_a, Bool)
- (bound at NamedWildcardExplicitForall.hs:14:1)
-
-NamedWildcardExplicitForall.hs:14:16: error:
- • Couldn't match expected type ‘Bool’ with actual type ‘_a’
- ‘_a’ is a rigid type variable bound by
- the inferred type of baz :: _a -> Bool -> (_a, Bool)
- at NamedWildcardExplicitForall.hs:13:15
- • In the first argument of ‘not’, namely ‘x’
- In the expression: not x
- In the expression: (not x, not y)
- • Relevant bindings include
- x :: _a (bound at NamedWildcardExplicitForall.hs:14:5)
- baz :: _a -> Bool -> (_a, Bool)
- (bound at NamedWildcardExplicitForall.hs:14:1)
-
-NamedWildcardExplicitForall.hs:16:8: error:
- • Found type wildcard ‘_a’ standing for ‘Bool’
- To use the inferred type, enable PartialTypeSignatures
- • In the type signature:
- qux :: _a -> (forall _a. _a -> _a) -> _a
- • Relevant bindings include
- qux :: Bool -> (forall _a. _a -> _a) -> Bool
- (bound at NamedWildcardExplicitForall.hs:17:1)
+
+NamedWildcardExplicitForall.hs:8:7: error:
+ • Couldn't match type ‘_a’ with ‘Bool’
+ ‘_a’ is a rigid type variable bound by
+ the type signature for:
+ foo :: forall _a. _a -> _a
+ at NamedWildcardExplicitForall.hs:7:1-27
+ Expected type: _a -> _a
+ Actual type: Bool -> Bool
+ • In the expression: not
+ In an equation for ‘foo’: foo = not
+ • Relevant bindings include
+ foo :: _a -> _a (bound at NamedWildcardExplicitForall.hs:8:1)
+
+NamedWildcardExplicitForall.hs:10:8: error:
+ • Found type wildcard ‘_a’ standing for ‘Bool’
+ To use the inferred type, enable PartialTypeSignatures
+ • In the type signature: bar :: _a -> _a
+
+NamedWildcardExplicitForall.hs:13:26: error:
+ • Found type wildcard ‘_b’ standing for ‘Bool’
+ To use the inferred type, enable PartialTypeSignatures
+ • In the type signature: baz :: forall _a. _a -> _b -> (_a, _b)
+
+NamedWildcardExplicitForall.hs:14:16: error:
+ • Couldn't match expected type ‘Bool’ with actual type ‘_a’
+ ‘_a’ is a rigid type variable bound by
+ the inferred type of baz :: _a -> Bool -> (_a, Bool)
+ at NamedWildcardExplicitForall.hs:14:1-24
+ • In the first argument of ‘not’, namely ‘x’
+ In the expression: not x
+ In the expression: (not x, not y)
+ • Relevant bindings include
+ x :: _a (bound at NamedWildcardExplicitForall.hs:14:5)
+ baz :: _a -> Bool -> (_a, Bool)
+ (bound at NamedWildcardExplicitForall.hs:14:1)
+
+NamedWildcardExplicitForall.hs:16:8: error:
+ • Found type wildcard ‘_a’ standing for ‘Bool’
+ To use the inferred type, enable PartialTypeSignatures
+ • In the type signature: qux :: _a -> (forall _a. _a -> _a) -> _a
diff --git a/testsuite/tests/partial-sigs/should_fail/NamedWildcardsEnabled.stderr b/testsuite/tests/partial-sigs/should_fail/NamedWildcardsEnabled.stderr
index 805854a1f2..34bf595a7f 100644
--- a/testsuite/tests/partial-sigs/should_fail/NamedWildcardsEnabled.stderr
+++ b/testsuite/tests/partial-sigs/should_fail/NamedWildcardsEnabled.stderr
@@ -1,16 +1,10 @@
-
-NamedWildcardsEnabled.hs:4:8: error:
- • Found type wildcard ‘_a’ standing for ‘Bool’
- To use the inferred type, enable PartialTypeSignatures
- • In the type signature:
- foo :: _a -> _b
- • Relevant bindings include
- foo :: Bool -> Bool (bound at NamedWildcardsEnabled.hs:5:1)
-
-NamedWildcardsEnabled.hs:4:14: error:
- • Found type wildcard ‘_b’ standing for ‘Bool’
- To use the inferred type, enable PartialTypeSignatures
- • In the type signature:
- foo :: _a -> _b
- • Relevant bindings include
- foo :: Bool -> Bool (bound at NamedWildcardsEnabled.hs:5:1)
+
+NamedWildcardsEnabled.hs:4:8: error:
+ • Found type wildcard ‘_a’ standing for ‘Bool’
+ To use the inferred type, enable PartialTypeSignatures
+ • In the type signature: foo :: _a -> _b
+
+NamedWildcardsEnabled.hs:4:14: error:
+ • Found type wildcard ‘_b’ standing for ‘Bool’
+ To use the inferred type, enable PartialTypeSignatures
+ • In the type signature: foo :: _a -> _b
diff --git a/testsuite/tests/partial-sigs/should_fail/NamedWildcardsNotEnabled.stderr b/testsuite/tests/partial-sigs/should_fail/NamedWildcardsNotEnabled.stderr
index 46cad28a12..baaaf010d7 100644
--- a/testsuite/tests/partial-sigs/should_fail/NamedWildcardsNotEnabled.stderr
+++ b/testsuite/tests/partial-sigs/should_fail/NamedWildcardsNotEnabled.stderr
@@ -1,24 +1,24 @@
-
-NamedWildcardsNotEnabled.hs:4:9: error:
- • Couldn't match expected type ‘_b’ with actual type ‘Bool’
- ‘_b’ is a rigid type variable bound by
- the type signature for:
- foo :: forall _a _b. _a -> _b
- at NamedWildcardsNotEnabled.hs:3:8
- • In the expression: not x
- In an equation for ‘foo’: foo x = not x
- • Relevant bindings include
- foo :: _a -> _b (bound at NamedWildcardsNotEnabled.hs:4:1)
-
-NamedWildcardsNotEnabled.hs:4:13: error:
- • Couldn't match expected type ‘Bool’ with actual type ‘_a’
- ‘_a’ is a rigid type variable bound by
- the type signature for:
- foo :: forall _a _b. _a -> _b
- at NamedWildcardsNotEnabled.hs:3:8
- • In the first argument of ‘not’, namely ‘x’
- In the expression: not x
- In an equation for ‘foo’: foo x = not x
- • Relevant bindings include
- x :: _a (bound at NamedWildcardsNotEnabled.hs:4:5)
- foo :: _a -> _b (bound at NamedWildcardsNotEnabled.hs:4:1)
+
+NamedWildcardsNotEnabled.hs:4:9: error:
+ • Couldn't match expected type ‘_b’ with actual type ‘Bool’
+ ‘_b’ is a rigid type variable bound by
+ the type signature for:
+ foo :: forall _a _b. _a -> _b
+ at NamedWildcardsNotEnabled.hs:3:1-15
+ • In the expression: not x
+ In an equation for ‘foo’: foo x = not x
+ • Relevant bindings include
+ foo :: _a -> _b (bound at NamedWildcardsNotEnabled.hs:4:1)
+
+NamedWildcardsNotEnabled.hs:4:13: error:
+ • Couldn't match expected type ‘Bool’ with actual type ‘_a’
+ ‘_a’ is a rigid type variable bound by
+ the type signature for:
+ foo :: forall _a _b. _a -> _b
+ at NamedWildcardsNotEnabled.hs:3:1-15
+ • In the first argument of ‘not’, namely ‘x’
+ In the expression: not x
+ In an equation for ‘foo’: foo x = not x
+ • Relevant bindings include
+ x :: _a (bound at NamedWildcardsNotEnabled.hs:4:5)
+ foo :: _a -> _b (bound at NamedWildcardsNotEnabled.hs:4:1)
diff --git a/testsuite/tests/partial-sigs/should_fail/NamedWildcardsNotInMonotype.stderr b/testsuite/tests/partial-sigs/should_fail/NamedWildcardsNotInMonotype.stderr
index 244b470e81..20176895eb 100644
--- a/testsuite/tests/partial-sigs/should_fail/NamedWildcardsNotInMonotype.stderr
+++ b/testsuite/tests/partial-sigs/should_fail/NamedWildcardsNotInMonotype.stderr
@@ -1,12 +1,12 @@
-
-NamedWildcardsNotInMonotype.hs:5:1: error:
- • Could not deduce (Eq t0)
- from the context: (Show a, Eq t, Eq a)
- bound by the inferred type for ‘foo’:
- (Show a, Eq t, Eq a) => a -> a -> String
- at NamedWildcardsNotInMonotype.hs:5:1-33
- The type variable ‘t0’ is ambiguous
- • In the ambiguity check for the inferred type for ‘foo’
- To defer the ambiguity check to use sites, enable AllowAmbiguousTypes
- When checking the inferred type
- foo :: forall t a. (Show a, Eq t, Eq a) => a -> a -> String
+
+NamedWildcardsNotInMonotype.hs:5:1: error:
+ • Could not deduce (Eq w0)
+ from the context: (Show a, Eq w, Eq a)
+ bound by the inferred type for ‘foo’:
+ (Show a, Eq w, Eq a) => a -> a -> String
+ at NamedWildcardsNotInMonotype.hs:5:1-33
+ The type variable ‘w0’ is ambiguous
+ • In the ambiguity check for the inferred type for ‘foo’
+ To defer the ambiguity check to use sites, enable AllowAmbiguousTypes
+ When checking the inferred type
+ foo :: forall w a. (Show a, Eq w, Eq a) => a -> a -> String
diff --git a/testsuite/tests/partial-sigs/should_fail/PartialTypeSignaturesDisabled.stderr b/testsuite/tests/partial-sigs/should_fail/PartialTypeSignaturesDisabled.stderr
index 025379a67d..91a8dbe7fd 100644
--- a/testsuite/tests/partial-sigs/should_fail/PartialTypeSignaturesDisabled.stderr
+++ b/testsuite/tests/partial-sigs/should_fail/PartialTypeSignaturesDisabled.stderr
@@ -1,16 +1,10 @@
-
-PartialTypeSignaturesDisabled.hs:4:8: error:
- • Found type wildcard ‘_’ standing for ‘Bool’
- To use the inferred type, enable PartialTypeSignatures
- • In the type signature:
- foo :: _ -> _
- • Relevant bindings include
- foo :: Bool -> Bool (bound at PartialTypeSignaturesDisabled.hs:5:1)
-
-PartialTypeSignaturesDisabled.hs:4:13: error:
- • Found type wildcard ‘_’ standing for ‘Bool’
- To use the inferred type, enable PartialTypeSignatures
- • In the type signature:
- foo :: _ -> _
- • Relevant bindings include
- foo :: Bool -> Bool (bound at PartialTypeSignaturesDisabled.hs:5:1)
+
+PartialTypeSignaturesDisabled.hs:4:8: error:
+ • Found type wildcard ‘_’ standing for ‘Bool’
+ To use the inferred type, enable PartialTypeSignatures
+ • In the type signature: foo :: _ -> _
+
+PartialTypeSignaturesDisabled.hs:4:13: error:
+ • Found type wildcard ‘_’ standing for ‘Bool’
+ To use the inferred type, enable PartialTypeSignatures
+ • In the type signature: foo :: _ -> _
diff --git a/testsuite/tests/partial-sigs/should_fail/PatBind3.stderr b/testsuite/tests/partial-sigs/should_fail/PatBind3.stderr
index 436777b2d8..c04cfa2315 100644
--- a/testsuite/tests/partial-sigs/should_fail/PatBind3.stderr
+++ b/testsuite/tests/partial-sigs/should_fail/PatBind3.stderr
@@ -1,9 +1,9 @@
PatBind3.hs:6:12: error:
- • Couldn't match type ‘(Bool, t)’ with ‘Char’
- Expected type: Maybe ((Bool, t) -> Char)
- Actual type: Maybe ((Bool, t) -> (Bool, t))
+ • Couldn't match type ‘(Bool, w)’ with ‘Char’
+ Expected type: Maybe ((Bool, w) -> Char)
+ Actual type: Maybe ((Bool, w) -> (Bool, w))
• In the expression: Just id
In a pattern binding: Just foo = Just id
• Relevant bindings include
- foo :: (Bool, t) -> Char (bound at PatBind3.hs:6:6)
+ foo :: (Bool, w) -> Char (bound at PatBind3.hs:6:6)
diff --git a/testsuite/tests/partial-sigs/should_fail/T10045.stderr b/testsuite/tests/partial-sigs/should_fail/T10045.stderr
index d6a3a5ac37..74bfaae357 100644
--- a/testsuite/tests/partial-sigs/should_fail/T10045.stderr
+++ b/testsuite/tests/partial-sigs/should_fail/T10045.stderr
@@ -1,25 +1,23 @@
-
-T10045.hs:6:18: error:
- • Found type wildcard ‘_’ standing for ‘t2 -> Bool -> t1’
- Where: ‘t1’ is a rigid type variable bound by
- the inferred type of copy :: t2 -> Bool -> t1 at T10045.hs:7:10
- ‘t2’ is a rigid type variable bound by
- the inferred type of copy :: t2 -> Bool -> t1 at T10045.hs:7:10
- To use the inferred type, enable PartialTypeSignatures
- • In the type signature:
- copy :: _
- In the expression:
- let
- copy :: _
- copy w from = copy w True
- in copy ws1 False
- In an equation for ‘foo’:
- foo (Meta ws1)
- = let
- copy :: _
- copy w from = copy w True
- in copy ws1 False
- • Relevant bindings include
- copy :: t2 -> Bool -> t1 (bound at T10045.hs:7:10)
- ws1 :: () (bound at T10045.hs:5:11)
- foo :: Meta -> t (bound at T10045.hs:5:1)
+
+T10045.hs:6:18: error:
+ • Found type wildcard ‘_’ standing for ‘t2 -> Bool -> t1’
+ Where: ‘t1’ is a rigid type variable bound by
+ the inferred type of copy :: t2 -> Bool -> t1 at T10045.hs:7:10-34
+ ‘t2’ is a rigid type variable bound by
+ the inferred type of copy :: t2 -> Bool -> t1 at T10045.hs:7:10-34
+ To use the inferred type, enable PartialTypeSignatures
+ • In the type signature: copy :: _
+ In the expression:
+ let
+ copy :: _
+ copy w from = copy w True
+ in copy ws1 False
+ In an equation for ‘foo’:
+ foo (Meta ws1)
+ = let
+ copy :: _
+ copy w from = copy w True
+ in copy ws1 False
+ • Relevant bindings include
+ ws1 :: () (bound at T10045.hs:5:11)
+ foo :: Meta -> t (bound at T10045.hs:5:1)
diff --git a/testsuite/tests/partial-sigs/should_fail/T10615.stderr b/testsuite/tests/partial-sigs/should_fail/T10615.stderr
index 842b2eb10a..9e46dd20d1 100644
--- a/testsuite/tests/partial-sigs/should_fail/T10615.stderr
+++ b/testsuite/tests/partial-sigs/should_fail/T10615.stderr
@@ -1,36 +1,32 @@
-
-T10615.hs:4:7: error:
- • Found type wildcard ‘_’ standing for ‘a1’
- Where: ‘a1’ is an ambiguous type variable
- To use the inferred type, enable PartialTypeSignatures
- • In the type signature:
- f1 :: _ -> f
- • Relevant bindings include f1 :: a1 -> f (bound at T10615.hs:5:1)
-
-T10615.hs:5:6: error:
- • Couldn't match type ‘f’ with ‘b1 -> a1’
- ‘f’ is a rigid type variable bound by
- the inferred type of f1 :: a1 -> f at T10615.hs:4:7
- Expected type: a1 -> f
- Actual type: a1 -> b1 -> a1
- • In the expression: const
- In an equation for ‘f1’: f1 = const
- • Relevant bindings include f1 :: a1 -> f (bound at T10615.hs:5:1)
-
-T10615.hs:7:7: error:
- • Found type wildcard ‘_’ standing for ‘a0’
- Where: ‘a0’ is an ambiguous type variable
- To use the inferred type, enable PartialTypeSignatures
- • In the type signature:
- f2 :: _ -> _f
- • Relevant bindings include f2 :: a0 -> _f (bound at T10615.hs:8:1)
-
-T10615.hs:8:6: error:
- • Couldn't match type ‘_f’ with ‘b0 -> a0’
- ‘_f’ is a rigid type variable bound by
- the inferred type of f2 :: a0 -> _f at T10615.hs:7:7
- Expected type: a0 -> _f
- Actual type: a0 -> b0 -> a0
- • In the expression: const
- In an equation for ‘f2’: f2 = const
- • Relevant bindings include f2 :: a0 -> _f (bound at T10615.hs:8:1)
+
+T10615.hs:4:7: error:
+ • Found type wildcard ‘_’ standing for ‘a1’
+ Where: ‘a1’ is an ambiguous type variable
+ To use the inferred type, enable PartialTypeSignatures
+ • In the type signature: f1 :: _ -> f
+
+T10615.hs:5:6: error:
+ • Couldn't match type ‘f’ with ‘b1 -> a1’
+ ‘f’ is a rigid type variable bound by
+ the inferred type of f1 :: a1 -> f at T10615.hs:5:1-10
+ Expected type: a1 -> f
+ Actual type: a1 -> b1 -> a1
+ • In the expression: const
+ In an equation for ‘f1’: f1 = const
+ • Relevant bindings include f1 :: a1 -> f (bound at T10615.hs:5:1)
+
+T10615.hs:7:7: error:
+ • Found type wildcard ‘_’ standing for ‘a0’
+ Where: ‘a0’ is an ambiguous type variable
+ To use the inferred type, enable PartialTypeSignatures
+ • In the type signature: f2 :: _ -> _f
+
+T10615.hs:8:6: error:
+ • Couldn't match type ‘_f’ with ‘b0 -> a0’
+ ‘_f’ is a rigid type variable bound by
+ the inferred type of f2 :: a0 -> _f at T10615.hs:8:1-10
+ Expected type: a0 -> _f
+ Actual type: a0 -> b0 -> a0
+ • In the expression: const
+ In an equation for ‘f2’: f2 = const
+ • Relevant bindings include f2 :: a0 -> _f (bound at T10615.hs:8:1)
diff --git a/testsuite/tests/partial-sigs/should_fail/T10999.stderr b/testsuite/tests/partial-sigs/should_fail/T10999.stderr
index c74719addf..fff2bdeae9 100644
--- a/testsuite/tests/partial-sigs/should_fail/T10999.stderr
+++ b/testsuite/tests/partial-sigs/should_fail/T10999.stderr
@@ -1,16 +1,34 @@
-
-T10999.hs:5:6: error:
- Found constraint wildcard ‘_’ standing for ‘Ord a’
- To use the inferred type, enable PartialTypeSignatures
- In the type signature:
- f :: _ => () -> _
-
-T10999.hs:5:17: error:
- • Found type wildcard ‘_’ standing for ‘Set.Set a’
- Where: ‘a’ is a rigid type variable bound by
- the inferred type of f :: Ord a => () -> Set.Set a at T10999.hs:6:1
- To use the inferred type, enable PartialTypeSignatures
- • In the type signature:
- f :: _ => () -> _
- • Relevant bindings include
- f :: () -> Set.Set a (bound at T10999.hs:6:1)
+
+T10999.hs:5:6: error:
+ • Found type wildcard ‘_’ standing for ‘Ord a’
+ Where: ‘a’ is a rigid type variable bound by
+ the inferred type of f :: Ord a => () -> Set.Set a
+ at T10999.hs:6:1-28
+ To use the inferred type, enable PartialTypeSignatures
+ • In the type signature: f :: _ => () -> _
+
+T10999.hs:5:17: error:
+ • Found type wildcard ‘_’ standing for ‘Set.Set a’
+ Where: ‘a’ is a rigid type variable bound by
+ the inferred type of f :: Ord a => () -> Set.Set a
+ at T10999.hs:6:1-28
+ To use the inferred type, enable PartialTypeSignatures
+ • In the type signature: f :: _ => () -> _
+
+T10999.hs:8:28: error:
+ • Ambiguous type variable ‘b0’ arising from a use of ‘f’
+ prevents the constraint ‘(Ord b0)’ from being solved.
+ Relevant bindings include g :: [b0] (bound at T10999.hs:8:1)
+ Probable fix: use a type annotation to specify what ‘b0’ should be.
+ These potential instances exist:
+ instance Ord a => Ord (Set.Set a)
+ -- Defined in ‘containers-0.5.7.1:Data.Set.Base’
+ instance Ord Ordering -- Defined in ‘GHC.Classes’
+ instance Ord Integer
+ -- Defined in ‘integer-gmp-1.0.0.1:GHC.Integer.Type’
+ ...plus 23 others
+ ...plus two instances involving out-of-scope types
+ (use -fprint-potential-instances to see them all)
+ • In the second argument of ‘($)’, namely ‘f ()’
+ In the second argument of ‘($)’, namely ‘Set.toList $ f ()’
+ In the expression: map fst $ Set.toList $ f ()
diff --git a/testsuite/tests/partial-sigs/should_fail/T11122.stderr b/testsuite/tests/partial-sigs/should_fail/T11122.stderr
index 4a8b75be4a..9216985a58 100644
--- a/testsuite/tests/partial-sigs/should_fail/T11122.stderr
+++ b/testsuite/tests/partial-sigs/should_fail/T11122.stderr
@@ -1,7 +1,4 @@
-
-T11122.hs:19:18: warning: [-Wpartial-type-signatures (in -Wdefault)]
- • Found type wildcard ‘_’ standing for ‘Int’
- • In the type signature:
- parser :: Parser _
- • Relevant bindings include
- parser :: Parser Int (bound at T11122.hs:21:1)
+
+T11122.hs:19:18: warning: [-Wpartial-type-signatures (in -Wdefault)]
+ • Found type wildcard ‘_’ standing for ‘Int’
+ • In the type signature: parser :: Parser _
diff --git a/testsuite/tests/partial-sigs/should_fail/T11976.stderr b/testsuite/tests/partial-sigs/should_fail/T11976.stderr
index 06320d9aa9..ac7319891e 100644
--- a/testsuite/tests/partial-sigs/should_fail/T11976.stderr
+++ b/testsuite/tests/partial-sigs/should_fail/T11976.stderr
@@ -1,7 +1,7 @@
-
-T11976.hs:7:20: error:
- • Expecting one fewer arguments to ‘Lens t0 t1’
- Expected kind ‘k0 -> *’, but ‘Lens t0 t1’ has kind ‘*’
- • In the type ‘Lens _ _ _’
- In the expression: undefined :: Lens _ _ _
- In an equation for ‘foo’: foo = undefined :: Lens _ _ _
+
+T11976.hs:7:20: error:
+ • Expecting one fewer arguments to ‘Lens w0 w1’
+ Expected kind ‘k0 -> *’, but ‘Lens w0 w1’ has kind ‘*’
+ • In the type ‘Lens _ _ _’
+ In an expression type signature: Lens _ _ _
+ In the expression: undefined :: Lens _ _ _
diff --git a/testsuite/tests/partial-sigs/should_fail/TidyClash.stderr b/testsuite/tests/partial-sigs/should_fail/TidyClash.stderr
index 884a4c0bf4..596abe1160 100644
--- a/testsuite/tests/partial-sigs/should_fail/TidyClash.stderr
+++ b/testsuite/tests/partial-sigs/should_fail/TidyClash.stderr
@@ -1,18 +1,16 @@
TidyClash.hs:8:19: error:
- • Found type wildcard ‘_’ standing for ‘t1’
- Where: ‘t1’ is a rigid type variable bound by
- the inferred type of bar :: w_ -> (w_, t1 -> t) at TidyClash.hs:9:1
+ • Found type wildcard ‘_’ standing for ‘w1’
+ Where: ‘w1’ is a rigid type variable bound by
+ the inferred type of bar :: w_ -> (w_, w1 -> w)
+ at TidyClash.hs:9:1-28
To use the inferred type, enable PartialTypeSignatures
• In the type signature: bar :: w_ -> (w_, _ -> _)
- • Relevant bindings include
- bar :: w_ -> (w_, t1 -> t) (bound at TidyClash.hs:9:1)
TidyClash.hs:8:24: error:
- • Found type wildcard ‘_’ standing for ‘t’
- Where: ‘t’ is a rigid type variable bound by
- the inferred type of bar :: w_ -> (w_, t1 -> t) at TidyClash.hs:9:1
+ • Found type wildcard ‘_’ standing for ‘w’
+ Where: ‘w’ is a rigid type variable bound by
+ the inferred type of bar :: w_ -> (w_, w1 -> w)
+ at TidyClash.hs:9:1-28
To use the inferred type, enable PartialTypeSignatures
• In the type signature: bar :: w_ -> (w_, _ -> _)
- • Relevant bindings include
- bar :: w_ -> (w_, t1 -> t) (bound at TidyClash.hs:9:1)
diff --git a/testsuite/tests/partial-sigs/should_fail/TidyClash2.stderr b/testsuite/tests/partial-sigs/should_fail/TidyClash2.stderr
index f59ab4d6c9..00c3874a4b 100644
--- a/testsuite/tests/partial-sigs/should_fail/TidyClash2.stderr
+++ b/testsuite/tests/partial-sigs/should_fail/TidyClash2.stderr
@@ -1,57 +1,53 @@
TidyClash2.hs:13:20: error:
- • Found type wildcard ‘_’ standing for ‘t2’
- Where: ‘t2’ is a rigid type variable bound by
- the inferred type of barry :: t2 -> t1 -> t at TidyClash2.hs:14:1
+ • Found type wildcard ‘_’ standing for ‘w1’
+ Where: ‘w1’ is a rigid type variable bound by
+ the inferred type of barry :: w1 -> w -> t at TidyClash2.hs:14:1-40
To use the inferred type, enable PartialTypeSignatures
• In the type signature: barry :: forall t. _ -> _ -> t
- • Relevant bindings include
- barry :: t2 -> t1 -> t (bound at TidyClash2.hs:14:1)
TidyClash2.hs:13:25: error:
- • Found type wildcard ‘_’ standing for ‘t1’
- Where: ‘t1’ is a rigid type variable bound by
- the inferred type of barry :: t2 -> t1 -> t at TidyClash2.hs:14:1
+ • Found type wildcard ‘_’ standing for ‘w’
+ Where: ‘w’ is a rigid type variable bound by
+ the inferred type of barry :: w1 -> w -> t at TidyClash2.hs:14:1-40
To use the inferred type, enable PartialTypeSignatures
• In the type signature: barry :: forall t. _ -> _ -> t
- • Relevant bindings include
- barry :: t2 -> t1 -> t (bound at TidyClash2.hs:14:1)
TidyClash2.hs:14:13: error:
- • Found type wildcard ‘_’ standing for ‘t2’
- Where: ‘t2’ is a rigid type variable bound by
- the inferred type of barry :: t2 -> t1 -> t at TidyClash2.hs:14:1
+ • Found type wildcard ‘_’ standing for ‘w1’
+ Where: ‘w1’ is a rigid type variable bound by
+ the inferred type of barry :: w1 -> w -> t at TidyClash2.hs:14:1-40
To use the inferred type, enable PartialTypeSignatures
• In a pattern type signature: _
In the pattern: x :: _
In an equation for ‘barry’:
barry (x :: _) (y :: _) = undefined :: _
• Relevant bindings include
- barry :: t2 -> t1 -> t (bound at TidyClash2.hs:14:1)
+ barry :: w1 -> w -> t (bound at TidyClash2.hs:14:1)
TidyClash2.hs:14:22: error:
- • Found type wildcard ‘_’ standing for ‘t1’
- Where: ‘t1’ is a rigid type variable bound by
- the inferred type of barry :: t2 -> t1 -> t at TidyClash2.hs:14:1
+ • Found type wildcard ‘_’ standing for ‘w’
+ Where: ‘w’ is a rigid type variable bound by
+ the inferred type of barry :: w1 -> w -> t at TidyClash2.hs:14:1-40
To use the inferred type, enable PartialTypeSignatures
• In a pattern type signature: _
In the pattern: y :: _
In an equation for ‘barry’:
barry (x :: _) (y :: _) = undefined :: _
• Relevant bindings include
- x :: t2 (bound at TidyClash2.hs:14:8)
- barry :: t2 -> t1 -> t (bound at TidyClash2.hs:14:1)
+ x :: w1 (bound at TidyClash2.hs:14:8)
+ barry :: w1 -> w -> t (bound at TidyClash2.hs:14:1)
TidyClash2.hs:14:40: error:
- • Found type wildcard ‘_’ standing for ‘t3’
- Where: ‘t3’ is a rigid type variable bound by
- the inferred type of <expression> :: t3 at TidyClash2.hs:14:27
+ • Found type wildcard ‘_’ standing for ‘w2’
+ Where: ‘w2’ is a rigid type variable bound by
+ the inferred type of <expression> :: w2 at TidyClash2.hs:14:40
To use the inferred type, enable PartialTypeSignatures
• In an expression type signature: _
In the expression: undefined :: _
In an equation for ‘barry’:
barry (x :: _) (y :: _) = undefined :: _
• Relevant bindings include
- y :: t1 (bound at TidyClash2.hs:14:17)
- x :: t2 (bound at TidyClash2.hs:14:8)
- barry :: t2 -> t1 -> t (bound at TidyClash2.hs:14:1)
+ y :: w (bound at TidyClash2.hs:14:17)
+ x :: w1 (bound at TidyClash2.hs:14:8)
+ barry :: w1 -> w -> t (bound at TidyClash2.hs:14:1)
diff --git a/testsuite/tests/partial-sigs/should_fail/WildcardInstantiations.stderr b/testsuite/tests/partial-sigs/should_fail/WildcardInstantiations.stderr
index e134fbbcd3..d026cbc70d 100644
--- a/testsuite/tests/partial-sigs/should_fail/WildcardInstantiations.stderr
+++ b/testsuite/tests/partial-sigs/should_fail/WildcardInstantiations.stderr
@@ -1,58 +1,48 @@
-
-WildcardInstantiations.hs:5:14: error:
- • Found type wildcard ‘_a’ standing for ‘a’
- Where: ‘a’ is a rigid type variable bound by
- the inferred type of foo :: (Show a, Enum a) => a -> String
- at WildcardInstantiations.hs:6:1
- To use the inferred type, enable PartialTypeSignatures
- • In the type signature: foo :: (Show _a, _) => _a -> _
- • Relevant bindings include
- foo :: a -> String (bound at WildcardInstantiations.hs:6:1)
-
-WildcardInstantiations.hs:5:18: error:
- Found constraint wildcard ‘_’ standing for ‘Enum a’
- To use the inferred type, enable PartialTypeSignatures
- In the type signature: foo :: (Show _a, _) => _a -> _
-
-WildcardInstantiations.hs:5:30: error:
- • Found type wildcard ‘_’ standing for ‘String’
- To use the inferred type, enable PartialTypeSignatures
- • In the type signature: foo :: (Show _a, _) => _a -> _
- • Relevant bindings include
- foo :: a -> String (bound at WildcardInstantiations.hs:6:1)
-
-WildcardInstantiations.hs:8:8: error:
- • Found type wildcard ‘_’ standing for ‘t1’
- Where: ‘t1’ is a rigid type variable bound by
- the inferred type of bar :: t1 -> (t1 -> t) -> t
- at WildcardInstantiations.hs:9:1
- To use the inferred type, enable PartialTypeSignatures
- • In the type signature: bar :: _ -> _ -> _
- • Relevant bindings include
- bar :: t1 -> (t1 -> t) -> t
- (bound at WildcardInstantiations.hs:9:1)
-
-WildcardInstantiations.hs:8:13: error:
- • Found type wildcard ‘_’ standing for ‘t1 -> t’
- Where: ‘t’ is a rigid type variable bound by
- the inferred type of bar :: t1 -> (t1 -> t) -> t
- at WildcardInstantiations.hs:9:1
- ‘t1’ is a rigid type variable bound by
- the inferred type of bar :: t1 -> (t1 -> t) -> t
- at WildcardInstantiations.hs:9:1
- To use the inferred type, enable PartialTypeSignatures
- • In the type signature: bar :: _ -> _ -> _
- • Relevant bindings include
- bar :: t1 -> (t1 -> t) -> t
- (bound at WildcardInstantiations.hs:9:1)
-
-WildcardInstantiations.hs:8:18: error:
- • Found type wildcard ‘_’ standing for ‘t’
- Where: ‘t’ is a rigid type variable bound by
- the inferred type of bar :: t1 -> (t1 -> t) -> t
- at WildcardInstantiations.hs:9:1
- To use the inferred type, enable PartialTypeSignatures
- • In the type signature: bar :: _ -> _ -> _
- • Relevant bindings include
- bar :: t1 -> (t1 -> t) -> t
- (bound at WildcardInstantiations.hs:9:1)
+
+WildcardInstantiations.hs:5:14: error:
+ • Found type wildcard ‘_a’ standing for ‘a’
+ Where: ‘a’ is a rigid type variable bound by
+ the inferred type of foo :: (Show a, Enum a) => a -> String
+ at WildcardInstantiations.hs:6:1-21
+ To use the inferred type, enable PartialTypeSignatures
+ • In the type signature: foo :: (Show _a, _) => _a -> _
+
+WildcardInstantiations.hs:5:18: error:
+ • Found type wildcard ‘_’ standing for ‘Enum a’
+ Where: ‘a’ is a rigid type variable bound by
+ the inferred type of foo :: (Show a, Enum a) => a -> String
+ at WildcardInstantiations.hs:6:1-21
+ To use the inferred type, enable PartialTypeSignatures
+ • In the type signature: foo :: (Show _a, _) => _a -> _
+
+WildcardInstantiations.hs:5:30: error:
+ • Found type wildcard ‘_’ standing for ‘String’
+ To use the inferred type, enable PartialTypeSignatures
+ • In the type signature: foo :: (Show _a, _) => _a -> _
+
+WildcardInstantiations.hs:8:8: error:
+ • Found type wildcard ‘_’ standing for ‘t’
+ Where: ‘t’ is a rigid type variable bound by
+ the inferred type of bar :: t -> (t -> w) -> w
+ at WildcardInstantiations.hs:9:1-13
+ To use the inferred type, enable PartialTypeSignatures
+ • In the type signature: bar :: _ -> _ -> _
+
+WildcardInstantiations.hs:8:13: error:
+ • Found type wildcard ‘_’ standing for ‘t -> w’
+ Where: ‘w’ is a rigid type variable bound by
+ the inferred type of bar :: t -> (t -> w) -> w
+ at WildcardInstantiations.hs:9:1-13
+ ‘t’ is a rigid type variable bound by
+ the inferred type of bar :: t -> (t -> w) -> w
+ at WildcardInstantiations.hs:9:1-13
+ To use the inferred type, enable PartialTypeSignatures
+ • In the type signature: bar :: _ -> _ -> _
+
+WildcardInstantiations.hs:8:18: error:
+ • Found type wildcard ‘_’ standing for ‘w’
+ Where: ‘w’ is a rigid type variable bound by
+ the inferred type of bar :: t -> (t -> w) -> w
+ at WildcardInstantiations.hs:9:1-13
+ To use the inferred type, enable PartialTypeSignatures
+ • In the type signature: bar :: _ -> _ -> _
diff --git a/testsuite/tests/partial-sigs/should_fail/WildcardsInPatternAndExprSig.stderr b/testsuite/tests/partial-sigs/should_fail/WildcardsInPatternAndExprSig.stderr
index db14490466..44879c9d4f 100644
--- a/testsuite/tests/partial-sigs/should_fail/WildcardsInPatternAndExprSig.stderr
+++ b/testsuite/tests/partial-sigs/should_fail/WildcardsInPatternAndExprSig.stderr
@@ -1,74 +1,74 @@
-
-WildcardsInPatternAndExprSig.hs:4:18: error:
- • Found type wildcard ‘_a’ standing for ‘t’
- Where: ‘t’ is a rigid type variable bound by
- the inferred type of bar :: Maybe [t] -> t -> [t]
- at WildcardsInPatternAndExprSig.hs:4:1
- To use the inferred type, enable PartialTypeSignatures
- • In a pattern type signature: _a
- In the pattern: x :: _a
- In the pattern: [x :: _a]
- • Relevant bindings include
- bar :: Maybe [t] -> t -> [t]
- (bound at WildcardsInPatternAndExprSig.hs:4:1)
-
-WildcardsInPatternAndExprSig.hs:4:25: error:
- • Found type wildcard ‘_’ standing for ‘[t]’
- Where: ‘t’ is a rigid type variable bound by
- the inferred type of bar :: Maybe [t] -> t -> [t]
- at WildcardsInPatternAndExprSig.hs:4:1
- To use the inferred type, enable PartialTypeSignatures
- • In a pattern type signature: _
- In the pattern: [x :: _a] :: _
- In the pattern: Just ([x :: _a] :: _)
- • Relevant bindings include
- bar :: Maybe [t] -> t -> [t]
- (bound at WildcardsInPatternAndExprSig.hs:4:1)
-
-WildcardsInPatternAndExprSig.hs:4:38: error:
- • Found type wildcard ‘_b’ standing for ‘t’
- Where: ‘t’ is a rigid type variable bound by
- the inferred type of bar :: Maybe [t] -> t -> [t]
- at WildcardsInPatternAndExprSig.hs:4:1
- To use the inferred type, enable PartialTypeSignatures
- • In a pattern type signature: Maybe [_b]
- In the pattern: Just ([x :: _a] :: _) :: Maybe [_b]
- In an equation for ‘bar’:
- bar (Just ([x :: _a] :: _) :: Maybe [_b]) (z :: _c)
- = [x, z] :: [_d]
- • Relevant bindings include
- bar :: Maybe [t] -> t -> [t]
- (bound at WildcardsInPatternAndExprSig.hs:4:1)
-
-WildcardsInPatternAndExprSig.hs:4:49: error:
- • Found type wildcard ‘_c’ standing for ‘t’
- Where: ‘t’ is a rigid type variable bound by
- the inferred type of bar :: Maybe [t] -> t -> [t]
- at WildcardsInPatternAndExprSig.hs:4:1
- To use the inferred type, enable PartialTypeSignatures
- • In a pattern type signature: _c
- In the pattern: z :: _c
- In an equation for ‘bar’:
- bar (Just ([x :: _a] :: _) :: Maybe [_b]) (z :: _c)
- = [x, z] :: [_d]
- • Relevant bindings include
- x :: t (bound at WildcardsInPatternAndExprSig.hs:4:13)
- bar :: Maybe [t] -> t -> [t]
- (bound at WildcardsInPatternAndExprSig.hs:4:1)
-
-WildcardsInPatternAndExprSig.hs:4:66: error:
- • Found type wildcard ‘_d’ standing for ‘t’
- Where: ‘t’ is a rigid type variable bound by
- the inferred type of bar :: Maybe [t] -> t -> [t]
- at WildcardsInPatternAndExprSig.hs:4:1
- To use the inferred type, enable PartialTypeSignatures
- • In an expression type signature: [_d]
- In the expression: [x, z] :: [_d]
- In an equation for ‘bar’:
- bar (Just ([x :: _a] :: _) :: Maybe [_b]) (z :: _c)
- = [x, z] :: [_d]
- • Relevant bindings include
- z :: t (bound at WildcardsInPatternAndExprSig.hs:4:44)
- x :: t (bound at WildcardsInPatternAndExprSig.hs:4:13)
- bar :: Maybe [t] -> t -> [t]
- (bound at WildcardsInPatternAndExprSig.hs:4:1)
+
+WildcardsInPatternAndExprSig.hs:4:18: error:
+ • Found type wildcard ‘_a’ standing for ‘w’
+ Where: ‘w’ is a rigid type variable bound by
+ the inferred type of bar :: Maybe [w] -> w -> [w]
+ at WildcardsInPatternAndExprSig.hs:4:1-68
+ To use the inferred type, enable PartialTypeSignatures
+ • In a pattern type signature: _a
+ In the pattern: x :: _a
+ In the pattern: [x :: _a]
+ • Relevant bindings include
+ bar :: Maybe [w] -> w -> [w]
+ (bound at WildcardsInPatternAndExprSig.hs:4:1)
+
+WildcardsInPatternAndExprSig.hs:4:25: error:
+ • Found type wildcard ‘_’ standing for ‘[w]’
+ Where: ‘w’ is a rigid type variable bound by
+ the inferred type of bar :: Maybe [w] -> w -> [w]
+ at WildcardsInPatternAndExprSig.hs:4:1-68
+ To use the inferred type, enable PartialTypeSignatures
+ • In a pattern type signature: _
+ In the pattern: [x :: _a] :: _
+ In the pattern: Just ([x :: _a] :: _)
+ • Relevant bindings include
+ bar :: Maybe [w] -> w -> [w]
+ (bound at WildcardsInPatternAndExprSig.hs:4:1)
+
+WildcardsInPatternAndExprSig.hs:4:38: error:
+ • Found type wildcard ‘_b’ standing for ‘w’
+ Where: ‘w’ is a rigid type variable bound by
+ the inferred type of bar :: Maybe [w] -> w -> [w]
+ at WildcardsInPatternAndExprSig.hs:4:1-68
+ To use the inferred type, enable PartialTypeSignatures
+ • In a pattern type signature: Maybe [_b]
+ In the pattern: Just ([x :: _a] :: _) :: Maybe [_b]
+ In an equation for ‘bar’:
+ bar (Just ([x :: _a] :: _) :: Maybe [_b]) (z :: _c)
+ = [x, z] :: [_d]
+ • Relevant bindings include
+ bar :: Maybe [w] -> w -> [w]
+ (bound at WildcardsInPatternAndExprSig.hs:4:1)
+
+WildcardsInPatternAndExprSig.hs:4:49: error:
+ • Found type wildcard ‘_c’ standing for ‘w’
+ Where: ‘w’ is a rigid type variable bound by
+ the inferred type of bar :: Maybe [w] -> w -> [w]
+ at WildcardsInPatternAndExprSig.hs:4:1-68
+ To use the inferred type, enable PartialTypeSignatures
+ • In a pattern type signature: _c
+ In the pattern: z :: _c
+ In an equation for ‘bar’:
+ bar (Just ([x :: _a] :: _) :: Maybe [_b]) (z :: _c)
+ = [x, z] :: [_d]
+ • Relevant bindings include
+ x :: w (bound at WildcardsInPatternAndExprSig.hs:4:13)
+ bar :: Maybe [w] -> w -> [w]
+ (bound at WildcardsInPatternAndExprSig.hs:4:1)
+
+WildcardsInPatternAndExprSig.hs:4:66: error:
+ • Found type wildcard ‘_d’ standing for ‘w’
+ Where: ‘w’ is a rigid type variable bound by
+ the inferred type of bar :: Maybe [w] -> w -> [w]
+ at WildcardsInPatternAndExprSig.hs:4:1-68
+ To use the inferred type, enable PartialTypeSignatures
+ • In an expression type signature: [_d]
+ In the expression: [x, z] :: [_d]
+ In an equation for ‘bar’:
+ bar (Just ([x :: _a] :: _) :: Maybe [_b]) (z :: _c)
+ = [x, z] :: [_d]
+ • Relevant bindings include
+ z :: w (bound at WildcardsInPatternAndExprSig.hs:4:44)
+ x :: w (bound at WildcardsInPatternAndExprSig.hs:4:13)
+ bar :: Maybe [w] -> w -> [w]
+ (bound at WildcardsInPatternAndExprSig.hs:4:1)
diff --git a/testsuite/tests/partial-sigs/should_fail/all.T b/testsuite/tests/partial-sigs/should_fail/all.T
index 67d59a5ced..e8f5928c45 100644
--- a/testsuite/tests/partial-sigs/should_fail/all.T
+++ b/testsuite/tests/partial-sigs/should_fail/all.T
@@ -1,7 +1,7 @@
test('AnnotatedConstraint', normal, compile_fail, [''])
test('AnnotatedConstraintNotForgotten', normal, compile_fail, [''])
test('Defaulting1MROff', normal, compile, [''])
-test('ExtraConstraintsWildcardInExpressionSignature', normal, compile_fail, [''])
+test('ExtraConstraintsWildcardInExpressionSignature', normal, compile, [''])
test('ExtraConstraintsWildcardInPatternSignature', normal, compile_fail, [''])
test('ExtraConstraintsWildcardInPatternSplice', normal, compile_fail, [''])
test('ExtraConstraintsWildcardInTypeSpliceUsed',
@@ -62,3 +62,4 @@ test('T11122', normal, compile, [''])
test('T11976', normal, compile_fail, [''])
test('PatBind3', normal, compile_fail, [''])
test('T12039', normal, compile_fail, [''])
+
diff --git a/testsuite/tests/patsyn/should_fail/T11010.stderr b/testsuite/tests/patsyn/should_fail/T11010.stderr
index 47492cde3a..1bd83c83b4 100644
--- a/testsuite/tests/patsyn/should_fail/T11010.stderr
+++ b/testsuite/tests/patsyn/should_fail/T11010.stderr
@@ -1,14 +1,14 @@
-
-T11010.hs:9:36: error:
- • Couldn't match type ‘a1’ with ‘Int’
- ‘a1’ is a rigid type variable bound by
- a pattern with constructor:
- Fun :: forall b a. String -> (a -> b) -> Expr a -> Expr b,
- in a pattern synonym declaration
- at T11010.hs:9:26
- Expected type: a -> b
- Actual type: a1 -> b
- • In the declaration for pattern synonym ‘IntFun’
- • Relevant bindings include
- x :: Expr a1 (bound at T11010.hs:9:36)
- f :: a1 -> b (bound at T11010.hs:9:34)
+
+T11010.hs:9:36: error:
+ • Couldn't match type ‘a1’ with ‘Int’
+ ‘a1’ is a rigid type variable bound by
+ a pattern with constructor:
+ Fun :: forall b a. String -> (a -> b) -> Expr a -> Expr b,
+ in a pattern synonym declaration
+ at T11010.hs:9:26-36
+ Expected type: a -> b
+ Actual type: a1 -> b
+ • In the declaration for pattern synonym ‘IntFun’
+ • Relevant bindings include
+ x :: Expr a1 (bound at T11010.hs:9:36)
+ f :: a1 -> b (bound at T11010.hs:9:34)
diff --git a/testsuite/tests/patsyn/should_fail/T11039.stderr b/testsuite/tests/patsyn/should_fail/T11039.stderr
index 9b749d1758..15a56e01ac 100644
--- a/testsuite/tests/patsyn/should_fail/T11039.stderr
+++ b/testsuite/tests/patsyn/should_fail/T11039.stderr
@@ -1,9 +1,9 @@
-
-T11039.hs:8:15: error:
- • Couldn't match type ‘f’ with ‘A’
- ‘f’ is a rigid type variable bound by
- the signature for pattern synonym ‘Q’ at T11039.hs:7:14
- Expected type: f a
- Actual type: A a
- • In the pattern: A a
- In the declaration for pattern synonym ‘Q’
+
+T11039.hs:8:15: error:
+ • Couldn't match type ‘f’ with ‘A’
+ ‘f’ is a rigid type variable bound by
+ the signature for pattern synonym ‘Q’ at T11039.hs:7:14-38
+ Expected type: f a
+ Actual type: A a
+ • In the pattern: A a
+ In the declaration for pattern synonym ‘Q’
diff --git a/testsuite/tests/patsyn/should_fail/T11667.stderr b/testsuite/tests/patsyn/should_fail/T11667.stderr
index 44bf88ced9..0407d00d09 100644
--- a/testsuite/tests/patsyn/should_fail/T11667.stderr
+++ b/testsuite/tests/patsyn/should_fail/T11667.stderr
@@ -1,41 +1,41 @@
-
-T11667.hs:12:22: error:
- • Could not deduce (Num a) arising from the literal ‘42’
- from the context: Eq a
- bound by the signature for pattern synonym ‘Pat1’
- at T11667.hs:12:9-12
- Possible fix:
- add (Num a) to the "required" context of
- the signature for pattern synonym ‘Pat1’
- • In the pattern: 42
- In the pattern: Just 42
- In the declaration for pattern synonym ‘Pat1’
-
-T11667.hs:18:28: error:
- • Couldn't match type ‘b’ with ‘Bool’
- arising from the "provided" constraints claimed by
- the signature of ‘Pat2’
- ‘b’ is a rigid type variable bound by
- the signature for pattern synonym ‘Pat2’ at T11667.hs:17:17
- • In the declaration for pattern synonym ‘Pat2’
- • Relevant bindings include y :: b (bound at T11667.hs:18:21)
-
-T11667.hs:24:24: error:
- • No instance for (Show a)
- arising from the "provided" constraints claimed by
- the signature of ‘Pat3’
- In other words, a successful match on the pattern
- Just x
- does not provide the constraint (Show a)
- • In the declaration for pattern synonym ‘Pat3’
-
-T11667.hs:31:16: error:
- • Could not deduce (Num a) arising from a use of ‘MkS’
- from the context: (Eq a, Show a)
- bound by the signature for pattern synonym ‘Pat4’
- at T11667.hs:31:1-21
- Possible fix:
- add (Num a) to the "required" context of
- the signature for pattern synonym ‘Pat4’
- • In the expression: MkS 42
- In an equation for ‘Pat4’: Pat4 = MkS 42
+
+T11667.hs:12:22: error:
+ • Could not deduce (Num a) arising from the literal ‘42’
+ from the context: Eq a
+ bound by the signature for pattern synonym ‘Pat1’
+ at T11667.hs:12:9-12
+ Possible fix:
+ add (Num a) to the "required" context of
+ the signature for pattern synonym ‘Pat1’
+ • In the pattern: 42
+ In the pattern: Just 42
+ In the declaration for pattern synonym ‘Pat1’
+
+T11667.hs:18:28: error:
+ • Couldn't match type ‘b’ with ‘Bool’
+ arising from the "provided" constraints claimed by
+ the signature of ‘Pat2’
+ ‘b’ is a rigid type variable bound by
+ the signature for pattern synonym ‘Pat2’ at T11667.hs:17:17-50
+ • In the declaration for pattern synonym ‘Pat2’
+ • Relevant bindings include y :: b (bound at T11667.hs:18:21)
+
+T11667.hs:24:24: error:
+ • No instance for (Show a)
+ arising from the "provided" constraints claimed by
+ the signature of ‘Pat3’
+ In other words, a successful match on the pattern
+ Just x
+ does not provide the constraint (Show a)
+ • In the declaration for pattern synonym ‘Pat3’
+
+T11667.hs:31:16: error:
+ • Could not deduce (Num a) arising from a use of ‘MkS’
+ from the context: (Eq a, Show a)
+ bound by the signature for pattern synonym ‘Pat4’
+ at T11667.hs:31:1-21
+ Possible fix:
+ add (Num a) to the "required" context of
+ the signature for pattern synonym ‘Pat4’
+ • In the expression: MkS 42
+ In an equation for ‘Pat4’: Pat4 = MkS 42
diff --git a/testsuite/tests/polykinds/T10503.stderr b/testsuite/tests/polykinds/T10503.stderr
index a74615cd06..8bfdc6bd6d 100644
--- a/testsuite/tests/polykinds/T10503.stderr
+++ b/testsuite/tests/polykinds/T10503.stderr
@@ -1,16 +1,16 @@
-
-T10503.hs:8:6: error:
- • Could not deduce: k ~ *
- from the context: Proxy 'KProxy ~ Proxy 'KProxy
- bound by the type signature for:
- h :: Proxy 'KProxy ~ Proxy 'KProxy => r
- at T10503.hs:8:6-85
- ‘k’ is a rigid type variable bound by
- the type signature for:
- h :: forall k r. (Proxy 'KProxy ~ Proxy 'KProxy => r) -> r
- at T10503.hs:8:6
- • In the ambiguity check for ‘h’
- To defer the ambiguity check to use sites, enable AllowAmbiguousTypes
- In the type signature:
- h :: forall r.
- (Proxy (KProxy :: KProxy k) ~ Proxy (KProxy :: KProxy *) => r) -> r
+
+T10503.hs:8:6: error:
+ • Could not deduce: k ~ *
+ from the context: Proxy 'KProxy ~ Proxy 'KProxy
+ bound by the type signature for:
+ h :: Proxy 'KProxy ~ Proxy 'KProxy => r
+ at T10503.hs:8:6-85
+ ‘k’ is a rigid type variable bound by
+ the type signature for:
+ h :: forall k r. (Proxy 'KProxy ~ Proxy 'KProxy => r) -> r
+ at T10503.hs:8:6-85
+ • In the ambiguity check for ‘h’
+ To defer the ambiguity check to use sites, enable AllowAmbiguousTypes
+ In the type signature:
+ h :: forall r.
+ (Proxy (KProxy :: KProxy k) ~ Proxy (KProxy :: KProxy *) => r) -> r
diff --git a/testsuite/tests/polykinds/T11399.hs b/testsuite/tests/polykinds/T11399.hs
index 56f1faa682..bc9e60d7f3 100644
--- a/testsuite/tests/polykinds/T11399.hs
+++ b/testsuite/tests/polykinds/T11399.hs
@@ -4,4 +4,7 @@ module T11399 where
import Data.Kind
newtype UhOh (k :: * -> *) (a :: k *) = UhOh (k *)
-instance Functor k => Functor (UhOh k) where
+
+-- UhOh :: forall (k : * -> *). k * -> *
+
+instance Functor a => Functor (UhOh a) where
diff --git a/testsuite/tests/polykinds/T11399.stderr b/testsuite/tests/polykinds/T11399.stderr
index 5e09870088..4af1c57b75 100644
--- a/testsuite/tests/polykinds/T11399.stderr
+++ b/testsuite/tests/polykinds/T11399.stderr
@@ -1,9 +1,9 @@
-
-T11399.hs:7:32: error:
- • Couldn't match kind ‘*’ with ‘GHC.Types.RuntimeRep’
- When matching kinds
- k :: * -> *
- TYPE :: GHC.Types.RuntimeRep -> *
- Expected kind ‘* -> *’, but ‘UhOh k’ has kind ‘k * -> *’
- • In the first argument of ‘Functor’, namely ‘UhOh k’
- In the instance declaration for ‘Functor (UhOh k)’
+
+T11399.hs:10:32: error:
+ • Couldn't match kind ‘*’ with ‘GHC.Types.RuntimeRep’
+ When matching kinds
+ a :: * -> *
+ TYPE :: GHC.Types.RuntimeRep -> *
+ Expected kind ‘* -> *’, but ‘UhOh a’ has kind ‘a * -> *’
+ • In the first argument of ‘Functor’, namely ‘UhOh a’
+ In the instance declaration for ‘Functor (UhOh a)’
diff --git a/testsuite/tests/polykinds/T7438.stderr b/testsuite/tests/polykinds/T7438.stderr
index 12d93fcf0f..31ac2a356e 100644
--- a/testsuite/tests/polykinds/T7438.stderr
+++ b/testsuite/tests/polykinds/T7438.stderr
@@ -1,19 +1,21 @@
-
-T7438.hs:6:14: error:
- • Couldn't match expected type ‘t2’ with actual type ‘t3’
- ‘t2’ is untouchable
- inside the constraints: t ~ t1
- bound by a pattern with constructor:
- Nil :: forall k (a :: k). Thrist a a,
- in an equation for ‘go’
- at T7438.hs:6:4-6
- ‘t2’ is a rigid type variable bound by
- the inferred type of go :: Thrist t1 t -> t3 -> t2 at T7438.hs:6:1
- ‘t3’ is a rigid type variable bound by
- the inferred type of go :: Thrist t1 t -> t3 -> t2 at T7438.hs:6:1
- Possible fix: add a type signature for ‘go’
- • In the expression: acc
- In an equation for ‘go’: go Nil acc = acc
- • Relevant bindings include
- acc :: t3 (bound at T7438.hs:6:8)
- go :: Thrist t1 t -> t3 -> t2 (bound at T7438.hs:6:1)
+
+T7438.hs:6:14: error:
+ • Couldn't match expected type ‘t2’ with actual type ‘t3’
+ ‘t2’ is untouchable
+ inside the constraints: t ~ t1
+ bound by a pattern with constructor:
+ Nil :: forall k (a :: k). Thrist a a,
+ in an equation for ‘go’
+ at T7438.hs:6:4-6
+ ‘t2’ is a rigid type variable bound by
+ the inferred type of go :: Thrist t1 t -> t3 -> t2
+ at T7438.hs:6:1-16
+ ‘t3’ is a rigid type variable bound by
+ the inferred type of go :: Thrist t1 t -> t3 -> t2
+ at T7438.hs:6:1-16
+ Possible fix: add a type signature for ‘go’
+ • In the expression: acc
+ In an equation for ‘go’: go Nil acc = acc
+ • Relevant bindings include
+ acc :: t3 (bound at T7438.hs:6:8)
+ go :: Thrist t1 t -> t3 -> t2 (bound at T7438.hs:6:1)
diff --git a/testsuite/tests/polykinds/T7594.stderr b/testsuite/tests/polykinds/T7594.stderr
index be2acfebe0..f3d42af8a0 100644
--- a/testsuite/tests/polykinds/T7594.stderr
+++ b/testsuite/tests/polykinds/T7594.stderr
@@ -1,17 +1,17 @@
-
-T7594.hs:35:12: error:
- • Couldn't match type ‘b’ with ‘IO ()’
- ‘b’ is untouchable
- inside the constraints: (:&:) c0 Real a
- bound by a type expected by the context:
- (:&:) 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
- Possible fix: add a type signature for ‘bar2’
- Expected type: a -> b
- Actual type: a -> IO ()
- • In the first argument of ‘app’, namely ‘print’
- In the expression: app print q2
- In an equation for ‘bar2’: bar2 = app print q2
- • Relevant bindings include bar2 :: b (bound at T7594.hs:35:1)
+
+T7594.hs:35:12: error:
+ • Couldn't match type ‘b’ with ‘IO ()’
+ ‘b’ is untouchable
+ inside the constraints: (:&:) c0 Real a
+ bound by a type expected by the context:
+ (:&:) 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
+ Possible fix: add a type signature for ‘bar2’
+ Expected type: a -> b
+ Actual type: a -> IO ()
+ • In the first argument of ‘app’, namely ‘print’
+ In the expression: app print q2
+ In an equation for ‘bar2’: bar2 = app print q2
+ • Relevant bindings include bar2 :: b (bound at T7594.hs:35:1)
diff --git a/testsuite/tests/polykinds/T9017.stderr b/testsuite/tests/polykinds/T9017.stderr
index b52000e7a1..3e7f60e9b1 100644
--- a/testsuite/tests/polykinds/T9017.stderr
+++ b/testsuite/tests/polykinds/T9017.stderr
@@ -1,13 +1,13 @@
-
-T9017.hs:8:7: error:
- • Couldn't match kind ‘k1’ with ‘*’
- ‘k1’ is a rigid type variable bound by
- the type signature for:
- foo :: forall k k1 (a :: k1 -> k -> *) (b :: k1) (m :: k1 -> k).
- a b (m b)
- at T9017.hs:7:8
- When matching the kind of ‘a’
- • In the expression: arr return
- In an equation for ‘foo’: foo = arr return
- • Relevant bindings include
- foo :: a b (m b) (bound at T9017.hs:8:1)
+
+T9017.hs:8:7: error:
+ • Couldn't match kind ‘k1’ with ‘*’
+ ‘k1’ is a rigid type variable bound by
+ the type signature for:
+ foo :: forall k k1 (a :: k1 -> k -> *) (b :: k1) (m :: k1 -> k).
+ a b (m b)
+ at T9017.hs:7:1-16
+ When matching the kind of ‘a’
+ • In the expression: arr return
+ In an equation for ‘foo’: foo = arr return
+ • Relevant bindings include
+ foo :: a b (m b) (bound at T9017.hs:8:1)
diff --git a/testsuite/tests/rename/should_fail/rnfail026.stderr b/testsuite/tests/rename/should_fail/rnfail026.stderr
index 63a1a2130d..6c032b0487 100644
--- a/testsuite/tests/rename/should_fail/rnfail026.stderr
+++ b/testsuite/tests/rename/should_fail/rnfail026.stderr
@@ -1,10 +1,11 @@
-
-rnfail026.hs:16:27: error:
- • Expected kind ‘* -> *’, but ‘Set a’ has kind ‘*’
- • In the first argument of ‘Monad’, namely
- ‘forall a. Eq a => Set a’
- In the instance declaration for ‘Monad (forall a. Eq a => Set a)’
-
-rnfail026.hs:19:10: error:
- • Illegal polymorphic type: forall a. [a]
- • In the instance declaration for ‘Eq (forall a. [a])’
+
+rnfail026.hs:16:27: error:
+ • Expecting one fewer arguments to ‘Set a’
+ Expected kind ‘* -> *’, but ‘Set a’ has kind ‘*’
+ • In the first argument of ‘Monad’, namely
+ ‘forall a. Eq a => Set a’
+ In the instance declaration for ‘Monad (forall a. Eq a => Set a)’
+
+rnfail026.hs:19:10: error:
+ • Illegal polymorphic type: forall a. [a]
+ • In the instance declaration for ‘Eq (forall a. [a])’
diff --git a/testsuite/tests/th/T10267.stderr b/testsuite/tests/th/T10267.stderr
index 0a86955e1a..171c9e8f3a 100644
--- a/testsuite/tests/th/T10267.stderr
+++ b/testsuite/tests/th/T10267.stderr
@@ -1,46 +1,46 @@
-
-T10267.hs:8:1: error:
- • Found hole: _ :: a0
- Where: ‘a0’ is a rigid type variable bound by
- the type signature for:
- j :: forall a0. a0 -> a0
- at T10267.hs:8:1
- • In the expression: _
- In an equation for ‘j’: j x = _
- • Relevant bindings include
- x :: a0 (bound at T10267.hs:8:1)
- j :: a0 -> a0 (bound at T10267.hs:8:1)
-
-T10267.hs:8:1: error:
- • Found hole: _foo :: a0 -> a0
- Where: ‘a0’ is a rigid type variable bound by
- the type signature for:
- i :: forall a0. a0 -> a0
- at T10267.hs:8:1
- Or perhaps ‘_foo’ is mis-spelled, or not in scope
- • In the expression: _foo
- In an equation for ‘i’: i = _foo
- • Relevant bindings include i :: a0 -> a0 (bound at T10267.hs:8:1)
-
-T10267.hs:14:3: error:
- • Found hole: _foo :: a -> a
- Where: ‘a’ is a rigid type variable bound by
- the type signature for:
- k :: forall a. a -> a
- at T10267.hs:14:3
- Or perhaps ‘_foo’ is mis-spelled, or not in scope
- • In the expression: _foo
- In an equation for ‘k’: k = _foo
- • Relevant bindings include k :: a -> a (bound at T10267.hs:14:3)
-
-T10267.hs:23:3: error:
- • Found hole: _ :: a
- Where: ‘a’ is a rigid type variable bound by
- the type signature for:
- l :: forall a. a -> a
- at T10267.hs:23:3
- • In the expression: _
- In an equation for ‘l’: l x = _
- • Relevant bindings include
- x :: a (bound at T10267.hs:23:3)
- l :: a -> a (bound at T10267.hs:23:3)
+
+T10267.hs:8:1: error:
+ • Found hole: _ :: a
+ Where: ‘a’ is a rigid type variable bound by
+ the type signature for:
+ j :: forall a. a -> a
+ at T10267.hs:(8,1)-(12,14)
+ • In the expression: _
+ In an equation for ‘j’: j x = _
+ • Relevant bindings include
+ x :: a (bound at T10267.hs:8:1)
+ j :: a -> a (bound at T10267.hs:8:1)
+
+T10267.hs:8:1: error:
+ • Found hole: _foo :: a -> a
+ Where: ‘a’ is a rigid type variable bound by
+ the type signature for:
+ i :: forall a. a -> a
+ at T10267.hs:(8,1)-(12,14)
+ Or perhaps ‘_foo’ is mis-spelled, or not in scope
+ • In the expression: _foo
+ In an equation for ‘i’: i = _foo
+ • Relevant bindings include i :: a -> a (bound at T10267.hs:8:1)
+
+T10267.hs:14:3: error:
+ • Found hole: _foo :: a -> a
+ Where: ‘a’ is a rigid type variable bound by
+ the type signature for:
+ k :: forall a. a -> a
+ at T10267.hs:(14,3)-(21,2)
+ Or perhaps ‘_foo’ is mis-spelled, or not in scope
+ • In the expression: _foo
+ In an equation for ‘k’: k = _foo
+ • Relevant bindings include k :: a -> a (bound at T10267.hs:14:3)
+
+T10267.hs:23:3: error:
+ • Found hole: _ :: a
+ Where: ‘a’ is a rigid type variable bound by
+ the type signature for:
+ l :: forall a. a -> a
+ at T10267.hs:(23,3)-(30,2)
+ • In the expression: _
+ In an equation for ‘l’: l x = _
+ • Relevant bindings include
+ x :: a (bound at T10267.hs:23:3)
+ l :: a -> a (bound at T10267.hs:23:3)
diff --git a/testsuite/tests/typecheck/should_compile/ExPat.hs b/testsuite/tests/typecheck/should_compile/ExPat.hs
new file mode 100644
index 0000000000..a0b4b0b007
--- /dev/null
+++ b/testsuite/tests/typecheck/should_compile/ExPat.hs
@@ -0,0 +1,17 @@
+{-# LANGUAGE ViewPatterns, GADTs #-}
+
+module ExPat where
+
+data T where
+ MkT :: Integral a => a -> Int -> T
+
+-- c.f. T11700
+
+-- Succeeds becuase y::Int
+f x = let MkT _ y = x
+ in y
+
+-- Remarkablly, this succeeds because
+-- (toInteger (v::a)) is an Integer
+g x = let MkT (toInteger -> y) _ = x
+ in y
diff --git a/testsuite/tests/typecheck/should_compile/ExPatFail.hs b/testsuite/tests/typecheck/should_compile/ExPatFail.hs
new file mode 100644
index 0000000000..1a25adf388
--- /dev/null
+++ b/testsuite/tests/typecheck/should_compile/ExPatFail.hs
@@ -0,0 +1,13 @@
+{-# LANGUAGE GADTs #-}
+
+module ExPatFail where
+
+data T where
+ MkT :: Integral a => a -> Int -> T
+
+-- Fails becuase y is bound to an existential type
+-- Mind you, the error message is pretty terrible
+-- c.f. T11700
+
+f x = let MkT y _ = x
+ in y
diff --git a/testsuite/tests/typecheck/should_compile/ExPatFail.stderr b/testsuite/tests/typecheck/should_compile/ExPatFail.stderr
new file mode 100644
index 0000000000..afae403614
--- /dev/null
+++ b/testsuite/tests/typecheck/should_compile/ExPatFail.stderr
@@ -0,0 +1,14 @@
+
+ExPatFail.hs:12:15: error:
+ • Couldn't match expected type ‘t’ with actual type ‘a’
+ because type variable ‘a’ would escape its scope
+ This (rigid, skolem) type variable is bound by
+ a pattern with constructor:
+ MkT :: forall a. Integral a => a -> Int -> T,
+ in a pattern binding
+ at ExPatFail.hs:12:11-17
+ • In the pattern: MkT y _
+ In a pattern binding: MkT y _ = x
+ In the expression: let MkT y _ = x in y
+ • Relevant bindings include
+ f :: T -> t (bound at ExPatFail.hs:12:1)
diff --git a/testsuite/tests/typecheck/should_compile/FD1.stderr b/testsuite/tests/typecheck/should_compile/FD1.stderr
index 395217af8b..9223b8e946 100644
--- a/testsuite/tests/typecheck/should_compile/FD1.stderr
+++ b/testsuite/tests/typecheck/should_compile/FD1.stderr
@@ -1,10 +1,10 @@
-
-FD1.hs:16:1: error:
- • Couldn't match expected type ‘a’ with actual type ‘Int -> Int’
- ‘a’ is a rigid type variable bound by
- the type signature for:
- plus :: forall a. E a (Int -> Int) => Int -> a
- at FD1.hs:15:9
- • The equation(s) for ‘plus’ have two arguments,
- but its type ‘Int -> a’ has only one
- • Relevant bindings include plus :: Int -> a (bound at FD1.hs:16:1)
+
+FD1.hs:16:1: error:
+ • Couldn't match expected type ‘a’ with actual type ‘Int -> Int’
+ ‘a’ is a rigid type variable bound by
+ the type signature for:
+ plus :: forall a. E a (Int -> Int) => Int -> a
+ at FD1.hs:15:1-38
+ • The equation(s) for ‘plus’ have two arguments,
+ but its type ‘Int -> a’ has only one
+ • Relevant bindings include plus :: Int -> a (bound at FD1.hs:16:1)
diff --git a/testsuite/tests/typecheck/should_compile/FD2.stderr b/testsuite/tests/typecheck/should_compile/FD2.stderr
index ff3a923988..98de9d7f49 100644
--- a/testsuite/tests/typecheck/should_compile/FD2.stderr
+++ b/testsuite/tests/typecheck/should_compile/FD2.stderr
@@ -1,20 +1,20 @@
-
-FD2.hs:26:36: error:
- • Couldn't match expected type ‘e’ with actual type ‘e1’
- ‘e1’ is a rigid type variable bound by
- the type signature for:
- mf :: forall e1. Elem a e1 => e1 -> Maybe e1 -> Maybe e1
- at FD2.hs:24:18
- ‘e’ is a rigid type variable bound by
- the type signature for:
- foldr1 :: forall e. Elem a e => (e -> e -> e) -> a -> e
- at FD2.hs:21:13
- • In the first argument of ‘f’, namely ‘x’
- In the first argument of ‘Just’, namely ‘(f x y)’
- In the expression: Just (f x y)
- • Relevant bindings include
- y :: e1 (bound at FD2.hs:26:23)
- x :: e1 (bound at FD2.hs:26:15)
- mf :: e1 -> Maybe e1 -> Maybe e1 (bound at FD2.hs:25:12)
- f :: e -> e -> e (bound at FD2.hs:22:10)
- foldr1 :: (e -> e -> e) -> a -> e (bound at FD2.hs:22:3)
+
+FD2.hs:26:36: error:
+ • Couldn't match expected type ‘e’ with actual type ‘e1’
+ ‘e1’ is a rigid type variable bound by
+ the type signature for:
+ mf :: forall e1. Elem a e1 => e1 -> Maybe e1 -> Maybe e1
+ at FD2.hs:24:12-54
+ ‘e’ is a rigid type variable bound by
+ the type signature for:
+ foldr1 :: forall e. Elem a e => (e -> e -> e) -> a -> e
+ at FD2.hs:21:13-47
+ • In the first argument of ‘f’, namely ‘x’
+ In the first argument of ‘Just’, namely ‘(f x y)’
+ In the expression: Just (f x y)
+ • Relevant bindings include
+ y :: e1 (bound at FD2.hs:26:23)
+ x :: e1 (bound at FD2.hs:26:15)
+ mf :: e1 -> Maybe e1 -> Maybe e1 (bound at FD2.hs:25:12)
+ f :: e -> e -> e (bound at FD2.hs:22:10)
+ foldr1 :: (e -> e -> e) -> a -> e (bound at FD2.hs:22:3)
diff --git a/testsuite/tests/typecheck/should_compile/FD3.stderr b/testsuite/tests/typecheck/should_compile/FD3.stderr
index f0dafbe47c..19f819f239 100644
--- a/testsuite/tests/typecheck/should_compile/FD3.stderr
+++ b/testsuite/tests/typecheck/should_compile/FD3.stderr
@@ -1,15 +1,15 @@
-
-FD3.hs:15:15: error:
- • Couldn't match type ‘a’ with ‘(String, a)’
- arising from a functional dependency between:
- constraint ‘MkA (String, a) a’ arising from a use of ‘mkA’
- instance ‘MkA a1 a1’ at FD3.hs:12:10-16
- ‘a’ is a rigid type variable bound by
- the type signature for:
- translate :: forall a. (String, a) -> A a
- at FD3.hs:14:14
- • In the expression: mkA a
- In an equation for ‘translate’: translate a = mkA a
- • Relevant bindings include
- a :: (String, a) (bound at FD3.hs:15:11)
- translate :: (String, a) -> A a (bound at FD3.hs:15:1)
+
+FD3.hs:15:15: error:
+ • Couldn't match type ‘a’ with ‘(String, a)’
+ arising from a functional dependency between:
+ constraint ‘MkA (String, a) a’ arising from a use of ‘mkA’
+ instance ‘MkA a1 a1’ at FD3.hs:12:10-16
+ ‘a’ is a rigid type variable bound by
+ the type signature for:
+ translate :: forall a. (String, a) -> A a
+ at FD3.hs:14:1-31
+ • In the expression: mkA a
+ In an equation for ‘translate’: translate a = mkA a
+ • Relevant bindings include
+ a :: (String, a) (bound at FD3.hs:15:11)
+ translate :: (String, a) -> A a (bound at FD3.hs:15:1)
diff --git a/testsuite/tests/typecheck/should_compile/SigTyVars.hs b/testsuite/tests/typecheck/should_compile/SigTyVars.hs
new file mode 100644
index 0000000000..7950ae7d45
--- /dev/null
+++ b/testsuite/tests/typecheck/should_compile/SigTyVars.hs
@@ -0,0 +1,12 @@
+{-# LANGUAGE ScopedTypeVariables #-}
+
+module SigTyVars where
+
+-- Here the lexically scoped type variables 'a' and 'b'
+-- both map to the same skolem 'x'. It's perhaps a bit
+-- surprising, but it's awkward to prevent, and it seems
+-- easier to leave it.
+
+f :: x -> x -> [x]
+f (x::a) (y::b) = [x::b, y::a]
+
diff --git a/testsuite/tests/typecheck/should_compile/T10072.stderr b/testsuite/tests/typecheck/should_compile/T10072.stderr
index eb14ad8de5..768658133c 100644
--- a/testsuite/tests/typecheck/should_compile/T10072.stderr
+++ b/testsuite/tests/typecheck/should_compile/T10072.stderr
@@ -1,8 +1,8 @@
-
-T10072.hs:3:31: error:
- • Found type wildcard ‘_’ standing for ‘b’
- Where: ‘b’ is a rigid type variable bound by
- the RULE "map/empty" at T10072.hs:3:1
- To use the inferred type, enable PartialTypeSignatures
- • In a RULE for ‘f’: a -> _
- When checking the transformation rule "map/empty"
+
+T10072.hs:3:31: error:
+ • Found type wildcard ‘_’ standing for ‘b’
+ Where: ‘b’ is a rigid type variable bound by
+ the RULE "map/empty" at T10072.hs:3:1-47
+ To use the inferred type, enable PartialTypeSignatures
+ • In a RULE for ‘f’: a -> _
+ When checking the transformation rule "map/empty"
diff --git a/testsuite/tests/typecheck/should_compile/T10632.stderr b/testsuite/tests/typecheck/should_compile/T10632.stderr
index c3d112f6bf..45fd33c7f4 100644
--- a/testsuite/tests/typecheck/should_compile/T10632.stderr
+++ b/testsuite/tests/typecheck/should_compile/T10632.stderr
@@ -1,5 +1,5 @@
-
-T10632.hs:3:1: warning: [-Wredundant-constraints (in -Wall)]
- • Redundant constraint: ?file1::String
- • In the type signature for:
- f :: (?file1::String) => IO ()
+
+T10632.hs:3:1: warning: [-Wredundant-constraints (in -Wall)]
+ • Redundant constraint: ?file1::String
+ • In the type signature for:
+ f :: (?file1::String) => IO ()
diff --git a/testsuite/tests/typecheck/should_compile/T11339.hs b/testsuite/tests/typecheck/should_compile/T11339.hs
new file mode 100644
index 0000000000..9f108083f8
--- /dev/null
+++ b/testsuite/tests/typecheck/should_compile/T11339.hs
@@ -0,0 +1,32 @@
+{-# LANGUAGE RankNTypes, ScopedTypeVariables #-}
+
+module T11339 where
+
+import Control.Applicative ( Const(Const, getConst) )
+import Data.Functor.Identity ( Identity(Identity) )
+
+type Traversal s t a b = forall f. Applicative f => (a -> f b) -> s -> f t
+
+failing :: forall s t a b . Traversal s t a b -> Traversal s t a b -> Traversal s t a b
+failing left right afb s = case pins t of
+ [] -> right afb s
+ _ -> t afb
+ where
+ t :: Applicative f => (a -> f b) -> f t
+ -- Does not work because the MR applies to this binding group
+ Bazaar { getBazaar = t } = left sell s
+
+ sell :: a -> Bazaar a b b
+ sell w = Bazaar ($ w)
+
+ pins :: ((a -> Const [Identity a] b) -> Const [Identity a] t) -> [Identity a]
+ pins f = getConst (f (\ra -> Const [Identity ra]))
+
+newtype Bazaar a b t = Bazaar { getBazaar :: (forall f. Applicative f => (a -> f b) -> f t) }
+
+instance Functor (Bazaar a b) where
+ fmap f (Bazaar k) = Bazaar (fmap f . k)
+
+instance Applicative (Bazaar a b) where
+ pure a = Bazaar $ \_ -> pure a
+ Bazaar mf <*> Bazaar ma = Bazaar $ \afb -> mf afb <*> ma afb
diff --git a/testsuite/tests/typecheck/should_compile/T11339.stderr b/testsuite/tests/typecheck/should_compile/T11339.stderr
new file mode 100644
index 0000000000..9e8a8eca53
--- /dev/null
+++ b/testsuite/tests/typecheck/should_compile/T11339.stderr
@@ -0,0 +1,15 @@
+
+T11339.hs:15:5: error:
+ • Illegal overloaded signature conflicts with monomorphism restriction
+ t :: forall (f :: * -> *). Applicative f => (a -> f b) -> f t
+ • In an equation for ‘failing’:
+ failing left right afb s
+ = case pins t of {
+ [] -> right afb s
+ _ -> t afb }
+ where
+ t :: Applicative f => (a -> f b) -> f t
+ Bazaar {getBazaar = t} = left sell s
+ sell :: a -> Bazaar a b b
+ sell w = Bazaar ($ w)
+ ....
diff --git a/testsuite/tests/typecheck/should_compile/T11339b.hs b/testsuite/tests/typecheck/should_compile/T11339b.hs
new file mode 100644
index 0000000000..5401364e77
--- /dev/null
+++ b/testsuite/tests/typecheck/should_compile/T11339b.hs
@@ -0,0 +1,32 @@
+{-# LANGUAGE NoMonomorphismRestriction, RankNTypes, ScopedTypeVariables #-}
+
+module T11339b where
+
+import Control.Applicative ( Const(Const, getConst) )
+import Data.Functor.Identity ( Identity(Identity) )
+
+type Traversal s t a b = forall f. Applicative f => (a -> f b) -> s -> f t
+
+failing :: forall s t a b . Traversal s t a b -> Traversal s t a b -> Traversal s t a b
+failing left right afb s = case pins t of
+ [] -> right afb s
+ _ -> t afb
+ where
+ t :: Applicative f => (a -> f b) -> f t
+ -- Works because of NoMonomorphismRestriction
+ Bazaar { getBazaar = t } = left sell s
+
+ sell :: a -> Bazaar a b b
+ sell w = Bazaar ($ w)
+
+ pins :: ((a -> Const [Identity a] b) -> Const [Identity a] t) -> [Identity a]
+ pins f = getConst (f (\ra -> Const [Identity ra]))
+
+newtype Bazaar a b t = Bazaar { getBazaar :: (forall f. Applicative f => (a -> f b) -> f t) }
+
+instance Functor (Bazaar a b) where
+ fmap f (Bazaar k) = Bazaar (fmap f . k)
+
+instance Applicative (Bazaar a b) where
+ pure a = Bazaar $ \_ -> pure a
+ Bazaar mf <*> Bazaar ma = Bazaar $ \afb -> mf afb <*> ma afb
diff --git a/testsuite/tests/typecheck/should_compile/T11339c.hs b/testsuite/tests/typecheck/should_compile/T11339c.hs
new file mode 100644
index 0000000000..0104a24765
--- /dev/null
+++ b/testsuite/tests/typecheck/should_compile/T11339c.hs
@@ -0,0 +1,32 @@
+{-# LANGUAGE MonoLocalBinds, RankNTypes, ScopedTypeVariables #-}
+
+module T11339c where
+
+import Control.Applicative ( Const(Const, getConst) )
+import Data.Functor.Identity ( Identity(Identity) )
+
+type Traversal s t a b = forall f. Applicative f => (a -> f b) -> s -> f t
+
+failing :: forall s t a b . Traversal s t a b -> Traversal s t a b -> Traversal s t a b
+failing left right afb s = case pins t of
+ [] -> right afb s
+ _ -> t afb
+ where
+ t :: Applicative f => (a -> f b) -> f t
+ -- Works because of MonoLocalBinds
+ Bazaar { getBazaar = t } = left sell s
+
+ sell :: a -> Bazaar a b b
+ sell w = Bazaar ($ w)
+
+ pins :: ((a -> Const [Identity a] b) -> Const [Identity a] t) -> [Identity a]
+ pins f = getConst (f (\ra -> Const [Identity ra]))
+
+newtype Bazaar a b t = Bazaar { getBazaar :: (forall f. Applicative f => (a -> f b) -> f t) }
+
+instance Functor (Bazaar a b) where
+ fmap f (Bazaar k) = Bazaar (fmap f . k)
+
+instance Applicative (Bazaar a b) where
+ pure a = Bazaar $ \_ -> pure a
+ Bazaar mf <*> Bazaar ma = Bazaar $ \afb -> mf afb <*> ma afb
diff --git a/testsuite/tests/typecheck/should_compile/T11339d.hs b/testsuite/tests/typecheck/should_compile/T11339d.hs
new file mode 100644
index 0000000000..cdc1bcf7e4
--- /dev/null
+++ b/testsuite/tests/typecheck/should_compile/T11339d.hs
@@ -0,0 +1,15 @@
+{-# LANGUAGE NoMonoLocalBinds, RankNTypes #-}
+
+-- Ross Paterson's example from
+-- https://prime.haskell.org/wiki/MonomorphicPatternBindings
+
+module T11339d where
+
+import Control.Monad.ST
+
+newtype ListMap m a b = ListMap ([a] -> m [b])
+
+runMap :: (forall s. ListMap (ST s) a b) -> [a] -> [b]
+runMap lf as = runST (f as)
+ where
+ ListMap f = lf
diff --git a/testsuite/tests/typecheck/should_compile/T11700.hs b/testsuite/tests/typecheck/should_compile/T11700.hs
new file mode 100644
index 0000000000..9cf43af9d9
--- /dev/null
+++ b/testsuite/tests/typecheck/should_compile/T11700.hs
@@ -0,0 +1,18 @@
+{-# LANGUAGE GADTs, TypeFamilies #-} -- Remove this line and the code compiles.
+
+module T11700 where
+
+data Muse
+data Message
+data Folder
+
+class PersistEntity record
+
+data Entity record where
+ Entity :: PersistEntity record => record -> Entity record
+
+fn1 :: (Entity Muse, Entity Message) -> Message
+fn1 cluster = let (Entity foo, Entity msg) = cluster
+ in msg
+-- fn1 (Entity foo, Entity msg) = msg
+
diff --git a/testsuite/tests/typecheck/should_compile/T12069.hs b/testsuite/tests/typecheck/should_compile/T12069.hs
new file mode 100644
index 0000000000..0da87dc7e6
--- /dev/null
+++ b/testsuite/tests/typecheck/should_compile/T12069.hs
@@ -0,0 +1,4 @@
+{-# LANGUAGE ScopedTypeVariables #-}
+module T12069 where
+
+foo (_ :: p a) = [] :: [a]
diff --git a/testsuite/tests/typecheck/should_compile/T2357.hs b/testsuite/tests/typecheck/should_compile/T2357.hs
index cdc77c1507..61d95f1045 100644
--- a/testsuite/tests/typecheck/should_compile/T2357.hs
+++ b/testsuite/tests/typecheck/should_compile/T2357.hs
@@ -1,7 +1,11 @@
+{-# LANGUAGE NoMonomorphismRestriction #-}
+
module Foo where
-f :: Show a => a
-(f, _) = undefined
+f :: Read a => a
+-- This one needs NoMonomorphismRestriction else f could
+-- not get a polymoprhic type
+(f, _) = (read "3", True)
-g :: Show a => a
+g :: Read a => a
g = f
diff --git a/testsuite/tests/typecheck/should_compile/T2494.stderr b/testsuite/tests/typecheck/should_compile/T2494.stderr
index b398459aa9..93c46fce53 100644
--- a/testsuite/tests/typecheck/should_compile/T2494.stderr
+++ b/testsuite/tests/typecheck/should_compile/T2494.stderr
@@ -1,36 +1,36 @@
-
-T2494.hs:15:14: error:
- • Couldn't match type ‘b’ with ‘a’
- ‘b’ is a rigid type variable bound by
- the RULE "foo/foo" at T2494.hs:14:16
- ‘a’ is a rigid type variable bound by
- the RULE "foo/foo" at T2494.hs:13:16
- Expected type: Maybe (m a) -> Maybe (m a)
- Actual type: Maybe (m b) -> Maybe (m b)
- • In the first argument of ‘foo’, namely ‘g’
- In the second argument of ‘foo’, namely ‘(foo g x)’
- In the expression: foo f (foo g x)
- • Relevant bindings include
- f :: forall (m :: * -> *). Monad m => Maybe (m a) -> Maybe (m a)
- (bound at T2494.hs:13:11)
- g :: forall (m :: * -> *). Monad m => Maybe (m b) -> Maybe (m b)
- (bound at T2494.hs:14:11)
- x :: Maybe a (bound at T2494.hs:14:65)
-
-T2494.hs:15:30: error:
- • Couldn't match type ‘b’ with ‘a’
- ‘b’ is a rigid type variable bound by
- the RULE "foo/foo" at T2494.hs:14:16
- ‘a’ is a rigid type variable bound by
- the RULE "foo/foo" at T2494.hs:13:16
- Expected type: Maybe (m b) -> Maybe (m a)
- Actual type: Maybe (m b) -> Maybe (m b)
- • In the second argument of ‘(.)’, namely ‘g’
- In the first argument of ‘foo’, namely ‘(f . g)’
- In the expression: foo (f . g) x
- • Relevant bindings include
- f :: forall (m :: * -> *). Monad m => Maybe (m a) -> Maybe (m a)
- (bound at T2494.hs:13:11)
- g :: forall (m :: * -> *). Monad m => Maybe (m b) -> Maybe (m b)
- (bound at T2494.hs:14:11)
- x :: Maybe a (bound at T2494.hs:14:65)
+
+T2494.hs:15:14: error:
+ • Couldn't match type ‘b’ with ‘a’
+ ‘b’ is a rigid type variable bound by
+ the RULE "foo/foo" at T2494.hs:14:16-62
+ ‘a’ is a rigid type variable bound by
+ the RULE "foo/foo" at T2494.hs:13:16-62
+ Expected type: Maybe (m a) -> Maybe (m a)
+ Actual type: Maybe (m b) -> Maybe (m b)
+ • In the first argument of ‘foo’, namely ‘g’
+ In the second argument of ‘foo’, namely ‘(foo g x)’
+ In the expression: foo f (foo g x)
+ • Relevant bindings include
+ f :: forall (m :: * -> *). Monad m => Maybe (m a) -> Maybe (m a)
+ (bound at T2494.hs:13:11)
+ g :: forall (m :: * -> *). Monad m => Maybe (m b) -> Maybe (m b)
+ (bound at T2494.hs:14:11)
+ x :: Maybe a (bound at T2494.hs:14:65)
+
+T2494.hs:15:30: error:
+ • Couldn't match type ‘b’ with ‘a’
+ ‘b’ is a rigid type variable bound by
+ the RULE "foo/foo" at T2494.hs:14:16-62
+ ‘a’ is a rigid type variable bound by
+ the RULE "foo/foo" at T2494.hs:13:16-62
+ Expected type: Maybe (m b) -> Maybe (m a)
+ Actual type: Maybe (m b) -> Maybe (m b)
+ • In the second argument of ‘(.)’, namely ‘g’
+ In the first argument of ‘foo’, namely ‘(f . g)’
+ In the expression: foo (f . g) x
+ • Relevant bindings include
+ f :: forall (m :: * -> *). Monad m => Maybe (m a) -> Maybe (m a)
+ (bound at T2494.hs:13:11)
+ g :: forall (m :: * -> *). Monad m => Maybe (m b) -> Maybe (m b)
+ (bound at T2494.hs:14:11)
+ x :: Maybe a (bound at T2494.hs:14:65)
diff --git a/testsuite/tests/typecheck/should_compile/T9834.stderr b/testsuite/tests/typecheck/should_compile/T9834.stderr
index 9e66a49770..75392ea2ba 100644
--- a/testsuite/tests/typecheck/should_compile/T9834.stderr
+++ b/testsuite/tests/typecheck/should_compile/T9834.stderr
@@ -1,46 +1,46 @@
-
-T9834.hs:23:10: warning: [-Wdeferred-type-errors (in -Wdefault)]
- • Couldn't match type ‘p’ with ‘(->) (p a0)’
- ‘p’ is a rigid type variable bound by
- the class declaration for ‘ApplicativeFix’ at T9834.hs:21:39
- Expected type: (forall (q :: * -> *).
- Applicative q =>
- Comp p q a -> Comp p q a)
- -> p a
- Actual type: (forall (q :: * -> *).
- Applicative q =>
- Nat (Comp p q) (Comp p q))
- -> p a0 -> p a0
- • In the expression: wrapIdComp
- In an equation for ‘afix’: afix = wrapIdComp
- • Relevant bindings include
- afix :: (forall (q :: * -> *).
- Applicative q =>
- Comp p q a -> Comp p q a)
- -> p a
- (bound at T9834.hs:23:3)
-
-T9834.hs:23:10: warning: [-Wdeferred-type-errors (in -Wdefault)]
- • Couldn't match type ‘a’ with ‘a1’
- ‘a’ is a rigid type variable bound by
- the type signature for:
- afix :: forall a.
- (forall (q :: * -> *). Applicative q => Comp p q a -> Comp p q a)
- -> p a
- at T9834.hs:22:11
- ‘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
- at T9834.hs:23:10
- Expected type: Comp p q a1 -> Comp p q a1
- Actual type: Comp p q a -> Comp p q a
- • In the expression: wrapIdComp
- In an equation for ‘afix’: afix = wrapIdComp
- • Relevant bindings include
- afix :: (forall (q :: * -> *).
- Applicative q =>
- Comp p q a -> Comp p q a)
- -> p a
- (bound at T9834.hs:23:3)
+
+T9834.hs:23:10: warning: [-Wdeferred-type-errors (in -Wdefault)]
+ • Couldn't match type ‘p’ with ‘(->) (p a0)’
+ ‘p’ is a rigid type variable bound by
+ the class declaration for ‘ApplicativeFix’ at T9834.hs:21:39
+ Expected type: (forall (q :: * -> *).
+ Applicative q =>
+ Comp p q a -> Comp p q a)
+ -> p a
+ Actual type: (forall (q :: * -> *).
+ Applicative q =>
+ Nat (Comp p q) (Comp p q))
+ -> p a0 -> p a0
+ • In the expression: wrapIdComp
+ In an equation for ‘afix’: afix = wrapIdComp
+ • Relevant bindings include
+ afix :: (forall (q :: * -> *).
+ Applicative q =>
+ Comp p q a -> Comp p q a)
+ -> p a
+ (bound at T9834.hs:23:3)
+
+T9834.hs:23:10: warning: [-Wdeferred-type-errors (in -Wdefault)]
+ • Couldn't match type ‘a’ with ‘a1’
+ ‘a’ is a rigid type variable bound by
+ the type signature for:
+ afix :: forall a.
+ (forall (q :: * -> *). Applicative q => Comp p q a -> Comp p q a)
+ -> p a
+ 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
+ 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
+ • In the expression: wrapIdComp
+ In an equation for ‘afix’: afix = wrapIdComp
+ • Relevant bindings include
+ afix :: (forall (q :: * -> *).
+ Applicative q =>
+ Comp p q a -> Comp p q a)
+ -> p a
+ (bound at T9834.hs:23:3)
diff --git a/testsuite/tests/typecheck/should_compile/T9939.stderr b/testsuite/tests/typecheck/should_compile/T9939.stderr
index d10c51016d..5e227b2702 100644
--- a/testsuite/tests/typecheck/should_compile/T9939.stderr
+++ b/testsuite/tests/typecheck/should_compile/T9939.stderr
@@ -1,20 +1,20 @@
-
-T9939.hs:5:1: warning: [-Wredundant-constraints (in -Wall)]
- • Redundant constraint: Eq a
- • In the type signature for:
- f1 :: (Eq a, Ord a) => a -> a -> Bool
-
-T9939.hs:9:1: warning: [-Wredundant-constraints (in -Wall)]
- • Redundant constraint: Eq a
- • In the type signature for:
- f2 :: (Eq a, Ord a) => a -> a -> Bool
-
-T9939.hs:13:1: warning: [-Wredundant-constraints (in -Wall)]
- • Redundant constraint: Eq b
- • In the type signature for:
- f3 :: (Eq a, a ~ b, Eq b) => a -> b -> Bool
-
-T9939.hs:20:1: warning: [-Wredundant-constraints (in -Wall)]
- • Redundant constraint: Eq a
- • In the type signature for:
- f4 :: (Eq a, Eq b) => a -> b -> Equal a b -> Bool
+
+T9939.hs:5:1: warning: [-Wredundant-constraints (in -Wall)]
+ • Redundant constraint: Eq a
+ • In the type signature for:
+ f1 :: (Eq a, Ord a) => a -> a -> Bool
+
+T9939.hs:9:1: warning: [-Wredundant-constraints (in -Wall)]
+ • Redundant constraint: Eq a
+ • In the type signature for:
+ f2 :: (Eq a, Ord a) => a -> a -> Bool
+
+T9939.hs:13:1: warning: [-Wredundant-constraints (in -Wall)]
+ • Redundant constraint: Eq b
+ • In the type signature for:
+ f3 :: (Eq a, a ~ b, Eq b) => a -> b -> Bool
+
+T9939.hs:20:1: warning: [-Wredundant-constraints (in -Wall)]
+ • Redundant constraint: Eq a
+ • In the type signature for:
+ f4 :: (Eq a, Eq b) => a -> b -> Equal a b -> Bool
diff --git a/testsuite/tests/typecheck/should_compile/all.T b/testsuite/tests/typecheck/should_compile/all.T
index 0f43d00e6f..3b6e186d8c 100644
--- a/testsuite/tests/typecheck/should_compile/all.T
+++ b/testsuite/tests/typecheck/should_compile/all.T
@@ -517,3 +517,12 @@ test('T11348', normal, compile, [''])
test('T11947', normal, compile, [''])
test('T12064', extra_clean(['T12064.hi-boot', 'T12064.o-boot', 'T11062a.hi', 'T11062a.o']),
multimod_compile, ['T12064', '-v0'])
+test('ExPat', normal, compile, [''])
+test('ExPatFail', normal, compile_fail, [''])
+test('SigTyVars', normal, compile, [''])
+test('T12069', normal, compile, [''])
+test('T11700', normal, compile, [''])
+test('T11339', normal, compile_fail, [''])
+test('T11339b', normal, compile, [''])
+test('T11339c', normal, compile, [''])
+test('T11339d', normal, compile, [''])
diff --git a/testsuite/tests/typecheck/should_compile/holes.stderr b/testsuite/tests/typecheck/should_compile/holes.stderr
index 0d0582d126..6bb117796f 100644
--- a/testsuite/tests/typecheck/should_compile/holes.stderr
+++ b/testsuite/tests/typecheck/should_compile/holes.stderr
@@ -1,33 +1,33 @@
-
-holes.hs:3:5: warning: [-Wtyped-holes (in -Wdefault)]
- • Found hole: _ :: t
- Where: ‘t’ is a rigid type variable bound by
- the inferred type of f :: t at holes.hs:3:1
- • In the expression: _
- In an equation for ‘f’: f = _
- • Relevant bindings include f :: t (bound at holes.hs:3:1)
-
-holes.hs:6:7: warning: [-Wtyped-holes (in -Wdefault)]
- • Found hole: _ :: Char
- • In the expression: _
- In an equation for ‘g’: g x = _
- • Relevant bindings include
- x :: Int (bound at holes.hs:6:3)
- g :: Int -> Char (bound at holes.hs:6:1)
-
-holes.hs:8:5: warning: [-Wtyped-holes (in -Wdefault)]
- • Found hole: _ :: [Char]
- • In the first argument of ‘(++)’, namely ‘_’
- In the expression: _ ++ "a"
- In an equation for ‘h’: h = _ ++ "a"
- • Relevant bindings include h :: [Char] (bound at holes.hs:8:1)
-
-holes.hs:11:15: warning: [-Wtyped-holes (in -Wdefault)]
- • Found hole: _ :: b0
- Where: ‘b0’ is an ambiguous type variable
- • In the second argument of ‘const’, namely ‘_’
- In the expression: const y _
- In an equation for ‘z’: z y = const y _
- • Relevant bindings include
- y :: [a] (bound at holes.hs:11:3)
- z :: [a] -> [a] (bound at holes.hs:11:1)
+
+holes.hs:3:5: warning: [-Wtyped-holes (in -Wdefault)]
+ • Found hole: _ :: t
+ Where: ‘t’ is a rigid type variable bound by
+ the inferred type of f :: t at holes.hs:3:1-5
+ • In the expression: _
+ In an equation for ‘f’: f = _
+ • Relevant bindings include f :: t (bound at holes.hs:3:1)
+
+holes.hs:6:7: warning: [-Wtyped-holes (in -Wdefault)]
+ • Found hole: _ :: Char
+ • In the expression: _
+ In an equation for ‘g’: g x = _
+ • Relevant bindings include
+ x :: Int (bound at holes.hs:6:3)
+ g :: Int -> Char (bound at holes.hs:6:1)
+
+holes.hs:8:5: warning: [-Wtyped-holes (in -Wdefault)]
+ • Found hole: _ :: [Char]
+ • In the first argument of ‘(++)’, namely ‘_’
+ In the expression: _ ++ "a"
+ In an equation for ‘h’: h = _ ++ "a"
+ • Relevant bindings include h :: [Char] (bound at holes.hs:8:1)
+
+holes.hs:11:15: warning: [-Wtyped-holes (in -Wdefault)]
+ • Found hole: _ :: b0
+ Where: ‘b0’ is an ambiguous type variable
+ • In the second argument of ‘const’, namely ‘_’
+ In the expression: const y _
+ In an equation for ‘z’: z y = const y _
+ • Relevant bindings include
+ y :: [a] (bound at holes.hs:11:3)
+ z :: [a] -> [a] (bound at holes.hs:11:1)
diff --git a/testsuite/tests/typecheck/should_compile/holes3.stderr b/testsuite/tests/typecheck/should_compile/holes3.stderr
index 2d1261b278..7edaed8e3e 100644
--- a/testsuite/tests/typecheck/should_compile/holes3.stderr
+++ b/testsuite/tests/typecheck/should_compile/holes3.stderr
@@ -1,36 +1,36 @@
-
-holes3.hs:3:5: error:
- • Found hole: _ :: t
- Where: ‘t’ is a rigid type variable bound by
- the inferred type of f :: t at holes3.hs:3:1
- • In the expression: _
- In an equation for ‘f’: f = _
- • Relevant bindings include f :: t (bound at holes3.hs:3:1)
-
-holes3.hs:6:7: error:
- • Found hole: _gr :: Char
- Or perhaps ‘_gr’ is mis-spelled, or not in scope
- • In the expression: _gr
- In an equation for ‘g’: g x = _gr
- • Relevant bindings include
- x :: Int (bound at holes3.hs:6:3)
- g :: Int -> Char (bound at holes3.hs:6:1)
-
-holes3.hs:8:5: error:
- • Found hole: _aa :: [Char]
- Or perhaps ‘_aa’ is mis-spelled, or not in scope
- • In the first argument of ‘(++)’, namely ‘_aa’
- In the expression: _aa ++ "a"
- In an equation for ‘h’: h = _aa ++ "a"
- • Relevant bindings include h :: [Char] (bound at holes3.hs:8:1)
-
-holes3.hs:11:15: error:
- • Found hole: _x :: b0
- Where: ‘b0’ is an ambiguous type variable
- Or perhaps ‘_x’ is mis-spelled, or not in scope
- • In the second argument of ‘const’, namely ‘_x’
- In the expression: const y _x
- In an equation for ‘z’: z y = const y _x
- • Relevant bindings include
- y :: [a] (bound at holes3.hs:11:3)
- z :: [a] -> [a] (bound at holes3.hs:11:1)
+
+holes3.hs:3:5: error:
+ • Found hole: _ :: t
+ Where: ‘t’ is a rigid type variable bound by
+ the inferred type of f :: t at holes3.hs:3:1-5
+ • In the expression: _
+ In an equation for ‘f’: f = _
+ • Relevant bindings include f :: t (bound at holes3.hs:3:1)
+
+holes3.hs:6:7: error:
+ • Found hole: _gr :: Char
+ Or perhaps ‘_gr’ is mis-spelled, or not in scope
+ • In the expression: _gr
+ In an equation for ‘g’: g x = _gr
+ • Relevant bindings include
+ x :: Int (bound at holes3.hs:6:3)
+ g :: Int -> Char (bound at holes3.hs:6:1)
+
+holes3.hs:8:5: error:
+ • Found hole: _aa :: [Char]
+ Or perhaps ‘_aa’ is mis-spelled, or not in scope
+ • In the first argument of ‘(++)’, namely ‘_aa’
+ In the expression: _aa ++ "a"
+ In an equation for ‘h’: h = _aa ++ "a"
+ • Relevant bindings include h :: [Char] (bound at holes3.hs:8:1)
+
+holes3.hs:11:15: error:
+ • Found hole: _x :: b0
+ Where: ‘b0’ is an ambiguous type variable
+ Or perhaps ‘_x’ is mis-spelled, or not in scope
+ • In the second argument of ‘const’, namely ‘_x’
+ In the expression: const y _x
+ In an equation for ‘z’: z y = const y _x
+ • Relevant bindings include
+ y :: [a] (bound at holes3.hs:11:3)
+ z :: [a] -> [a] (bound at holes3.hs:11:1)
diff --git a/testsuite/tests/typecheck/should_compile/tc141.stderr b/testsuite/tests/typecheck/should_compile/tc141.stderr
index 49a26d6363..ab778a0133 100644
--- a/testsuite/tests/typecheck/should_compile/tc141.stderr
+++ b/testsuite/tests/typecheck/should_compile/tc141.stderr
@@ -1,54 +1,54 @@
-
-tc141.hs:11:12: error:
- • You cannot bind scoped type variable ‘a’
- in a pattern binding signature
- • In the pattern: p :: a
- In the pattern: (p :: a, q :: a)
- In a pattern binding: (p :: a, q :: a) = x
-
-tc141.hs:11:31: error:
- • Couldn't match expected type ‘a1’ with actual type ‘a’
- because type variable ‘a1’ would escape its scope
- This (rigid, skolem) type variable is bound by
- an expression type signature:
- a1
- at tc141.hs:11:31-34
- • In the expression: q :: a
- In the expression: (q :: a, p)
- In the expression: let (p :: a, q :: a) = x in (q :: a, p)
- • Relevant bindings include
- p :: a (bound at tc141.hs:11:12)
- q :: a (bound at tc141.hs:11:17)
- x :: (a, a) (bound at tc141.hs:11:3)
- f :: (a, a) -> (t, a) (bound at tc141.hs:11:1)
-
-tc141.hs:13:13: error:
- • You cannot bind scoped type variable ‘a’
- in a pattern binding signature
- • In the pattern: y :: a
- In a pattern binding: y :: a = a
- In the expression:
- let y :: a = a in
- let
- v :: a
- v = b
- in v
-
-tc141.hs:15:18: error:
- • Couldn't match expected type ‘a1’ with actual type ‘t’
- because type variable ‘a1’ would escape its scope
- This (rigid, skolem) type variable is bound by
- the type signature for:
- v :: a1
- at tc141.hs:14:14-19
- • In the expression: b
- In an equation for ‘v’: v = b
- In the expression:
- let
- v :: a
- v = b
- in v
- • Relevant bindings include
- v :: a1 (bound at tc141.hs:15:14)
- b :: t (bound at tc141.hs:13:5)
- g :: t1 -> t -> forall a. a (bound at tc141.hs:13:1)
+
+tc141.hs:11:12: error:
+ • You cannot bind scoped type variable ‘a’
+ in a pattern binding signature
+ • In the pattern: p :: a
+ In the pattern: (p :: a, q :: a)
+ In a pattern binding: (p :: a, q :: a) = x
+
+tc141.hs:11:31: error:
+ • Couldn't match expected type ‘a1’ with actual type ‘a’
+ because type variable ‘a1’ would escape its scope
+ This (rigid, skolem) type variable is bound by
+ an expression type signature:
+ a1
+ at tc141.hs:11:34
+ • In the expression: q :: a
+ In the expression: (q :: a, p)
+ In the expression: let (p :: a, q :: a) = x in (q :: a, p)
+ • Relevant bindings include
+ p :: a (bound at tc141.hs:11:12)
+ q :: a (bound at tc141.hs:11:17)
+ x :: (a, a) (bound at tc141.hs:11:3)
+ f :: (a, a) -> (t, a) (bound at tc141.hs:11:1)
+
+tc141.hs:13:13: error:
+ • You cannot bind scoped type variable ‘a’
+ in a pattern binding signature
+ • In the pattern: y :: a
+ In a pattern binding: y :: a = a
+ In the expression:
+ let y :: a = a in
+ let
+ v :: a
+ v = b
+ in v
+
+tc141.hs:15:18: error:
+ • Couldn't match expected type ‘a1’ with actual type ‘t’
+ because type variable ‘a1’ would escape its scope
+ This (rigid, skolem) type variable is bound by
+ the type signature for:
+ v :: a1
+ at tc141.hs:14:14-19
+ • In the expression: b
+ In an equation for ‘v’: v = b
+ In the expression:
+ let
+ v :: a
+ v = b
+ in v
+ • Relevant bindings include
+ v :: a1 (bound at tc141.hs:15:14)
+ b :: t (bound at tc141.hs:13:5)
+ g :: t1 -> t -> forall a. a (bound at tc141.hs:13:1)
diff --git a/testsuite/tests/typecheck/should_fail/T10285.stderr b/testsuite/tests/typecheck/should_fail/T10285.stderr
index ebc5f97503..a8e5b011e4 100644
--- a/testsuite/tests/typecheck/should_fail/T10285.stderr
+++ b/testsuite/tests/typecheck/should_fail/T10285.stderr
@@ -1,22 +1,22 @@
-
-T10285.hs:8:17: error:
- • Could not deduce: Coercible a b arising from a use of ‘coerce’
- from the context: Coercible (N a) (N b)
- bound by a pattern with constructor:
- Coercion :: forall k (a :: k) (b :: k).
- Coercible a b =>
- Coercion a b,
- in an equation for ‘oops’
- at T10285.hs:8:6-13
- ‘a’ is a rigid type variable bound by
- the type signature for:
- oops :: forall a b. Coercion (N a) (N b) -> a -> b
- at T10285.hs:7:9
- ‘b’ is a rigid type variable bound by
- the type signature for:
- oops :: forall a b. Coercion (N a) (N b) -> a -> b
- at T10285.hs:7:9
- • In the expression: coerce
- In an equation for ‘oops’: oops Coercion = coerce
- • Relevant bindings include
- oops :: Coercion (N a) (N b) -> a -> b (bound at T10285.hs:8:1)
+
+T10285.hs:8:17: error:
+ • Could not deduce: Coercible a b arising from a use of ‘coerce’
+ from the context: Coercible (N a) (N b)
+ bound by a pattern with constructor:
+ Coercion :: forall k (a :: k) (b :: k).
+ Coercible a b =>
+ Coercion a b,
+ in an equation for ‘oops’
+ at T10285.hs:8:6-13
+ ‘a’ is a rigid type variable bound by
+ the type signature for:
+ oops :: forall a b. Coercion (N a) (N b) -> a -> b
+ at T10285.hs:7:1-38
+ ‘b’ is a rigid type variable bound by
+ the type signature for:
+ oops :: forall a b. Coercion (N a) (N b) -> a -> b
+ at T10285.hs:7:1-38
+ • In the expression: coerce
+ In an equation for ‘oops’: oops Coercion = coerce
+ • Relevant bindings include
+ oops :: Coercion (N a) (N b) -> a -> b (bound at T10285.hs:8:1)
diff --git a/testsuite/tests/typecheck/should_fail/T10534.stderr b/testsuite/tests/typecheck/should_fail/T10534.stderr
index ecdb6d2935..5ba1c89d27 100644
--- a/testsuite/tests/typecheck/should_fail/T10534.stderr
+++ b/testsuite/tests/typecheck/should_fail/T10534.stderr
@@ -1,19 +1,19 @@
-
-T10534a.hs:10:9: error:
- • Could not deduce: Coercible a b arising from a use of ‘coerce’
- from the context: Coercible (DF a) (DF b)
- bound by the type signature for:
- silly :: Coercible (DF a) (DF b) => a -> b
- at T10534a.hs:9:1-42
- ‘a’ is a rigid type variable bound by
- the type signature for:
- silly :: forall a b. Coercible (DF a) (DF b) => a -> b
- at T10534a.hs:9:10
- ‘b’ is a rigid type variable bound by
- the type signature for:
- silly :: forall a b. Coercible (DF a) (DF b) => a -> b
- at T10534a.hs:9:10
- • In the expression: coerce
- In an equation for ‘silly’: silly = coerce
- • Relevant bindings include
- silly :: a -> b (bound at T10534a.hs:10:1)
+
+T10534a.hs:10:9: error:
+ • Could not deduce: Coercible a b arising from a use of ‘coerce’
+ from the context: Coercible (DF a) (DF b)
+ bound by the type signature for:
+ silly :: Coercible (DF a) (DF b) => a -> b
+ at T10534a.hs:9:1-42
+ ‘a’ is a rigid type variable bound by
+ the type signature for:
+ silly :: forall a b. Coercible (DF a) (DF b) => a -> b
+ at T10534a.hs:9:1-42
+ ‘b’ is a rigid type variable bound by
+ the type signature for:
+ silly :: forall a b. Coercible (DF a) (DF b) => a -> b
+ at T10534a.hs:9:1-42
+ • In the expression: coerce
+ In an equation for ‘silly’: silly = coerce
+ • Relevant bindings include
+ silly :: a -> b (bound at T10534a.hs:10:1)
diff --git a/testsuite/tests/typecheck/should_fail/T10715.stderr b/testsuite/tests/typecheck/should_fail/T10715.stderr
index 0bbaa35573..9b98acbfb5 100644
--- a/testsuite/tests/typecheck/should_fail/T10715.stderr
+++ b/testsuite/tests/typecheck/should_fail/T10715.stderr
@@ -1,14 +1,13 @@
-
-T10715.hs:9:13: error:
- Couldn't match representation of type ‘a’ with that of ‘X a’
- ‘a’ is a rigid type variable bound by
- the type signature for:
- doCoerce :: forall a. Coercible a (X a) => a -> X a
- at T10715.hs:9:13
- Inaccessible code in
- the type signature for:
- doCoerce :: Coercible a (X a) => a -> X a
- In the ambiguity check for ‘doCoerce’
- To defer the ambiguity check to use sites, enable AllowAmbiguousTypes
- In the type signature:
- doCoerce :: Coercible a (X a) => a -> X a
+
+T10715.hs:9:13: error:
+ • Couldn't match representation of type ‘a’ with that of ‘X a’
+ ‘a’ is a rigid type variable bound by
+ the type signature for:
+ doCoerce :: forall a. Coercible a (X a) => a -> X a
+ at T10715.hs:9:13-41
+ Inaccessible code in
+ the type signature for:
+ doCoerce :: Coercible a (X a) => a -> X a
+ • In the ambiguity check for ‘doCoerce’
+ To defer the ambiguity check to use sites, enable AllowAmbiguousTypes
+ In the type signature: doCoerce :: Coercible a (X a) => a -> X a
diff --git a/testsuite/tests/typecheck/should_fail/T11347.stderr b/testsuite/tests/typecheck/should_fail/T11347.stderr
index 6154984201..54061068c6 100644
--- a/testsuite/tests/typecheck/should_fail/T11347.stderr
+++ b/testsuite/tests/typecheck/should_fail/T11347.stderr
@@ -1,11 +1,11 @@
-
-T11347.hs:6:41: error:
- • Couldn't match representation of type ‘a’ with that of ‘b’
- arising from the coercion of the method ‘unsafe’
- from type ‘Id1 a -> Discern (Id1 a) b’
- to type ‘Id2 a -> Discern (Id2 a) b’
- ‘a’ is a rigid type variable bound by
- the deriving clause for ‘UnsafeCast b (Id2 a)’ at T11347.hs:6:41
- ‘b’ is a rigid type variable bound by
- the deriving clause for ‘UnsafeCast b (Id2 a)’ at T11347.hs:6:41
- • When deriving the instance for (UnsafeCast b (Id2 a))
+
+T11347.hs:6:41: error:
+ • Couldn't match representation of type ‘a’ with that of ‘b’
+ arising from the coercion of the method ‘unsafe’
+ from type ‘Id1 a -> Discern (Id1 a) b’
+ to type ‘Id2 a -> Discern (Id2 a) b’
+ ‘a’ is a rigid type variable bound by
+ the deriving clause for ‘UnsafeCast b (Id2 a)’ at T11347.hs:6:41-52
+ ‘b’ is a rigid type variable bound by
+ the deriving clause for ‘UnsafeCast b (Id2 a)’ at T11347.hs:6:41-52
+ • When deriving the instance for (UnsafeCast b (Id2 a))
diff --git a/testsuite/tests/typecheck/should_fail/T1899.stderr b/testsuite/tests/typecheck/should_fail/T1899.stderr
index c4db8fe1e7..c88ae9ace2 100644
--- a/testsuite/tests/typecheck/should_fail/T1899.stderr
+++ b/testsuite/tests/typecheck/should_fail/T1899.stderr
@@ -1,15 +1,15 @@
-
-T1899.hs:14:36: error:
- • Couldn't match type ‘a’ with ‘Proposition a0’
- ‘a’ is a rigid type variable bound by
- the type signature for:
- transRHS :: forall a. [a] -> Int -> Constraint a
- at T1899.hs:9:14
- Expected type: [Proposition a0]
- Actual type: [a]
- • In the first argument of ‘Auxiliary’, namely ‘varSet’
- In the first argument of ‘Prop’, namely ‘(Auxiliary varSet)’
- In the expression: Prop (Auxiliary varSet)
- • Relevant bindings include
- varSet :: [a] (bound at T1899.hs:10:11)
- transRHS :: [a] -> Int -> Constraint a (bound at T1899.hs:10:2)
+
+T1899.hs:14:36: error:
+ • Couldn't match type ‘a’ with ‘Proposition a0’
+ ‘a’ is a rigid type variable bound by
+ the type signature for:
+ transRHS :: forall a. [a] -> Int -> Constraint a
+ at T1899.hs:9:2-39
+ Expected type: [Proposition a0]
+ Actual type: [a]
+ • In the first argument of ‘Auxiliary’, namely ‘varSet’
+ In the first argument of ‘Prop’, namely ‘(Auxiliary varSet)’
+ In the expression: Prop (Auxiliary varSet)
+ • Relevant bindings include
+ varSet :: [a] (bound at T1899.hs:10:11)
+ transRHS :: [a] -> Int -> Constraint a (bound at T1899.hs:10:2)
diff --git a/testsuite/tests/typecheck/should_fail/T2714.stderr b/testsuite/tests/typecheck/should_fail/T2714.stderr
index bba821bcac..f60855d682 100644
--- a/testsuite/tests/typecheck/should_fail/T2714.stderr
+++ b/testsuite/tests/typecheck/should_fail/T2714.stderr
@@ -1,13 +1,13 @@
-
-T2714.hs:8:5: error:
- • Couldn't match type ‘a’ with ‘f0 b’
- ‘a’ is a rigid type variable bound by
- the type signature for:
- f :: forall a b. ((a -> b) -> b) -> forall c. c -> a
- at T2714.hs:7:6
- Expected type: ((a -> b) -> b) -> c -> a
- Actual type: ((a -> b) -> b) -> f0 (a -> b) -> f0 b
- • In the expression: ffmap
- In an equation for ‘f’: f = ffmap
- • Relevant bindings include
- f :: ((a -> b) -> b) -> forall c. c -> a (bound at T2714.hs:8:1)
+
+T2714.hs:8:5: error:
+ • Couldn't match type ‘a’ with ‘f0 b’
+ ‘a’ is a rigid type variable bound by
+ the type signature for:
+ f :: forall a b. ((a -> b) -> b) -> forall c. c -> a
+ at T2714.hs:7:1-42
+ Expected type: ((a -> b) -> b) -> c -> a
+ Actual type: ((a -> b) -> b) -> f0 (a -> b) -> f0 b
+ • In the expression: ffmap
+ In an equation for ‘f’: f = ffmap
+ • Relevant bindings include
+ f :: ((a -> b) -> b) -> forall c. c -> a (bound at T2714.hs:8:1)
diff --git a/testsuite/tests/typecheck/should_fail/T3102.stderr b/testsuite/tests/typecheck/should_fail/T3102.stderr
index a5a410efeb..6ff8d1cb67 100644
--- a/testsuite/tests/typecheck/should_fail/T3102.stderr
+++ b/testsuite/tests/typecheck/should_fail/T3102.stderr
@@ -1,12 +1,12 @@
-
-T3102.hs:11:12: error:
- • Couldn't match type ‘a’ with ‘(?p::Int) => a0’
- ‘a’ is a rigid type variable bound by
- a type expected by the context:
- forall a. a -> String
- at T3102.hs:11:10
- Expected type: a -> String
- Actual type: ((?p::Int) => a0) -> String
- • In the first argument of ‘f’, namely ‘t’
- In the expression: f t
- In an equation for ‘result’: result = f t
+
+T3102.hs:11:12: error:
+ • Couldn't match type ‘a’ with ‘(?p::Int) => a0’
+ ‘a’ is a rigid type variable bound by
+ a type expected by the context:
+ forall a. a -> String
+ at T3102.hs:11:10-12
+ Expected type: a -> String
+ Actual type: ((?p::Int) => a0) -> String
+ • In the first argument of ‘f’, namely ‘t’
+ In the expression: f t
+ In an equation for ‘result’: result = f t
diff --git a/testsuite/tests/typecheck/should_fail/T5691.stderr b/testsuite/tests/typecheck/should_fail/T5691.stderr
index 132df4dacf..585dcdf71c 100644
--- a/testsuite/tests/typecheck/should_fail/T5691.stderr
+++ b/testsuite/tests/typecheck/should_fail/T5691.stderr
@@ -1,19 +1,19 @@
-
-T5691.hs:14:9: error:
- Couldn't match type ‘p’ with ‘PrintRuleInterp’
- Expected type: p a
- Actual type: PrintRuleInterp a
- When checking that the pattern signature: p a
- fits the type of its context: PrintRuleInterp a
- In the pattern: f :: p a
- In an equation for ‘test’: test (f :: p a) = MkPRI $ printRule_ f
-
-T5691.hs:24:10: error:
- No instance for (Alternative RecDecParser)
- arising from the superclasses of an instance declaration
- In the instance declaration for ‘MonadPlus RecDecParser’
-
-T5691.hs:24:10: error:
- No instance for (Monad RecDecParser)
- arising from the superclasses of an instance declaration
- In the instance declaration for ‘MonadPlus RecDecParser’
+
+T5691.hs:15:24: error:
+ • Couldn't match type ‘p’ with ‘PrintRuleInterp’
+ Expected type: PrintRuleInterp a
+ Actual type: p a
+ • In the first argument of ‘printRule_’, namely ‘f’
+ In the second argument of ‘($)’, namely ‘printRule_ f’
+ In the expression: MkPRI $ printRule_ f
+ • Relevant bindings include f :: p a (bound at T5691.hs:14:9)
+
+T5691.hs:24:10: error:
+ • No instance for (Alternative RecDecParser)
+ arising from the superclasses of an instance declaration
+ • In the instance declaration for ‘MonadPlus RecDecParser’
+
+T5691.hs:24:10: error:
+ • No instance for (Monad RecDecParser)
+ arising from the superclasses of an instance declaration
+ • In the instance declaration for ‘MonadPlus RecDecParser’
diff --git a/testsuite/tests/typecheck/should_fail/T7264.stderr b/testsuite/tests/typecheck/should_fail/T7264.stderr
index b343d88cd1..57d3699a37 100644
--- a/testsuite/tests/typecheck/should_fail/T7264.stderr
+++ b/testsuite/tests/typecheck/should_fail/T7264.stderr
@@ -1,13 +1,13 @@
-
-T7264.hs:13:19: error:
- • Couldn't match type ‘a’ with ‘forall r. r -> String’
- ‘a’ is a rigid type variable bound by
- the inferred type of mkFoo2 :: a -> Maybe Foo at T7264.hs:13:1
- Expected type: a -> Foo
- Actual type: (forall r. r -> String) -> Foo
- • In the first argument of ‘mmap’, namely ‘Foo’
- In the expression: mmap Foo (Just val)
- In an equation for ‘mkFoo2’: mkFoo2 val = mmap Foo (Just val)
- • Relevant bindings include
- val :: a (bound at T7264.hs:13:8)
- mkFoo2 :: a -> Maybe Foo (bound at T7264.hs:13:1)
+
+T7264.hs:13:19: error:
+ • Couldn't match type ‘a’ with ‘forall r. r -> String’
+ ‘a’ is a rigid type variable bound by
+ the inferred type of mkFoo2 :: a -> Maybe Foo at T7264.hs:13:1-32
+ Expected type: a -> Foo
+ Actual type: (forall r. r -> String) -> Foo
+ • In the first argument of ‘mmap’, namely ‘Foo’
+ In the expression: mmap Foo (Just val)
+ In an equation for ‘mkFoo2’: mkFoo2 val = mmap Foo (Just val)
+ • Relevant bindings include
+ val :: a (bound at T7264.hs:13:8)
+ mkFoo2 :: a -> Maybe Foo (bound at T7264.hs:13:1)
diff --git a/testsuite/tests/typecheck/should_fail/T7748a.stderr b/testsuite/tests/typecheck/should_fail/T7748a.stderr
index 2f4c35598f..d63f406ce4 100644
--- a/testsuite/tests/typecheck/should_fail/T7748a.stderr
+++ b/testsuite/tests/typecheck/should_fail/T7748a.stderr
@@ -1,20 +1,20 @@
-
-T7748a.hs:16:24: error:
- • Couldn't match expected type ‘a’
- with actual type ‘Maybe (Maybe (r -> ()))’
- ‘a’ is a rigid type variable bound by
- the type signature for:
- test :: forall a r. a -> r -> ()
- at T7748a.hs:11:9
- • In the pattern: Just (Just p)
- In a case alternative: Just (Just p) -> p
- In the expression:
- case zd of {
- Nothing -> const ()
- Just Nothing -> const ()
- Just (Just p) -> p }
- • Relevant bindings include
- g :: r -> () (bound at T7748a.hs:13:16)
- f :: r -> () (bound at T7748a.hs:13:8)
- zd :: a (bound at T7748a.hs:12:6)
- test :: a -> r -> () (bound at T7748a.hs:12:1)
+
+T7748a.hs:16:24: error:
+ • Couldn't match expected type ‘a’
+ with actual type ‘Maybe (Maybe (r -> ()))’
+ ‘a’ is a rigid type variable bound by
+ the type signature for:
+ test :: forall a r. a -> r -> ()
+ at T7748a.hs:11:1-20
+ • In the pattern: Just (Just p)
+ In a case alternative: Just (Just p) -> p
+ In the expression:
+ case zd of {
+ Nothing -> const ()
+ Just Nothing -> const ()
+ Just (Just p) -> p }
+ • Relevant bindings include
+ g :: r -> () (bound at T7748a.hs:13:16)
+ f :: r -> () (bound at T7748a.hs:13:8)
+ zd :: a (bound at T7748a.hs:12:6)
+ test :: a -> r -> () (bound at T7748a.hs:12:1)
diff --git a/testsuite/tests/typecheck/should_fail/T7869.stderr b/testsuite/tests/typecheck/should_fail/T7869.stderr
index 44902922a6..95dc5a9ca4 100644
--- a/testsuite/tests/typecheck/should_fail/T7869.stderr
+++ b/testsuite/tests/typecheck/should_fail/T7869.stderr
@@ -1,14 +1,14 @@
-
-T7869.hs:3:12: error:
- • Couldn't match type ‘b’ with ‘b1’
- because type variable ‘b1’ would escape its scope
- This (rigid, skolem) type variable is bound by
- an expression type signature:
- [a1] -> b1
- at T7869.hs:3:5-27
- Expected type: [a1] -> b1
- Actual type: [a] -> b
- • In the expression: f x
- In the expression: (\ x -> f x) :: [a] -> b
- In an equation for ‘f’: f = (\ x -> f x) :: [a] -> b
- • Relevant bindings include f :: [a] -> b (bound at T7869.hs:3:1)
+
+T7869.hs:3:12: error:
+ • Couldn't match type ‘b’ with ‘b1’
+ because type variable ‘b1’ would escape its scope
+ This (rigid, skolem) type variable is bound by
+ an expression type signature:
+ [a1] -> b1
+ at T7869.hs:3:20-27
+ Expected type: [a1] -> b1
+ Actual type: [a] -> b
+ • In the expression: f x
+ In the expression: (\ x -> f x) :: [a] -> b
+ In an equation for ‘f’: f = (\ x -> f x) :: [a] -> b
+ • Relevant bindings include f :: [a] -> b (bound at T7869.hs:3:1)
diff --git a/testsuite/tests/typecheck/should_fail/T8450.stderr b/testsuite/tests/typecheck/should_fail/T8450.stderr
index 5697e4db2b..c5a751d867 100644
--- a/testsuite/tests/typecheck/should_fail/T8450.stderr
+++ b/testsuite/tests/typecheck/should_fail/T8450.stderr
@@ -1,11 +1,11 @@
-
-T8450.hs:8:7: error:
- • Couldn't match expected type ‘a’ with actual type ‘()’
- ‘a’ is a rigid type variable bound by
- the type signature for:
- run :: forall a. a
- at T8450.hs:7:15
- • In the expression: runEffect $ (undefined :: Either a ())
- In an equation for ‘run’:
- run = runEffect $ (undefined :: Either a ())
- • Relevant bindings include run :: a (bound at T8450.hs:8:1)
+
+T8450.hs:8:7: error:
+ • Couldn't match expected type ‘a’ with actual type ‘()’
+ ‘a’ is a rigid type variable bound by
+ the type signature for:
+ run :: forall a. a
+ at T8450.hs:7:1-18
+ • In the expression: runEffect $ (undefined :: Either a ())
+ In an equation for ‘run’:
+ run = runEffect $ (undefined :: Either a ())
+ • Relevant bindings include run :: a (bound at T8450.hs:8:1)
diff --git a/testsuite/tests/typecheck/should_fail/T9109.stderr b/testsuite/tests/typecheck/should_fail/T9109.stderr
index 71d88efdc8..996da6e534 100644
--- a/testsuite/tests/typecheck/should_fail/T9109.stderr
+++ b/testsuite/tests/typecheck/should_fail/T9109.stderr
@@ -1,15 +1,15 @@
-
-T9109.hs:8:13: error:
- • Couldn't match expected type ‘t’ with actual type ‘Bool’
- ‘t’ is untouchable
- inside the constraints: t1 ~ Bool
- bound by a pattern with constructor: GBool :: G Bool,
- in an equation for ‘foo’
- at T9109.hs:8:5-9
- ‘t’ is a rigid type variable bound by
- the inferred type of foo :: G t1 -> t at T9109.hs:8:1
- Possible fix: add a type signature for ‘foo’
- • In the expression: True
- In an equation for ‘foo’: foo GBool = True
- • Relevant bindings include
- foo :: G t1 -> t (bound at T9109.hs:8:1)
+
+T9109.hs:8:13: error:
+ • Couldn't match expected type ‘t’ with actual type ‘Bool’
+ ‘t’ is untouchable
+ inside the constraints: t1 ~ Bool
+ bound by a pattern with constructor: GBool :: G Bool,
+ in an equation for ‘foo’
+ at T9109.hs:8:5-9
+ ‘t’ is a rigid type variable bound by
+ the inferred type of foo :: G t1 -> t at T9109.hs:8:1-16
+ Possible fix: add a type signature for ‘foo’
+ • In the expression: True
+ In an equation for ‘foo’: foo GBool = True
+ • Relevant bindings include
+ foo :: G t1 -> t (bound at T9109.hs:8:1)
diff --git a/testsuite/tests/typecheck/should_fail/mc19.stderr b/testsuite/tests/typecheck/should_fail/mc19.stderr
index 5f004dc4a8..4b00eeaecc 100644
--- a/testsuite/tests/typecheck/should_fail/mc19.stderr
+++ b/testsuite/tests/typecheck/should_fail/mc19.stderr
@@ -1,12 +1,12 @@
-
-mc19.hs:10:31: error:
- • Couldn't match type ‘a’ with ‘[a]’
- ‘a’ is a rigid type variable bound by
- a type expected by the context:
- forall a. [a] -> [a]
- at mc19.hs:10:10
- Expected type: [a] -> [a]
- Actual type: [a] -> [[a]]
- • In the expression: inits
- In a stmt of a monad comprehension: then inits
- In the expression: [x | x <- [3, 2, 1], then inits]
+
+mc19.hs:10:31: error:
+ • Couldn't match type ‘a’ with ‘[a]’
+ ‘a’ is a rigid type variable bound by
+ a type expected by the context:
+ forall a. [a] -> [a]
+ at mc19.hs:10:10-35
+ Expected type: [a] -> [a]
+ Actual type: [a] -> [[a]]
+ • In the expression: inits
+ In a stmt of a monad comprehension: then inits
+ In the expression: [x | x <- [3, 2, 1], then inits]
diff --git a/testsuite/tests/typecheck/should_fail/mc21.stderr b/testsuite/tests/typecheck/should_fail/mc21.stderr
index 74a13b14bc..d650f0ebda 100644
--- a/testsuite/tests/typecheck/should_fail/mc21.stderr
+++ b/testsuite/tests/typecheck/should_fail/mc21.stderr
@@ -1,13 +1,13 @@
-
-mc21.hs:12:26: error:
- • Couldn't match type ‘a’ with ‘[a]’
- ‘a’ is a rigid type variable bound by
- a type expected by the context:
- forall a. [a] -> [[a]]
- at mc21.hs:11:9
- Expected type: [a] -> [[a]]
- Actual type: [[a]] -> [[a]]
- • In the expression: take 5
- In a stmt of a monad comprehension: then group using take 5
- In the expression:
- [GHC.List.length x | x <- [Gnorf, Brain], then group using take 5]
+
+mc21.hs:12:26: error:
+ • Couldn't match type ‘a’ with ‘[a]’
+ ‘a’ is a rigid type variable bound by
+ a type expected by the context:
+ forall a. [a] -> [[a]]
+ at mc21.hs:(11,9)-(12,31)
+ Expected type: [a] -> [[a]]
+ Actual type: [[a]] -> [[a]]
+ • In the expression: take 5
+ In a stmt of a monad comprehension: then group using take 5
+ In the expression:
+ [GHC.List.length x | x <- [Gnorf, Brain], then group using take 5]
diff --git a/testsuite/tests/typecheck/should_fail/mc22.stderr b/testsuite/tests/typecheck/should_fail/mc22.stderr
index d15dd7bde3..a394859f1d 100644
--- a/testsuite/tests/typecheck/should_fail/mc22.stderr
+++ b/testsuite/tests/typecheck/should_fail/mc22.stderr
@@ -1,15 +1,15 @@
-
-mc22.hs:10:26: error:
- • Couldn't match type ‘a’ with ‘t a’
- ‘a’ is a rigid type variable bound by
- a type expected by the context:
- forall a. [a] -> [t a]
- at mc22.hs:9:9
- Expected type: [a] -> [t a]
- Actual type: [t a] -> [t a]
- • In the expression: take 5
- In a stmt of a monad comprehension: then group using take 5
- In the expression:
- [x + 1 | x <- ["Hello", "World"], then group using take 5]
- • Relevant bindings include
- foo :: [t [Char]] (bound at mc22.hs:8:1)
+
+mc22.hs:10:26: error:
+ • Couldn't match type ‘a’ with ‘t a’
+ ‘a’ is a rigid type variable bound by
+ a type expected by the context:
+ forall a. [a] -> [t a]
+ at mc22.hs:(9,9)-(10,31)
+ Expected type: [a] -> [t a]
+ Actual type: [t a] -> [t a]
+ • In the expression: take 5
+ In a stmt of a monad comprehension: then group using take 5
+ In the expression:
+ [x + 1 | x <- ["Hello", "World"], then group using take 5]
+ • Relevant bindings include
+ foo :: [t [Char]] (bound at mc22.hs:8:1)
diff --git a/testsuite/tests/typecheck/should_fail/tcfail032.stderr b/testsuite/tests/typecheck/should_fail/tcfail032.stderr
index ce3ce2d018..b576a1e380 100644
--- a/testsuite/tests/typecheck/should_fail/tcfail032.stderr
+++ b/testsuite/tests/typecheck/should_fail/tcfail032.stderr
@@ -1,13 +1,13 @@
-
-tcfail032.hs:14:8: error:
- • Couldn't match expected type ‘a1 -> Int’ with actual type ‘t’
- because type variable ‘a1’ would escape its scope
- This (rigid, skolem) type variable is bound by
- an expression type signature:
- Eq a1 => a1 -> Int
- at tcfail032.hs:14:8-30
- • In the expression: (x :: (Eq a) => a -> Int)
- In an equation for ‘f’: f x = (x :: (Eq a) => a -> Int)
- • Relevant bindings include
- x :: t (bound at tcfail032.hs:14:3)
- f :: t -> forall a. Eq a => a -> Int (bound at tcfail032.hs:14:1)
+
+tcfail032.hs:14:8: error:
+ • Couldn't match expected type ‘a1 -> Int’ with actual type ‘t’
+ because type variable ‘a1’ would escape its scope
+ This (rigid, skolem) type variable is bound by
+ an expression type signature:
+ Eq a1 => a1 -> Int
+ at tcfail032.hs:14:13-30
+ • In the expression: (x :: (Eq a) => a -> Int)
+ In an equation for ‘f’: f x = (x :: (Eq a) => a -> Int)
+ • Relevant bindings include
+ x :: t (bound at tcfail032.hs:14:3)
+ f :: t -> forall a. Eq a => a -> Int (bound at tcfail032.hs:14:1)
diff --git a/testsuite/tests/typecheck/should_fail/tcfail065.stderr b/testsuite/tests/typecheck/should_fail/tcfail065.stderr
index 369b0807d7..e38196980d 100644
--- a/testsuite/tests/typecheck/should_fail/tcfail065.stderr
+++ b/testsuite/tests/typecheck/should_fail/tcfail065.stderr
@@ -1,17 +1,17 @@
-
-tcfail065.hs:29:18: error:
- • Couldn't match type ‘x1’ with ‘x’
- ‘x1’ is a rigid type variable bound by
- the type signature for:
- setX :: forall x1. x1 -> X x -> X x
- at tcfail065.hs:29:3
- ‘x’ is a rigid type variable bound by
- the instance declaration at tcfail065.hs:28:10
- Expected type: X x
- Actual type: X x1
- • In the expression: X x
- In an equation for ‘setX’: setX x (X _) = X x
- In the instance declaration for ‘HasX (X x)’
- • Relevant bindings include
- x :: x1 (bound at tcfail065.hs:29:8)
- setX :: x1 -> X x -> X x (bound at tcfail065.hs:29:3)
+
+tcfail065.hs:29:18: error:
+ • Couldn't match type ‘x1’ with ‘x’
+ ‘x1’ is a rigid type variable bound by
+ the type signature for:
+ setX :: forall x1. x1 -> X x -> X x
+ at tcfail065.hs:29:3-6
+ ‘x’ is a rigid type variable bound by
+ the instance declaration at tcfail065.hs:28:10-19
+ Expected type: X x
+ Actual type: X x1
+ • In the expression: X x
+ In an equation for ‘setX’: setX x (X _) = X x
+ In the instance declaration for ‘HasX (X x)’
+ • Relevant bindings include
+ x :: x1 (bound at tcfail065.hs:29:8)
+ setX :: x1 -> X x -> X x (bound at tcfail065.hs:29:3)
diff --git a/testsuite/tests/typecheck/should_fail/tcfail068.stderr b/testsuite/tests/typecheck/should_fail/tcfail068.stderr
index eb42f9a33b..66e7f09064 100644
--- a/testsuite/tests/typecheck/should_fail/tcfail068.stderr
+++ b/testsuite/tests/typecheck/should_fail/tcfail068.stderr
@@ -1,142 +1,142 @@
-
-tcfail068.hs:14:9: error:
- • Couldn't match type ‘s1’ with ‘s’
- ‘s1’ is a rigid type variable bound by
- a type expected by the context:
- forall s1. GHC.ST.ST s1 (IndTree s a)
- at tcfail068.hs:13:9
- ‘s’ is a rigid type variable bound by
- the type signature for:
- itgen :: forall a s.
- Constructed a =>
- (Int, Int) -> a -> IndTree s a
- at tcfail068.hs:11:10
- Expected type: GHC.ST.ST s1 (IndTree s a)
- Actual type: GHC.ST.ST s1 (STArray s1 (Int, Int) a)
- • In the first argument of ‘runST’, namely
- ‘(newSTArray ((1, 1), n) x)’
- In the expression: runST (newSTArray ((1, 1), n) x)
- In an equation for ‘itgen’:
- itgen n x = runST (newSTArray ((1, 1), n) x)
- • Relevant bindings include
- itgen :: (Int, Int) -> a -> IndTree s a
- (bound at tcfail068.hs:12:1)
-
-tcfail068.hs:19:9: error:
- • Couldn't match type ‘s’ with ‘s1’
- ‘s’ is a rigid type variable bound by
- the type signature for:
- itiap :: forall a s.
- Constructed a =>
- (Int, Int) -> (a -> a) -> IndTree s a -> IndTree s a
- at tcfail068.hs:16:10
- ‘s1’ is a rigid type variable bound by
- a type expected by the context:
- forall s1. GHC.ST.ST s1 (IndTree s a)
- at tcfail068.hs:18:9
- Expected type: GHC.ST.ST s1 (IndTree s a)
- Actual type: GHC.ST.ST s (IndTree s a)
- • In the first argument of ‘runST’, namely
- ‘(readSTArray arr i
- >>= \ val -> writeSTArray arr i (f val) >> return arr)’
- In the expression:
- runST
- (readSTArray arr i
- >>= \ val -> writeSTArray arr i (f val) >> return arr)
- In an equation for ‘itiap’:
- itiap i f arr
- = runST
- (readSTArray arr i
- >>= \ val -> writeSTArray arr i (f val) >> return arr)
- • Relevant bindings include
- arr :: IndTree s a (bound at tcfail068.hs:17:11)
- itiap :: (Int, Int) -> (a -> a) -> IndTree s a -> IndTree s a
- (bound at tcfail068.hs:17:1)
-
-tcfail068.hs:24:36: error:
- • Couldn't match type ‘s’ with ‘s1’
- ‘s’ is a rigid type variable bound by
- the type signature for:
- itrap :: forall a s.
- Constructed a =>
- ((Int, Int), (Int, Int)) -> (a -> a) -> IndTree s a -> IndTree s a
- at tcfail068.hs:23:10
- ‘s1’ is a rigid type variable bound by
- a type expected by the context:
- forall s1. GHC.ST.ST s1 (IndTree s a)
- at tcfail068.hs:24:29
- Expected type: GHC.ST.ST s1 (IndTree s a)
- Actual type: GHC.ST.ST s (IndTree s a)
- • In the first argument of ‘runST’, namely ‘(itrap' i k)’
- In the expression: runST (itrap' i k)
- In an equation for ‘itrap’:
- itrap ((i, k), (j, l)) f arr
- = runST (itrap' i k)
- where
- itrap' i k
- = if k > l then return arr else (itrapsnd i k >> itrap' i (k + 1))
- itrapsnd i k
- = if i > j then
- return arr
- else
- (readSTArray arr (i, k) >>= \ val -> ...)
- • Relevant bindings include
- itrap' :: Int -> Int -> GHC.ST.ST s (IndTree s a)
- (bound at tcfail068.hs:26:9)
- itrapsnd :: Int -> Int -> GHC.ST.ST s (IndTree s a)
- (bound at tcfail068.hs:29:9)
- arr :: IndTree s a (bound at tcfail068.hs:24:23)
- itrap :: ((Int, Int), (Int, Int))
- -> (a -> a) -> IndTree s a -> IndTree s a
- (bound at tcfail068.hs:24:1)
-
-tcfail068.hs:36:46: error:
- • Couldn't match type ‘s’ with ‘s1’
- ‘s’ is a rigid type variable bound by
- the type signature for:
- itrapstate :: forall b a c s.
- Constructed b =>
- ((Int, Int), (Int, Int))
- -> (a -> b -> (a, b))
- -> ((Int, Int) -> c -> a)
- -> (a -> c)
- -> c
- -> IndTree s b
- -> (c, IndTree s b)
- at tcfail068.hs:34:15
- ‘s1’ is a rigid type variable bound by
- a type expected by the context:
- forall s1. GHC.ST.ST s1 (c, IndTree s b)
- at tcfail068.hs:36:40
- Expected type: GHC.ST.ST s1 (c, IndTree s b)
- Actual type: GHC.ST.ST s (c, IndTree s b)
- • In the first argument of ‘runST’, namely ‘(itrapstate' i k s)’
- In the expression: runST (itrapstate' i k s)
- In an equation for ‘itrapstate’:
- itrapstate ((i, k), (j, l)) f c d s arr
- = runST (itrapstate' i k s)
- where
- itrapstate' i k s
- = if k > l then
- return (s, arr)
- else
- (itrapstatesnd i k s >>= \ (s, arr) -> ...)
- itrapstatesnd i k s
- = if i > j then
- return (s, arr)
- else
- (readSTArray arr (i, k) >>= \ val -> ...)
- • Relevant bindings include
- itrapstate' :: Int -> Int -> c -> GHC.ST.ST s (c, IndTree s b)
- (bound at tcfail068.hs:38:9)
- itrapstatesnd :: Int -> Int -> c -> GHC.ST.ST s (c, IndTree s b)
- (bound at tcfail068.hs:41:9)
- arr :: IndTree s b (bound at tcfail068.hs:36:34)
- itrapstate :: ((Int, Int), (Int, Int))
- -> (a -> b -> (a, b))
- -> ((Int, Int) -> c -> a)
- -> (a -> c)
- -> c
- -> IndTree s b
- -> (c, IndTree s b)
- (bound at tcfail068.hs:36:1)
+
+tcfail068.hs:14:9: error:
+ • Couldn't match type ‘s1’ with ‘s’
+ ‘s1’ is a rigid type variable bound by
+ a type expected by the context:
+ forall s1. GHC.ST.ST s1 (IndTree s a)
+ at tcfail068.hs:(13,9)-(14,31)
+ ‘s’ is a rigid type variable bound by
+ the type signature for:
+ itgen :: forall a s.
+ Constructed a =>
+ (Int, Int) -> a -> IndTree s a
+ at tcfail068.hs:11:1-55
+ Expected type: GHC.ST.ST s1 (IndTree s a)
+ Actual type: GHC.ST.ST s1 (STArray s1 (Int, Int) a)
+ • In the first argument of ‘runST’, namely
+ ‘(newSTArray ((1, 1), n) x)’
+ In the expression: runST (newSTArray ((1, 1), n) x)
+ In an equation for ‘itgen’:
+ itgen n x = runST (newSTArray ((1, 1), n) x)
+ • Relevant bindings include
+ itgen :: (Int, Int) -> a -> IndTree s a
+ (bound at tcfail068.hs:12:1)
+
+tcfail068.hs:19:9: error:
+ • Couldn't match type ‘s’ with ‘s1’
+ ‘s’ is a rigid type variable bound by
+ the type signature for:
+ itiap :: forall a s.
+ Constructed a =>
+ (Int, Int) -> (a -> a) -> IndTree s a -> IndTree s a
+ at tcfail068.hs:16:1-75
+ ‘s1’ is a rigid type variable bound by
+ a type expected by the context:
+ forall s1. GHC.ST.ST s1 (IndTree s a)
+ at tcfail068.hs:(18,9)-(21,19)
+ Expected type: GHC.ST.ST s1 (IndTree s a)
+ Actual type: GHC.ST.ST s (IndTree s a)
+ • In the first argument of ‘runST’, namely
+ ‘(readSTArray arr i
+ >>= \ val -> writeSTArray arr i (f val) >> return arr)’
+ In the expression:
+ runST
+ (readSTArray arr i
+ >>= \ val -> writeSTArray arr i (f val) >> return arr)
+ In an equation for ‘itiap’:
+ itiap i f arr
+ = runST
+ (readSTArray arr i
+ >>= \ val -> writeSTArray arr i (f val) >> return arr)
+ • Relevant bindings include
+ arr :: IndTree s a (bound at tcfail068.hs:17:11)
+ itiap :: (Int, Int) -> (a -> a) -> IndTree s a -> IndTree s a
+ (bound at tcfail068.hs:17:1)
+
+tcfail068.hs:24:36: error:
+ • Couldn't match type ‘s’ with ‘s1’
+ ‘s’ is a rigid type variable bound by
+ the type signature for:
+ itrap :: forall a s.
+ Constructed a =>
+ ((Int, Int), (Int, Int)) -> (a -> a) -> IndTree s a -> IndTree s a
+ at tcfail068.hs:23:1-87
+ ‘s1’ is a rigid type variable bound by
+ a type expected by the context:
+ forall s1. GHC.ST.ST s1 (IndTree s a)
+ at tcfail068.hs:24:29-46
+ Expected type: GHC.ST.ST s1 (IndTree s a)
+ Actual type: GHC.ST.ST s (IndTree s a)
+ • In the first argument of ‘runST’, namely ‘(itrap' i k)’
+ In the expression: runST (itrap' i k)
+ In an equation for ‘itrap’:
+ itrap ((i, k), (j, l)) f arr
+ = runST (itrap' i k)
+ where
+ itrap' i k
+ = if k > l then return arr else (itrapsnd i k >> itrap' i (k + 1))
+ itrapsnd i k
+ = if i > j then
+ return arr
+ else
+ (readSTArray arr (i, k) >>= \ val -> ...)
+ • Relevant bindings include
+ itrap' :: Int -> Int -> GHC.ST.ST s (IndTree s a)
+ (bound at tcfail068.hs:26:9)
+ itrapsnd :: Int -> Int -> GHC.ST.ST s (IndTree s a)
+ (bound at tcfail068.hs:29:9)
+ arr :: IndTree s a (bound at tcfail068.hs:24:23)
+ itrap :: ((Int, Int), (Int, Int))
+ -> (a -> a) -> IndTree s a -> IndTree s a
+ (bound at tcfail068.hs:24:1)
+
+tcfail068.hs:36:46: error:
+ • Couldn't match type ‘s’ with ‘s1’
+ ‘s’ is a rigid type variable bound by
+ the type signature for:
+ itrapstate :: forall b a c s.
+ Constructed b =>
+ ((Int, Int), (Int, Int))
+ -> (a -> b -> (a, b))
+ -> ((Int, Int) -> c -> a)
+ -> (a -> c)
+ -> c
+ -> IndTree s b
+ -> (c, IndTree s b)
+ at tcfail068.hs:(34,1)-(35,62)
+ ‘s1’ is a rigid type variable bound by
+ a type expected by the context:
+ forall s1. GHC.ST.ST s1 (c, IndTree s b)
+ at tcfail068.hs:36:40-63
+ Expected type: GHC.ST.ST s1 (c, IndTree s b)
+ Actual type: GHC.ST.ST s (c, IndTree s b)
+ • In the first argument of ‘runST’, namely ‘(itrapstate' i k s)’
+ In the expression: runST (itrapstate' i k s)
+ In an equation for ‘itrapstate’:
+ itrapstate ((i, k), (j, l)) f c d s arr
+ = runST (itrapstate' i k s)
+ where
+ itrapstate' i k s
+ = if k > l then
+ return (s, arr)
+ else
+ (itrapstatesnd i k s >>= \ (s, arr) -> ...)
+ itrapstatesnd i k s
+ = if i > j then
+ return (s, arr)
+ else
+ (readSTArray arr (i, k) >>= \ val -> ...)
+ • Relevant bindings include
+ itrapstate' :: Int -> Int -> c -> GHC.ST.ST s (c, IndTree s b)
+ (bound at tcfail068.hs:38:9)
+ itrapstatesnd :: Int -> Int -> c -> GHC.ST.ST s (c, IndTree s b)
+ (bound at tcfail068.hs:41:9)
+ arr :: IndTree s b (bound at tcfail068.hs:36:34)
+ itrapstate :: ((Int, Int), (Int, Int))
+ -> (a -> b -> (a, b))
+ -> ((Int, Int) -> c -> a)
+ -> (a -> c)
+ -> c
+ -> IndTree s b
+ -> (c, IndTree s b)
+ (bound at tcfail068.hs:36:1)
diff --git a/testsuite/tests/typecheck/should_fail/tcfail076.stderr b/testsuite/tests/typecheck/should_fail/tcfail076.stderr
index 242c62235e..bee39a2c68 100644
--- a/testsuite/tests/typecheck/should_fail/tcfail076.stderr
+++ b/testsuite/tests/typecheck/should_fail/tcfail076.stderr
@@ -1,19 +1,19 @@
-
-tcfail076.hs:18:82: error:
- • Couldn't match type ‘res’ with ‘res1’
- ‘res’ is a rigid type variable bound by
- a type expected by the context:
- forall res. (a -> m res) -> m res
- at tcfail076.hs:18:28
- ‘res1’ is a rigid type variable bound by
- a type expected by the context:
- forall res1. (b -> m res1) -> m res1
- at tcfail076.hs:18:64
- Expected type: m res1
- Actual type: m res
- • In the expression: cont a
- In the first argument of ‘KContT’, namely ‘(\ cont' -> cont a)’
- In the expression: KContT (\ cont' -> cont a)
- • Relevant bindings include
- cont' :: b -> m res1 (bound at tcfail076.hs:18:73)
- cont :: a -> m res (bound at tcfail076.hs:18:37)
+
+tcfail076.hs:18:82: error:
+ • Couldn't match type ‘res’ with ‘res1’
+ ‘res’ is a rigid type variable bound by
+ a type expected by the context:
+ forall res. (a -> m res) -> m res
+ at tcfail076.hs:18:28-96
+ ‘res1’ is a rigid type variable bound by
+ a type expected by the context:
+ forall res1. (b -> m res1) -> m res1
+ at tcfail076.hs:18:64-88
+ Expected type: m res1
+ Actual type: m res
+ • In the expression: cont a
+ In the first argument of ‘KContT’, namely ‘(\ cont' -> cont a)’
+ In the expression: KContT (\ cont' -> cont a)
+ • Relevant bindings include
+ cont' :: b -> m res1 (bound at tcfail076.hs:18:73)
+ cont :: a -> m res (bound at tcfail076.hs:18:37)
diff --git a/testsuite/tests/typecheck/should_fail/tcfail103.stderr b/testsuite/tests/typecheck/should_fail/tcfail103.stderr
index 2d76dc588a..59635a3638 100644
--- a/testsuite/tests/typecheck/should_fail/tcfail103.stderr
+++ b/testsuite/tests/typecheck/should_fail/tcfail103.stderr
@@ -1,24 +1,24 @@
-
-tcfail103.hs:15:13: error:
- • Couldn't match type ‘t’ with ‘s’
- ‘t’ is a rigid type variable bound by
- the type signature for:
- f :: forall t. ST t Int
- at tcfail103.hs:10:5
- ‘s’ is a rigid type variable bound by
- the type signature for:
- g :: forall s. ST s Int
- at tcfail103.hs:13:14
- Expected type: ST s Int
- Actual type: ST t Int
- • In the expression: readSTRef v
- In an equation for ‘g’: g = readSTRef v
- In the expression:
- do { v <- newSTRef 5;
- let g :: ST s Int
- g = readSTRef v;
- g }
- • Relevant bindings include
- g :: ST s Int (bound at tcfail103.hs:15:9)
- v :: STRef t Int (bound at tcfail103.hs:12:5)
- f :: ST t Int (bound at tcfail103.hs:11:1)
+
+tcfail103.hs:15:13: error:
+ • Couldn't match type ‘t’ with ‘s’
+ ‘t’ is a rigid type variable bound by
+ the type signature for:
+ f :: forall t. ST t Int
+ at tcfail103.hs:10:1-12
+ ‘s’ is a rigid type variable bound by
+ the type signature for:
+ g :: forall s. ST s Int
+ at tcfail103.hs:13:9-21
+ Expected type: ST s Int
+ Actual type: ST t Int
+ • In the expression: readSTRef v
+ In an equation for ‘g’: g = readSTRef v
+ In the expression:
+ do { v <- newSTRef 5;
+ let g :: ST s Int
+ g = readSTRef v;
+ g }
+ • Relevant bindings include
+ g :: ST s Int (bound at tcfail103.hs:15:9)
+ v :: STRef t Int (bound at tcfail103.hs:12:5)
+ f :: ST t Int (bound at tcfail103.hs:11:1)
diff --git a/testsuite/tests/typecheck/should_fail/tcfail131.stderr b/testsuite/tests/typecheck/should_fail/tcfail131.stderr
index 2ae70a0928..e9920ea55e 100644
--- a/testsuite/tests/typecheck/should_fail/tcfail131.stderr
+++ b/testsuite/tests/typecheck/should_fail/tcfail131.stderr
@@ -1,13 +1,13 @@
-
-tcfail131.hs:7:11: error:
- • Couldn't match expected type ‘Integer’ with actual type ‘b’
- ‘b’ is a rigid type variable bound by
- the type signature for:
- g :: forall b. Num b => b -> b
- at tcfail131.hs:6:8
- • In the first argument of ‘f’, namely ‘x’
- In the expression: f x x
- In an equation for ‘g’: g x = f x x
- • Relevant bindings include
- x :: b (bound at tcfail131.hs:7:5)
- g :: b -> b (bound at tcfail131.hs:7:3)
+
+tcfail131.hs:7:11: error:
+ • Couldn't match expected type ‘Integer’ with actual type ‘b’
+ ‘b’ is a rigid type variable bound by
+ the type signature for:
+ g :: forall b. Num b => b -> b
+ at tcfail131.hs:6:3-22
+ • In the first argument of ‘f’, namely ‘x’
+ In the expression: f x x
+ In an equation for ‘g’: g x = f x x
+ • Relevant bindings include
+ x :: b (bound at tcfail131.hs:7:5)
+ g :: b -> b (bound at tcfail131.hs:7:3)
diff --git a/testsuite/tests/typecheck/should_fail/tcfail153.stderr b/testsuite/tests/typecheck/should_fail/tcfail153.stderr
index 5f4ec3e013..e80add6e90 100644
--- a/testsuite/tests/typecheck/should_fail/tcfail153.stderr
+++ b/testsuite/tests/typecheck/should_fail/tcfail153.stderr
@@ -1,17 +1,17 @@
-
-tcfail153.hs:6:9: error:
- • Couldn't match expected type ‘Bool’ with actual type ‘a’
- ‘a’ is a rigid type variable bound by
- the type signature for:
- f :: forall a. a -> [a]
- at tcfail153.hs:5:6
- • In the first argument of ‘g’, namely ‘x’
- In the expression: g x
- In an equation for ‘f’:
- f x
- = g x
- where
- g y = if y then [] else [...]
- • Relevant bindings include
- x :: a (bound at tcfail153.hs:6:3)
- f :: a -> [a] (bound at tcfail153.hs:6:1)
+
+tcfail153.hs:6:9: error:
+ • Couldn't match expected type ‘Bool’ with actual type ‘a’
+ ‘a’ is a rigid type variable bound by
+ the type signature for:
+ f :: forall a. a -> [a]
+ at tcfail153.hs:5:1-13
+ • In the first argument of ‘g’, namely ‘x’
+ In the expression: g x
+ In an equation for ‘f’:
+ f x
+ = g x
+ where
+ g y = if y then [] else [...]
+ • Relevant bindings include
+ x :: a (bound at tcfail153.hs:6:3)
+ f :: a -> [a] (bound at tcfail153.hs:6:1)
diff --git a/testsuite/tests/typecheck/should_fail/tcfail174.stderr b/testsuite/tests/typecheck/should_fail/tcfail174.stderr
index 9c473e9884..66a057bd9b 100644
--- a/testsuite/tests/typecheck/should_fail/tcfail174.stderr
+++ b/testsuite/tests/typecheck/should_fail/tcfail174.stderr
@@ -1,30 +1,30 @@
-
-tcfail174.hs:14:14: error:
- • Couldn't match type ‘a’ with ‘a1’
- because type variable ‘a1’ would escape its scope
- This (rigid, skolem) type variable is bound by
- the type a1 -> a1
- at tcfail174.hs:14:1-14
- Expected type: Capture (forall x. x -> a)
- Actual type: Capture (forall a. a -> a)
- • In the first argument of ‘Capture’, namely ‘g’
- In the expression: Capture g
- In an equation for ‘h1’: h1 = Capture g
- • Relevant bindings include
- h1 :: Capture a (bound at tcfail174.hs:14:1)
-
-tcfail174.hs:17:14: error:
- • Couldn't match type ‘a’ with ‘b’
- ‘a’ is a rigid type variable bound by
- the type a -> a at tcfail174.hs:1:1
- ‘b’ is a rigid type variable bound by
- the type signature for:
- h2 :: forall b. Capture b
- at tcfail174.hs:16:7
- Expected type: Capture (forall x. x -> b)
- Actual type: Capture (forall a. a -> a)
- • In the first argument of ‘Capture’, namely ‘g’
- In the expression: Capture g
- In an equation for ‘h2’: h2 = Capture g
- • Relevant bindings include
- h2 :: Capture b (bound at tcfail174.hs:17:1)
+
+tcfail174.hs:14:14: error:
+ • Couldn't match type ‘a’ with ‘a1’
+ because type variable ‘a1’ would escape its scope
+ This (rigid, skolem) type variable is bound by
+ the type a1 -> a1
+ at tcfail174.hs:14:1-14
+ Expected type: Capture (forall x. x -> a)
+ Actual type: Capture (forall a. a -> a)
+ • In the first argument of ‘Capture’, namely ‘g’
+ In the expression: Capture g
+ In an equation for ‘h1’: h1 = Capture g
+ • Relevant bindings include
+ h1 :: Capture a (bound at tcfail174.hs:14:1)
+
+tcfail174.hs:17:14: error:
+ • Couldn't match type ‘a’ with ‘b’
+ ‘a’ is a rigid type variable bound by
+ the type a -> a at tcfail174.hs:1:1
+ ‘b’ is a rigid type variable bound by
+ the type signature for:
+ h2 :: forall b. Capture b
+ at tcfail174.hs:16:1-15
+ Expected type: Capture (forall x. x -> b)
+ Actual type: Capture (forall a. a -> a)
+ • In the first argument of ‘Capture’, namely ‘g’
+ In the expression: Capture g
+ In an equation for ‘h2’: h2 = Capture g
+ • Relevant bindings include
+ h2 :: Capture b (bound at tcfail174.hs:17:1)
diff --git a/testsuite/tests/typecheck/should_fail/tcfail175.stderr b/testsuite/tests/typecheck/should_fail/tcfail175.stderr
index c421684b8d..b55203de3f 100644
--- a/testsuite/tests/typecheck/should_fail/tcfail175.stderr
+++ b/testsuite/tests/typecheck/should_fail/tcfail175.stderr
@@ -1,12 +1,12 @@
-
-tcfail175.hs:11:1: error:
- • Couldn't match expected type ‘a’
- with actual type ‘String -> String -> String’
- ‘a’ is a rigid type variable bound by
- the type signature for:
- evalRHS :: forall a. Int -> a
- at tcfail175.hs:10:12
- • The equation(s) for ‘evalRHS’ have three arguments,
- but its type ‘Int -> a’ has only one
- • Relevant bindings include
- evalRHS :: Int -> a (bound at tcfail175.hs:11:1)
+
+tcfail175.hs:11:1: error:
+ • Couldn't match expected type ‘a’
+ with actual type ‘String -> String -> String’
+ ‘a’ is a rigid type variable bound by
+ the type signature for:
+ evalRHS :: forall a. Int -> a
+ at tcfail175.hs:10:1-19
+ • The equation(s) for ‘evalRHS’ have three arguments,
+ but its type ‘Int -> a’ has only one
+ • Relevant bindings include
+ evalRHS :: Int -> a (bound at tcfail175.hs:11:1)
diff --git a/testsuite/tests/typecheck/should_fail/tcfail179.stderr b/testsuite/tests/typecheck/should_fail/tcfail179.stderr
index 2a0a5bf614..cb01a3c483 100644
--- a/testsuite/tests/typecheck/should_fail/tcfail179.stderr
+++ b/testsuite/tests/typecheck/should_fail/tcfail179.stderr
@@ -1,22 +1,22 @@
-
-tcfail179.hs:14:41: error:
- • Couldn't match type ‘x’ with ‘s’
- ‘x’ is a rigid type variable bound by
- a pattern with constructor:
- T :: forall s x. (s -> (x -> s) -> (x, s, Int)) -> T s,
- in a case alternative
- at tcfail179.hs:14:14
- ‘s’ is a rigid type variable bound by
- the type signature for:
- run :: forall s. T s -> Int
- at tcfail179.hs:12:8
- Expected type: x -> s
- Actual type: s -> s
- • In the second argument of ‘g’, namely ‘id’
- In the expression: g x id
- In a pattern binding: (x, _, b) = g x id
- • Relevant bindings include
- x :: s (bound at tcfail179.hs:14:26)
- g :: s -> (x -> s) -> (x, s, Int) (bound at tcfail179.hs:14:16)
- ts :: T s (bound at tcfail179.hs:13:5)
- run :: T s -> Int (bound at tcfail179.hs:13:1)
+
+tcfail179.hs:14:41: error:
+ • Couldn't match type ‘x’ with ‘s’
+ ‘x’ is a rigid type variable bound by
+ a pattern with constructor:
+ T :: forall s x. (s -> (x -> s) -> (x, s, Int)) -> T s,
+ in a case alternative
+ at tcfail179.hs:14:14-16
+ ‘s’ is a rigid type variable bound by
+ the type signature for:
+ run :: forall s. T s -> Int
+ at tcfail179.hs:12:1-17
+ Expected type: x -> s
+ Actual type: s -> s
+ • In the second argument of ‘g’, namely ‘id’
+ In the expression: g x id
+ In a pattern binding: (x, _, b) = g x id
+ • Relevant bindings include
+ x :: s (bound at tcfail179.hs:14:26)
+ g :: s -> (x -> s) -> (x, s, Int) (bound at tcfail179.hs:14:16)
+ ts :: T s (bound at tcfail179.hs:13:5)
+ run :: T s -> Int (bound at tcfail179.hs:13:1)
diff --git a/testsuite/tests/typecheck/should_fail/tcfail191.stderr b/testsuite/tests/typecheck/should_fail/tcfail191.stderr
index 6b338eb5ed..fe831aeae2 100644
--- a/testsuite/tests/typecheck/should_fail/tcfail191.stderr
+++ b/testsuite/tests/typecheck/should_fail/tcfail191.stderr
@@ -1,13 +1,13 @@
-
-tcfail191.hs:11:26: error:
- • Couldn't match type ‘a’ with ‘[a]’
- ‘a’ is a rigid type variable bound by
- a type expected by the context:
- forall a. [a] -> [[a]]
- at tcfail191.hs:10:9
- Expected type: [a] -> [[a]]
- Actual type: [[a]] -> [[a]]
- • In the expression: take 5
- In a stmt of a list comprehension: then group using take 5
- In the expression:
- [() | x <- [Gnorf, Brain], then group using take 5]
+
+tcfail191.hs:11:26: error:
+ • Couldn't match type ‘a’ with ‘[a]’
+ ‘a’ is a rigid type variable bound by
+ a type expected by the context:
+ forall a. [a] -> [[a]]
+ at tcfail191.hs:(10,9)-(11,31)
+ Expected type: [a] -> [[a]]
+ Actual type: [[a]] -> [[a]]
+ • In the expression: take 5
+ In a stmt of a list comprehension: then group using take 5
+ In the expression:
+ [() | x <- [Gnorf, Brain], then group using take 5]
diff --git a/testsuite/tests/typecheck/should_fail/tcfail193.stderr b/testsuite/tests/typecheck/should_fail/tcfail193.stderr
index 4a96fa4aef..0e24649578 100644
--- a/testsuite/tests/typecheck/should_fail/tcfail193.stderr
+++ b/testsuite/tests/typecheck/should_fail/tcfail193.stderr
@@ -1,12 +1,12 @@
-
-tcfail193.hs:10:31: error:
- • Couldn't match type ‘a’ with ‘[a]’
- ‘a’ is a rigid type variable bound by
- a type expected by the context:
- forall a. [a] -> [a]
- at tcfail193.hs:10:10
- Expected type: [a] -> [a]
- Actual type: [a] -> [[a]]
- • In the expression: inits
- In a stmt of a list comprehension: then inits
- In the expression: [x | x <- [3, 2, 1], then inits]
+
+tcfail193.hs:10:31: error:
+ • Couldn't match type ‘a’ with ‘[a]’
+ ‘a’ is a rigid type variable bound by
+ a type expected by the context:
+ forall a. [a] -> [a]
+ at tcfail193.hs:10:10-35
+ Expected type: [a] -> [a]
+ Actual type: [a] -> [[a]]
+ • In the expression: inits
+ In a stmt of a list comprehension: then inits
+ In the expression: [x | x <- [3, 2, 1], then inits]
diff --git a/testsuite/tests/typecheck/should_fail/tcfail198.stderr b/testsuite/tests/typecheck/should_fail/tcfail198.stderr
index 56b1b70670..f073b5e66e 100644
--- a/testsuite/tests/typecheck/should_fail/tcfail198.stderr
+++ b/testsuite/tests/typecheck/should_fail/tcfail198.stderr
@@ -5,7 +5,7 @@ tcfail198.hs:6:36: error:
This (rigid, skolem) type variable is bound by
an expression type signature:
a1
- at tcfail198.hs:6:36-41
+ at tcfail198.hs:6:41
• In the expression: x :: a
In the second argument of ‘(++)’, namely ‘[x :: a]’
In the expression: xs ++ [x :: a]
diff --git a/testsuite/tests/typecheck/should_fail/tcfail201.stderr b/testsuite/tests/typecheck/should_fail/tcfail201.stderr
index b142cb18bd..9df11cafff 100644
--- a/testsuite/tests/typecheck/should_fail/tcfail201.stderr
+++ b/testsuite/tests/typecheck/should_fail/tcfail201.stderr
@@ -1,19 +1,19 @@
-
-tcfail201.hs:17:56: error:
- • Couldn't match type ‘a’ with ‘HsDoc t0’
- ‘a’ is a rigid type variable bound by
- the type signature for:
- gfoldl' :: forall (c :: * -> *) a.
- (forall a1 b. c (a1 -> b) -> a1 -> c b)
- -> (forall g. g -> c g) -> a -> c a
- at tcfail201.hs:15:12
- Expected type: c a
- Actual type: c (HsDoc t0)
- • In the expression: z DocEmpty
- In a case alternative: DocEmpty -> z DocEmpty
- In the expression: case hsDoc of { DocEmpty -> z DocEmpty }
- • Relevant bindings include
- hsDoc :: a (bound at tcfail201.hs:16:13)
- gfoldl' :: (forall a1 b. c (a1 -> b) -> a1 -> c b)
- -> (forall g. g -> c g) -> a -> c a
- (bound at tcfail201.hs:16:1)
+
+tcfail201.hs:17:56: error:
+ • Couldn't match type ‘a’ with ‘HsDoc t0’
+ ‘a’ is a rigid type variable bound by
+ the type signature for:
+ gfoldl' :: forall (c :: * -> *) a.
+ (forall a1 b. c (a1 -> b) -> a1 -> c b)
+ -> (forall g. g -> c g) -> a -> c a
+ at tcfail201.hs:15:1-85
+ Expected type: c a
+ Actual type: c (HsDoc t0)
+ • In the expression: z DocEmpty
+ In a case alternative: DocEmpty -> z DocEmpty
+ In the expression: case hsDoc of { DocEmpty -> z DocEmpty }
+ • Relevant bindings include
+ hsDoc :: a (bound at tcfail201.hs:16:13)
+ gfoldl' :: (forall a1 b. c (a1 -> b) -> a1 -> c b)
+ -> (forall g. g -> c g) -> a -> c a
+ (bound at tcfail201.hs:16:1)
diff --git a/testsuite/tests/typecheck/should_fail/tcfail206.stderr b/testsuite/tests/typecheck/should_fail/tcfail206.stderr
index e60856aaf9..3eb7bfc029 100644
--- a/testsuite/tests/typecheck/should_fail/tcfail206.stderr
+++ b/testsuite/tests/typecheck/should_fail/tcfail206.stderr
@@ -1,55 +1,55 @@
-
-tcfail206.hs:5:5: error:
- • Couldn't match type ‘Bool’ with ‘Int’
- Expected type: Bool -> (Int, Bool)
- Actual type: Int -> (Int, Bool)
- • In the expression: (, True)
- In an equation for ‘a’: a = (, True)
-
-tcfail206.hs:8:5: error:
- • Couldn't match type ‘(Integer, Int)’ with ‘Bool -> (Int, Bool)’
- Expected type: Int -> Bool -> (Int, Bool)
- Actual type: Int -> (Integer, Int)
- • In the expression: (1,)
- In an equation for ‘b’: b = (1,)
-
-tcfail206.hs:11:5: error:
- • Couldn't match type ‘a’ with ‘Bool’
- ‘a’ is a rigid type variable bound by
- the type signature for:
- c :: forall a. a -> (a, Bool)
- at tcfail206.hs:10:6
- Expected type: a -> (a, Bool)
- Actual type: Bool -> (a, Bool)
- • In the expression: (True || False,)
- In an equation for ‘c’: c = (True || False,)
- • Relevant bindings include
- c :: a -> (a, Bool) (bound at tcfail206.hs:11:1)
-
-tcfail206.hs:14:5: error:
- • Couldn't match type ‘Bool’ with ‘Int’
- Expected type: Bool -> (# Int, Bool #)
- Actual type: Int -> (# Int, Bool #)
- • In the expression: (# , True #)
- In an equation for ‘d’: d = (# , True #)
-
-tcfail206.hs:17:5: error:
- • Couldn't match type ‘(# Integer, Int #)’
- with ‘Bool -> (# Int, Bool #)’
- Expected type: Int -> Bool -> (# Int, Bool #)
- Actual type: Int -> (# Integer, Int #)
- • In the expression: (# 1, #)
- In an equation for ‘e’: e = (# 1, #)
-
-tcfail206.hs:20:5: error:
- • Couldn't match type ‘a’ with ‘Bool’
- ‘a’ is a rigid type variable bound by
- the type signature for:
- f :: forall a. a -> (# a, Bool #)
- at tcfail206.hs:19:6
- Expected type: a -> (# a, Bool #)
- Actual type: Bool -> (# a, Bool #)
- • In the expression: (# True || False, #)
- In an equation for ‘f’: f = (# True || False, #)
- • Relevant bindings include
- f :: a -> (# a, Bool #) (bound at tcfail206.hs:20:1)
+
+tcfail206.hs:5:5: error:
+ • Couldn't match type ‘Bool’ with ‘Int’
+ Expected type: Bool -> (Int, Bool)
+ Actual type: Int -> (Int, Bool)
+ • In the expression: (, True)
+ In an equation for ‘a’: a = (, True)
+
+tcfail206.hs:8:5: error:
+ • Couldn't match type ‘(Integer, Int)’ with ‘Bool -> (Int, Bool)’
+ Expected type: Int -> Bool -> (Int, Bool)
+ Actual type: Int -> (Integer, Int)
+ • In the expression: (1,)
+ In an equation for ‘b’: b = (1,)
+
+tcfail206.hs:11:5: error:
+ • Couldn't match type ‘a’ with ‘Bool’
+ ‘a’ is a rigid type variable bound by
+ the type signature for:
+ c :: forall a. a -> (a, Bool)
+ at tcfail206.hs:10:1-19
+ Expected type: a -> (a, Bool)
+ Actual type: Bool -> (a, Bool)
+ • In the expression: (True || False,)
+ In an equation for ‘c’: c = (True || False,)
+ • Relevant bindings include
+ c :: a -> (a, Bool) (bound at tcfail206.hs:11:1)
+
+tcfail206.hs:14:5: error:
+ • Couldn't match type ‘Bool’ with ‘Int’
+ Expected type: Bool -> (# Int, Bool #)
+ Actual type: Int -> (# Int, Bool #)
+ • In the expression: (# , True #)
+ In an equation for ‘d’: d = (# , True #)
+
+tcfail206.hs:17:5: error:
+ • Couldn't match type ‘(# Integer, Int #)’
+ with ‘Bool -> (# Int, Bool #)’
+ Expected type: Int -> Bool -> (# Int, Bool #)
+ Actual type: Int -> (# Integer, Int #)
+ • In the expression: (# 1, #)
+ In an equation for ‘e’: e = (# 1, #)
+
+tcfail206.hs:20:5: error:
+ • Couldn't match type ‘a’ with ‘Bool’
+ ‘a’ is a rigid type variable bound by
+ the type signature for:
+ f :: forall a. a -> (# a, Bool #)
+ at tcfail206.hs:19:1-21
+ Expected type: a -> (# a, Bool #)
+ Actual type: Bool -> (# a, Bool #)
+ • In the expression: (# True || False, #)
+ In an equation for ‘f’: f = (# True || False, #)
+ • Relevant bindings include
+ f :: a -> (# a, Bool #) (bound at tcfail206.hs:20:1)