diff options
author | Matthías Páll Gissurarson <mpg@mpg.is> | 2018-01-18 00:49:38 -0500 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2018-01-18 00:49:40 -0500 |
commit | 1e14fd3ecfd468c3beddb2e5f992c358e1a798de (patch) | |
tree | 080300ea965349584307202930ef7d1cbd8e5c1f /compiler/typecheck/TcRnTypes.hs | |
parent | 6b1ff0098e7595d5f3b8e6ad7c5d8e4104b02445 (diff) | |
download | haskell-1e14fd3ecfd468c3beddb2e5f992c358e1a798de.tar.gz |
Inform hole substitutions of typeclass constraints (fixes #14273).
This implements SPJ's suggestion on the ticket (#14273). We find the
relevant constraints (ones that whose free unification variables are all
mentioned in the type of the hole), and then clone the free unification
variables of the hole and the relevant constraints. We then add a
subsumption constraints and run the simplifier, and then check whether
all the constraints were solved.
Reviewers: bgamari
Reviewed By: bgamari
Subscribers: RyanGlScott, rwbarton, thomie, carter
GHC Trac Issues: #14273
Differential Revision: https://phabricator.haskell.org/D4315
Diffstat (limited to 'compiler/typecheck/TcRnTypes.hs')
-rw-r--r-- | compiler/typecheck/TcRnTypes.hs | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/compiler/typecheck/TcRnTypes.hs b/compiler/typecheck/TcRnTypes.hs index 7766a38aa1..5e97935f55 100644 --- a/compiler/typecheck/TcRnTypes.hs +++ b/compiler/typecheck/TcRnTypes.hs @@ -113,7 +113,7 @@ module TcRnTypes( isWanted, isGiven, isDerived, isGivenOrWDeriv, ctEvRole, - wrapType, + wrapType, wrapTypeWithImplication, -- Constraint solver plugins TcPlugin(..), TcPluginResult(..), TcPluginSolver, @@ -2564,13 +2564,18 @@ pprEvVarWithType v = ppr v <+> dcolon <+> pprType (evVarPred v) -- | Wraps the given type with the constraints (via ic_given) in the given -- implication, according to the variables mentioned (via ic_skols) -- in the implication. -wrapType :: Type -> Implication -> Type -wrapType ty (Implic {ic_skols = skols, ic_given=givens}) = - wrapWithAllSkols $ mkFunTys (map idType givens) $ ty +wrapTypeWithImplication :: Type -> Implication -> Type +wrapTypeWithImplication ty impl = + wrapType ty (ic_skols impl) (map idType $ ic_given impl) + +wrapType :: Type -> [TyVar] -> [PredType] -> Type +wrapType ty skols givens = + wrapWithAllSkols $ mkFunTys givens ty where forAllTy :: Type -> TyVar -> Type forAllTy ty tv = mkForAllTy tv Specified ty wrapWithAllSkols ty = foldl forAllTy ty skols + {- ************************************************************************ * * |