summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Peyton Jones <simonpj@microsoft.com>2019-01-10 12:08:47 +0000
committerBen Gamari <ben@well-typed.com>2019-01-17 13:39:40 -0500
commit56c26f5e523f4441019f707cc08d6778e1a739bb (patch)
tree399e18c67316d6f4707a1f00ce70c69291ae7574
parent7b7b338b9a18cccaf2692556da868e45164938b7 (diff)
downloadhaskell-56c26f5e523f4441019f707cc08d6778e1a739bb.tar.gz
Small refactor
...to use the same error message rather than duplicating it
-rw-r--r--compiler/typecheck/TcInstDcls.hs14
1 files changed, 6 insertions, 8 deletions
diff --git a/compiler/typecheck/TcInstDcls.hs b/compiler/typecheck/TcInstDcls.hs
index ba33fe205c..fccf8b7917 100644
--- a/compiler/typecheck/TcInstDcls.hs
+++ b/compiler/typecheck/TcInstDcls.hs
@@ -21,7 +21,7 @@ import TcBinds
import TcTyClsDecls
import TcTyDecls ( addTyConsToGblEnv )
import TcClassDcl( tcClassDecl2, tcATDefault,
- HsSigFun, mkHsSigFun,
+ HsSigFun, mkHsSigFun, badMethodErr,
findMethodBind, instantiateMethod )
import TcSigs
import TcRnMonad
@@ -1539,13 +1539,11 @@ tcMethods dfun_id clas tyvars dfun_ev_vars inst_tys
-- Check if any method bindings do not correspond to the class.
-- See Note [Mismatched class methods and associated type families].
checkMethBindMembership
- = let bind_nms = map unLoc $ collectMethodBinders binds
- cls_meth_nms = map (idName . fst) op_items
- mismatched_meths = bind_nms `minusList` cls_meth_nms
- in forM_ mismatched_meths $ \mismatched_meth ->
- addErrTc $ hsep
- [ text "Class", quotes (ppr (className clas))
- , text "does not have a method", quotes (ppr mismatched_meth)]
+ = mapM_ (addErrTc . badMethodErr clas) mismatched_meths
+ where
+ bind_nms = map unLoc $ collectMethodBinders binds
+ cls_meth_nms = map (idName . fst) op_items
+ mismatched_meths = bind_nms `minusList` cls_meth_nms
{-
Note [Mismatched class methods and associated type families]