diff options
author | Simon Peyton Jones <simonpj@microsoft.com> | 2015-07-10 16:24:46 +0100 |
---|---|---|
committer | Simon Peyton Jones <simonpj@microsoft.com> | 2015-07-10 16:31:14 +0100 |
commit | 2d06a9f19d5b3ab8c3ff0b24f508c15bedae99d2 (patch) | |
tree | 137d6b38788bd86a08b4085ea94d0ae729bfafc8 /compiler | |
parent | 888026dba01279dd6de5216856c81432836abaf1 (diff) | |
download | haskell-2d06a9f19d5b3ab8c3ff0b24f508c15bedae99d2.tar.gz |
Improve error message for fundeps
Improve error message fundeps, especially when PolyKinds means that
the un-determined variables are (invisible) kind variables.
See Trac #10570.
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/typecheck/FunDeps.hs | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/compiler/typecheck/FunDeps.hs b/compiler/typecheck/FunDeps.hs index 3b44caae9d..9d4ef1c72e 100644 --- a/compiler/typecheck/FunDeps.hs +++ b/compiler/typecheck/FunDeps.hs @@ -377,19 +377,22 @@ checkInstCoverage be_liberal clas theta inst_taus where (tyvars, fds) = classTvsFds clas fundep_ok fd - | if be_liberal then liberal_ok else conservative_ok - = IsValid - | otherwise - = NotValid msg + | isEmptyVarSet undetermined_tvs = IsValid + | otherwise = NotValid msg where (ls,rs) = instFD fd tyvars inst_taus ls_tvs = tyVarsOfTypes ls rs_tvs = tyVarsOfTypes rs - conservative_ok = rs_tvs `subVarSet` closeOverKinds ls_tvs - liberal_ok = rs_tvs `subVarSet` oclose theta (closeOverKinds ls_tvs) + undetermined_tvs | be_liberal = liberal_undet_tvs + | otherwise = conserv_undet_tvs + + liberal_undet_tvs = rs_tvs `minusVarSet`oclose theta (closeOverKinds ls_tvs) + conserv_undet_tvs = rs_tvs `minusVarSet` closeOverKinds ls_tvs -- closeOverKinds: see Note [Closing over kinds in coverage] + undet_list = varSetElemsKvsFirst undetermined_tvs + msg = vcat [ -- text "ls_tvs" <+> ppr ls_tvs -- , text "closed ls_tvs" <+> ppr (closeOverKinds ls_tvs) -- , text "theta" <+> ppr theta @@ -408,7 +411,11 @@ checkInstCoverage be_liberal clas theta inst_taus else ptext (sLit "do not jointly")) <+> ptext (sLit "determine rhs type")<>plural rs <+> pprQuotedList rs ] - , ppWhen (not be_liberal && liberal_ok) $ + , ptext (sLit "Un-determined variable") <> plural undet_list <> colon + <+> pprWithCommas ppr undet_list + , ppWhen (all isKindVar undet_list) $ + ptext (sLit "(Use -fprint-explicit-kinds to see the kind variables in the types)") + , ppWhen (not be_liberal && isEmptyVarSet liberal_undet_tvs) $ ptext (sLit "Using UndecidableInstances might help") ] {- Note [Closing over kinds in coverage] |