-- Stability : provisional
-- Portability : portable
--
+-- NOTE: Data.FiniteMap is DEPRECATED, please use "Data.Map" instead.
+--
-- A finite map implementation, derived from the paper:
-- /Efficient sets: a balancing act/, S. Adams,
-- Journal of functional programming 3(4) Oct 1993, pp553-562
#define OUTPUTABLE_key {--}
#endif
-module Data.FiniteMap (
+module Data.FiniteMap
+ {-# DEPRECATED "Please use Data.Map instead." #-}
+ (
-- * The @FiniteMap@ type
FiniteMap, -- abstract type
#endif
) where
+import Prelude -- necessary to get dependencies right
+
import Data.Maybe ( isJust )
#ifdef __GLASGOW_HASKELL__
import GHC.Base
#endif
+#ifdef __HADDOCK__
+import Prelude
+#endif
+
#ifdef COMPILING_GHC
IMP_Ubiq(){-uitous-}
# ifdef DEBUG
-> FiniteMap key elt -> FiniteMap key elt -> FiniteMap key elt
-- | @(minusFM a1 a2)@ deletes from @a1@ any mappings which are bound in @a2@
-minusFM :: (Ord key OUTPUTABLE_key) => FiniteMap key elt -> FiniteMap key elt -> FiniteMap key elt
+minusFM :: (Ord key OUTPUTABLE_key) => FiniteMap key elt1 -> FiniteMap key elt2 -> FiniteMap key elt1
-- | @(intersectFM a1 a2)@ returns a new 'FiniteMap' containing
-- mappings from @a1@ for which @a2@ also has a mapping with the same
-- key.
intersectFM :: (Ord key OUTPUTABLE_key) => FiniteMap key elt -> FiniteMap key elt -> FiniteMap key elt
--- | Returns the interesction of two mappings, using the specified
+-- | Returns the intersection of two mappings, using the specified
-- combination function to combine values.
intersectFM_C :: (Ord key OUTPUTABLE_key) => (elt1 -> elt2 -> elt3)
-> FiniteMap key elt1 -> FiniteMap key elt2 -> FiniteMap key elt3
bagToFM = foldBag plusFM (\ (k,v) -> unitFM k v) emptyFM
#endif
+instance (Show k, Show e) => Show (FiniteMap k e) where
+ showsPrec p m = showsPrec p (fmToList m)
+
+instance Functor (FiniteMap k) where
+ fmap f = mapFM (const f)
-- ---------------------------------------------------------------------------
-- Adding to and deleting from @FiniteMaps@