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,325
Issues
4,325
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
369
Merge Requests
369
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
01a1f4fb
Commit
01a1f4fb
authored
Jan 16, 2020
by
Simon Peyton Jones
Committed by
Ben Gamari
Feb 06, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use foldTyCo for noFreeVarsOfType
parent
ed2f0e5c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
64 deletions
+15
-64
compiler/types/TyCoFVs.hs
compiler/types/TyCoFVs.hs
+15
-64
No files found.
compiler/types/TyCoFVs.hs
View file @
01a1f4fb
...
...
@@ -47,8 +47,7 @@ import GhcPrelude
import
{-#
SOURCE
#-
}
Type
(
coreView
,
tcView
,
partitionInvisibleTypes
)
-- import Data.Monoid as DM ( Endo(..), All(..) )
import
Data.Monoid
as
DM
(
Endo
(
..
)
)
import
Data.Monoid
as
DM
(
Endo
(
..
),
All
(
..
)
)
import
TyCoRep
import
TyCon
import
Var
...
...
@@ -261,9 +260,9 @@ tyCoVarsOfCo co = runTyCoVars (deep_co co)
tyCoVarsOfCos
::
[
Coercion
]
->
TyCoVarSet
tyCoVarsOfCos
cos
=
runTyCoVars
(
deep_cos
cos
)
deep_ty
::
Type
->
Endo
TyCoVarSet
deep_tys
::
[
Type
]
->
Endo
TyCoVarSet
deep_co
::
Coercion
->
Endo
TyCoVarSet
deep_ty
::
Type
->
Endo
TyCoVarSet
deep_tys
::
[
Type
]
->
Endo
TyCoVarSet
deep_co
::
Coercion
->
Endo
TyCoVarSet
deep_cos
::
[
Coercion
]
->
Endo
TyCoVarSet
(
deep_ty
,
deep_tys
,
deep_co
,
deep_cos
)
=
foldTyCo
deepTcvFolder
emptyVarSet
...
...
@@ -316,9 +315,9 @@ shallowTyCoVarsOfCoVarEnv cos = shallowTyCoVarsOfCos (nonDetEltsUFM cos)
-- It's OK to use nonDetEltsUFM here because we immediately
-- forget the ordering by returning a set
shallow_ty
::
Type
->
Endo
TyCoVarSet
shallow_tys
::
[
Type
]
->
Endo
TyCoVarSet
shallow_co
::
Coercion
->
Endo
TyCoVarSet
shallow_ty
::
Type
->
Endo
TyCoVarSet
shallow_tys
::
[
Type
]
->
Endo
TyCoVarSet
shallow_co
::
Coercion
->
Endo
TyCoVarSet
shallow_cos
::
[
Coercion
]
->
Endo
TyCoVarSet
(
shallow_ty
,
shallow_tys
,
shallow_co
,
shallow_cos
)
=
foldTyCo
shallowTcvFolder
emptyVarSet
...
...
@@ -858,8 +857,6 @@ invisibleVarsOfTypes = mapUnionFV invisibleVarsOfType
* *
********************************************************************* -}
{- Desired!
nfvFolder
::
TyCoFolder
TyCoVarSet
DM
.
All
nfvFolder
=
TyCoFolder
{
tcf_tyvar
=
do_tcv
,
tcf_covar
=
do_tcv
,
tcf_hole
=
do_hole
,
tcf_tycobinder
=
do_bndr
}
...
...
@@ -868,66 +865,20 @@ nfvFolder = TyCoFolder { tcf_tyvar = do_tcv, tcf_covar = do_tcv
do_hole
_
_
=
All
True
-- I'm unsure; probably never happens
do_bndr
is
tv
_
=
is
`
extendVarSet
`
tv
noFreeVarsOfType :: Type -> Bool
noFreeVarsOfType = DM.getAll . foldType nfvFolder emptyVarSet
noFreeVarsOfTypes :: [Type] -> Bool
noFreeVarsOfTypes = DM.getAll . foldTypes nfvFolder emptyVarSet
noFreeVarsOfCo :: Coercion -> Bool
noFreeVarsOfCo = getAll . foldCoercion nfvFolder emptyVarSet
-}
nfv_ty
::
Type
->
DM
.
All
nfv_tys
::
[
Type
]
->
DM
.
All
nfv_co
::
Coercion
->
DM
.
All
(
nfv_ty
,
nfv_tys
,
nfv_co
,
_
)
=
foldTyCo
nfvFolder
emptyVarSet
-- | Returns True if this type has no free variables. Should be the same as
-- isEmptyVarSet . tyCoVarsOfType, but faster in the non-forall case.
noFreeVarsOfType
::
Type
->
Bool
noFreeVarsOfType
(
TyVarTy
_
)
=
False
noFreeVarsOfType
(
AppTy
t1
t2
)
=
noFreeVarsOfType
t1
&&
noFreeVarsOfType
t2
noFreeVarsOfType
(
TyConApp
_
tys
)
=
all
noFreeVarsOfType
tys
noFreeVarsOfType
ty
@
(
ForAllTy
{})
=
isEmptyVarSet
(
tyCoVarsOfType
ty
)
noFreeVarsOfType
(
FunTy
_
t1
t2
)
=
noFreeVarsOfType
t1
&&
noFreeVarsOfType
t2
noFreeVarsOfType
(
LitTy
_
)
=
True
noFreeVarsOfType
(
CastTy
ty
co
)
=
noFreeVarsOfType
ty
&&
noFreeVarsOfCo
co
noFreeVarsOfType
(
CoercionTy
co
)
=
noFreeVarsOfCo
co
noFreeVarsOfMCo
::
MCoercion
->
Bool
noFreeVarsOfMCo
MRefl
=
True
noFreeVarsOfMCo
(
MCo
co
)
=
noFreeVarsOfCo
co
noFreeVarsOfType
ty
=
DM
.
getAll
(
nfv_ty
ty
)
noFreeVarsOfTypes
::
[
Type
]
->
Bool
noFreeVarsOfTypes
=
all
noFreeVarsOfType
noFreeVarsOfTypes
tys
=
DM
.
getAll
(
nfv_tys
tys
)
-- | Returns True if this coercion has no free variables. Should be the same as
-- isEmptyVarSet . tyCoVarsOfCo, but faster in the non-forall case.
noFreeVarsOfCo
::
Coercion
->
Bool
noFreeVarsOfCo
(
Refl
ty
)
=
noFreeVarsOfType
ty
noFreeVarsOfCo
(
GRefl
_
ty
co
)
=
noFreeVarsOfType
ty
&&
noFreeVarsOfMCo
co
noFreeVarsOfCo
(
TyConAppCo
_
_
args
)
=
all
noFreeVarsOfCo
args
noFreeVarsOfCo
(
AppCo
c1
c2
)
=
noFreeVarsOfCo
c1
&&
noFreeVarsOfCo
c2
noFreeVarsOfCo
co
@
(
ForAllCo
{})
=
isEmptyVarSet
(
tyCoVarsOfCo
co
)
noFreeVarsOfCo
(
FunCo
_
c1
c2
)
=
noFreeVarsOfCo
c1
&&
noFreeVarsOfCo
c2
noFreeVarsOfCo
(
CoVarCo
_
)
=
False
noFreeVarsOfCo
(
HoleCo
{})
=
True
-- I'm unsure; probably never happens
noFreeVarsOfCo
(
AxiomInstCo
_
_
args
)
=
all
noFreeVarsOfCo
args
noFreeVarsOfCo
(
UnivCo
p
_
t1
t2
)
=
noFreeVarsOfProv
p
&&
noFreeVarsOfType
t1
&&
noFreeVarsOfType
t2
noFreeVarsOfCo
(
SymCo
co
)
=
noFreeVarsOfCo
co
noFreeVarsOfCo
(
TransCo
co1
co2
)
=
noFreeVarsOfCo
co1
&&
noFreeVarsOfCo
co2
noFreeVarsOfCo
(
NthCo
_
_
co
)
=
noFreeVarsOfCo
co
noFreeVarsOfCo
(
LRCo
_
co
)
=
noFreeVarsOfCo
co
noFreeVarsOfCo
(
InstCo
co1
co2
)
=
noFreeVarsOfCo
co1
&&
noFreeVarsOfCo
co2
noFreeVarsOfCo
(
KindCo
co
)
=
noFreeVarsOfCo
co
noFreeVarsOfCo
(
SubCo
co
)
=
noFreeVarsOfCo
co
noFreeVarsOfCo
(
AxiomRuleCo
_
cs
)
=
all
noFreeVarsOfCo
cs
-- | Returns True if this UnivCoProv has no free variables. Should be the same as
-- isEmptyVarSet . tyCoVarsOfProv, but faster in the non-forall case.
noFreeVarsOfProv
::
UnivCoProvenance
->
Bool
noFreeVarsOfProv
UnsafeCoerceProv
=
True
noFreeVarsOfProv
(
PhantomProv
co
)
=
noFreeVarsOfCo
co
noFreeVarsOfProv
(
ProofIrrelProv
co
)
=
noFreeVarsOfCo
co
noFreeVarsOfProv
(
PluginProv
{})
=
True
noFreeVarsOfCo
co
=
getAll
(
nfv_co
co
)
{- *********************************************************************
* *
...
...
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