Commit e0b44e2e authored by Matthías Páll Gissurarson's avatar Matthías Páll Gissurarson Committed by Ben Gamari

Improved Valid Hole Fits

I've changed the name from `Valid substitutions` to `Valid hole fits`,
since "substitution" already has a well defined meaning within the
theory. As part of this change, the flags and output is reanamed, with
substitution turning into hole-fit in most cases. "hole fit" was already
used internally in the code, it's clear and shouldn't cause any
confusion.

In this update, I've also reworked how we manage side-effects in the
hole we are considering.

This allows us to consider local bindings such as where clauses and
arguments to functions, suggesting e.g. `a` for `head (x:xs) where head
:: [a] -> a`.

It also allows us to find suggestions such as `maximum` for holes of
type `Ord a => a -> [a]`, and `max` when looking for a match for the
hole in `g = foldl1 _`, where `g :: Ord a => [a] -> a`.

We also show much improved output for refinement hole fits, and
fixes #14990. We now show the correct type of the function, but we also
now show what the arguments to the function should be e.g. `foldl1 (_ ::
Integer -> Integer -> Integer)` when looking for `[Integer] -> Integer`.

I've moved the bulk of the code from `TcErrors.hs` to a new file,
`TcHoleErrors.hs`, since it was getting too big to not live on it's own.

This addresses the considerations raised in #14969, and takes proper
care to set the `tcLevel` of the variables to the right level before
passing it to the simplifier.

We now also zonk the suggestions properly, which improves the output of
the refinement hole fits considerably.

This also filters out suggestions from the `GHC.Err` module, since even
though `error` and `undefined` are indeed valid hole fits, they are
"trivial", and almost never useful to the user.

We now find the hole fits using the proper manner, namely by solving
nested implications. This entails that the givens are passed along using
the implications the hole was nested in, which in turn should mean that
there will be fewer weird bugs in the typed holes.

I've also added a new sorting method (as suggested by SPJ) and sort by
the size of the types needed to turn the hole fits into the type of the
hole. This gives a reasonable approximation to relevance, and is much
faster than the subsumption check. I've also added a flag to toggle
whether to use this new sorting algorithm (as is done by default) or the
subsumption algorithm. This fixes #14969

I've also added documentation for these new flags and update the
documentation according to the new output.

Reviewers: bgamari, goldfire

Reviewed By: bgamari

Subscribers: simonpj, rwbarton, thomie, carter

GHC Trac Issues: #14969, #14990, #10946

Differential Revision: https://phabricator.haskell.org/D4444
parent b876c1bb
......@@ -468,6 +468,7 @@ Library
TcRnTypes
TcRules
TcSimplify
TcHoleErrors
TcErrors
TcTyClsDecls
TcTyDecls
......
......@@ -566,10 +566,21 @@ data GeneralFlag
| Opt_PprCaseAsLet
| Opt_PprShowTicks
| Opt_ShowHoleConstraints
| Opt_NoShowValidSubstitutions
| Opt_UnclutterValidSubstitutions
| Opt_NoSortValidSubstitutions
| Opt_AbstractRefSubstitutions
-- Options relating to the display of valid hole fits
-- when generating an error message for a typed hole
-- See Note [Valid hole fits include] in TcHoleErrors.hs
| Opt_ShowValidHoleFits
| Opt_SortValidHoleFits
| Opt_SortBySizeHoleFits
| Opt_SortBySubsumHoleFits
| Opt_AbstractRefHoleFits
| Opt_UnclutterValidHoleFits
| Opt_ShowTypeAppOfHoleFits
| Opt_ShowTypeAppVarsOfHoleFits
| Opt_ShowTypeOfHoleFits
| Opt_ShowProvOfHoleFits
| Opt_ShowMatchesOfHoleFits
| Opt_ShowLoadedModules
| Opt_HexWordLiterals -- See Note [Print Hexadecimal Literals]
......@@ -850,14 +861,14 @@ data DynFlags = DynFlags {
maxRelevantBinds :: Maybe Int, -- ^ Maximum number of bindings from the type envt
-- to show in type error messages
maxValidSubstitutions :: Maybe Int, -- ^ Maximum number of substitutions to
-- show in typed hole error messages
maxRefSubstitutions :: Maybe Int, -- ^ Maximum number of refinement
-- substitutions to show in typed hole
maxValidHoleFits :: Maybe Int, -- ^ Maximum number of hole fits to show
-- in typed hole error messages
maxRefHoleFits :: Maybe Int, -- ^ Maximum number of refinement hole
-- fits to show in typed hole error
-- messages
refLevelHoleFits :: Maybe Int, -- ^ Maximum level of refinement for
-- refinement hole fits in typed hole
-- error messages
refLevelSubstitutions :: Maybe Int, -- ^ Maximum level of refinement for
-- refinement substitutions in typed
-- typed hole error messages
maxUncoveredPatterns :: Int, -- ^ Maximum number of unmatched patterns to show
-- in non-exhaustiveness warnings
simplTickFactor :: Int, -- ^ Multiplier for simplifier ticks
......@@ -1741,9 +1752,9 @@ defaultDynFlags mySettings (myLlvmTargets, myLlvmPasses) =
ruleCheck = Nothing,
inlineCheck = Nothing,
maxRelevantBinds = Just 6,
maxValidSubstitutions = Just 6,
maxRefSubstitutions = Just 6,
refLevelSubstitutions = Nothing,
maxValidHoleFits = Just 6,
maxRefHoleFits = Just 6,
refLevelHoleFits = Nothing,
maxUncoveredPatterns = 4,
simplTickFactor = 100,
specConstrThreshold = Just 2000,
......@@ -3333,18 +3344,20 @@ dynamic_flags_deps = [
(intSuffix (\n d -> d { maxRelevantBinds = Just n }))
, make_ord_flag defFlag "fno-max-relevant-binds"
(noArg (\d -> d { maxRelevantBinds = Nothing }))
, make_ord_flag defFlag "fmax-valid-substitutions"
(intSuffix (\n d -> d { maxValidSubstitutions = Just n }))
, make_ord_flag defFlag "fno-max-valid-substitutions"
(noArg (\d -> d { maxValidSubstitutions = Nothing }))
, make_ord_flag defFlag "fmax-refinement-substitutions"
(intSuffix (\n d -> d { maxRefSubstitutions = Just n }))
, make_ord_flag defFlag "fno-max-refinement-substitutions"
(noArg (\d -> d { maxRefSubstitutions = Nothing }))
, make_ord_flag defFlag "frefinement-level-substitutions"
(intSuffix (\n d -> d { refLevelSubstitutions = Just n }))
, make_ord_flag defFlag "fno-refinement-level-substitutions"
(noArg (\d -> d { refLevelSubstitutions = Nothing }))
, make_ord_flag defFlag "fmax-valid-hole-fits"
(intSuffix (\n d -> d { maxValidHoleFits = Just n }))
, make_ord_flag defFlag "fno-max-valid-hole-fits"
(noArg (\d -> d { maxValidHoleFits = Nothing }))
, make_ord_flag defFlag "fmax-refinement-hole-fits"
(intSuffix (\n d -> d { maxRefHoleFits = Just n }))
, make_ord_flag defFlag "fno-max-refinement-hole-fits"
(noArg (\d -> d { maxRefHoleFits = Nothing }))
, make_ord_flag defFlag "frefinement-level-hole-fits"
(intSuffix (\n d -> d { refLevelHoleFits = Just n }))
, make_ord_flag defFlag "fno-refinement-level-hole-fits"
(noArg (\d -> d { refLevelHoleFits = Nothing }))
, make_ord_flag defFlag "fmax-uncovered-patterns"
(intSuffix (\n d -> d { maxUncoveredPatterns = n }))
, make_ord_flag defFlag "fsimplifier-phases"
......@@ -3964,14 +3977,34 @@ fFlagsDeps = [
flagSpec "alignment-sanitisation" Opt_AlignmentSanitisation,
flagSpec "show-warning-groups" Opt_ShowWarnGroups,
flagSpec "hide-source-paths" Opt_HideSourcePaths,
flagSpec "show-hole-constraints" Opt_ShowHoleConstraints,
flagSpec "no-show-valid-substitutions" Opt_NoShowValidSubstitutions,
flagSpec "no-sort-valid-substitutions" Opt_NoSortValidSubstitutions,
flagSpec "abstract-refinement-substitutions" Opt_AbstractRefSubstitutions,
flagSpec "unclutter-valid-substitutions" Opt_UnclutterValidSubstitutions,
flagSpec "show-loaded-modules" Opt_ShowLoadedModules,
flagSpec "whole-archive-hs-libs" Opt_WholeArchiveHsLibs
]
++ fHoleFlags
-- | These @-f\<blah\>@ flags have to do with the typed-hole error message or
-- the valid hole fits in that message. See Note [Valid hole fits include ...]
-- in the TcHoleErrors module. These flags can all be reversed with
-- @-fno-\<blah\>@
fHoleFlags :: [(Deprecation, FlagSpec GeneralFlag)]
fHoleFlags = [
flagSpec "show-hole-constraints" Opt_ShowHoleConstraints,
depFlagSpec' "show-valid-substitutions" Opt_ShowValidHoleFits
(useInstead "-f" "show-valid-hole-fits"),
flagSpec "show-valid-hole-fits" Opt_ShowValidHoleFits,
-- Sorting settings
flagSpec "sort-valid-hole-fits" Opt_SortValidHoleFits,
flagSpec "sort-by-size-hole-fits" Opt_SortBySizeHoleFits,
flagSpec "sort-by-subsumption-hole-fits" Opt_SortBySubsumHoleFits,
flagSpec "abstract-refinement-hole-fits" Opt_AbstractRefHoleFits,
-- Output format settings
flagSpec "show-hole-matches-of-hole-fits" Opt_ShowMatchesOfHoleFits,
flagSpec "show-provenance-of-hole-fits" Opt_ShowProvOfHoleFits,
flagSpec "show-type-of-hole-fits" Opt_ShowTypeOfHoleFits,
flagSpec "show-type-app-of-hole-fits" Opt_ShowTypeAppOfHoleFits,
flagSpec "show-type-app-vars-of-hole-fits" Opt_ShowTypeAppVarsOfHoleFits,
flagSpec "unclutter-valid-hole-fits" Opt_UnclutterValidHoleFits
]
-- | These @-f\<blah\>@ flags can all be reversed with @-fno-\<blah\>@
fLangFlags :: [FlagSpec LangExt.Extension]
......@@ -4226,9 +4259,32 @@ defaultFlags settings
++ default_PIC platform
++ concatMap (wayGeneralFlags platform) (defaultWays settings)
++ validHoleFitDefaults
where platform = sTargetPlatform settings
-- | These are the default settings for the display and sorting of valid hole
-- fits in typed-hole error messages. See Note [Valid hole fits include ...]
-- in the TcHoleErrors module.
validHoleFitDefaults :: [GeneralFlag]
validHoleFitDefaults
= [ Opt_ShowTypeAppOfHoleFits
, Opt_ShowTypeOfHoleFits
, Opt_ShowProvOfHoleFits
, Opt_ShowMatchesOfHoleFits
, Opt_ShowValidHoleFits
, Opt_SortValidHoleFits
, Opt_SortBySizeHoleFits
, Opt_ShowHoleConstraints ]
validHoleFitsImpliedGFlags :: [(GeneralFlag, TurnOnFlag, GeneralFlag)]
validHoleFitsImpliedGFlags
= [ (Opt_UnclutterValidHoleFits, turnOff, Opt_ShowTypeAppOfHoleFits)
, (Opt_UnclutterValidHoleFits, turnOff, Opt_ShowTypeAppVarsOfHoleFits)
, (Opt_ShowTypeAppVarsOfHoleFits, turnOff, Opt_ShowTypeAppOfHoleFits)
, (Opt_UnclutterValidHoleFits, turnOff, Opt_ShowProvOfHoleFits) ]
default_PIC :: Platform -> [GeneralFlag]
default_PIC platform =
case (platformOS platform, platformArch platform) of
......@@ -4247,7 +4303,7 @@ impliedGFlags :: [(GeneralFlag, TurnOnFlag, GeneralFlag)]
impliedGFlags = [(Opt_DeferTypeErrors, turnOn, Opt_DeferTypedHoles)
,(Opt_DeferTypeErrors, turnOn, Opt_DeferOutOfScopeVariables)
,(Opt_Strictness, turnOn, Opt_WorkerWrapper)
]
] ++ validHoleFitsImpliedGFlags
-- General flags that are switched on/off when other general flags are switched
-- off
......
This diff is collapsed.
This diff is collapsed.
-- This boot file is in place to break the loop where:
-- + TcSimplify calls 'TcErrors.reportUnsolved',
-- + which calls 'TcHoleErrors.findValidHoleFits`
-- + which calls 'TcSimplify.simpl_top'
module TcHoleErrors where
import TcRnTypes ( TcM, Ct, Implication )
import Outputable ( SDoc )
import VarEnv ( TidyEnv )
findValidHoleFits :: TidyEnv -> [Implication] -> [Ct] -> Ct
-> TcM (TidyEnv, SDoc)
......@@ -65,7 +65,7 @@ module TcMType (
--------------------------------
-- Zonking and tidying
zonkTidyTcType, zonkTidyOrigin,
zonkTidyTcType, zonkTidyTcTypes, zonkTidyOrigin,
tidyEvVar, tidyCt, tidySkolemInfo,
skolemiseRuntimeUnk,
zonkTcTyVar, zonkTcTyVars,
......@@ -1624,6 +1624,13 @@ zonkTidyTcType :: TidyEnv -> TcType -> TcM (TidyEnv, TcType)
zonkTidyTcType env ty = do { ty' <- zonkTcType ty
; return (tidyOpenType env ty') }
zonkTidyTcTypes :: TidyEnv -> [TcType] -> TcM (TidyEnv, [TcType])
zonkTidyTcTypes = zonkTidyTcTypes' []
where zonkTidyTcTypes' zs env [] = return (env, reverse zs)
zonkTidyTcTypes' zs env (ty:tys)
= do { (env', ty') <- zonkTidyTcType env ty
; zonkTidyTcTypes' (ty':zs) env' tys }
zonkTidyOrigin :: TidyEnv -> CtOrigin -> TcM (TidyEnv, CtOrigin)
zonkTidyOrigin env (GivenOrigin skol_info)
= do { skol_info1 <- zonkSkolemInfo skol_info
......
......@@ -83,7 +83,7 @@ module TcRnTypes(
tyCoVarsOfCtList, tyCoVarsOfCtsList,
WantedConstraints(..), insolubleWC, emptyWC, isEmptyWC,
andWC, unionsWC, mkSimpleWC, mkImplicWC,
isSolvedWC, andWC, unionsWC, mkSimpleWC, mkImplicWC,
addInsols, insolublesOnly, addSimples, addImplics,
tyCoVarsOfWC, dropDerivedWC, dropDerivedSimples,
tyCoVarsOfWCList, insolubleWantedCt, insolubleEqCt,
......@@ -113,6 +113,7 @@ module TcRnTypes(
ctEvRole,
wrapType, wrapTypeWithImplication,
removeBindingShadowing,
-- Constraint solver plugins
TcPlugin(..), TcPluginResult(..), TcPluginSolver,
......@@ -935,6 +936,23 @@ instance HasOccName TcBinder where
occName (TcIdBndr_ExpType name _ _) = occName name
occName (TcTvBndr name _) = occName name
-- fixes #12177
-- Builds up a list of bindings whose OccName has not been seen before
-- i.e., If ys = removeBindingShadowing xs
-- then
-- - ys is obtained from xs by deleting some elements
-- - ys has no duplicate OccNames
-- - The first duplicated OccName in xs is retained in ys
-- Overloaded so that it can be used for both GlobalRdrElt in typed-hole
-- substitutions and TcBinder when looking for relevant bindings.
removeBindingShadowing :: HasOccName a => [a] -> [a]
removeBindingShadowing bindings = reverse $ fst $ foldl
(\(bindingAcc, seenNames) binding ->
if occName binding `elemOccSet` seenNames -- if we've seen it
then (bindingAcc, seenNames) -- skip it
else (binding:bindingAcc, extendOccSet seenNames (occName binding)))
([], emptyOccSet) bindings
---------------------------
-- Template Haskell stages and levels
---------------------------
......@@ -2303,6 +2321,14 @@ isEmptyWC :: WantedConstraints -> Bool
isEmptyWC (WC { wc_simple = f, wc_impl = i })
= isEmptyBag f && isEmptyBag i
-- | Checks whether a the given wanted constraints are solved, i.e.
-- that there are no simple constraints left and all the implications
-- are solved.
isSolvedWC :: WantedConstraints -> Bool
isSolvedWC WC {wc_simple = wc_simple, wc_impl = wc_impl} =
isEmptyBag wc_simple && allBag (isSolvedStatus . ic_status) wc_impl
andWC :: WantedConstraints -> WantedConstraints -> WantedConstraints
andWC (WC { wc_simple = f1, wc_impl = i1 })
(WC { wc_simple = f2, wc_impl = i2 })
......
......@@ -10,8 +10,8 @@ module TcSimplify(
solveEqualities, solveLocalEqualities,
simplifyWantedsTcM,
tcCheckSatisfiability,
tcSubsumes,
tcCheckHoleFit,
simpl_top,
promoteTyVar,
promoteTyVarSet,
......@@ -49,7 +49,6 @@ import TrieMap () -- DV: for now
import Type
import TysWiredIn ( liftedRepTy )
import Unify ( tcMatchTyKi )
import TcUnify ( tcSubType_NC )
import Util
import Var
import VarSet
......@@ -177,6 +176,8 @@ solveEqualities thing_inside
; traceTc "reportAllUnsolved }" empty
; return result }
-- | Simplify top-level constraints, but without reporting any unsolved
-- constraints nor unsafe overlapping.
simpl_top :: WantedConstraints -> TcS WantedConstraints
-- See Note [Top-level Defaulting Plan]
simpl_top wanteds
......@@ -511,31 +512,6 @@ simplifyDefault theta
; traceTc "reportUnsolved }" empty
; return () }
-- | Reports whether first type (ty_a) subsumes the second type (ty_b),
-- discarding any errors. Subsumption here means that the ty_b can fit into the
-- ty_a, i.e. `tcSubsumes a b == True` if b is a subtype of a.
-- N.B.: Make sure that the types contain all the constraints
-- contained in any associated implications.
tcSubsumes :: TcSigmaType -> TcSigmaType -> TcM Bool
tcSubsumes = tcCheckHoleFit emptyBag
-- | A tcSubsumes which takes into account relevant constraints, to fix trac
-- #14273. Make sure that the constraints are cloned, since the simplifier may
-- perform unification.
tcCheckHoleFit :: Cts -> TcSigmaType -> TcSigmaType -> TcM Bool
tcCheckHoleFit _ hole_ty ty | hole_ty `eqType` ty = return True
tcCheckHoleFit relevantCts hole_ty ty = discardErrs $
do { (tclevel, wanted, _) <- pushLevelAndCaptureConstraints $
tcSubType_NC ExprSigCtxt ty hole_ty
; rem <- setTcLevel tclevel $ runTcSDeriveds $
simpl_top $ addSimples wanted relevantCts
-- We don't want any insoluble or simple constraints left,
-- but solved implications are ok (and neccessary for e.g. undefined)
; return (isEmptyBag (wc_simple rem)
&& allBag (isSolvedStatus . ic_status) (wc_impl rem))
}
------------------
tcCheckSatisfiability :: Bag EvVar -> TcM Bool
-- Return True if satisfiable, False if definitely contradictory
......@@ -1610,7 +1586,7 @@ setImplicationStatus implic@(Implic { ic_status = status
, ic_given = givens })
| ASSERT2( not (isSolvedStatus status ), ppr info )
-- Precondition: we only set the status if it is not already solved
not all_solved
not (isSolvedWC pruned_wc)
= do { traceTcS "setImplicationStatus(not-all-solved) {" (ppr implic)
; implic <- neededEvVars implic
......@@ -1666,9 +1642,6 @@ setImplicationStatus implic@(Implic { ic_status = status
pruned_wc = WC { wc_simple = pruned_simples
, wc_impl = pruned_implics }
all_solved = isEmptyBag pruned_simples
&& allBag (isSolvedStatus . ic_status) pruned_implics
keep_me :: Implication -> Bool
keep_me ic
| IC_Solved { ics_dead = dead_givens } <- ic_status ic
......
module TcSimplify where
import GhcPrelude
import TcRnTypes ( TcM, Cts )
import TcType ( TcSigmaType )
-- This boot file exists solely to make tcCheckHoleFit and tcSubsumes avaialble
-- in TcErrors
tcSubsumes :: TcSigmaType -> TcSigmaType -> TcM Bool
tcCheckHoleFit :: Cts -> TcSigmaType -> TcSigmaType -> TcM Bool
......@@ -109,6 +109,10 @@ Compiler
This will result in significantly better code being generated for some
programs. See :ghc-ticket:`9136`.
- GHC now offers significantly more information about typed holes such as valid
hole fits and refinement hole fits. See :ref:`Valid Hole Fits <typed-hole-valid-hole-fits>`
for more information.
- The code-generation effects of :ghc-flag:`-dynamic` can now be
enabled independently by the flag
:ghc-flag:`-fexternal-dynamic-refs`. If you don't know why you might
......
This diff is collapsed.
......@@ -4,13 +4,13 @@ T12468.hs:9:7: error:
• In the expression: _
In an equation for ‘f’: f I = _
• Relevant bindings include f :: T a -> a (bound at T12468.hs:9:1)
Valid substitutions include
Constraints include a ~ Int (from T12468.hs:9:3)
Valid hole fits include
maxBound :: forall a. Bounded a => a
with maxBound @Int
(imported from ‘Prelude’ at T12468.hs:3:8-13
(and originally defined in ‘GHC.Enum’))
minBound :: forall a. Bounded a => a
with minBound @Int
(imported from ‘Prelude’ at T12468.hs:3:8-13
(and originally defined in ‘GHC.Enum’))
undefined :: forall a. GHC.Stack.Types.HasCallStack => a
(imported from ‘Prelude’ at T12468.hs:3:8-13
(and originally defined in ‘GHC.Err’))
......@@ -9,6 +9,4 @@
In an equation for ‘it’: it = Just <$> _
• Relevant bindings include
it :: f (Maybe a) (bound at <interactive>:2:1)
Valid substitutions include
undefined :: forall a. GHC.Stack.Types.HasCallStack => a
(imported from ‘Prelude’ (and originally defined in ‘GHC.Err’))
Constraints include Functor f (from <interactive>:2:1-10)
......@@ -7,6 +7,3 @@
• In the expression: _
In an equation for ‘it’: it = _
• Relevant bindings include it :: t (bound at <interactive>:1:1)
Valid substitutions include
undefined :: forall a. GHC.Stack.Types.HasCallStack => a
(imported from ‘Prelude’ (and originally defined in ‘GHC.Err’))
......@@ -9,18 +9,17 @@ Defer03.hs:7:5: warning: [-Wtyped-holes (in -Wdefault)]
• In the expression: _
In an equation for ‘f’: f = _
• Relevant bindings include f :: Int (bound at Defer03.hs:7:1)
Valid substitutions include
Valid hole fits include
f :: Int (bound at Defer03.hs:7:1)
a :: Int (defined at Defer03.hs:4:1)
f :: Int (defined at Defer03.hs:7:1)
maxBound :: forall a. Bounded a => a
with maxBound @Int
(imported from ‘Prelude’ at Defer03.hs:1:8-11
(and originally defined in ‘GHC.Enum’))
minBound :: forall a. Bounded a => a
with minBound @Int
(imported from ‘Prelude’ at Defer03.hs:1:8-11
(and originally defined in ‘GHC.Enum’))
undefined :: forall a. GHC.Stack.Types.HasCallStack => a
(imported from ‘Prelude’ at Defer03.hs:1:8-11
(and originally defined in ‘GHC.Err’))
Defer03.hs:4:5: error:
• Couldn't match expected type ‘Int’ with actual type ‘Char’
......@@ -32,18 +31,17 @@ Defer03.hs:7:5: error:
• In the expression: _
In an equation for ‘f’: f = _
• Relevant bindings include f :: Int (bound at Defer03.hs:7:1)
Valid substitutions include
Valid hole fits include
f :: Int (bound at Defer03.hs:7:1)
a :: Int (defined at Defer03.hs:4:1)
f :: Int (defined at Defer03.hs:7:1)
maxBound :: forall a. Bounded a => a
with maxBound @Int
(imported from ‘Prelude’ at Defer03.hs:1:8-11
(and originally defined in ‘GHC.Enum’))
minBound :: forall a. Bounded a => a
with minBound @Int
(imported from ‘Prelude’ at Defer03.hs:1:8-11
(and originally defined in ‘GHC.Enum’))
undefined :: forall a. GHC.Stack.Types.HasCallStack => a
(imported from ‘Prelude’ at Defer03.hs:1:8-11
(and originally defined in ‘GHC.Err’))
Defer03.hs:4:5: warning: [-Wdeferred-type-errors (in -Wdefault)]
• Couldn't match expected type ‘Int’ with actual type ‘Char’
......@@ -55,18 +53,17 @@ Defer03.hs:7:5: warning: [-Wtyped-holes (in -Wdefault)]
• In the expression: _
In an equation for ‘f’: f = _
• Relevant bindings include f :: Int (bound at Defer03.hs:7:1)
Valid substitutions include
Valid hole fits include
f :: Int (bound at Defer03.hs:7:1)
a :: Int (defined at Defer03.hs:4:1)
f :: Int (defined at Defer03.hs:7:1)
maxBound :: forall a. Bounded a => a
with maxBound @Int
(imported from ‘Prelude’ at Defer03.hs:1:8-11
(and originally defined in ‘GHC.Enum’))
minBound :: forall a. Bounded a => a
with minBound @Int
(imported from ‘Prelude’ at Defer03.hs:1:8-11
(and originally defined in ‘GHC.Enum’))
undefined :: forall a. GHC.Stack.Types.HasCallStack => a
(imported from ‘Prelude’ at Defer03.hs:1:8-11
(and originally defined in ‘GHC.Err’))
Defer03.hs:4:5: error:
• Couldn't match expected type ‘Int’ with actual type ‘Char’
......@@ -78,18 +75,17 @@ Defer03.hs:7:5: error:
• In the expression: _
In an equation for ‘f’: f = _
• Relevant bindings include f :: Int (bound at Defer03.hs:7:1)
Valid substitutions include
Valid hole fits include
f :: Int (bound at Defer03.hs:7:1)
a :: Int (defined at Defer03.hs:4:1)
f :: Int (defined at Defer03.hs:7:1)
maxBound :: forall a. Bounded a => a
with maxBound @Int
(imported from ‘Prelude’ at Defer03.hs:1:8-11
(and originally defined in ‘GHC.Enum’))
minBound :: forall a. Bounded a => a
with minBound @Int
(imported from ‘Prelude’ at Defer03.hs:1:8-11
(and originally defined in ‘GHC.Enum’))
undefined :: forall a. GHC.Stack.Types.HasCallStack => a
(imported from ‘Prelude’ at Defer03.hs:1:8-11
(and originally defined in ‘GHC.Err’))
Defer03.hs:4:5: warning: [-Wdeferred-type-errors (in -Wdefault)]
• Couldn't match expected type ‘Int’ with actual type ‘Char’
......@@ -101,15 +97,14 @@ Defer03.hs:7:5: warning: [-Wtyped-holes (in -Wdefault)]
• In the expression: _
In an equation for ‘f’: f = _
• Relevant bindings include f :: Int (bound at Defer03.hs:7:1)
Valid substitutions include
Valid hole fits include
f :: Int (bound at Defer03.hs:7:1)
a :: Int (defined at Defer03.hs:4:1)
f :: Int (defined at Defer03.hs:7:1)
maxBound :: forall a. Bounded a => a
with maxBound @Int
(imported from ‘Prelude’ at Defer03.hs:1:8-11
(and originally defined in ‘GHC.Enum’))
minBound :: forall a. Bounded a => a
with minBound @Int
(imported from ‘Prelude’ at Defer03.hs:1:8-11
(and originally defined in ‘GHC.Enum’))
undefined :: forall a. GHC.Stack.Types.HasCallStack => a
(imported from ‘Prelude’ at Defer03.hs:1:8-11
(and originally defined in ‘GHC.Err’))
......@@ -10,7 +10,4 @@ mod71.hs:4:9: error:
• Relevant bindings include
x :: t1 -> t -> t2 (bound at mod71.hs:4:3)
f :: (t1 -> t -> t2) -> t2 (bound at mod71.hs:4:1)
Valid substitutions include
undefined :: forall a. GHC.Stack.Types.HasCallStack => a
(imported from ‘Prelude’ at mod71.hs:3:8
(and originally defined in ‘GHC.Err’))
Constraints include Num t (from mod71.hs:4:1-11)
......@@ -7,7 +7,4 @@ T12531.hs:6:11: warning: [-Wtyped-holes (in -Wdefault)]
• Relevant bindings include
x :: Int# (bound at T12531.hs:6:3)
f :: Int# -> Int (bound at T12531.hs:6:1)
Valid substitutions include
undefined :: forall a. GHC.Stack.Types.HasCallStack => a
(imported from ‘Prelude’ at T12531.hs:3:8-13
(and originally defined in ‘GHC.Err’))
Valid hole fits include x :: Int# (bound at T12531.hs:6:3)
......@@ -10,10 +10,7 @@ T10267.hs:8:1: error:
• Relevant bindings include
x :: a (bound at T10267.hs:8:1)
j :: a -> a (bound at T10267.hs:8:1)
Valid substitutions include
undefined :: forall a. GHC.Stack.Types.HasCallStack => a
(imported from ‘Prelude’ at T10267.hs:3:8-13
(and originally defined in ‘GHC.Err’))
Valid hole fits include x :: a (bound at T10267.hs:8:1)
T10267.hs:8:1: error:
• Found hole: _foo :: a -> a
......@@ -25,18 +22,24 @@ T10267.hs:8:1: error:
• In the expression: _foo
In an equation for ‘i’: i = _foo
• Relevant bindings include i :: a -> a (bound at T10267.hs:8:1)
Valid substitutions include
j :: forall a. a -> a (defined at T10267.hs:8:1)
i :: forall a. a -> a (defined at T10267.hs:8:1)
k :: forall a. a -> a (defined at T10267.hs:14:3)
l :: forall a. a -> a (defined at T10267.hs:23:3)
foo :: forall a. a -> a (defined at T10267.hs:33:1)
Valid hole fits include
i :: a -> a (bound at T10267.hs:8:1)
j :: forall a. a -> a
with j @a
(bound at T10267.hs:8:1)
k :: forall a. a -> a
with k @a
(defined at T10267.hs:14:3)
l :: forall a. a -> a
with l @a
(defined at T10267.hs:23:3)
foo :: forall a. a -> a
with foo @a
(defined at T10267.hs:33:1)
id :: forall a. a -> a
with id @a
(imported from ‘Prelude’ at T10267.hs:3:8-13
(and originally defined in ‘GHC.Base’))
undefined :: forall a. GHC.Stack.Types.HasCallStack => a
(imported from ‘Prelude’ at T10267.hs:3:8-13
(and originally defined in ‘GHC.Err’))
T10267.hs:14:3: error:
• Found hole: _foo :: a -> a
......@@ -48,18 +51,24 @@ T10267.hs:14:3: error:
• In the expression: _foo
In an equation for ‘k’: k = _foo
• Relevant bindings include k :: a -> a (bound at T10267.hs:14:3)
Valid substitutions include
j :: forall a. a -> a (defined at T10267.hs:8:1)
i :: forall a. a -> a (defined at T10267.hs:8:1)
k :: forall a. a -> a (defined at T10267.hs:14:3)
l :: forall a. a -> a (defined at T10267.hs:23:3)
foo :: forall a. a -> a (defined at T10267.hs:33:1)
Valid hole fits include
k :: a -> a (bound at T10267.hs:14:3)
j :: forall a. a -> a
with j @a
(bound at T10267.hs:8:1)
i :: forall a. a -> a
with i @a
(bound at T10267.hs:8:1)
l :: forall a. a -> a
with l @a
(defined at T10267.hs:23:3)
foo :: forall a. a -> a
with foo @a
(defined at T10267.hs:33:1)
id :: forall a. a -> a
with id @a
(imported from ‘Prelude’ at T10267.hs:3:8-13
(and originally defined in ‘GHC.Base’))
undefined :: forall a. GHC.Stack.Types.HasCallStack => a
(imported from ‘Prelude’ at T10267.hs:3:8-13
(and originally defined in ‘GHC.Err’))
T10267.hs:23:3: error:
• Found hole: _ :: a
......@@ -72,7 +81,4 @@ T10267.hs:23:3: error:
• Relevant bindings include
x :: a (bound at T10267.hs:23:3)
l :: a -> a (bound at T10267.hs:23:3)
Valid substitutions include
undefined :: forall a. GHC.Stack.Types.HasCallStack => a
(imported from ‘Prelude’ at T10267.hs:3:8-13
(and originally defined in ‘GHC.Err’))
Valid hole fits include x :: a (bound at T10267.hs:23:3)
......@@ -305,7 +305,7 @@ test('TH_Lift', normal, compile, ['-v0'])
test('T10047', only_ways(['ghci']), ghci_script, ['T10047.script'])
test('T10019', only_ways(['ghci']), ghci_script, ['T10019.script'])
test('T10267', [], multimod_compile_fail,
['T10267', '-fno-max-valid-substitutions -dsuppress-uniques -v0 ' + config.ghc_th_way_flags])
['T10267', '-fno-max-valid-hole-fits -dsuppress-uniques -v0 ' + config.ghc_th_way_flags])
test('T10279', normal, compile_fail, ['-v0'])
test('T10306', normal, compile, ['-v0'])
test('T10596', normal, compile, ['-v0'])
......
......@@ -28,8 +28,19 @@ T14273.hs:7:32: warning: [-Wtyped-holes (in -Wdefault)]
• Relevant bindings include
a :: a (bound at T14273.hs:7:17)
pleaseShow :: Bool -> a -> Maybe String (bound at T14273.hs:6:1)
Valid substitutions include
k :: String (defined at T14273.hs:10:1)
Constraints include Show a (from T14273.hs:5:1-49)
Valid hole fits include
a :: a (bound at T14273.hs:7:17)
k :: String (bound at T14273.hs:10:1)
otherwise :: Bool
(imported from ‘Prelude’ at T14273.hs:1:8-40
(and originally defined in ‘GHC.Base’))
False :: Bool
(imported from ‘Prelude’ at T14273.hs:1:8-40
(and originally defined in ‘GHC.Types’))
True :: Bool
(imported from ‘Prelude’ at T14273.hs:1:8-40
(and originally defined in ‘GHC.Types’))
EQ :: Ordering
(imported from ‘Prelude’ at T14273.hs:1:8-40
(and originally defined in ‘GHC.Types’))
......@@ -40,17 +51,9 @@ T14273.hs:7:32: warning: [-Wtyped-holes (in -Wdefault)]
(imported from ‘Prelude’ at T14273.hs:1:8-40
(and originally defined in ‘GHC.Types’))
pi :: forall a. Floating a => a
with pi @Double
(imported from ‘Prelude’ at T14273.hs:1:8-40
(and originally defined in ‘GHC.Float’))
otherwise :: Bool
(imported from ‘Prelude’ at T14273.hs:1:8-40
(and originally defined in ‘GHC.Base’))
False :: Bool
(imported from ‘Prelude’ at T14273.hs:1:8-40
(and originally defined in ‘GHC.Types’))
True :: Bool
(imported from ‘Prelude’ at T14273.hs:1:8-40
(and originally defined in ‘GHC.Types’))
T14273.hs:13:10: warning: [-Wdeferred-type-errors (in -Wdefault)]
• Ambiguous type variable ‘a0’ arising from a use of ‘show’
......@@ -77,4 +80,4 @@ T14273.hs:13:16: warning: [-Wtyped-holes (in -Wdefault)]
• Relevant bindings include
xs :: [a] (bound at T14273.hs:13:5)
foo :: [a] -> String (bound at T14273.hs:13:1)
Valid substitutions include k :: String (defined at T14273.hs:10:1)
Valid hole fits include k :: String (defined at T14273.hs:10:1)
......@@ -5,14 +5,13 @@ T9497a.hs:2:8: warning: [-Wtyped-holes (in -Wdefault)]
• In the expression: _main
In an equation for ‘main’: main = _main
• Relevant bindings include main :: IO () (bound at T9497a.hs:2:1)
Valid substitutions include
main :: IO () (defined at T9497a.hs:2:1)
Valid hole fits include
main :: IO () (bound at T9497a.hs:2:1)
readLn :: forall a. Read a => IO a