2 % (c) The AQUA Project, Glasgow University, 1994-1998
4 \section[FiniteMap]{An implementation of finite maps}
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)
23 FiniteMap, -- abstract type
25 emptyFM, unitFM, listToFM,
43 sizeFM, isEmptyFM, elemFM, lookupFM, lookupWithDefaultFM,
45 fmToList, keysFM, eltsFM
48 , FiniteSet, emptySet, mkSet, isEmptySet
49 , elementOf, setToList, union, insert, minusSet
53 #include "HsVersions.h"
54 #define IF_NOT_GHC(a) {--}
56 #if defined(DEBUG_FINITEMAPS)/* NB NB NB */
57 #define OUTPUTABLE_key , Outputable key
59 #define OUTPUTABLE_key {--}
62 import {-# SOURCE #-} Name ( Name )
66 import Bag ( Bag, foldrBag )
69 #if ! OMIT_NATIVE_CODEGEN
72 # define IF_NCG(a) {--}
76 -- SIGH: but we use unboxed "sizes"...
77 #if __GLASGOW_HASKELL__
85 %************************************************************************
87 \subsection{The signature of the module}
89 %************************************************************************
93 emptyFM :: FiniteMap key elt
94 unitFM :: key -> elt -> FiniteMap key elt
95 listToFM :: (Ord key OUTPUTABLE_key) => [(key,elt)] -> FiniteMap key elt
96 -- In the case of duplicates, the last is taken
97 bagToFM :: (Ord key OUTPUTABLE_key) => Bag (key,elt) -> FiniteMap key elt
98 -- In the case of duplicates, who knows which is taken
100 -- ADDING AND DELETING
101 -- Throws away any previous binding
102 -- In the list case, the items are added starting with the
103 -- first one in the list
104 addToFM :: (Ord key OUTPUTABLE_key) => FiniteMap key elt -> key -> elt -> FiniteMap key elt
105 addListToFM :: (Ord key OUTPUTABLE_key) => FiniteMap key elt -> [(key,elt)] -> FiniteMap key elt
107 -- Combines with previous binding
108 -- The combining fn goes (old -> new -> new)
109 addToFM_C :: (Ord key OUTPUTABLE_key) => (elt -> elt -> elt)
110 -> FiniteMap key elt -> key -> elt
112 addListToFM_C :: (Ord key OUTPUTABLE_key) => (elt -> elt -> elt)
113 -> FiniteMap key elt -> [(key,elt)]
116 -- Deletion doesn't complain if you try to delete something
118 delFromFM :: (Ord key OUTPUTABLE_key) => FiniteMap key elt -> key -> FiniteMap key elt
119 delListFromFM :: (Ord key OUTPUTABLE_key) => FiniteMap key elt -> [key] -> FiniteMap key elt
122 -- Bindings in right argument shadow those in the left
123 plusFM :: (Ord key OUTPUTABLE_key) => FiniteMap key elt -> FiniteMap key elt
126 -- Combines bindings for the same thing with the given function
127 plusFM_C :: (Ord key OUTPUTABLE_key) => (elt -> elt -> elt)
128 -> FiniteMap key elt -> FiniteMap key elt -> FiniteMap key elt
130 minusFM :: (Ord key OUTPUTABLE_key) => FiniteMap key elt -> FiniteMap key elt -> FiniteMap key elt
131 -- (minusFM a1 a2) deletes from a1 any bindings which are bound in a2
133 intersectFM :: (Ord key OUTPUTABLE_key) => FiniteMap key elt -> FiniteMap key elt -> FiniteMap key elt
134 intersectFM_C :: (Ord key OUTPUTABLE_key) => (elt -> elt -> elt2)
135 -> FiniteMap key elt -> FiniteMap key elt -> FiniteMap key elt2
137 -- MAPPING, FOLDING, FILTERING
138 foldFM :: (key -> elt -> a -> a) -> a -> FiniteMap key elt -> a
139 mapFM :: (key -> elt1 -> elt2) -> FiniteMap key elt1 -> FiniteMap key elt2
140 filterFM :: (Ord key OUTPUTABLE_key) => (key -> elt -> Bool)
141 -> FiniteMap key elt -> FiniteMap key elt
145 sizeFM :: FiniteMap key elt -> Int
146 isEmptyFM :: FiniteMap key elt -> Bool
148 elemFM :: (Ord key OUTPUTABLE_key) => key -> FiniteMap key elt -> Bool
149 lookupFM :: (Ord key OUTPUTABLE_key) => FiniteMap key elt -> key -> Maybe elt
151 :: (Ord key OUTPUTABLE_key) => FiniteMap key elt -> elt -> key -> elt
152 -- lookupWithDefaultFM supplies a "default" elt
153 -- to return for an unmapped key
156 fmToList :: FiniteMap key elt -> [(key,elt)]
157 keysFM :: FiniteMap key elt -> [key]
158 eltsFM :: FiniteMap key elt -> [elt]
161 %************************************************************************
163 \subsection{The @FiniteMap@ data type, and building of same}
165 %************************************************************************
167 Invariants about @FiniteMap@:
170 all keys in a FiniteMap are distinct
172 all keys in left subtree are $<$ key in Branch and
173 all keys in right subtree are $>$ key in Branch
175 size field of a Branch gives number of Branch nodes in the tree
177 size of left subtree is differs from size of right subtree by a
178 factor of at most \tr{sIZE_RATIO}
182 data FiniteMap key elt
184 | Branch key elt -- Key and elt stored here
185 IF_GHC(Int#,Int{-STRICT-}) -- Size >= 1
186 (FiniteMap key elt) -- Children
194 = Branch bottom bottom IF_GHC(0#,0) bottom bottom
196 bottom = panic "emptyFM"
199 -- #define EmptyFM (Branch _ _ IF_GHC(0#,0) _ _)
201 unitFM key elt = Branch key elt IF_GHC(1#,1) emptyFM emptyFM
203 listToFM = addListToFM emptyFM
205 bagToFM = foldrBag (\(k,v) fm -> addToFM fm k v) emptyFM
208 %************************************************************************
210 \subsection{Adding to and deleting from @FiniteMaps@}
212 %************************************************************************
215 addToFM fm key elt = addToFM_C (\ old new -> new) fm key elt
217 addToFM_C combiner EmptyFM key elt = unitFM key elt
218 addToFM_C combiner (Branch key elt size fm_l fm_r) new_key new_elt
219 = case compare new_key key of
220 LT -> mkBalBranch key elt (addToFM_C combiner fm_l new_key new_elt) fm_r
221 GT -> mkBalBranch key elt fm_l (addToFM_C combiner fm_r new_key new_elt)
222 EQ -> Branch new_key (combiner elt new_elt) size fm_l fm_r
224 addListToFM fm key_elt_pairs = addListToFM_C (\ old new -> new) fm key_elt_pairs
226 addListToFM_C combiner fm key_elt_pairs
227 = foldl add fm key_elt_pairs -- foldl adds from the left
229 add fmap (key,elt) = addToFM_C combiner fmap key elt
233 delFromFM EmptyFM del_key = emptyFM
234 delFromFM (Branch key elt size fm_l fm_r) del_key
235 = case compare del_key key of
236 GT -> mkBalBranch key elt fm_l (delFromFM fm_r del_key)
237 LT -> mkBalBranch key elt (delFromFM fm_l del_key) fm_r
238 EQ -> glueBal fm_l fm_r
240 delListFromFM fm keys = foldl delFromFM fm keys
243 %************************************************************************
245 \subsection{Combining @FiniteMaps@}
247 %************************************************************************
250 plusFM_C combiner EmptyFM fm2 = fm2
251 plusFM_C combiner fm1 EmptyFM = fm1
252 plusFM_C combiner fm1 (Branch split_key elt2 _ left right)
253 = mkVBalBranch split_key new_elt
254 (plusFM_C combiner lts left)
255 (plusFM_C combiner gts right)
257 lts = splitLT fm1 split_key
258 gts = splitGT fm1 split_key
259 new_elt = case lookupFM fm1 split_key of
261 Just elt1 -> combiner elt1 elt2
263 -- It's worth doing plusFM specially, because we don't need
264 -- to do the lookup in fm1.
265 -- FM2 over-rides FM1.
267 plusFM EmptyFM fm2 = fm2
268 plusFM fm1 EmptyFM = fm1
269 plusFM fm1 (Branch split_key elt1 _ left right)
270 = mkVBalBranch split_key elt1 (plusFM lts left) (plusFM gts right)
272 lts = splitLT fm1 split_key
273 gts = splitGT fm1 split_key
275 minusFM EmptyFM fm2 = emptyFM
276 minusFM fm1 EmptyFM = fm1
277 minusFM fm1 (Branch split_key elt _ left right)
278 = glueVBal (minusFM lts left) (minusFM gts right)
279 -- The two can be way different, so we need glueVBal
281 lts = splitLT fm1 split_key -- NB gt and lt, so the equal ones
282 gts = splitGT fm1 split_key -- are not in either.
284 intersectFM fm1 fm2 = intersectFM_C (\ left right -> right) fm1 fm2
286 intersectFM_C combiner fm1 EmptyFM = emptyFM
287 intersectFM_C combiner EmptyFM fm2 = emptyFM
288 intersectFM_C combiner fm1 (Branch split_key elt2 _ left right)
290 | maybeToBool maybe_elt1 -- split_elt *is* in intersection
291 = mkVBalBranch split_key (combiner elt1 elt2) (intersectFM_C combiner lts left)
292 (intersectFM_C combiner gts right)
294 | otherwise -- split_elt is *not* in intersection
295 = glueVBal (intersectFM_C combiner lts left) (intersectFM_C combiner gts right)
298 lts = splitLT fm1 split_key -- NB gt and lt, so the equal ones
299 gts = splitGT fm1 split_key -- are not in either.
301 maybe_elt1 = lookupFM fm1 split_key
302 Just elt1 = maybe_elt1
305 %************************************************************************
307 \subsection{Mapping, folding, and filtering with @FiniteMaps@}
309 %************************************************************************
312 foldFM k z EmptyFM = z
313 foldFM k z (Branch key elt _ fm_l fm_r)
314 = foldFM k (k key elt (foldFM k z fm_r)) fm_l
316 mapFM f EmptyFM = emptyFM
317 mapFM f (Branch key elt size fm_l fm_r)
318 = Branch key (f key elt) size (mapFM f fm_l) (mapFM f fm_r)
320 filterFM p EmptyFM = emptyFM
321 filterFM p (Branch key elt _ fm_l fm_r)
322 | p key elt -- Keep the item
323 = mkVBalBranch key elt (filterFM p fm_l) (filterFM p fm_r)
325 | otherwise -- Drop the item
326 = glueVBal (filterFM p fm_l) (filterFM p fm_r)
329 %************************************************************************
331 \subsection{Interrogating @FiniteMaps@}
333 %************************************************************************
336 --{-# INLINE sizeFM #-}
338 sizeFM (Branch _ _ size _ _) = IF_GHC(I# size, size)
340 isEmptyFM fm = sizeFM fm == 0
342 lookupFM EmptyFM key = Nothing
343 lookupFM (Branch key elt _ fm_l fm_r) key_to_find
344 = case compare key_to_find key of
345 LT -> lookupFM fm_l key_to_find
346 GT -> lookupFM fm_r key_to_find
350 = case (lookupFM fm key) of { Nothing -> False; Just elt -> True }
352 lookupWithDefaultFM fm deflt key
353 = case (lookupFM fm key) of { Nothing -> deflt; Just elt -> elt }
356 %************************************************************************
358 \subsection{Listifying @FiniteMaps@}
360 %************************************************************************
363 fmToList fm = foldFM (\ key elt rest -> (key,elt) : rest) [] fm
364 keysFM fm = foldFM (\ key elt rest -> key : rest) [] fm
365 eltsFM fm = foldFM (\ key elt rest -> elt : rest) [] fm
369 %************************************************************************
371 \subsection{The implementation of balancing}
373 %************************************************************************
375 %************************************************************************
377 \subsubsection{Basic construction of a @FiniteMap@}
379 %************************************************************************
381 @mkBranch@ simply gets the size component right. This is the ONLY
382 (non-trivial) place the Branch object is built, so the ASSERTion
383 recursively checks consistency. (The trivial use of Branch is in
390 mkBranch :: (Ord key OUTPUTABLE_key) -- Used for the assertion checking only
393 -> FiniteMap key elt -> FiniteMap key elt
396 mkBranch which key elt fm_l fm_r
397 = --ASSERT( left_ok && right_ok && balance_ok )
398 #if defined(DEBUG_FINITEMAPS)
399 if not ( left_ok && right_ok && balance_ok ) then
400 pprPanic ("mkBranch:"++show which) (vcat [ppr [left_ok, right_ok, balance_ok],
407 result = Branch key elt (unbox (1 + left_size + right_size)) fm_l fm_r
409 -- if sizeFM result <= 8 then
412 -- pprTrace ("mkBranch:"++(show which)) (ppr result) (
416 left_ok = case fm_l of
418 Branch left_key _ _ _ _ -> let
419 biggest_left_key = fst (findMax fm_l)
421 biggest_left_key < key
422 right_ok = case fm_r of
424 Branch right_key _ _ _ _ -> let
425 smallest_right_key = fst (findMin fm_r)
427 key < smallest_right_key
428 balance_ok = True -- sigh
431 = -- Both subtrees have one or no elements...
432 (left_size + right_size <= 1)
433 -- NO || left_size == 0 -- ???
434 -- NO || right_size == 0 -- ???
435 -- ... or the number of elements in a subtree does not exceed
436 -- sIZE_RATIO times the number of elements in the other subtree
437 || (left_size * sIZE_RATIO >= right_size &&
438 right_size * sIZE_RATIO >= left_size)
441 left_size = sizeFM fm_l
442 right_size = sizeFM fm_r
444 #ifdef __GLASGOW_HASKELL__
446 unbox (I# size) = size
453 %************************************************************************
455 \subsubsection{{\em Balanced} construction of a @FiniteMap@}
457 %************************************************************************
459 @mkBalBranch@ rebalances, assuming that the subtrees aren't too far
463 mkBalBranch :: (Ord key OUTPUTABLE_key)
465 -> FiniteMap key elt -> FiniteMap key elt
468 mkBalBranch key elt fm_L fm_R
470 | size_l + size_r < 2
471 = mkBranch 1{-which-} key elt fm_L fm_R
473 | size_r > sIZE_RATIO * size_l -- Right tree too big
475 Branch _ _ _ fm_rl fm_rr
476 | sizeFM fm_rl < 2 * sizeFM fm_rr -> single_L fm_L fm_R
477 | otherwise -> double_L fm_L fm_R
478 -- Other case impossible
480 | size_l > sIZE_RATIO * size_r -- Left tree too big
482 Branch _ _ _ fm_ll fm_lr
483 | sizeFM fm_lr < 2 * sizeFM fm_ll -> single_R fm_L fm_R
484 | otherwise -> double_R fm_L fm_R
485 -- Other case impossible
487 | otherwise -- No imbalance
488 = mkBranch 2{-which-} key elt fm_L fm_R
494 single_L fm_l (Branch key_r elt_r _ fm_rl fm_rr)
495 = mkBranch 3{-which-} key_r elt_r (mkBranch 4{-which-} key elt fm_l fm_rl) fm_rr
497 double_L fm_l (Branch key_r elt_r _ (Branch key_rl elt_rl _ fm_rll fm_rlr) fm_rr)
498 = mkBranch 5{-which-} key_rl elt_rl (mkBranch 6{-which-} key elt fm_l fm_rll)
499 (mkBranch 7{-which-} key_r elt_r fm_rlr fm_rr)
501 single_R (Branch key_l elt_l _ fm_ll fm_lr) fm_r
502 = mkBranch 8{-which-} key_l elt_l fm_ll (mkBranch 9{-which-} key elt fm_lr fm_r)
504 double_R (Branch key_l elt_l _ fm_ll (Branch key_lr elt_lr _ fm_lrl fm_lrr)) fm_r
505 = mkBranch 10{-which-} key_lr elt_lr (mkBranch 11{-which-} key_l elt_l fm_ll fm_lrl)
506 (mkBranch 12{-which-} key elt fm_lrr fm_r)
511 mkVBalBranch :: (Ord key OUTPUTABLE_key)
513 -> FiniteMap key elt -> FiniteMap key elt
516 -- Assert: in any call to (mkVBalBranch_C comb key elt l r),
517 -- (a) all keys in l are < all keys in r
518 -- (b) all keys in l are < key
519 -- (c) all keys in r are > key
521 mkVBalBranch key elt EmptyFM fm_r = addToFM fm_r key elt
522 mkVBalBranch key elt fm_l EmptyFM = addToFM fm_l key elt
524 mkVBalBranch key elt fm_l@(Branch key_l elt_l _ fm_ll fm_lr)
525 fm_r@(Branch key_r elt_r _ fm_rl fm_rr)
526 | sIZE_RATIO * size_l < size_r
527 = mkBalBranch key_r elt_r (mkVBalBranch key elt fm_l fm_rl) fm_rr
529 | sIZE_RATIO * size_r < size_l
530 = mkBalBranch key_l elt_l fm_ll (mkVBalBranch key elt fm_lr fm_r)
533 = mkBranch 13{-which-} key elt fm_l fm_r
540 %************************************************************************
542 \subsubsection{Gluing two trees together}
544 %************************************************************************
546 @glueBal@ assumes its two arguments aren't too far out of whack, just
547 like @mkBalBranch@. But: all keys in first arg are $<$ all keys in
551 glueBal :: (Ord key OUTPUTABLE_key)
552 => FiniteMap key elt -> FiniteMap key elt
555 glueBal EmptyFM fm2 = fm2
556 glueBal fm1 EmptyFM = fm1
558 -- The case analysis here (absent in Adams' program) is really to deal
559 -- with the case where fm2 is a singleton. Then deleting the minimum means
560 -- we pass an empty tree to mkBalBranch, which breaks its invariant.
561 | sizeFM fm2 > sizeFM fm1
562 = mkBalBranch mid_key2 mid_elt2 fm1 (deleteMin fm2)
565 = mkBalBranch mid_key1 mid_elt1 (deleteMax fm1) fm2
567 (mid_key1, mid_elt1) = findMax fm1
568 (mid_key2, mid_elt2) = findMin fm2
571 @glueVBal@ copes with arguments which can be of any size.
572 But: all keys in first arg are $<$ all keys in second.
575 glueVBal :: (Ord key OUTPUTABLE_key)
576 => FiniteMap key elt -> FiniteMap key elt
579 glueVBal EmptyFM fm2 = fm2
580 glueVBal fm1 EmptyFM = fm1
581 glueVBal fm_l@(Branch key_l elt_l _ fm_ll fm_lr)
582 fm_r@(Branch key_r elt_r _ fm_rl fm_rr)
583 | sIZE_RATIO * size_l < size_r
584 = mkBalBranch key_r elt_r (glueVBal fm_l fm_rl) fm_rr
586 | sIZE_RATIO * size_r < size_l
587 = mkBalBranch key_l elt_l fm_ll (glueVBal fm_lr fm_r)
589 | otherwise -- We now need the same two cases as in glueBal above.
592 (mid_key_l,mid_elt_l) = findMax fm_l
593 (mid_key_r,mid_elt_r) = findMin fm_r
598 %************************************************************************
600 \subsection{Local utilities}
602 %************************************************************************
605 splitLT, splitGT :: (Ord key OUTPUTABLE_key) => FiniteMap key elt -> key -> FiniteMap key elt
607 -- splitLT fm split_key = fm restricted to keys < split_key
608 -- splitGT fm split_key = fm restricted to keys > split_key
610 splitLT EmptyFM split_key = emptyFM
611 splitLT (Branch key elt _ fm_l fm_r) split_key
612 = case compare split_key key of
613 LT -> splitLT fm_l split_key
614 GT -> mkVBalBranch key elt fm_l (splitLT fm_r split_key)
617 splitGT EmptyFM split_key = emptyFM
618 splitGT (Branch key elt _ fm_l fm_r) split_key
619 = case compare split_key key of
620 GT -> splitGT fm_r split_key
621 LT -> mkVBalBranch key elt (splitGT fm_l split_key) fm_r
624 findMin :: FiniteMap key elt -> (key,elt)
625 findMin (Branch key elt _ EmptyFM _) = (key,elt)
626 findMin (Branch key elt _ fm_l _) = findMin fm_l
628 deleteMin :: (Ord key OUTPUTABLE_key) => FiniteMap key elt -> FiniteMap key elt
629 deleteMin (Branch key elt _ EmptyFM fm_r) = fm_r
630 deleteMin (Branch key elt _ fm_l fm_r) = mkBalBranch key elt (deleteMin fm_l) fm_r
632 findMax :: FiniteMap key elt -> (key,elt)
633 findMax (Branch key elt _ _ EmptyFM) = (key,elt)
634 findMax (Branch key elt _ _ fm_r) = findMax fm_r
636 deleteMax :: (Ord key OUTPUTABLE_key) => FiniteMap key elt -> FiniteMap key elt
637 deleteMax (Branch key elt _ fm_l EmptyFM) = fm_l
638 deleteMax (Branch key elt _ fm_l fm_r) = mkBalBranch key elt fm_l (deleteMax fm_r)
641 %************************************************************************
643 \subsection{Output-ery}
645 %************************************************************************
648 #if defined(DEBUG_FINITEMAPS)
650 instance (Outputable key) => Outputable (FiniteMap key elt) where
653 pprX EmptyFM = char '!'
654 pprX (Branch key elt sz fm_l fm_r)
655 = parens (hcat [pprX fm_l, space,
656 ppr key, space, int (IF_GHC(I# sz, sz)), space,
661 instance (Eq key, Eq elt) => Eq (FiniteMap key elt) where
662 fm_1 == fm_2 = (sizeFM fm_1 == sizeFM fm_2) && -- quick test
663 (fmToList fm_1 == fmToList fm_2)
665 {- NO: not clear what The Right Thing to do is:
666 instance (Ord key, Ord elt) => Ord (FiniteMap key elt) where
667 fm_1 <= fm_2 = (sizeFM fm_1 <= sizeFM fm_2) && -- quick test
668 (fmToList fm_1 <= fmToList fm_2)
673 %************************************************************************
675 \subsection{FiniteSets---a thin veneer}
677 %************************************************************************
680 type FiniteSet key = FiniteMap key ()
681 emptySet :: FiniteSet key
682 mkSet :: (Ord key OUTPUTABLE_key) => [key] -> FiniteSet key
683 isEmptySet :: FiniteSet key -> Bool
684 elementOf :: (Ord key OUTPUTABLE_key) => key -> FiniteSet key -> Bool
685 minusSet :: (Ord key OUTPUTABLE_key) => FiniteSet key -> FiniteSet key -> FiniteSet key
686 setToList :: FiniteSet key -> [key]
687 union :: (Ord key OUTPUTABLE_key) => FiniteSet key -> FiniteSet key -> FiniteSet key
688 insert :: (Ord key OUTPUTABLE_key) => FiniteSet key -> key -> FiniteSet key
691 mkSet xs = listToFM [ (x, ()) | x <- xs]
692 isEmptySet = isEmptyFM
697 insert s v = addToFM s v ()
700 %************************************************************************
702 \subsection{Efficiency pragmas for GHC}
704 %************************************************************************
706 When the FiniteMap module is used in GHC, we specialise it for
707 \tr{Uniques}, for dastardly efficiency reasons.
710 #if __GLASGOW_HASKELL__ && !defined(REALLY_HASKELL_1_3)
712 {-# SPECIALIZE addListToFM
713 :: FiniteMap (FAST_STRING, FAST_STRING) elt -> [((FAST_STRING, FAST_STRING),elt)] -> FiniteMap (FAST_STRING, FAST_STRING) elt
714 , FiniteMap RdrName elt -> [(RdrName,elt)] -> FiniteMap RdrName elt
715 IF_NCG(COMMA FiniteMap Reg elt -> [(Reg COMMA elt)] -> FiniteMap Reg elt)
717 {-# SPECIALIZE addListToFM_C
718 :: (elt -> elt -> elt) -> FiniteMap TyCon elt -> [(TyCon,elt)] -> FiniteMap TyCon elt
719 , (elt -> elt -> elt) -> FiniteMap FAST_STRING elt -> [(FAST_STRING,elt)] -> FiniteMap FAST_STRING elt
720 IF_NCG(COMMA (elt -> elt -> elt) -> FiniteMap Reg elt -> [(Reg COMMA elt)] -> FiniteMap Reg elt)
722 {-# SPECIALIZE addToFM
723 :: FiniteMap CLabel elt -> CLabel -> elt -> FiniteMap CLabel elt
724 , FiniteMap FAST_STRING elt -> FAST_STRING -> elt -> FiniteMap FAST_STRING elt
725 , FiniteMap (FAST_STRING, FAST_STRING) elt -> (FAST_STRING, FAST_STRING) -> elt -> FiniteMap (FAST_STRING, FAST_STRING) elt
726 , FiniteMap RdrName elt -> RdrName -> elt -> FiniteMap RdrName elt
727 IF_NCG(COMMA FiniteMap Reg elt -> Reg -> elt -> FiniteMap Reg elt)
729 {-# SPECIALIZE addToFM_C
730 :: (elt -> elt -> elt) -> FiniteMap (RdrName, RdrName) elt -> (RdrName, RdrName) -> elt -> FiniteMap (RdrName, RdrName) elt
731 , (elt -> elt -> elt) -> FiniteMap FAST_STRING elt -> FAST_STRING -> elt -> FiniteMap FAST_STRING elt
732 IF_NCG(COMMA (elt -> elt -> elt) -> FiniteMap Reg elt -> Reg -> elt -> FiniteMap Reg elt)
734 {-# SPECIALIZE bagToFM
735 :: Bag (FAST_STRING,elt) -> FiniteMap FAST_STRING elt
737 {-# SPECIALIZE delListFromFM
738 :: FiniteMap RdrName elt -> [RdrName] -> FiniteMap RdrName elt
739 , FiniteMap FAST_STRING elt -> [FAST_STRING] -> FiniteMap FAST_STRING elt
740 IF_NCG(COMMA FiniteMap Reg elt -> [Reg] -> FiniteMap Reg elt)
742 {-# SPECIALIZE listToFM
743 :: [([Char],elt)] -> FiniteMap [Char] elt
744 , [(FAST_STRING,elt)] -> FiniteMap FAST_STRING elt
745 , [((FAST_STRING,FAST_STRING),elt)] -> FiniteMap (FAST_STRING, FAST_STRING) elt
746 IF_NCG(COMMA [(Reg COMMA elt)] -> FiniteMap Reg elt)
748 {-# SPECIALIZE lookupFM
749 :: FiniteMap CLabel elt -> CLabel -> Maybe elt
750 , FiniteMap [Char] elt -> [Char] -> Maybe elt
751 , FiniteMap FAST_STRING elt -> FAST_STRING -> Maybe elt
752 , FiniteMap (FAST_STRING,FAST_STRING) elt -> (FAST_STRING,FAST_STRING) -> Maybe elt
753 , FiniteMap RdrName elt -> RdrName -> Maybe elt
754 , FiniteMap (RdrName,RdrName) elt -> (RdrName,RdrName) -> Maybe elt
755 IF_NCG(COMMA FiniteMap Reg elt -> Reg -> Maybe elt)
757 {-# SPECIALIZE lookupWithDefaultFM
758 :: FiniteMap FAST_STRING elt -> elt -> FAST_STRING -> elt
759 IF_NCG(COMMA FiniteMap Reg elt -> elt -> Reg -> elt)
761 {-# SPECIALIZE plusFM
762 :: FiniteMap RdrName elt -> FiniteMap RdrName elt -> FiniteMap RdrName elt
763 , FiniteMap FAST_STRING elt -> FiniteMap FAST_STRING elt -> FiniteMap FAST_STRING elt
764 IF_NCG(COMMA FiniteMap Reg elt -> FiniteMap Reg elt -> FiniteMap Reg elt)
766 {-# SPECIALIZE plusFM_C
767 :: (elt -> elt -> elt) -> FiniteMap FAST_STRING elt -> FiniteMap FAST_STRING elt -> FiniteMap FAST_STRING elt
768 IF_NCG(COMMA (elt -> elt -> elt) -> FiniteMap Reg elt -> FiniteMap Reg elt -> FiniteMap Reg elt)
771 #endif {- compiling with ghc and have specialiser -}