Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
GHC
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Alexander Kaznacheev
GHC
Commits
32a5d959
Commit
32a5d959
authored
10 years ago
by
Iavor S. Diatchki
Committed by
Austin Seipp
10 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Improve `Typeable` solver.
(cherry picked from commit
3a0019e3
)
parent
6153d16c
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
compiler/typecheck/TcInteract.hs
+14
-17
14 additions, 17 deletions
compiler/typecheck/TcInteract.hs
with
14 additions
and
17 deletions
compiler/typecheck/TcInteract.hs
+
14
−
17
View file @
32a5d959
...
...
@@ -2121,23 +2121,19 @@ constraint solving.
matchTypeableClass
::
Class
->
Kind
->
Type
->
CtLoc
->
TcS
LookupInstResult
matchTypeableClass
clas
k
t
loc
|
isForAllTy
k
=
return
NoInstance
|
Just
(
tc
,
ks_tys
)
<-
splitTyConApp_maybe
t
=
doTyConApp
tc
ks_tys
|
Just
(
tc
,
ks
)
<-
splitTyConApp_maybe
t
,
all
isKind
ks
=
doTyCon
tc
ks
|
Just
(
f
,
kt
)
<-
splitAppTy_maybe
t
=
doTyApp
f
kt
|
Just
_
<-
isNumLitTy
t
=
mk
Ev
[]
(
EvTypeableTyLit
t
)
|
Just
_
<-
isStrLitTy
t
=
mk
Ev
[]
(
EvTypeableTyLit
t
)
|
Just
_
<-
isNumLitTy
t
=
mk
SimpEv
(
EvTypeableTyLit
t
)
|
Just
_
<-
isStrLitTy
t
=
mk
SimpEv
(
EvTypeableTyLit
t
)
|
otherwise
=
return
NoInstance
where
-- Representation for type constructor applied to some kinds
and some types.
doTyCon
App
tc
ks
_ts
=
-- Representation for type constructor applied to some kinds
doTyCon
tc
ks
=
case
mapM
kindRep
ks
of
Nothing
->
return
NoInstance
-- Not concrete kinds
Just
kReps
->
do
tCts
<-
mapM
subGoal
ts
mkEv
tCts
(
EvTypeableTyCon
tc
kReps
(
map
ctEvTerm
tCts
`
zip
`
ts
))
where
(
ks
,
ts
)
=
span
isKind
ks_ts
Nothing
->
return
NoInstance
Just
kReps
->
mkSimpEv
(
EvTypeableTyCon
tc
kReps
[]
)
{- Representation for an application of a type to a type-or-kind.
This may happen when the type expression starts with a type variable.
...
...
@@ -2152,7 +2148,9 @@ matchTypeableClass clas k t loc
|
otherwise
=
do
ct1
<-
subGoal
f
ct2
<-
subGoal
tk
mkEv
[
ct1
,
ct2
]
(
EvTypeableTyApp
(
ctEvTerm
ct1
,
f
)
(
ctEvTerm
ct2
,
tk
))
let
realSubs
=
[
c
|
(
c
,
Fresh
)
<-
[
ct1
,
ct2
]
]
return
$
GenInst
realSubs
$
EvTypeable
$
EvTypeableTyApp
(
getEv
ct1
,
f
)
(
getEv
ct2
,
tk
)
-- Representation for concrete kinds. We just use the kind itself,
...
...
@@ -2162,11 +2160,10 @@ matchTypeableClass clas k t loc
mapM_
kindRep
ks
return
ki
getEv
(
ct
,
_fresh
)
=
ctEvTerm
ct
-- Emit a `Typeable` constraint for the given type.
subGoal
ty
=
do
let
goal
=
mkClassPred
clas
[
typeKind
ty
,
ty
]
ev
<-
newWantedEvVarNC
loc
goal
return
ev
newWantedEvVar
loc
goal
mk
Ev
subs
ev
=
return
(
GenInst
subs
(
EvTypeable
ev
))
mk
SimpEv
ev
=
return
(
GenInst
[]
(
EvTypeable
ev
))
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment