2 % (c) The University of Glasgow 2006
3 % (c) The AQUA Project, Glasgow University, 1994-1998
6 ``Finite maps'' are the heart of the compiler's
7 lookup-tables/environments and its implementation of sets. Important
10 This code is derived from that in the paper:
13 "Efficient sets: a balancing act"
14 Journal of functional programming 3(4) Oct 1993, pp553-562
17 The code is SPECIALIZEd to various highly-desirable types (e.g., Id)
22 -- The above warning supression flag is a temporary kludge.
23 -- While working on this module you are encouraged to remove it and fix
24 -- any warnings in the module. See
25 -- http://hackage.haskell.org/trac/ghc/wiki/Commentary/CodingStyle#Warnings
29 FiniteMap, -- abstract type
31 emptyFM, unitFM, listToFM,
49 sizeFM, isEmptyFM, elemFM, lookupFM, lookupWithDefaultFM,
51 fmToList, keysFM, eltsFM
57 #include "HsVersions.h"
59 #if defined(DEBUG_FINITEMAPS)/* NB NB NB */
60 #define OUTPUTABLE_key , Outputable key
62 #define OUTPUTABLE_key {--}
66 import Bag ( Bag, foldrBag )
72 -- was this import only needed for I#, or does it have something
73 -- to do with the (not-presently-used) IF_NCG also?
79 #if ! OMIT_NATIVE_CODEGEN
82 # define IF_NCG(a) {--}
88 %************************************************************************
90 \subsection{The signature of the module}
92 %************************************************************************
96 emptyFM :: FiniteMap key elt
97 unitFM :: key -> elt -> FiniteMap key elt
98 listToFM :: (Ord key OUTPUTABLE_key) => [(key,elt)] -> FiniteMap key elt
99 -- In the case of duplicates, the last is taken
100 bagToFM :: (Ord key OUTPUTABLE_key) => Bag (key,elt) -> FiniteMap key elt
101 -- In the case of duplicates, who knows which is taken
103 -- ADDING AND DELETING
104 -- Throws away any previous binding
105 -- In the list case, the items are added starting with the
106 -- first one in the list
107 addToFM :: (Ord key OUTPUTABLE_key) => FiniteMap key elt -> key -> elt -> FiniteMap key elt
108 addListToFM :: (Ord key OUTPUTABLE_key) => FiniteMap key elt -> [(key,elt)] -> FiniteMap key elt
110 -- Combines with previous binding
111 -- The combining fn goes (old -> new -> new)
112 addToFM_C :: (Ord key OUTPUTABLE_key) => (elt -> elt -> elt)
113 -> FiniteMap key elt -> key -> elt
115 addListToFM_C :: (Ord key OUTPUTABLE_key) => (elt -> elt -> elt)
116 -> FiniteMap key elt -> [(key,elt)]
119 -- Deletion doesn't complain if you try to delete something
121 delFromFM :: (Ord key OUTPUTABLE_key) => FiniteMap key elt -> key -> FiniteMap key elt
122 delListFromFM :: (Ord key OUTPUTABLE_key) => FiniteMap key elt -> [key] -> FiniteMap key elt
125 -- Bindings in right argument shadow those in the left
126 plusFM :: (Ord key OUTPUTABLE_key) => FiniteMap key elt -> FiniteMap key elt
129 -- Combines bindings for the same thing with the given function
130 plusFM_C :: (Ord key OUTPUTABLE_key) => (elt -> elt -> elt)
131 -> FiniteMap key elt -> FiniteMap key elt -> FiniteMap key elt
133 minusFM :: (Ord key OUTPUTABLE_key) => FiniteMap key elt -> FiniteMap key elt -> FiniteMap key elt
134 -- (minusFM a1 a2) deletes from a1 any bindings which are bound in a2
136 intersectFM :: (Ord key OUTPUTABLE_key) => FiniteMap key elt -> FiniteMap key elt -> FiniteMap key elt
137 intersectFM_C :: (Ord key OUTPUTABLE_key) => (elt1 -> elt2 -> elt3)
138 -> FiniteMap key elt1 -> FiniteMap key elt2 -> FiniteMap key elt3
140 -- MAPPING, FOLDING, FILTERING
141 foldFM :: (key -> elt -> a -> a) -> a -> FiniteMap key elt -> a
142 mapFM :: (key -> elt1 -> elt2) -> FiniteMap key elt1 -> FiniteMap key elt2
143 filterFM :: (Ord key OUTPUTABLE_key) => (key -> elt -> Bool)
144 -> FiniteMap key elt -> FiniteMap key elt
148 sizeFM :: FiniteMap key elt -> Int
149 isEmptyFM :: FiniteMap key elt -> Bool
151 elemFM :: (Ord key OUTPUTABLE_key) => key -> FiniteMap key elt -> Bool
152 lookupFM :: (Ord key OUTPUTABLE_key) => FiniteMap key elt -> key -> Maybe elt
154 :: (Ord key OUTPUTABLE_key) => FiniteMap key elt -> elt -> key -> elt
155 -- lookupWithDefaultFM supplies a "default" elt
156 -- to return for an unmapped key
159 fmToList :: FiniteMap key elt -> [(key,elt)]
160 keysFM :: FiniteMap key elt -> [key]
161 eltsFM :: FiniteMap key elt -> [elt]
164 %************************************************************************
166 \subsection{The @FiniteMap@ data type, and building of same}
168 %************************************************************************
170 Invariants about @FiniteMap@:
173 all keys in a FiniteMap are distinct
175 all keys in left subtree are $<$ key in Branch and
176 all keys in right subtree are $>$ key in Branch
178 size field of a Branch gives number of Branch nodes in the tree
180 size of left subtree is differs from size of right subtree by a
181 factor of at most \tr{sIZE_RATIO}
185 data FiniteMap key elt
187 | Branch key elt -- Key and elt stored here
188 {-# UNPACK #-} !Int -- Size >= 1
189 (FiniteMap key elt) -- Children
197 = Branch bottom bottom 0 bottom bottom
199 bottom = panic "emptyFM"
202 -- #define EmptyFM (Branch _ _ 0 _ _)
204 unitFM key elt = Branch key elt 1 emptyFM emptyFM
206 listToFM = addListToFM emptyFM
208 bagToFM = foldrBag (\(k,v) fm -> addToFM fm k v) emptyFM
211 %************************************************************************
213 \subsection{Adding to and deleting from @FiniteMaps@}
215 %************************************************************************
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 = case compare new_key key of
223 LT -> mkBalBranch key elt (addToFM_C combiner fm_l new_key new_elt) fm_r
224 GT -> mkBalBranch key elt fm_l (addToFM_C combiner fm_r new_key new_elt)
225 EQ -> Branch new_key (combiner elt new_elt) size fm_l fm_r
227 addListToFM fm key_elt_pairs = addListToFM_C (\ old new -> new) fm key_elt_pairs
229 addListToFM_C combiner fm key_elt_pairs
230 = foldl' add fm key_elt_pairs -- foldl adds from the left
232 add fmap (key,elt) = addToFM_C combiner fmap key elt
236 delFromFM EmptyFM del_key = emptyFM
237 delFromFM (Branch key elt size fm_l fm_r) del_key
238 = case compare del_key key of
239 GT -> mkBalBranch key elt fm_l (delFromFM fm_r del_key)
240 LT -> mkBalBranch key elt (delFromFM fm_l del_key) fm_r
241 EQ -> glueBal fm_l fm_r
243 delListFromFM fm keys = foldl' delFromFM fm keys
246 %************************************************************************
248 \subsection{Combining @FiniteMaps@}
250 %************************************************************************
253 plusFM_C combiner EmptyFM fm2 = fm2
254 plusFM_C combiner fm1 EmptyFM = fm1
255 plusFM_C combiner fm1 (Branch split_key elt2 _ left right)
256 = mkVBalBranch split_key new_elt
257 (plusFM_C combiner lts left)
258 (plusFM_C combiner gts right)
260 lts = splitLT fm1 split_key
261 gts = splitGT fm1 split_key
262 new_elt = case lookupFM fm1 split_key of
264 Just elt1 -> combiner elt1 elt2
266 -- It's worth doing plusFM specially, because we don't need
267 -- to do the lookup in fm1.
268 -- FM2 over-rides FM1.
270 plusFM EmptyFM fm2 = fm2
271 plusFM fm1 EmptyFM = fm1
272 plusFM fm1 (Branch split_key elt1 _ left right)
273 = mkVBalBranch split_key elt1 (plusFM lts left) (plusFM gts right)
275 lts = splitLT fm1 split_key
276 gts = splitGT fm1 split_key
278 minusFM EmptyFM fm2 = emptyFM
279 minusFM fm1 EmptyFM = fm1
280 minusFM fm1 (Branch split_key elt _ left right)
281 = glueVBal (minusFM lts left) (minusFM gts right)
282 -- The two can be way different, so we need glueVBal
284 lts = splitLT fm1 split_key -- NB gt and lt, so the equal ones
285 gts = splitGT fm1 split_key -- are not in either.
287 intersectFM fm1 fm2 = intersectFM_C (\ left right -> right) fm1 fm2
289 intersectFM_C combiner fm1 EmptyFM = emptyFM
290 intersectFM_C combiner EmptyFM fm2 = emptyFM
291 intersectFM_C combiner fm1 (Branch split_key elt2 _ left right)
293 | maybeToBool maybe_elt1 -- split_elt *is* in intersection
294 = mkVBalBranch split_key (combiner elt1 elt2) (intersectFM_C combiner lts left)
295 (intersectFM_C combiner gts right)
297 | otherwise -- split_elt is *not* in intersection
298 = glueVBal (intersectFM_C combiner lts left) (intersectFM_C combiner gts right)
301 lts = splitLT fm1 split_key -- NB gt and lt, so the equal ones
302 gts = splitGT fm1 split_key -- are not in either.
304 maybe_elt1 = lookupFM fm1 split_key
305 Just elt1 = maybe_elt1
308 %************************************************************************
310 \subsection{Mapping, folding, and filtering with @FiniteMaps@}
312 %************************************************************************
315 foldFM k z EmptyFM = z
316 foldFM k z (Branch key elt _ fm_l fm_r)
317 = foldFM k (k key elt (foldFM k z fm_r)) fm_l
319 mapFM f EmptyFM = emptyFM
320 mapFM f (Branch key elt size fm_l fm_r)
321 = Branch key (f key elt) size (mapFM f fm_l) (mapFM f fm_r)
323 filterFM p EmptyFM = emptyFM
324 filterFM p (Branch key elt _ fm_l fm_r)
325 | p key elt -- Keep the item
326 = mkVBalBranch key elt (filterFM p fm_l) (filterFM p fm_r)
328 | otherwise -- Drop the item
329 = glueVBal (filterFM p fm_l) (filterFM p fm_r)
332 %************************************************************************
334 \subsection{Interrogating @FiniteMaps@}
336 %************************************************************************
339 --{-# INLINE sizeFM #-}
341 sizeFM (Branch _ _ size _ _) = size
343 isEmptyFM fm = sizeFM fm == 0
345 lookupFM EmptyFM key = Nothing
346 lookupFM (Branch key elt _ fm_l fm_r) key_to_find
347 = case compare key_to_find key of
348 LT -> lookupFM fm_l key_to_find
349 GT -> lookupFM fm_r key_to_find
353 = case (lookupFM fm key) of { Nothing -> False; Just elt -> True }
355 lookupWithDefaultFM fm deflt key
356 = case (lookupFM fm key) of { Nothing -> deflt; Just elt -> elt }
359 %************************************************************************
361 \subsection{Listifying @FiniteMaps@}
363 %************************************************************************
366 fmToList fm = foldFM (\ key elt rest -> (key,elt) : rest) [] fm
367 keysFM fm = foldFM (\ key elt rest -> key : rest) [] fm
368 eltsFM fm = foldFM (\ key elt rest -> elt : rest) [] fm
372 %************************************************************************
374 \subsection{The implementation of balancing}
376 %************************************************************************
378 %************************************************************************
380 \subsubsection{Basic construction of a @FiniteMap@}
382 %************************************************************************
384 @mkBranch@ simply gets the size component right. This is the ONLY
385 (non-trivial) place the Branch object is built, so the ASSERTion
386 recursively checks consistency. (The trivial use of Branch is in
393 mkBranch :: (Ord key OUTPUTABLE_key) -- Used for the assertion checking only
396 -> FiniteMap key elt -> FiniteMap key elt
399 mkBranch which key elt fm_l fm_r
400 = --ASSERT( left_ok && right_ok && balance_ok )
401 #if defined(DEBUG_FINITEMAPS)
402 if not ( left_ok && right_ok && balance_ok ) then
403 pprPanic ("mkBranch:"++show which) (vcat [ppr [left_ok, right_ok, balance_ok],
410 result = Branch key elt (1 + left_size + right_size) fm_l fm_r
412 -- if sizeFM result <= 8 then
415 -- pprTrace ("mkBranch:"++(show which)) (ppr result) (
419 left_ok = case fm_l of
421 Branch left_key _ _ _ _ -> let
422 biggest_left_key = fst (findMax fm_l)
424 biggest_left_key < key
425 right_ok = case fm_r of
427 Branch right_key _ _ _ _ -> let
428 smallest_right_key = fst (findMin fm_r)
430 key < smallest_right_key
431 balance_ok = True -- sigh
434 = -- Both subtrees have one or no elements...
435 (left_size + right_size <= 1)
436 -- NO || left_size == 0 -- ???
437 -- NO || right_size == 0 -- ???
438 -- ... or the number of elements in a subtree does not exceed
439 -- sIZE_RATIO times the number of elements in the other subtree
440 || (left_size * sIZE_RATIO >= right_size &&
441 right_size * sIZE_RATIO >= left_size)
444 left_size = sizeFM fm_l
445 right_size = sizeFM fm_r
448 %************************************************************************
450 \subsubsection{{\em Balanced} construction of a @FiniteMap@}
452 %************************************************************************
454 @mkBalBranch@ rebalances, assuming that the subtrees aren't too far
458 mkBalBranch :: (Ord key OUTPUTABLE_key)
460 -> FiniteMap key elt -> FiniteMap key elt
463 mkBalBranch key elt fm_L fm_R
465 | size_l + size_r < 2
466 = mkBranch 1{-which-} key elt fm_L fm_R
468 | size_r > sIZE_RATIO * size_l -- Right tree too big
470 Branch _ _ _ fm_rl fm_rr
471 | sizeFM fm_rl < 2 * sizeFM fm_rr -> single_L fm_L fm_R
472 | otherwise -> double_L fm_L fm_R
473 -- Other case impossible
475 | size_l > sIZE_RATIO * size_r -- Left tree too big
477 Branch _ _ _ fm_ll fm_lr
478 | sizeFM fm_lr < 2 * sizeFM fm_ll -> single_R fm_L fm_R
479 | otherwise -> double_R fm_L fm_R
480 -- Other case impossible
482 | otherwise -- No imbalance
483 = mkBranch 2{-which-} key elt fm_L fm_R
489 single_L fm_l (Branch key_r elt_r _ fm_rl fm_rr)
490 = mkBranch 3{-which-} key_r elt_r (mkBranch 4{-which-} key elt fm_l fm_rl) fm_rr
492 double_L fm_l (Branch key_r elt_r _ (Branch key_rl elt_rl _ fm_rll fm_rlr) fm_rr)
493 = mkBranch 5{-which-} key_rl elt_rl (mkBranch 6{-which-} key elt fm_l fm_rll)
494 (mkBranch 7{-which-} key_r elt_r fm_rlr fm_rr)
496 single_R (Branch key_l elt_l _ fm_ll fm_lr) fm_r
497 = mkBranch 8{-which-} key_l elt_l fm_ll (mkBranch 9{-which-} key elt fm_lr fm_r)
499 double_R (Branch key_l elt_l _ fm_ll (Branch key_lr elt_lr _ fm_lrl fm_lrr)) fm_r
500 = mkBranch 10{-which-} key_lr elt_lr (mkBranch 11{-which-} key_l elt_l fm_ll fm_lrl)
501 (mkBranch 12{-which-} key elt fm_lrr fm_r)
506 mkVBalBranch :: (Ord key OUTPUTABLE_key)
508 -> FiniteMap key elt -> FiniteMap key elt
511 -- Assert: in any call to (mkVBalBranch_C comb key elt l r),
512 -- (a) all keys in l are < all keys in r
513 -- (b) all keys in l are < key
514 -- (c) all keys in r are > key
516 mkVBalBranch key elt EmptyFM fm_r = addToFM fm_r key elt
517 mkVBalBranch key elt fm_l EmptyFM = addToFM fm_l key elt
519 mkVBalBranch key elt fm_l@(Branch key_l elt_l _ fm_ll fm_lr)
520 fm_r@(Branch key_r elt_r _ fm_rl fm_rr)
521 | sIZE_RATIO * size_l < size_r
522 = mkBalBranch key_r elt_r (mkVBalBranch key elt fm_l fm_rl) fm_rr
524 | sIZE_RATIO * size_r < size_l
525 = mkBalBranch key_l elt_l fm_ll (mkVBalBranch key elt fm_lr fm_r)
528 = mkBranch 13{-which-} key elt fm_l fm_r
535 %************************************************************************
537 \subsubsection{Gluing two trees together}
539 %************************************************************************
541 @glueBal@ assumes its two arguments aren't too far out of whack, just
542 like @mkBalBranch@. But: all keys in first arg are $<$ all keys in
546 glueBal :: (Ord key OUTPUTABLE_key)
547 => FiniteMap key elt -> FiniteMap key elt
550 glueBal EmptyFM fm2 = fm2
551 glueBal fm1 EmptyFM = fm1
553 -- The case analysis here (absent in Adams' program) is really to deal
554 -- with the case where fm2 is a singleton. Then deleting the minimum means
555 -- we pass an empty tree to mkBalBranch, which breaks its invariant.
556 | sizeFM fm2 > sizeFM fm1
557 = mkBalBranch mid_key2 mid_elt2 fm1 (deleteMin fm2)
560 = mkBalBranch mid_key1 mid_elt1 (deleteMax fm1) fm2
562 (mid_key1, mid_elt1) = findMax fm1
563 (mid_key2, mid_elt2) = findMin fm2
566 @glueVBal@ copes with arguments which can be of any size.
567 But: all keys in first arg are $<$ all keys in second.
570 glueVBal :: (Ord key OUTPUTABLE_key)
571 => FiniteMap key elt -> FiniteMap key elt
574 glueVBal EmptyFM fm2 = fm2
575 glueVBal fm1 EmptyFM = fm1
576 glueVBal fm_l@(Branch key_l elt_l _ fm_ll fm_lr)
577 fm_r@(Branch key_r elt_r _ fm_rl fm_rr)
578 | sIZE_RATIO * size_l < size_r
579 = mkBalBranch key_r elt_r (glueVBal fm_l fm_rl) fm_rr
581 | sIZE_RATIO * size_r < size_l
582 = mkBalBranch key_l elt_l fm_ll (glueVBal fm_lr fm_r)
584 | otherwise -- We now need the same two cases as in glueBal above.
591 %************************************************************************
593 \subsection{Local utilities}
595 %************************************************************************
598 splitLT, splitGT :: (Ord key OUTPUTABLE_key) => FiniteMap key elt -> key -> FiniteMap key elt
600 -- splitLT fm split_key = fm restricted to keys < split_key
601 -- splitGT fm split_key = fm restricted to keys > split_key
603 splitLT EmptyFM split_key = emptyFM
604 splitLT (Branch key elt _ fm_l fm_r) split_key
605 = case compare split_key key of
606 LT -> splitLT fm_l split_key
607 GT -> mkVBalBranch key elt fm_l (splitLT fm_r split_key)
610 splitGT EmptyFM split_key = emptyFM
611 splitGT (Branch key elt _ fm_l fm_r) split_key
612 = case compare split_key key of
613 GT -> splitGT fm_r split_key
614 LT -> mkVBalBranch key elt (splitGT fm_l split_key) fm_r
617 findMin :: FiniteMap key elt -> (key,elt)
618 findMin (Branch key elt _ EmptyFM _) = (key,elt)
619 findMin (Branch key elt _ fm_l _) = findMin fm_l
621 deleteMin :: (Ord key OUTPUTABLE_key) => FiniteMap key elt -> FiniteMap key elt
622 deleteMin (Branch key elt _ EmptyFM fm_r) = fm_r
623 deleteMin (Branch key elt _ fm_l fm_r) = mkBalBranch key elt (deleteMin fm_l) fm_r
625 findMax :: FiniteMap key elt -> (key,elt)
626 findMax (Branch key elt _ _ EmptyFM) = (key,elt)
627 findMax (Branch key elt _ _ fm_r) = findMax fm_r
629 deleteMax :: (Ord key OUTPUTABLE_key) => FiniteMap key elt -> FiniteMap key elt
630 deleteMax (Branch key elt _ fm_l EmptyFM) = fm_l
631 deleteMax (Branch key elt _ fm_l fm_r) = mkBalBranch key elt fm_l (deleteMax fm_r)
634 %************************************************************************
636 \subsection{Output-ery}
638 %************************************************************************
641 #if defined(DEBUG_FINITEMAPS)
643 instance (Outputable key) => Outputable (FiniteMap key elt) where
646 pprX EmptyFM = char '!'
647 pprX (Branch key elt sz fm_l fm_r)
648 = parens (hcat [pprX fm_l, space,
649 ppr key, space, int sz, space,
652 -- and when not debugging the package itself...
653 instance (Outputable key, Outputable elt) => Outputable (FiniteMap key elt) where
654 ppr fm = ppr (fmToList fm)
658 instance (Eq key, Eq elt) => Eq (FiniteMap key elt) where
659 fm_1 == fm_2 = (sizeFM fm_1 == sizeFM fm_2) && -- quick test
660 (fmToList fm_1 == fmToList fm_2)
662 {- NO: not clear what The Right Thing to do is:
663 instance (Ord key, Ord elt) => Ord (FiniteMap key elt) where
664 fm_1 <= fm_2 = (sizeFM fm_1 <= sizeFM fm_2) && -- quick test
665 (fmToList fm_1 <= fmToList fm_2)
670 %************************************************************************
672 \subsection{Efficiency pragmas for GHC}
674 %************************************************************************
676 When the FiniteMap module is used in GHC, we specialise it for
677 \tr{Uniques}, for dastardly efficiency reasons.
682 #ifdef __GLASGOW_HASKELL__
684 {-# SPECIALIZE addListToFM
685 :: FiniteMap (FastString, FAST_STRING) elt -> [((FAST_STRING, FAST_STRING),elt)] -> FiniteMap (FAST_STRING, FAST_STRING) elt
686 , FiniteMap RdrName elt -> [(RdrName,elt)] -> FiniteMap RdrName elt
687 IF_NCG(COMMA FiniteMap Reg elt -> [(Reg COMMA elt)] -> FiniteMap Reg elt)
689 {-# SPECIALIZE addListToFM_C
690 :: (elt -> elt -> elt) -> FiniteMap TyCon elt -> [(TyCon,elt)] -> FiniteMap TyCon elt
691 , (elt -> elt -> elt) -> FiniteMap FastString elt -> [(FAST_STRING,elt)] -> FiniteMap FAST_STRING elt
692 IF_NCG(COMMA (elt -> elt -> elt) -> FiniteMap Reg elt -> [(Reg COMMA elt)] -> FiniteMap Reg elt)
694 {-# SPECIALIZE addToFM
695 :: FiniteMap CLabel elt -> CLabel -> elt -> FiniteMap CLabel elt
696 , FiniteMap FastString elt -> FAST_STRING -> elt -> FiniteMap FAST_STRING elt
697 , FiniteMap (FastString, FAST_STRING) elt -> (FAST_STRING, FAST_STRING) -> elt -> FiniteMap (FAST_STRING, FAST_STRING) elt
698 , FiniteMap RdrName elt -> RdrName -> elt -> FiniteMap RdrName elt
699 IF_NCG(COMMA FiniteMap Reg elt -> Reg -> elt -> FiniteMap Reg elt)
701 {-# SPECIALIZE addToFM_C
702 :: (elt -> elt -> elt) -> FiniteMap (RdrName, RdrName) elt -> (RdrName, RdrName) -> elt -> FiniteMap (RdrName, RdrName) elt
703 , (elt -> elt -> elt) -> FiniteMap FastString elt -> FAST_STRING -> elt -> FiniteMap FAST_STRING elt
704 IF_NCG(COMMA (elt -> elt -> elt) -> FiniteMap Reg elt -> Reg -> elt -> FiniteMap Reg elt)
706 {-# SPECIALIZE bagToFM
707 :: Bag (FastString,elt) -> FiniteMap FAST_STRING elt
709 {-# SPECIALIZE delListFromFM
710 :: FiniteMap RdrName elt -> [RdrName] -> FiniteMap RdrName elt
711 , FiniteMap FastString elt -> [FAST_STRING] -> FiniteMap FAST_STRING elt
712 IF_NCG(COMMA FiniteMap Reg elt -> [Reg] -> FiniteMap Reg elt)
714 {-# SPECIALIZE listToFM
715 :: [([Char],elt)] -> FiniteMap [Char] elt
716 , [(FastString,elt)] -> FiniteMap FAST_STRING elt
717 , [((FastString,FAST_STRING),elt)] -> FiniteMap (FAST_STRING, FAST_STRING) elt
718 IF_NCG(COMMA [(Reg COMMA elt)] -> FiniteMap Reg elt)
720 {-# SPECIALIZE lookupFM
721 :: FiniteMap CLabel elt -> CLabel -> Maybe elt
722 , FiniteMap [Char] elt -> [Char] -> Maybe elt
723 , FiniteMap FastString elt -> FAST_STRING -> Maybe elt
724 , FiniteMap (FastString,FAST_STRING) elt -> (FAST_STRING,FAST_STRING) -> Maybe elt
725 , FiniteMap RdrName elt -> RdrName -> Maybe elt
726 , FiniteMap (RdrName,RdrName) elt -> (RdrName,RdrName) -> Maybe elt
727 IF_NCG(COMMA FiniteMap Reg elt -> Reg -> Maybe elt)
729 {-# SPECIALIZE lookupWithDefaultFM
730 :: FiniteMap FastString elt -> elt -> FAST_STRING -> elt
731 IF_NCG(COMMA FiniteMap Reg elt -> elt -> Reg -> elt)
733 {-# SPECIALIZE plusFM
734 :: FiniteMap RdrName elt -> FiniteMap RdrName elt -> FiniteMap RdrName elt
735 , FiniteMap FastString elt -> FiniteMap FAST_STRING elt -> FiniteMap FAST_STRING elt
736 IF_NCG(COMMA FiniteMap Reg elt -> FiniteMap Reg elt -> FiniteMap Reg elt)
738 {-# SPECIALIZE plusFM_C
739 :: (elt -> elt -> elt) -> FiniteMap FastString elt -> FiniteMap FAST_STRING elt -> FiniteMap FAST_STRING elt
740 IF_NCG(COMMA (elt -> elt -> elt) -> FiniteMap Reg elt -> FiniteMap Reg elt -> FiniteMap Reg elt)
743 #endif /* compiling with ghc and have specialiser */