Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Open sidebar
Glasgow Haskell Compiler
GHC
Commits
c4e6b35d
Commit
c4e6b35d
authored
Dec 01, 2019
by
Ben Gamari
🐢
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move closeOverKinds and friends to TyCoFVs
parent
29b72c00
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
29 deletions
+37
-29
compiler/types/TyCoFVs.hs
compiler/types/TyCoFVs.hs
+33
-1
compiler/types/Type.hs
compiler/types/Type.hs
+4
-28
No files found.
compiler/types/TyCoFVs.hs
View file @
c4e6b35d
...
@@ -20,9 +20,14 @@ module TyCoFVs
...
@@ -20,9 +20,14 @@ module TyCoFVs
mkTyCoInScopeSet
,
mkTyCoInScopeSet
,
-- * Well
l
-scoped free variables
-- * Well-scoped free variables
scopedSort
,
tyCoVarsOfTypeWellScoped
,
scopedSort
,
tyCoVarsOfTypeWellScoped
,
tyCoVarsOfTypesWellScoped
,
tyCoVarsOfTypesWellScoped
,
-- * Closing over kinds
closeOverKindsDSet
,
closeOverKindsFV
,
closeOverKindsList
,
closeOverKinds
,
)
where
)
where
import
GhcPrelude
import
GhcPrelude
...
@@ -35,6 +40,7 @@ import Var
...
@@ -35,6 +40,7 @@ import Var
import
FV
import
FV
import
UniqFM
import
UniqFM
import
UniqSet
(
nonDetEltsUniqSet
)
import
VarSet
import
VarSet
import
VarEnv
import
VarEnv
import
Util
import
Util
...
@@ -859,3 +865,29 @@ tyCoVarsOfTypeWellScoped = scopedSort . tyCoVarsOfTypeList
...
@@ -859,3 +865,29 @@ tyCoVarsOfTypeWellScoped = scopedSort . tyCoVarsOfTypeList
-- | Get the free vars of types in scoped order
-- | Get the free vars of types in scoped order
tyCoVarsOfTypesWellScoped
::
[
Type
]
->
[
TyVar
]
tyCoVarsOfTypesWellScoped
::
[
Type
]
->
[
TyVar
]
tyCoVarsOfTypesWellScoped
=
scopedSort
.
tyCoVarsOfTypesList
tyCoVarsOfTypesWellScoped
=
scopedSort
.
tyCoVarsOfTypesList
------------- Closing over kinds -----------------
-- | Add the kind variables free in the kinds of the tyvars in the given set.
-- Returns a non-deterministic set.
closeOverKinds
::
TyVarSet
->
TyVarSet
closeOverKinds
=
fvVarSet
.
closeOverKindsFV
.
nonDetEltsUniqSet
-- It's OK to use nonDetEltsUniqSet here because we immediately forget
-- about the ordering by returning a set.
-- | Given a list of tyvars returns a deterministic FV computation that
-- returns the given tyvars with the kind variables free in the kinds of the
-- given tyvars.
closeOverKindsFV
::
[
TyVar
]
->
FV
closeOverKindsFV
tvs
=
mapUnionFV
(
tyCoFVsOfType
.
tyVarKind
)
tvs
`
unionFV
`
mkFVs
tvs
-- | Add the kind variables free in the kinds of the tyvars in the given set.
-- Returns a deterministically ordered list.
closeOverKindsList
::
[
TyVar
]
->
[
TyVar
]
closeOverKindsList
tvs
=
fvVarList
$
closeOverKindsFV
tvs
-- | Add the kind variables free in the kinds of the tyvars in the given set.
-- Returns a deterministic set.
closeOverKindsDSet
::
DTyVarSet
->
DTyVarSet
closeOverKindsDSet
=
fvDVarSet
.
closeOverKindsFV
.
dVarSetElems
compiler/types/Type.hs
View file @
c4e6b35d
...
@@ -141,14 +141,16 @@ module Type (
...
@@ -141,14 +141,16 @@ module Type (
tyCoVarsOfTypeDSet
,
tyCoVarsOfTypeDSet
,
coVarsOfType
,
coVarsOfType
,
coVarsOfTypes
,
coVarsOfTypes
,
closeOverKindsDSet
,
closeOverKindsFV
,
closeOverKindsList
,
closeOverKinds
,
noFreeVarsOfType
,
noFreeVarsOfType
,
splitVisVarsOfType
,
splitVisVarsOfTypes
,
splitVisVarsOfType
,
splitVisVarsOfTypes
,
expandTypeSynonyms
,
expandTypeSynonyms
,
typeSize
,
occCheckExpand
,
typeSize
,
occCheckExpand
,
-- ** Closing over kinds
closeOverKindsDSet
,
closeOverKindsFV
,
closeOverKindsList
,
closeOverKinds
,
-- * Well-scoped lists of variables
-- * Well-scoped lists of variables
scopedSort
,
tyCoVarsOfTypeWellScoped
,
scopedSort
,
tyCoVarsOfTypeWellScoped
,
tyCoVarsOfTypesWellScoped
,
tyCoVarsOfTypesWellScoped
,
...
@@ -1857,32 +1859,6 @@ binderRelevantType_maybe :: TyCoBinder -> Maybe Type
...
@@ -1857,32 +1859,6 @@ binderRelevantType_maybe :: TyCoBinder -> Maybe Type
binderRelevantType_maybe
(
Named
{})
=
Nothing
binderRelevantType_maybe
(
Named
{})
=
Nothing
binderRelevantType_maybe
(
Anon
_
ty
)
=
Just
ty
binderRelevantType_maybe
(
Anon
_
ty
)
=
Just
ty
------------- Closing over kinds -----------------
-- | Add the kind variables free in the kinds of the tyvars in the given set.
-- Returns a non-deterministic set.
closeOverKinds
::
TyVarSet
->
TyVarSet
closeOverKinds
=
fvVarSet
.
closeOverKindsFV
.
nonDetEltsUniqSet
-- It's OK to use nonDetEltsUniqSet here because we immediately forget
-- about the ordering by returning a set.
-- | Given a list of tyvars returns a deterministic FV computation that
-- returns the given tyvars with the kind variables free in the kinds of the
-- given tyvars.
closeOverKindsFV
::
[
TyVar
]
->
FV
closeOverKindsFV
tvs
=
mapUnionFV
(
tyCoFVsOfType
.
tyVarKind
)
tvs
`
unionFV
`
mkFVs
tvs
-- | Add the kind variables free in the kinds of the tyvars in the given set.
-- Returns a deterministically ordered list.
closeOverKindsList
::
[
TyVar
]
->
[
TyVar
]
closeOverKindsList
tvs
=
fvVarList
$
closeOverKindsFV
tvs
-- | Add the kind variables free in the kinds of the tyvars in the given set.
-- Returns a deterministic set.
closeOverKindsDSet
::
DTyVarSet
->
DTyVarSet
closeOverKindsDSet
=
fvDVarSet
.
closeOverKindsFV
.
dVarSetElems
{-
{-
************************************************************************
************************************************************************
* *
* *
...
...
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