[commit: ghc] wip/nested-cpr: Add documentation to plusUFM_CD (9805e2c)
git at git.haskell.org
git at git.haskell.org
Tue Dec 10 11:18:57 UTC 2013
Repository : ssh://git@git.haskell.org/ghc
On branch : wip/nested-cpr
Link : http://ghc.haskell.org/trac/ghc/changeset/9805e2c5fd9b40bd364db7601e6e0a47dc05d818/ghc
>---------------------------------------------------------------
commit 9805e2c5fd9b40bd364db7601e6e0a47dc05d818
Author: Joachim Breitner <mail at joachim-breitner.de>
Date: Mon Dec 9 16:46:55 2013 +0000
Add documentation to plusUFM_CD
>---------------------------------------------------------------
9805e2c5fd9b40bd364db7601e6e0a47dc05d818
compiler/utils/UniqFM.lhs | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/compiler/utils/UniqFM.lhs b/compiler/utils/UniqFM.lhs
index e74eefc..01acbf3 100644
--- a/compiler/utils/UniqFM.lhs
+++ b/compiler/utils/UniqFM.lhs
@@ -135,6 +135,13 @@ plusUFM :: UniqFM elt -> UniqFM elt -> UniqFM elt
plusUFM_C :: (elt -> elt -> elt)
-> UniqFM elt -> UniqFM elt -> UniqFM elt
+-- | plusUFM_CD f m1 d1 m2 d2
+-- merges the maps using `f` as the combinding function and d1 resp. d2 as
+-- the default value if there is no entry in m1 reps. m2. The domain is the union
+-- of the domains of m1 m2.
+-- Representative example:
+-- > plusUFM_CD f {A: 1, B: 2} 23 {B: 3, C: 4} 42
+-- > == {A: f 1 42, B: f 2 3, C: f 23 4 }
plusUFM_CD :: (elt -> elt -> elt)
-> UniqFM elt -> elt -> UniqFM elt -> elt -> UniqFM elt
@@ -226,7 +233,11 @@ delFromUFM_Directly (UFM m) u = UFM (M.delete (getKey u) m)
-- M.union is left-biased, plusUFM should be right-biased.
plusUFM (UFM x) (UFM y) = UFM (M.union y x)
+ -- Note (M.union y x), with arguments flipped
+ -- M.union is left-biased, plusUFM should be right-biased.
+
plusUFM_C f (UFM x) (UFM y) = UFM (M.unionWith f x y)
+
plusUFM_CD f (UFM xm) dx (UFM ym) dy
= UFM $ M.mergeWithKey
(\_ x y -> Just (x `f` y))
More information about the ghc-commits
mailing list