[commit: ghc] master: Improve comments, triggered by Trac #15135 (a9a09b5)

git at git.haskell.org git at git.haskell.org
Thu Oct 25 11:49:24 UTC 2018


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

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

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

commit a9a09b53c3f50df576564e8616b6dd4be029dcf6
Author: Simon Peyton Jones <simonpj at microsoft.com>
Date:   Thu Oct 25 12:47:48 2018 +0100

    Improve comments, triggered by Trac #15135


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

a9a09b53c3f50df576564e8616b6dd4be029dcf6
 compiler/typecheck/ClsInst.hs    | 21 +++++++++++++++++++++
 compiler/typecheck/TcInteract.hs | 14 +-------------
 2 files changed, 22 insertions(+), 13 deletions(-)

diff --git a/compiler/typecheck/ClsInst.hs b/compiler/typecheck/ClsInst.hs
index cacceef..03adfde 100644
--- a/compiler/typecheck/ClsInst.hs
+++ b/compiler/typecheck/ClsInst.hs
@@ -170,6 +170,27 @@ match_one so dfun_id mb_inst_tys
                                                            , iw_safe_over = so } } }
 
 
+{- Note [Shortcut solving: overlap]
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+Suppose we have
+  instance {-# OVERLAPPABLE #-} C a where ...
+and we are typechecking
+  f :: C a => a -> a
+  f = e  -- Gives rise to [W] C a
+
+We don't want to solve the wanted constraint with the overlappable
+instance; rather we want to use the supplied (C a)! That was the whole
+point of it being overlappable!  Trac #14434 wwas an example.
+
+Alas even if the instance has no overlap flag, thus
+  instance C a where ...
+there is nothing to stop it being overlapped. GHC provides no way to
+declare an instance as "final" so it can't be overlapped.  But really
+only final instances are OK for short-cut solving.  Sigh. Trac #15135
+was a puzzling example.
+-}
+
+
 {- ********************************************************************
 *                                                                     *
                    Class lookup for CTuples
diff --git a/compiler/typecheck/TcInteract.hs b/compiler/typecheck/TcInteract.hs
index 3914db6..32b4718 100644
--- a/compiler/typecheck/TcInteract.hs
+++ b/compiler/typecheck/TcInteract.hs
@@ -921,18 +921,6 @@ unique match on the (Take n) instance.  That leads immediately to an
 infinite loop.  Hence the check that 'preds' have no type families
 (isTyFamFree).
 
-Note [Shortcut solving: overlap]
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-Suppose we have
-  instance {-# OVERLAPPABLE #-} C a where ...
-and we are typechecking
-  f :: C a => a -> a
-  f = e  -- Gives rise to [W] C a
-
-We don't want to solve the wanted constraint with the overlappable
-instance; rather we want to use the supplied (C a)! That was the whole
-point of it being overlappable!  Trac #14434 wwas an example.
-
 Note [Shortcut solving: incoherence]
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 This optimization relies on coherence of dictionaries to be correct. When we
@@ -1002,7 +990,7 @@ The workhorse of the short-cut solver is
                             -> MaybeT TcS (EvBindMap, DictMap CtEvidence)
 Note that:
 
-* The CtEvidence is teh goal to be solved
+* The CtEvidence is the goal to be solved
 
 * The MaybeT anages early failure if we find a subgoal that
   cannot be solved from instances.



More information about the ghc-commits mailing list