[commit: ghc] master: Make TcLevel increase by 1 not 2 (d61c7e8)

git at git.haskell.org git at git.haskell.org
Fri Oct 21 16:16:31 UTC 2016


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

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

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

commit d61c7e8d418331e4db783dace9c7ad75306ce05a
Author: Simon Peyton Jones <simonpj at microsoft.com>
Date:   Tue Sep 20 23:29:51 2016 +0100

    Make TcLevel increase by 1 not 2
    
    Make the TcLevel of a flatten-meta-var be always zero.
    See TcType.fmvTcLevel.
    
    This allows the levels of implication constraints to to
    up by 1 each time instead of 2, which is less confusing.
    
    This change has no effect on type checking.


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

d61c7e8d418331e4db783dace9c7ad75306ce05a
 compiler/typecheck/TcType.hs | 17 ++++++-----------
 1 file changed, 6 insertions(+), 11 deletions(-)

diff --git a/compiler/typecheck/TcType.hs b/compiler/typecheck/TcType.hs
index f814a5f..5013f47 100644
--- a/compiler/typecheck/TcType.hs
+++ b/compiler/typecheck/TcType.hs
@@ -646,23 +646,18 @@ Note [TcLevel assignment]
 ~~~~~~~~~~~~~~~~~~~~~~~~~
 We arrange the TcLevels like this
 
+   0   Level for flatten meta-vars
    1   Top level
-   2     Flatten-meta-vars of level 3
-   3   First-level implication constraints
-   4     Flatten-meta-vars of level 5
-   5   Second-level implication constraints
+   2   First-level implication constraints
+   3   Second-level implication constraints
    ...etc...
 
-The even-numbered levels are for the flatten-meta-variables assigned
-at the next level in.  Eg for a second-level implication constraint
-(level 5), the flatten meta-vars are level 4, which makes them untouchable.
-The flatten meta-vars could equally well all have level 0, or just NotALevel
-since they do not live across implications.
+The flatten meta-vars are all at level 0, just to make them untouchable.
 -}
 
 fmvTcLevel :: TcLevel -> TcLevel
 -- See Note [TcLevel assignment]
-fmvTcLevel (TcLevel n) = TcLevel (n-1)
+fmvTcLevel _ = TcLevel 0
 
 topTcLevel :: TcLevel
 -- See Note [TcLevel assignment]
@@ -674,7 +669,7 @@ isTopTcLevel _           = False
 
 pushTcLevel :: TcLevel -> TcLevel
 -- See Note [TcLevel assignment]
-pushTcLevel (TcLevel us) = TcLevel (us + 2)
+pushTcLevel (TcLevel us) = TcLevel (us + 1)
 
 strictlyDeeperThan :: TcLevel -> TcLevel -> Bool
 strictlyDeeperThan (TcLevel tv_tclvl) (TcLevel ctxt_tclvl)



More information about the ghc-commits mailing list