From dc667ab52ab208427094e497ece94132c57db8f2 Mon Sep 17 00:00:00 2001 From: "simonpj@microsoft.com" Date: Mon, 1 Dec 2008 16:28:45 +0000 Subject: [PATCH] Better error message for fundep conflict --- compiler/types/Class.lhs | 10 +++++----- compiler/types/FunDeps.lhs | 5 +++-- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/compiler/types/Class.lhs b/compiler/types/Class.lhs index fb7cab1..e7bda63 100644 --- a/compiler/types/Class.lhs +++ b/compiler/types/Class.lhs @@ -10,7 +10,7 @@ module Class ( Class, ClassOpItem, DefMeth (..), - FunDep, pprFundeps, + FunDep, pprFundeps, pprFunDep, mkClass, classTyVars, classArity, classKey, className, classATs, classSelIds, classTyCon, classMethods, @@ -174,9 +174,9 @@ instance Outputable DefMeth where pprFundeps :: Outputable a => [FunDep a] -> SDoc pprFundeps [] = empty -pprFundeps fds = hsep (ptext (sLit "|") : punctuate comma (map ppr_fd fds)) - where - ppr_fd (us, vs) = hsep [interppSP us, ptext (sLit "->"), - interppSP vs] +pprFundeps fds = hsep (ptext (sLit "|") : punctuate comma (map pprFunDep fds)) + +pprFunDep :: Outputable a => FunDep a -> SDoc +pprFunDep (us, vs) = hsep [interppSP us, ptext (sLit "->"), interppSP vs] \end{code} diff --git a/compiler/types/FunDeps.lhs b/compiler/types/FunDeps.lhs index 170304c..af7cfec 100644 --- a/compiler/types/FunDeps.lhs +++ b/compiler/types/FunDeps.lhs @@ -294,8 +294,9 @@ improveOne inst_env pred@(ClassP cls tys, _) preds , not (instanceCantMatch inst_tcs trimmed_tcs) , eqn <- checkClsFD qtvs fd cls_tvs tys_inst tys , let p_inst = (mkClassPred cls tys_inst, - ptext (sLit "arising from the instance declaration at") - <+> ppr (getSrcLoc ispec)) + sep [ ptext (sLit "arising from the dependency") <+> quotes (pprFunDep fd) + , ptext (sLit "in the instance declaration at") + <+> ppr (getSrcLoc ispec)]) ] improveOne _ _ _ -- 1.7.10.4