[project @ 2003-07-28 15:03:05 by panne]
[ghc-base.git] / Data / FiniteMap.hs
index 244b811..3b1b785 100644 (file)
@@ -79,8 +79,6 @@ module Data.FiniteMap (
 #endif
     ) where
 
-import Prelude
-
 import Data.Maybe ( isJust )
 #ifdef __GLASGOW_HASKELL__
 import GHC.Base
@@ -142,7 +140,8 @@ addListToFM :: (Ord key OUTPUTABLE_key) => FiniteMap key elt -> [(key,elt)] -> F
 
 -- | Adds an element to a 'FiniteMap'.  If there is already an element
 -- with the same key, then the specified combination function is used
--- to calculate the new value.
+-- to calculate the new value. The already present element is passed as
+-- the first argument and the new element to add as second.
 addToFM_C      :: (Ord key OUTPUTABLE_key) => (elt -> elt -> elt)
                           -> FiniteMap key elt -> key -> elt
                           -> FiniteMap key elt
@@ -210,8 +209,21 @@ lookupWithDefaultFM
                -- to return for an unmapped key
 
 --     LISTIFYING
+
+-- | Convert a 'FiniteMap' to a @[(key, elt)]@ sorted by 'Ord' key
+--
 fmToList       :: FiniteMap key elt -> [(key,elt)]
+
+-- | Extract the keys from a 'FiniteMap', in the order of the keys, so
+--
+-- > keysFM == map fst . fmToList
+--
 keysFM         :: FiniteMap key elt -> [key]
+
+-- | Extract the elements from a 'FiniteMap', in the order of the keys, so
+--
+-- > eltsFM == map snd . fmToList
+--
 eltsFM         :: FiniteMap key elt -> [elt]
 
 -- ---------------------------------------------------------------------------
@@ -775,4 +787,4 @@ instance (Ord key, Ord elt) => Ord (FiniteMap key elt) where
     IF_NCG(COMMA   (elt -> elt -> elt) -> FiniteMap Reg elt -> FiniteMap Reg elt -> FiniteMap Reg elt)
     #-}
 
-#endif {- compiling for GHC -}
+#endif /* compiling for GHC */