summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Peyton Jones <simonpj@microsoft.com>2018-02-07 11:56:58 +0000
committerSimon Peyton Jones <simonpj@microsoft.com>2018-02-07 11:56:58 +0000
commit41d29d5ad100d4c8bf4d2175c11cc710b23843da (patch)
treecc0a478ba07acfc0c6b5b256cdac6abf9aecac05
parent4aa98f4a3cb0c965c4df19af2f1ccc2c5483c3a5 (diff)
downloadhaskell-41d29d5ad100d4c8bf4d2175c11cc710b23843da.tar.gz
Comments only
-rw-r--r--compiler/typecheck/TcValidity.hs14
-rw-r--r--compiler/types/Type.hs4
2 files changed, 14 insertions, 4 deletions
diff --git a/compiler/typecheck/TcValidity.hs b/compiler/typecheck/TcValidity.hs
index 8c01460f2e..3bf9f52453 100644
--- a/compiler/typecheck/TcValidity.hs
+++ b/compiler/typecheck/TcValidity.hs
@@ -727,19 +727,25 @@ check_pred_help under_syn env dflags ctxt pred
| Just pred' <- tcView pred -- Switch on under_syn when going under a
-- synonym (Trac #9838, yuk)
= check_pred_help True env dflags ctxt pred'
- | otherwise
+
+ | otherwise -- A bit like classifyPredType, but not the same
+ -- E.g. we treat (~) like (~#); and we look inside tuples
= case splitTyConApp_maybe pred of
Just (tc, tys)
| isTupleTyCon tc
-> check_tuple_pred under_syn env dflags ctxt pred tys
- -- NB: this equality check must come first, because (~) is a class,
- -- too.
+
| tc `hasKey` heqTyConKey ||
tc `hasKey` eqTyConKey ||
tc `hasKey` eqPrimTyConKey
+ -- NB: this equality check must come first,
+ -- because (~) is a class,too.
-> check_eq_pred env dflags pred tc tys
+
| Just cls <- tyConClass_maybe tc
- -> check_class_pred env dflags ctxt pred cls tys -- Includes Coercible
+ -- Includes Coercible
+ -> check_class_pred env dflags ctxt pred cls tys
+
_ -> check_irred_pred under_syn env dflags ctxt pred
check_eq_pred :: TidyEnv -> DynFlags -> PredType -> TyCon -> [TcType] -> TcM ()
diff --git a/compiler/types/Type.hs b/compiler/types/Type.hs
index 3f893dbcb2..3ee8a4abea 100644
--- a/compiler/types/Type.hs
+++ b/compiler/types/Type.hs
@@ -1750,6 +1750,10 @@ eqRelRole ReprEq = Representational
data PredTree = ClassPred Class [Type]
| EqPred EqRel Type Type
| IrredPred PredType
+ -- NB: There is no TuplePred case
+ -- Tuple predicates like (Eq a, Ord b) are just treated
+ -- as ClassPred, as if we had a tuple class with two superclasses
+ -- class (c1, c2) => (%,%) c1 c2
classifyPredType :: PredType -> PredTree
classifyPredType ev_ty = case splitTyConApp_maybe ev_ty of