Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
GHC
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
4,251
Issues
4,251
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
394
Merge Requests
394
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Environments
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
Glasgow Haskell Compiler
GHC
Commits
24305bea
Commit
24305bea
authored
Feb 12, 2016
by
Simon Peyton Jones
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Minor refactoring to tauifyMultipleMatches
No change in behaviour
parent
d0846243
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
16 deletions
+15
-16
compiler/typecheck/TcMType.hs
compiler/typecheck/TcMType.hs
+7
-0
compiler/typecheck/TcMatches.hs
compiler/typecheck/TcMatches.hs
+8
-16
No files found.
compiler/typecheck/TcMType.hs
View file @
24305bea
...
...
@@ -32,6 +32,7 @@ module TcMType (
ExpType
(
..
),
ExpSigmaType
,
ExpRhoType
,
mkCheckExpType
,
newOpenInferExpType
,
readExpType
,
readExpType_maybe
,
writeExpType
,
expTypeToType
,
checkingExpType_maybe
,
checkingExpType
,
tauifyExpType
,
--------------------------------
-- Creating fresh type variables for pm checking
...
...
@@ -386,6 +387,12 @@ checkingExpType :: String -> ExpType -> TcType
checkingExpType
_
(
Check
ty
)
=
ty
checkingExpType
err
et
=
pprPanic
"checkingExpType"
(
text
err
$$
ppr
et
)
tauifyExpType
::
ExpType
->
TcM
ExpType
-- ^ Turn a (Infer hole) type into a (Check alpha),
-- where alpha is a fresh unificaiton variable
tauifyExpType
exp_ty
=
do
{
ty
<-
expTypeToType
exp_ty
;
return
(
Check
ty
)
}
-- | Extracts the expected type if there is one, or generates a new
-- TauTv if there isn't.
expTypeToType
::
ExpType
->
TcM
TcType
...
...
compiler/typecheck/TcMatches.hs
View file @
24305bea
...
...
@@ -90,9 +90,7 @@ tcMatchesFun fun_name matches exp_ty
<-
matchExpectedFunTys
herald
arity
exp_rho
$
\
pat_tys
rhs_ty
->
-- See Note [Case branches must never infer a non-tau type]
do
{
rhs_ty
:
pat_tys
<-
mapM
(
tauifyMultipleMatches
matches
)
(
rhs_ty
:
pat_tys
)
do
{
rhs_ty
:
pat_tys
<-
tauifyMultipleMatches
matches
(
rhs_ty
:
pat_tys
)
;
tcMatches
match_ctxt
pat_tys
rhs_ty
matches
}
;
return
(
wrap_fun
,
matches'
)
}
;
return
(
wrap_gen
<.>
wrap_fun
,
group
)
}
...
...
@@ -117,7 +115,7 @@ tcMatchesCase :: (Outputable (body Name)) =>
-- wrapper goes from MatchGroup's ty to expected ty
tcMatchesCase
ctxt
scrut_ty
matches
res_ty
=
do
{
res_ty
<-
tauifyMultipleMatches
matches
res_ty
=
do
{
[
res_ty
]
<-
tauifyMultipleMatches
matches
[
res_ty
]
;
tcMatches
ctxt
[
mkCheckExpType
scrut_ty
]
res_ty
matches
}
tcMatchLambda
::
SDoc
-- see Note [Herald for matchExpectedFunTys] in TcUnify
...
...
@@ -130,8 +128,7 @@ tcMatchLambda herald match_ctxt match res_ty
=
do
{
((
match'
,
pat_tys
),
wrap
)
<-
matchExpectedFunTys
herald
n_pats
res_ty
$
\
pat_tys
rhs_ty
->
do
{
rhs_ty
:
pat_tys
<-
mapM
(
tauifyMultipleMatches
match
)
(
rhs_ty
:
pat_tys
)
do
{
rhs_ty
:
pat_tys
<-
tauifyMultipleMatches
match
(
rhs_ty
:
pat_tys
)
;
match'
<-
tcMatches
match_ctxt
pat_tys
rhs_ty
match
;
pat_tys
<-
mapM
readExpType
pat_tys
;
return
(
match'
,
pat_tys
)
}
...
...
@@ -192,16 +189,11 @@ still gets assigned a polytype.
-- expected type into TauTvs.
-- See Note [Case branches must never infer a non-tau type]
tauifyMultipleMatches
::
MatchGroup
id
body
->
ExpType
->
TcM
ExpType
tauifyMultipleMatches
group
exp_ty
|
isSingletonMatchGroup
group
=
return
exp_ty
|
otherwise
=
mkCheckExpType
<$>
expTypeToType
exp_ty
-- NB: This also ensures that an empty match still fills in the
-- ExpType
->
[
ExpType
]
->
TcM
[
ExpType
]
tauifyMultipleMatches
group
exp_tys
|
isSingletonMatchGroup
group
=
return
exp_tys
|
otherwise
=
mapM
tauifyExpType
exp_tys
-- NB: In the empty-match case, this ensures we fill in the ExpType
-- | Type-check a MatchGroup. If there are multiple RHSs, the expected type
-- must already be tauified.
...
...
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