[commit: ghc] wip/spj-tc-branch2: Make TcLevel increase by 1 not 2 (a9c4e4d)

git at git.haskell.org git at git.haskell.org
Thu Sep 29 10:36:10 UTC 2016


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

On branch  : wip/spj-tc-branch2
Link       : http://ghc.haskell.org/trac/ghc/changeset/a9c4e4d8b7815ca54922c0eb78e201a7eb8b00f2/ghc

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

commit a9c4e4d8b7815ca54922c0eb78e201a7eb8b00f2
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.


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

a9c4e4d8b7815ca54922c0eb78e201a7eb8b00f2
 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 2970821..d955a80 100644
--- a/compiler/typecheck/TcType.hs
+++ b/compiler/typecheck/TcType.hs
@@ -655,18 +655,13 @@ 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 conststraint
-(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.
 -}
 
 maxTcLevel :: TcLevel -> TcLevel -> TcLevel
@@ -674,7 +669,7 @@ maxTcLevel (TcLevel a) (TcLevel b) = TcLevel (a `max` b)
 
 fmvTcLevel :: TcLevel -> TcLevel
 -- See Note [TcLevel assignment]
-fmvTcLevel (TcLevel n) = TcLevel (n-1)
+fmvTcLevel _ = TcLevel 0
 
 topTcLevel :: TcLevel
 -- See Note [TcLevel assignment]
@@ -686,7 +681,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