[commit: ghc] master: Comments only (41d29d5)

git at git.haskell.org git at git.haskell.org
Wed Feb 7 12:16:33 UTC 2018


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/41d29d5ad100d4c8bf4d2175c11cc710b23843da/ghc

>---------------------------------------------------------------

commit 41d29d5ad100d4c8bf4d2175c11cc710b23843da
Author: Simon Peyton Jones <simonpj at microsoft.com>
Date:   Wed Feb 7 11:56:58 2018 +0000

    Comments only


>---------------------------------------------------------------

41d29d5ad100d4c8bf4d2175c11cc710b23843da
 compiler/typecheck/TcValidity.hs | 14 ++++++++++----
 compiler/types/Type.hs           |  4 ++++
 2 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/compiler/typecheck/TcValidity.hs b/compiler/typecheck/TcValidity.hs
index 8c01460..3bf9f52 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 3f893db..3ee8a4a 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



More information about the ghc-commits mailing list