Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Glasgow Haskell Compiler
GHC
Commits
3833e71d
Commit
3833e71d
authored
Oct 06, 2015
by
Simon Peyton Jones
Browse files
Comments about TcLevel assignment
Triggered by investigations around Trac 10845
parent
7da3d30c
Changes
1
Hide whitespace changes
Inline
Side-by-side
compiler/typecheck/TcType.hs
View file @
3833e71d
...
@@ -433,6 +433,7 @@ data UserTypeCtxt
...
@@ -433,6 +433,7 @@ data UserTypeCtxt
newtype
TcLevel
=
TcLevel
Int
deriving
(
Eq
,
Ord
)
newtype
TcLevel
=
TcLevel
Int
deriving
(
Eq
,
Ord
)
-- See Note [TcLevel and untouchable type variables] for what this Int is
-- See Note [TcLevel and untouchable type variables] for what this Int is
-- See also Note [TcLevel assignment]
{-
{-
Note [TcLevel and untouchable type variables]
Note [TcLevel and untouchable type variables]
...
@@ -458,7 +459,6 @@ Note [TcLevel and untouchable type variables]
...
@@ -458,7 +459,6 @@ Note [TcLevel and untouchable type variables]
implication are all untouchable; ie their level
implication are all untouchable; ie their level
numbers are LESS THAN the ic_tclvl of the implication
numbers are LESS THAN the ic_tclvl of the implication
Note [Skolem escape prevention]
Note [Skolem escape prevention]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
We only unify touchable unification variables. Because of
We only unify touchable unification variables. Because of
...
@@ -491,15 +491,35 @@ emerges. If we (wrongly) spontaneously solved it to get uf := beta,
...
@@ -491,15 +491,35 @@ emerges. If we (wrongly) spontaneously solved it to get uf := beta,
the whole implication disappears but when we pop out again we are left with
the whole implication disappears but when we pop out again we are left with
(F Int ~ uf) which will be unified by our final zonking stage and
(F Int ~ uf) which will be unified by our final zonking stage and
uf will get unified *once more* to (F Int).
uf will get unified *once more* to (F Int).
Note [TcLevel assignment]
~~~~~~~~~~~~~~~~~~~~~~~~~
We arrange the TcLevels like this
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
...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.
-}
-}
fmvTcLevel
::
TcLevel
->
TcLevel
fmvTcLevel
::
TcLevel
->
TcLevel
-- See Note [TcLevel assignment]
fmvTcLevel
(
TcLevel
n
)
=
TcLevel
(
n
-
1
)
fmvTcLevel
(
TcLevel
n
)
=
TcLevel
(
n
-
1
)
topTcLevel
::
TcLevel
topTcLevel
::
TcLevel
-- See Note [TcLevel assignment]
topTcLevel
=
TcLevel
1
-- 1 = outermost level
topTcLevel
=
TcLevel
1
-- 1 = outermost level
pushTcLevel
::
TcLevel
->
TcLevel
pushTcLevel
::
TcLevel
->
TcLevel
-- See Note [TcLevel assignment]
pushTcLevel
(
TcLevel
us
)
=
TcLevel
(
us
+
2
)
pushTcLevel
(
TcLevel
us
)
=
TcLevel
(
us
+
2
)
strictlyDeeperThan
::
TcLevel
->
TcLevel
->
Bool
strictlyDeeperThan
::
TcLevel
->
TcLevel
->
Bool
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment