[commit: ghc] wip/nested-cpr: Add documentation to plusUFM_CD (5b1eac3)

git at git.haskell.org git at git.haskell.org
Mon Dec 9 18:44:27 UTC 2013


Repository : ssh://git@git.haskell.org/ghc

On branch  : wip/nested-cpr
Link       : http://ghc.haskell.org/trac/ghc/changeset/5b1eac3f16c05209f499ca30a92c4a00cdf9dcec/ghc

>---------------------------------------------------------------

commit 5b1eac3f16c05209f499ca30a92c4a00cdf9dcec
Author: Joachim Breitner <mail at joachim-breitner.de>
Date:   Mon Dec 9 16:46:55 2013 +0000

    Add documentation to plusUFM_CD


>---------------------------------------------------------------

5b1eac3f16c05209f499ca30a92c4a00cdf9dcec
 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