projects
/
ghc-hetmet.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Document UniqFM and add listToUFM_C
[ghc-hetmet.git]
/
compiler
/
utils
/
UniqFM.lhs
diff --git
a/compiler/utils/UniqFM.lhs
b/compiler/utils/UniqFM.lhs
index
59158f3
..
642522d
100644
(file)
--- a/
compiler/utils/UniqFM.lhs
+++ b/
compiler/utils/UniqFM.lhs
@@
-15,14
+15,17
@@
Basically, the things need to be in class @Uniquable@, and we use the
\begin{code}
{-# OPTIONS -Wall -fno-warn-name-shadowing #-}
module UniqFM (
\begin{code}
{-# OPTIONS -Wall -fno-warn-name-shadowing #-}
module UniqFM (
+ -- * Unique-keyed mappings
UniqFM(..), -- abstract type
-- (de-abstracted for MachRegs.trivColorable optimisation BL 2007/09)
UniqFM(..), -- abstract type
-- (de-abstracted for MachRegs.trivColorable optimisation BL 2007/09)
+ -- ** Manipulating those mappings
emptyUFM,
unitUFM,
unitDirectlyUFM,
listToUFM,
listToUFM_Directly,
emptyUFM,
unitUFM,
unitDirectlyUFM,
listToUFM,
listToUFM_Directly,
+ listToUFM_C,
addToUFM,addToUFM_C,addToUFM_Acc,
addListToUFM,addListToUFM_C,
addToUFM_Directly,
addToUFM,addToUFM_C,addToUFM_Acc,
addListToUFM,addListToUFM_C,
addToUFM_Directly,
@@
-74,6
+77,9
@@
unitDirectlyUFM -- got the Unique already
listToUFM :: Uniquable key => [(key,elt)] -> UniqFM elt
listToUFM_Directly
:: [(Unique, elt)] -> UniqFM elt
listToUFM :: Uniquable key => [(key,elt)] -> UniqFM elt
listToUFM_Directly
:: [(Unique, elt)] -> UniqFM elt
+listToUFM_C :: Uniquable key => (elt -> elt -> elt)
+ -> [(key, elt)]
+ -> UniqFM elt
addToUFM :: Uniquable key => UniqFM elt -> key -> elt -> UniqFM elt
addListToUFM :: Uniquable key => UniqFM elt -> [(key,elt)] -> UniqFM elt
addToUFM :: Uniquable key => UniqFM elt -> key -> elt -> UniqFM elt
addListToUFM :: Uniquable key => UniqFM elt -> [(key,elt)] -> UniqFM elt
@@
-196,18
+202,18
@@
This code is explained in the paper:
%* *
%************************************************************************
%* *
%************************************************************************
-@UniqFM a@ is a mapping from Unique to a.
-
First, the DataType itself; which is either a Node, a Leaf, or an Empty.
\begin{code}
First, the DataType itself; which is either a Node, a Leaf, or an Empty.
\begin{code}
+-- | @UniqFM a@ is a mapping from Unique to @a@. DO NOT use these constructors
+-- directly unless you live in this module!
data UniqFM ele
= EmptyUFM
data UniqFM ele
= EmptyUFM
- | LeafUFM FastInt ele
- | NodeUFM FastInt -- the switching
- FastInt -- the delta
- (UniqFM ele)
- (UniqFM ele)
+ | LeafUFM !FastInt ele
+ | NodeUFM !FastInt -- the switching
+ !FastInt -- the delta
+ (UniqFM ele)
+ (UniqFM ele)
-- INVARIANT: the children of a NodeUFM are never EmptyUFMs
{-
-- INVARIANT: the children of a NodeUFM are never EmptyUFMs
{-
@@
-243,6
+249,9
@@
listToUFM key_elt_pairs
listToUFM_Directly uniq_elt_pairs
= addListToUFM_directly_C use_snd EmptyUFM uniq_elt_pairs
listToUFM_Directly uniq_elt_pairs
= addListToUFM_directly_C use_snd EmptyUFM uniq_elt_pairs
+
+listToUFM_C combiner key_elt_pairs
+ = addListToUFM_C combiner EmptyUFM key_elt_pairs
\end{code}
Now ways of adding things to UniqFMs.
\end{code}
Now ways of adding things to UniqFMs.
@@
-698,7
+707,7
@@
insert_ele f (LeafUFM j old) i new
(indexToRoot j))
(mkLeafUFM i new)
(mkLeafUFM j old)
(indexToRoot j))
(mkLeafUFM i new)
(mkLeafUFM j old)
- | j ==# i = mkLeafUFM j (f old new)
+ | j ==# i = mkLeafUFM j $ f old new
| otherwise =
mkLLNodeUFM (getCommonNodeUFMData
(indexToRoot i)
| otherwise =
mkLLNodeUFM (getCommonNodeUFMData
(indexToRoot i)
@@
-839,7
+848,3
@@
use_snd :: a -> b -> b
use_snd _ b = b
\end{code}
use_snd _ b = b
\end{code}
-\begin{code}
-_unused :: FS.FastString
-_unused = undefined
-\end{code}