1 -----------------------------------------------------------------------------
3 -- Module : Data.FiniteMap
4 -- Copyright : (c) The University of Glasgow 2001
5 -- License : BSD-style (see the file libraries/base/LICENSE)
7 -- Maintainer : libraries@haskell.org
8 -- Stability : provisional
9 -- Portability : portable
11 -- A finite map implementation, derived from the paper:
12 -- S Adams, "Efficient sets: a balancing act"
13 -- Journal of functional programming 3(4) Oct 1993, pp553-562
15 -- ToDo: clean up, remove the COMPILING_GHC stuff.
17 -----------------------------------------------------------------------------
19 -- The code is SPECIALIZEd to various highly-desirable types (e.g., Id)
20 -- near the end (only \tr{#ifdef COMPILING_GHC}).
23 #include "HsVersions.h"
24 #define IF_NOT_GHC(a) {--}
26 #define ASSERT(e) {--}
27 #define IF_NOT_GHC(a) a
29 #define _tagCmp compare
35 #if defined(COMPILING_GHC) && defined(DEBUG_FINITEMAPS)/* NB NB NB */
36 #define OUTPUTABLE_key , Outputable key
38 #define OUTPUTABLE_key {--}
41 module Data.FiniteMap (
42 FiniteMap, -- abstract type
44 emptyFM, unitFM, listToFM,
50 IF_NOT_GHC(delFromFM COMMA)
58 IF_NOT_GHC(intersectFM COMMA)
59 IF_NOT_GHC(intersectFM_C COMMA)
60 IF_NOT_GHC(mapFM COMMA filterFM COMMA)
62 sizeFM, isEmptyFM, elemFM, lookupFM, lookupWithDefaultFM,
64 fmToList, keysFM, eltsFM
73 import Data.Maybe ( isJust )
74 #ifdef __GLASGOW_HASKELL__
83 import Bag ( foldBag )
85 # if ! OMIT_NATIVE_CODEGEN
88 # define IF_NCG(a) {--}
92 -- SIGH: but we use unboxed "sizes"...
93 #if __GLASGOW_HASKELL__
100 -- ---------------------------------------------------------------------------
101 -- The signature of the module
104 emptyFM :: FiniteMap key elt
105 unitFM :: key -> elt -> FiniteMap key elt
106 listToFM :: (Ord key OUTPUTABLE_key) => [(key,elt)] -> FiniteMap key elt
107 -- In the case of duplicates, the last is taken
109 bagToFM :: (Ord key OUTPUTABLE_key) => Bag (key,elt) -> FiniteMap key elt
110 -- In the case of duplicates, who knows which is taken
113 -- ADDING AND DELETING
114 -- Throws away any previous binding
115 -- In the list case, the items are added starting with the
116 -- first one in the list
117 addToFM :: (Ord key OUTPUTABLE_key) => FiniteMap key elt -> key -> elt -> FiniteMap key elt
118 addListToFM :: (Ord key OUTPUTABLE_key) => FiniteMap key elt -> [(key,elt)] -> FiniteMap key elt
120 -- Combines with previous binding
121 -- In the combining function, the first argument is the "old" element,
122 -- while the second is the "new" one.
123 addToFM_C :: (Ord key OUTPUTABLE_key) => (elt -> elt -> elt)
124 -> FiniteMap key elt -> key -> elt
126 addListToFM_C :: (Ord key OUTPUTABLE_key) => (elt -> elt -> elt)
127 -> FiniteMap key elt -> [(key,elt)]
130 -- Deletion doesn't complain if you try to delete something
132 delFromFM :: (Ord key OUTPUTABLE_key) => FiniteMap key elt -> key -> FiniteMap key elt
133 delListFromFM :: (Ord key OUTPUTABLE_key) => FiniteMap key elt -> [key] -> FiniteMap key elt
136 -- Bindings in right argument shadow those in the left
137 plusFM :: (Ord key OUTPUTABLE_key) => FiniteMap key elt -> FiniteMap key elt
140 -- Combines bindings for the same thing with the given function
141 plusFM_C :: (Ord key OUTPUTABLE_key) => (elt -> elt -> elt)
142 -> FiniteMap key elt -> FiniteMap key elt -> FiniteMap key elt
144 minusFM :: (Ord key OUTPUTABLE_key) => FiniteMap key elt -> FiniteMap key elt -> FiniteMap key elt
145 -- (minusFM a1 a2) deletes from a1 any bindings which are bound in a2
147 intersectFM :: (Ord key OUTPUTABLE_key) => FiniteMap key elt -> FiniteMap key elt -> FiniteMap key elt
148 intersectFM_C :: (Ord key OUTPUTABLE_key) => (elt1 -> elt2 -> elt3)
149 -> FiniteMap key elt1 -> FiniteMap key elt2 -> FiniteMap key elt3
151 -- MAPPING, FOLDING, FILTERING
152 foldFM :: (key -> elt -> a -> a) -> a -> FiniteMap key elt -> a
153 mapFM :: (key -> elt1 -> elt2) -> FiniteMap key elt1 -> FiniteMap key elt2
154 filterFM :: (Ord key OUTPUTABLE_key) => (key -> elt -> Bool)
155 -> FiniteMap key elt -> FiniteMap key elt
158 sizeFM :: FiniteMap key elt -> Int
159 isEmptyFM :: FiniteMap key elt -> Bool
161 elemFM :: (Ord key OUTPUTABLE_key) => key -> FiniteMap key elt -> Bool
162 lookupFM :: (Ord key OUTPUTABLE_key) => FiniteMap key elt -> key -> Maybe elt
164 :: (Ord key OUTPUTABLE_key) => FiniteMap key elt -> elt -> key -> elt
165 -- lookupWithDefaultFM supplies a "default" elt
166 -- to return for an unmapped key
169 fmToList :: FiniteMap key elt -> [(key,elt)]
170 keysFM :: FiniteMap key elt -> [key]
171 eltsFM :: FiniteMap key elt -> [elt]
173 -- ---------------------------------------------------------------------------
174 -- The @FiniteMap@ data type, and building of same
176 -- Invariants about @FiniteMap@:
178 -- * all keys in a FiniteMap are distinct
180 -- * all keys in left subtree are $<$ key in Branch and
181 -- all keys in right subtree are $>$ key in Branch
183 -- * size field of a Branch gives number of Branch nodes in the tree
185 -- * size of left subtree is differs from size of right subtree by a
186 -- factor of at most \tr{sIZE_RATIO}
188 data FiniteMap key elt
190 | Branch key elt -- Key and elt stored here
191 IF_GHC(Int#,Int{-STRICT-}) -- Size >= 1
192 (FiniteMap key elt) -- Children
199 = Branch bottom bottom IF_GHC(0#,0) bottom bottom
201 bottom = panic "emptyFM"
204 -- #define EmptyFM (Branch _ _ IF_GHC(0#,0) _ _)
206 unitFM key elt = Branch key elt IF_GHC(1#,1) emptyFM emptyFM
208 listToFM = addListToFM emptyFM
211 bagToFM = foldBag plusFM (\ (k,v) -> unitFM k v) emptyFM
215 -- ---------------------------------------------------------------------------
216 -- Adding to and deleting from @FiniteMaps@
218 addToFM fm key elt = addToFM_C (\ old new -> new) fm key elt
220 addToFM_C combiner EmptyFM key elt = unitFM key elt
221 addToFM_C combiner (Branch key elt size fm_l fm_r) new_key new_elt
222 #ifdef __GLASGOW_HASKELL__
223 = case _tagCmp new_key key of
224 _LT -> mkBalBranch key elt (addToFM_C combiner fm_l new_key new_elt) fm_r
225 _GT -> mkBalBranch key elt fm_l (addToFM_C combiner fm_r new_key new_elt)
226 _EQ -> Branch new_key (combiner elt new_elt) size fm_l fm_r
228 | new_key < key = mkBalBranch key elt (addToFM_C combiner fm_l new_key new_elt) fm_r
229 | new_key > key = mkBalBranch key elt fm_l (addToFM_C combiner fm_r new_key new_elt)
230 | otherwise = Branch new_key (combiner elt new_elt) size fm_l fm_r
233 addListToFM fm key_elt_pairs = addListToFM_C (\ old new -> new) fm key_elt_pairs
235 addListToFM_C combiner fm key_elt_pairs
236 = foldl add fm key_elt_pairs -- foldl adds from the left
238 add fmap (key,elt) = addToFM_C combiner fmap key elt
241 delFromFM EmptyFM del_key = emptyFM
242 delFromFM (Branch key elt size fm_l fm_r) del_key
243 #if __GLASGOW_HASKELL__
244 = case _tagCmp del_key key of
245 _GT -> mkBalBranch key elt fm_l (delFromFM fm_r del_key)
246 _LT -> mkBalBranch key elt (delFromFM fm_l del_key) fm_r
247 _EQ -> glueBal fm_l fm_r
250 = mkBalBranch key elt fm_l (delFromFM fm_r del_key)
253 = mkBalBranch key elt (delFromFM fm_l del_key) fm_r
259 delListFromFM fm keys = foldl delFromFM fm keys
261 -- ---------------------------------------------------------------------------
262 -- Combining @FiniteMaps@
264 plusFM_C combiner EmptyFM fm2 = fm2
265 plusFM_C combiner fm1 EmptyFM = fm1
266 plusFM_C combiner fm1 (Branch split_key elt2 _ left right)
267 = mkVBalBranch split_key new_elt
268 (plusFM_C combiner lts left)
269 (plusFM_C combiner gts right)
271 lts = splitLT fm1 split_key
272 gts = splitGT fm1 split_key
273 new_elt = case lookupFM fm1 split_key of
275 Just elt1 -> combiner elt1 elt2
277 -- It's worth doing plusFM specially, because we don't need
278 -- to do the lookup in fm1.
280 plusFM EmptyFM fm2 = fm2
281 plusFM fm1 EmptyFM = fm1
282 plusFM fm1 (Branch split_key elt1 _ left right)
283 = mkVBalBranch split_key elt1 (plusFM lts left) (plusFM gts right)
285 lts = splitLT fm1 split_key
286 gts = splitGT fm1 split_key
288 minusFM EmptyFM fm2 = emptyFM
289 minusFM fm1 EmptyFM = fm1
290 minusFM fm1 (Branch split_key elt _ left right)
291 = glueVBal (minusFM lts left) (minusFM gts right)
292 -- The two can be way different, so we need glueVBal
294 lts = splitLT fm1 split_key -- NB gt and lt, so the equal ones
295 gts = splitGT fm1 split_key -- are not in either.
297 intersectFM fm1 fm2 = intersectFM_C (\ left right -> right) fm1 fm2
299 intersectFM_C combiner fm1 EmptyFM = emptyFM
300 intersectFM_C combiner EmptyFM fm2 = emptyFM
301 intersectFM_C combiner fm1 (Branch split_key elt2 _ left right)
303 | isJust maybe_elt1 -- split_elt *is* in intersection
304 = mkVBalBranch split_key (combiner elt1 elt2) (intersectFM_C combiner lts left)
305 (intersectFM_C combiner gts right)
307 | otherwise -- split_elt is *not* in intersection
308 = glueVBal (intersectFM_C combiner lts left) (intersectFM_C combiner gts right)
311 lts = splitLT fm1 split_key -- NB gt and lt, so the equal ones
312 gts = splitGT fm1 split_key -- are not in either.
314 maybe_elt1 = lookupFM fm1 split_key
315 Just elt1 = maybe_elt1
318 -- ---------------------------------------------------------------------------
319 -- Mapping, folding, and filtering with @FiniteMaps@
321 foldFM k z EmptyFM = z
322 foldFM k z (Branch key elt _ fm_l fm_r)
323 = foldFM k (k key elt (foldFM k z fm_r)) fm_l
325 mapFM f EmptyFM = emptyFM
326 mapFM f (Branch key elt size fm_l fm_r)
327 = Branch key (f key elt) size (mapFM f fm_l) (mapFM f fm_r)
329 filterFM p EmptyFM = emptyFM
330 filterFM p (Branch key elt _ fm_l fm_r)
331 | p key elt -- Keep the item
332 = mkVBalBranch key elt (filterFM p fm_l) (filterFM p fm_r)
334 | otherwise -- Drop the item
335 = glueVBal (filterFM p fm_l) (filterFM p fm_r)
338 -- ---------------------------------------------------------------------------
339 -- Interrogating @FiniteMaps@
341 --{-# INLINE sizeFM #-}
343 sizeFM (Branch _ _ size _ _) = IF_GHC(I# size, size)
345 isEmptyFM fm = sizeFM fm == 0
347 lookupFM EmptyFM key = Nothing
348 lookupFM (Branch key elt _ fm_l fm_r) key_to_find
349 #if __GLASGOW_HASKELL__
350 = case _tagCmp key_to_find key of
351 _LT -> lookupFM fm_l key_to_find
352 _GT -> lookupFM fm_r key_to_find
355 | key_to_find < key = lookupFM fm_l key_to_find
356 | key_to_find > key = lookupFM fm_r key_to_find
357 | otherwise = Just elt
361 = case (lookupFM fm key) of { Nothing -> False; Just elt -> True }
363 lookupWithDefaultFM fm deflt key
364 = case (lookupFM fm key) of { Nothing -> deflt; Just elt -> elt }
367 -- ---------------------------------------------------------------------------
368 -- Listifying @FiniteMaps@
370 fmToList fm = foldFM (\ key elt rest -> (key,elt) : rest) [] fm
371 keysFM fm = foldFM (\ key elt rest -> key : rest) [] fm
372 eltsFM fm = foldFM (\ key elt rest -> elt : rest) [] fm
375 -- ---------------------------------------------------------------------------
376 -- The implementation of balancing
378 -- Basic construction of a @FiniteMap@:
380 -- @mkBranch@ simply gets the size component right. This is the ONLY
381 -- (non-trivial) place the Branch object is built, so the ASSERTion
382 -- recursively checks consistency. (The trivial use of Branch is in
388 mkBranch :: (Ord key OUTPUTABLE_key) -- Used for the assertion checking only
391 -> FiniteMap key elt -> FiniteMap key elt
394 mkBranch which key elt fm_l fm_r
395 = --ASSERT( left_ok && right_ok && balance_ok )
396 #if defined(COMPILING_GHC) && defined(DEBUG_FINITEMAPS)
397 if not ( left_ok && right_ok && balance_ok ) then
398 pprPanic ("mkBranch:"++show which) (ppAboves [ppr PprDebug [left_ok, right_ok, balance_ok],
405 result = Branch key elt (unbox (1 + left_size + right_size)) fm_l fm_r
407 -- if sizeFM result <= 8 then
410 -- pprTrace ("mkBranch:"++(show which)) (ppr PprDebug result) (
414 left_ok = case fm_l of
416 Branch left_key _ _ _ _ -> let
417 biggest_left_key = fst (findMax fm_l)
419 biggest_left_key < key
420 right_ok = case fm_r of
422 Branch right_key _ _ _ _ -> let
423 smallest_right_key = fst (findMin fm_r)
425 key < smallest_right_key
426 balance_ok = True -- sigh
429 = -- Both subtrees have one or no elements...
430 (left_size + right_size <= 1)
431 -- NO || left_size == 0 -- ???
432 -- NO || right_size == 0 -- ???
433 -- ... or the number of elements in a subtree does not exceed
434 -- sIZE_RATIO times the number of elements in the other subtree
435 || (left_size * sIZE_RATIO >= right_size &&
436 right_size * sIZE_RATIO >= left_size)
439 left_size = sizeFM fm_l
440 right_size = sizeFM fm_r
442 #if __GLASGOW_HASKELL__
444 unbox (I# size) = size
451 -- ---------------------------------------------------------------------------
452 -- {\em Balanced} construction of a @FiniteMap@
454 -- @mkBalBranch@ rebalances, assuming that the subtrees aren't too far
457 mkBalBranch :: (Ord key OUTPUTABLE_key)
459 -> FiniteMap key elt -> FiniteMap key elt
462 mkBalBranch key elt fm_L fm_R
464 | size_l + size_r < 2
465 = mkBranch 1{-which-} key elt fm_L fm_R
467 | size_r > sIZE_RATIO * size_l -- Right tree too big
469 Branch _ _ _ fm_rl fm_rr
470 | sizeFM fm_rl < 2 * sizeFM fm_rr -> single_L fm_L fm_R
471 | otherwise -> double_L fm_L fm_R
472 -- Other case impossible
474 | size_l > sIZE_RATIO * size_r -- Left tree too big
476 Branch _ _ _ fm_ll fm_lr
477 | sizeFM fm_lr < 2 * sizeFM fm_ll -> single_R fm_L fm_R
478 | otherwise -> double_R fm_L fm_R
479 -- Other case impossible
481 | otherwise -- No imbalance
482 = mkBranch 2{-which-} key elt fm_L fm_R
488 single_L fm_l (Branch key_r elt_r _ fm_rl fm_rr)
489 = mkBranch 3{-which-} key_r elt_r (mkBranch 4{-which-} key elt fm_l fm_rl) fm_rr
491 double_L fm_l (Branch key_r elt_r _ (Branch key_rl elt_rl _ fm_rll fm_rlr) fm_rr)
492 = mkBranch 5{-which-} key_rl elt_rl (mkBranch 6{-which-} key elt fm_l fm_rll)
493 (mkBranch 7{-which-} key_r elt_r fm_rlr fm_rr)
495 single_R (Branch key_l elt_l _ fm_ll fm_lr) fm_r
496 = mkBranch 8{-which-} key_l elt_l fm_ll (mkBranch 9{-which-} key elt fm_lr fm_r)
498 double_R (Branch key_l elt_l _ fm_ll (Branch key_lr elt_lr _ fm_lrl fm_lrr)) fm_r
499 = mkBranch 10{-which-} key_lr elt_lr (mkBranch 11{-which-} key_l elt_l fm_ll fm_lrl)
500 (mkBranch 12{-which-} key elt fm_lrr fm_r)
503 mkVBalBranch :: (Ord key OUTPUTABLE_key)
505 -> FiniteMap key elt -> FiniteMap key elt
508 -- Assert: in any call to (mkVBalBranch_C comb key elt l r),
509 -- (a) all keys in l are < all keys in r
510 -- (b) all keys in l are < key
511 -- (c) all keys in r are > key
513 mkVBalBranch key elt EmptyFM fm_r = addToFM fm_r key elt
514 mkVBalBranch key elt fm_l EmptyFM = addToFM fm_l key elt
516 mkVBalBranch key elt fm_l@(Branch key_l elt_l _ fm_ll fm_lr)
517 fm_r@(Branch key_r elt_r _ fm_rl fm_rr)
518 | sIZE_RATIO * size_l < size_r
519 = mkBalBranch key_r elt_r (mkVBalBranch key elt fm_l fm_rl) fm_rr
521 | sIZE_RATIO * size_r < size_l
522 = mkBalBranch key_l elt_l fm_ll (mkVBalBranch key elt fm_lr fm_r)
525 = mkBranch 13{-which-} key elt fm_l fm_r
531 -- ---------------------------------------------------------------------------
532 -- Gluing two trees together
534 -- @glueBal@ assumes its two arguments aren't too far out of whack, just
535 -- like @mkBalBranch@. But: all keys in first arg are $<$ all keys in
538 glueBal :: (Ord key OUTPUTABLE_key)
539 => FiniteMap key elt -> FiniteMap key elt
542 glueBal EmptyFM fm2 = fm2
543 glueBal fm1 EmptyFM = fm1
545 -- The case analysis here (absent in Adams' program) is really to deal
546 -- with the case where fm2 is a singleton. Then deleting the minimum means
547 -- we pass an empty tree to mkBalBranch, which breaks its invariant.
548 | sizeFM fm2 > sizeFM fm1
549 = mkBalBranch mid_key2 mid_elt2 fm1 (deleteMin fm2)
552 = mkBalBranch mid_key1 mid_elt1 (deleteMax fm1) fm2
554 (mid_key1, mid_elt1) = findMax fm1
555 (mid_key2, mid_elt2) = findMin fm2
557 -- @glueVBal@ copes with arguments which can be of any size.
558 -- But: all keys in first arg are $<$ all keys in second.
560 glueVBal :: (Ord key OUTPUTABLE_key)
561 => FiniteMap key elt -> FiniteMap key elt
564 glueVBal EmptyFM fm2 = fm2
565 glueVBal fm1 EmptyFM = fm1
566 glueVBal fm_l@(Branch key_l elt_l _ fm_ll fm_lr)
567 fm_r@(Branch key_r elt_r _ fm_rl fm_rr)
568 | sIZE_RATIO * size_l < size_r
569 = mkBalBranch key_r elt_r (glueVBal fm_l fm_rl) fm_rr
571 | sIZE_RATIO * size_r < size_l
572 = mkBalBranch key_l elt_l fm_ll (glueVBal fm_lr fm_r)
574 | otherwise -- We now need the same two cases as in glueBal above.
581 -- ---------------------------------------------------------------------------
584 splitLT, splitGT :: (Ord key OUTPUTABLE_key) => FiniteMap key elt -> key -> FiniteMap key elt
586 -- splitLT fm split_key = fm restricted to keys < split_key
587 -- splitGT fm split_key = fm restricted to keys > split_key
589 splitLT EmptyFM split_key = emptyFM
590 splitLT (Branch key elt _ fm_l fm_r) split_key
591 #if __GLASGOW_HASKELL__
592 = case _tagCmp split_key key of
593 _LT -> splitLT fm_l split_key
594 _GT -> mkVBalBranch key elt fm_l (splitLT fm_r split_key)
597 | split_key < key = splitLT fm_l split_key
598 | split_key > key = mkVBalBranch key elt fm_l (splitLT fm_r split_key)
602 splitGT EmptyFM split_key = emptyFM
603 splitGT (Branch key elt _ fm_l fm_r) split_key
604 #if __GLASGOW_HASKELL__
605 = case _tagCmp split_key key of
606 _GT -> splitGT fm_r split_key
607 _LT -> mkVBalBranch key elt (splitGT fm_l split_key) fm_r
610 | split_key > key = splitGT fm_r split_key
611 | split_key < key = mkVBalBranch key elt (splitGT fm_l split_key) fm_r
615 findMin :: FiniteMap key elt -> (key,elt)
616 findMin (Branch key elt _ EmptyFM _) = (key,elt)
617 findMin (Branch key elt _ fm_l _) = findMin fm_l
619 deleteMin :: (Ord key OUTPUTABLE_key) => FiniteMap key elt -> FiniteMap key elt
620 deleteMin (Branch key elt _ EmptyFM fm_r) = fm_r
621 deleteMin (Branch key elt _ fm_l fm_r) = mkBalBranch key elt (deleteMin fm_l) fm_r
623 findMax :: FiniteMap key elt -> (key,elt)
624 findMax (Branch key elt _ _ EmptyFM) = (key,elt)
625 findMax (Branch key elt _ _ fm_r) = findMax fm_r
627 deleteMax :: (Ord key OUTPUTABLE_key) => FiniteMap key elt -> FiniteMap key elt
628 deleteMax (Branch key elt _ fm_l EmptyFM) = fm_l
629 deleteMax (Branch key elt _ fm_l fm_r) = mkBalBranch key elt fm_l (deleteMax fm_r)
632 -- ---------------------------------------------------------------------------
635 #if defined(COMPILING_GHC) && defined(DEBUG_FINITEMAPS)
637 instance (Outputable key) => Outputable (FiniteMap key elt) where
638 ppr sty fm = pprX sty fm
640 pprX sty EmptyFM = ppChar '!'
641 pprX sty (Branch key elt sz fm_l fm_r)
642 = ppBesides [ppLparen, pprX sty fm_l, ppSP,
643 ppr sty key, ppSP, ppInt (IF_GHC(I# sz, sz)), ppSP,
644 pprX sty fm_r, ppRparen]
647 #ifndef COMPILING_GHC
648 instance (Eq key, Eq elt) => Eq (FiniteMap key elt) where
649 fm_1 == fm_2 = (sizeFM fm_1 == sizeFM fm_2) && -- quick test
650 (fmToList fm_1 == fmToList fm_2)
652 {- NO: not clear what The Right Thing to do is:
653 instance (Ord key, Ord elt) => Ord (FiniteMap key elt) where
654 fm_1 <= fm_2 = (sizeFM fm_1 <= sizeFM fm_2) && -- quick test
655 (fmToList fm_1 <= fmToList fm_2)
659 -- ---------------------------------------------------------------------------
660 -- Efficiency pragmas for GHC
662 -- When the FiniteMap module is used in GHC, we specialise it for
663 -- \tr{Uniques}, for dastardly efficiency reasons.
665 #if defined(COMPILING_GHC) && __GLASGOW_HASKELL__ && !defined(REALLY_HASKELL_1_3)
667 {-# SPECIALIZE addListToFM
668 :: FiniteMap (FAST_STRING, FAST_STRING) elt -> [((FAST_STRING, FAST_STRING),elt)] -> FiniteMap (FAST_STRING, FAST_STRING) elt
669 , FiniteMap RdrName elt -> [(RdrName,elt)] -> FiniteMap RdrName elt
670 IF_NCG(COMMA FiniteMap Reg elt -> [(Reg COMMA elt)] -> FiniteMap Reg elt)
672 {-# SPECIALIZE addListToFM_C
673 :: (elt -> elt -> elt) -> FiniteMap TyCon elt -> [(TyCon,elt)] -> FiniteMap TyCon elt
674 , (elt -> elt -> elt) -> FiniteMap FAST_STRING elt -> [(FAST_STRING,elt)] -> FiniteMap FAST_STRING elt
675 IF_NCG(COMMA (elt -> elt -> elt) -> FiniteMap Reg elt -> [(Reg COMMA elt)] -> FiniteMap Reg elt)
677 {-# SPECIALIZE addToFM
678 :: FiniteMap CLabel elt -> CLabel -> elt -> FiniteMap CLabel elt
679 , FiniteMap FAST_STRING elt -> FAST_STRING -> elt -> FiniteMap FAST_STRING elt
680 , FiniteMap (FAST_STRING, FAST_STRING) elt -> (FAST_STRING, FAST_STRING) -> elt -> FiniteMap (FAST_STRING, FAST_STRING) elt
681 , FiniteMap RdrName elt -> RdrName -> elt -> FiniteMap RdrName elt
682 , FiniteMap OrigName elt -> OrigName -> elt -> FiniteMap OrigName elt
683 IF_NCG(COMMA FiniteMap Reg elt -> Reg -> elt -> FiniteMap Reg elt)
685 {-# SPECIALIZE addToFM_C
686 :: (elt -> elt -> elt) -> FiniteMap (RdrName, RdrName) elt -> (RdrName, RdrName) -> elt -> FiniteMap (RdrName, RdrName) elt
687 , (elt -> elt -> elt) -> FiniteMap (OrigName, OrigName) elt -> (OrigName, OrigName) -> elt -> FiniteMap (OrigName, OrigName) elt
688 , (elt -> elt -> elt) -> FiniteMap FAST_STRING elt -> FAST_STRING -> elt -> FiniteMap FAST_STRING elt
689 IF_NCG(COMMA (elt -> elt -> elt) -> FiniteMap Reg elt -> Reg -> elt -> FiniteMap Reg elt)
691 {-# SPECIALIZE bagToFM
692 :: Bag (FAST_STRING,elt) -> FiniteMap FAST_STRING elt
694 {-# SPECIALIZE delListFromFM
695 :: FiniteMap RdrName elt -> [RdrName] -> FiniteMap RdrName elt
696 , FiniteMap OrigName elt -> [OrigName] -> FiniteMap OrigName elt
697 , FiniteMap FAST_STRING elt -> [FAST_STRING] -> FiniteMap FAST_STRING elt
698 IF_NCG(COMMA FiniteMap Reg elt -> [Reg] -> FiniteMap Reg elt)
700 {-# SPECIALIZE listToFM
701 :: [([Char],elt)] -> FiniteMap [Char] elt
702 , [(FAST_STRING,elt)] -> FiniteMap FAST_STRING elt
703 , [((FAST_STRING,FAST_STRING),elt)] -> FiniteMap (FAST_STRING, FAST_STRING) elt
704 , [(OrigName,elt)] -> FiniteMap OrigName elt
705 IF_NCG(COMMA [(Reg COMMA elt)] -> FiniteMap Reg elt)
707 {-# SPECIALIZE lookupFM
708 :: FiniteMap CLabel elt -> CLabel -> Maybe elt
709 , FiniteMap [Char] elt -> [Char] -> Maybe elt
710 , FiniteMap FAST_STRING elt -> FAST_STRING -> Maybe elt
711 , FiniteMap (FAST_STRING,FAST_STRING) elt -> (FAST_STRING,FAST_STRING) -> Maybe elt
712 , FiniteMap OrigName elt -> OrigName -> Maybe elt
713 , FiniteMap (OrigName,OrigName) elt -> (OrigName,OrigName) -> Maybe elt
714 , FiniteMap RdrName elt -> RdrName -> Maybe elt
715 , FiniteMap (RdrName,RdrName) elt -> (RdrName,RdrName) -> Maybe elt
716 IF_NCG(COMMA FiniteMap Reg elt -> Reg -> Maybe elt)
718 {-# SPECIALIZE lookupWithDefaultFM
719 :: FiniteMap FAST_STRING elt -> elt -> FAST_STRING -> elt
720 IF_NCG(COMMA FiniteMap Reg elt -> elt -> Reg -> elt)
722 {-# SPECIALIZE plusFM
723 :: FiniteMap RdrName elt -> FiniteMap RdrName elt -> FiniteMap RdrName elt
724 , FiniteMap OrigName elt -> FiniteMap OrigName elt -> FiniteMap OrigName elt
725 , FiniteMap FAST_STRING elt -> FiniteMap FAST_STRING elt -> FiniteMap FAST_STRING elt
726 IF_NCG(COMMA FiniteMap Reg elt -> FiniteMap Reg elt -> FiniteMap Reg elt)
728 {-# SPECIALIZE plusFM_C
729 :: (elt -> elt -> elt) -> FiniteMap FAST_STRING elt -> FiniteMap FAST_STRING elt -> FiniteMap FAST_STRING elt
730 IF_NCG(COMMA (elt -> elt -> elt) -> FiniteMap Reg elt -> FiniteMap Reg elt -> FiniteMap Reg elt)
733 #endif {- compiling for GHC -}