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
Terraform modules
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
Gesh
GHC
Commits
025f26d6
Commit
025f26d6
authored
27 years ago
by
sof
Browse files
Options
Downloads
Patches
Plain Diff
[project @ 1997-05-18 04:49:19 by sof]
new function: keysUFM
parent
57b42110
Loading
Loading
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
ghc/compiler/utils/UniqFM.lhs
+17
-20
17 additions, 20 deletions
ghc/compiler/utils/UniqFM.lhs
with
17 additions
and
20 deletions
ghc/compiler/utils/UniqFM.lhs
+
17
−
20
View file @
025f26d6
...
...
@@ -47,7 +47,7 @@ module UniqFM (
isNullUFM,
lookupUFM, lookupUFM_Directly,
lookupWithDefaultUFM, lookupWithDefaultUFM_Directly,
eltsUFM,
eltsUFM,
keysUFM,
ufmToList
#if defined(COMPILING_GHC)
,FAST_STRING
...
...
@@ -57,10 +57,11 @@ module UniqFM (
#if defined(COMPILING_GHC)
IMPORT_DELOOPER( SpecLoop )
#endif
IMP_Ubiq()
import Unique ( Unique, u2i, mkUniqueGrimily )
import Util
import Pretty (
SYN_IE(Pretty), PrettyRep
)
import Pretty (
Doc
)
import Outputable ( Outputable(..) )
import PprStyle ( PprStyle )
import SrcLoc ( SrcLoc )
...
...
@@ -129,6 +130,7 @@ lookupWithDefaultUFM
lookupWithDefaultUFM_Directly
:: UniqFM elt -> elt -> Unique -> elt
keysUFM :: UniqFM elt -> [Int] -- Get the keys
eltsUFM :: UniqFM elt -> [elt]
ufmToList :: UniqFM elt -> [(Unique, elt)]
\end{code}
...
...
@@ -512,9 +514,12 @@ intersectUFM_C f fm1 fm2 = intersect_trees fm1 fm2
Now the usual set of `collection' operators, like map, fold, etc.
\begin{code}
foldUFM fn a EmptyUFM = a
foldUFM fn a fm = fold_tree fn a fm
foldUFM f a (NodeUFM _ _ t1 t2) = foldUFM f (foldUFM f a t2) t1
foldUFM f a (LeafUFM _ obj) = f obj a
foldUFM f a EmptyUFM = a
\end{code}
\begin{code}
mapUFM fn EmptyUFM = EmptyUFM
mapUFM fn fm = map_tree fn fm
...
...
@@ -571,17 +576,15 @@ lookUp fm i = lookup_tree fm
folds are *wonderful* things.
\begin{code}
eltsUFM EmptyUFM = []
eltsUFM fm = fold_tree (:) [] fm
eltsUFM fm = foldUFM (:) [] fm
ufmToList EmptyUFM = []
ufmToList fm
= fold_tree (\ iu elt rest -> (mkUniqueGrimily iu, elt) : rest) [] fm
where
fold_tree f a (NodeUFM _ _ t1 t2) = fold_tree f (fold_tree f a t2) t1
fold_tree f a (LeafUFM iu obj) = f iu obj a
ufmToList fm = fold_tree (\ iu elt rest -> (mkUniqueGrimily iu, elt) : rest) [] fm
fold_tree f a EmptyUFM = panic "Should Never fold over an EmptyUFM"
keysUFM fm = fold_tree (\ iu elt rest -> IBOX(iu) : rest) [] fm
fold_tree f a (NodeUFM _ _ t1 t2) = fold_tree f (fold_tree f a t2) t1
fold_tree f a (LeafUFM iu obj) = f iu obj a
fold_tree f a EmptyUFM = a
\end{code}
%************************************************************************
...
...
@@ -691,14 +694,7 @@ insert_ele f n@(NodeUFM j p t1 t2) i a
(mkLeafUFM i a)
\end{code}
This has got a left to right ordering.
\begin{code}
fold_tree f a (NodeUFM _ _ t1 t2) = fold_tree f (fold_tree f a t2) t1
fold_tree f a (LeafUFM _ obj) = f obj a
fold_tree f a EmptyUFM = panic "Should Never fold over an EmptyUFM"
\end{code}
\begin{code}
map_tree f (NodeUFM j p t1 t2)
...
...
@@ -716,6 +712,7 @@ filter_tree f nd@(NodeUFM j p t1 t2)
filter_tree f lf@(LeafUFM i obj)
| f obj = lf
| otherwise = EmptyUFM
filter_tree f _ = panic "filter_tree failed"
\end{code}
%************************************************************************
...
...
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