Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Glasgow Haskell Compiler
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Package Registry
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Shayne Fletcher
Glasgow Haskell Compiler
Commits
e24da5ed
Commit
e24da5ed
authored
Jul 11, 2018
by
Simon Peyton Jones
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Better Note [The well-kinded type invariant]
c.f. Trac #14873
parent
81d8b179
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
20 deletions
+20
-20
compiler/typecheck/TcType.hs
compiler/typecheck/TcType.hs
+20
-20
No files found.
compiler/typecheck/TcType.hs
View file @
e24da5ed
...
...
@@ -1402,26 +1402,26 @@ getDFunTyLitKey (StrTyLit n) = mkOccName Name.varName (show n) -- hm
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
See also Note [The tcType invariant] in TcHsType.
During type inference, we maintain th
e invariant tha
t
INVARIANT: every type is well-kinded /without/ zonking
EXCEPT: you are allowed (ty |> co) even if the kind of ty
does not match the from-kind of co.
Main goal: if this invariant is respected, then typeKind cannot fail
(as it can for ill-kinded types).
In particular, we can get types lik
e
(k |> co) Int
where
k :: kappa
co :: Refl (Type -> Type)
kappa is a unification variable and kappa := Type already
So in the un-zonked form (k Int) would be ill-kinded,
but (k |> co) Int is well-kinded. So we want to keep that 'co'
/even though it is Refl/.
During type inference, we maintain th
is invarian
t
(INV-TK): it is legal to call 'typeKind' on any Type ty,
/without/ zonking ty
For example, suppose
kappa is a unification variable
We have already unified kappa := Type
yielding co :: Refl (Type -> Type)
a :: kappa
then consider the typ
e
(a Int)
If we call typeKind on that, we'll crash, because the (un-zonked)
kind of 'a' is just kappa, not an arrow kind. If we zonk first
we'd be fine, but that is too tiresome, so instead we maintain
(TK-INV). So we do not form (a Int); instead we form
(a |> co) Int
and typeKind has no problem with that.
Bottom line: we want to keep that 'co'
/even though it is Refl/.
Immediate consequence: during type inference we cannot use the "smart
contructors" for types, particularly
...
...
Write
Preview
Markdown
is supported
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