summaryrefslogtreecommitdiff
path: root/compiler/typecheck/TcInstDcls.hs
diff options
context:
space:
mode:
authorSimon Peyton Jones <simonpj@microsoft.com>2016-01-22 16:40:55 +0000
committerSimon Peyton Jones <simonpj@microsoft.com>2016-01-25 11:32:27 +0000
commit746764cce9a111a082a13bc3cd34b50e34fd2a31 (patch)
tree1668e8369688c7cfe0d02c6da28433afb21159f2 /compiler/typecheck/TcInstDcls.hs
parentff21795a0b9253e811a45626d5686e981ed07f82 (diff)
downloadhaskell-746764cce9a111a082a13bc3cd34b50e34fd2a31.tar.gz
Refactor validity checking for type/data instances
I found that there was some code duplication going on, so I've put more into the shared function checkValidFamPats. I did some refactoring in checkConsistentFamInst too, preparatory to #11450; the error messages change a little but no change in behaviour.
Diffstat (limited to 'compiler/typecheck/TcInstDcls.hs')
-rw-r--r--compiler/typecheck/TcInstDcls.hs9
1 files changed, 3 insertions, 6 deletions
diff --git a/compiler/typecheck/TcInstDcls.hs b/compiler/typecheck/TcInstDcls.hs
index a1cff1d8e3..241e1f1ec5 100644
--- a/compiler/typecheck/TcInstDcls.hs
+++ b/compiler/typecheck/TcInstDcls.hs
@@ -650,12 +650,9 @@ tcDataFamInstDecl mb_clsinfo
(kcDataDefn (unLoc fam_tc_name) pats defn) $
\tvs' pats' res_kind -> do
{
- -- Check that left-hand side contains no type family applications
- -- (vanilla synonyms are fine, though, and we checked for
- -- foralls earlier)
- ; checkValidFamPats fam_tc tvs' [] pats'
- -- Check that type patterns match class instance head, if any
- ; checkConsistentFamInst mb_clsinfo fam_tc tvs' pats'
+ -- Check that left-hand sides are ok (mono-types, no type families,
+ -- consistent instantiations, etc)
+ ; checkValidFamPats mb_clsinfo fam_tc tvs' [] pats'
-- Result kind must be '*' (otherwise, we have too few patterns)
; checkTc (isLiftedTypeKind res_kind) $ tooFewParmsErr (tyConArity fam_tc)