[project @ 2004-09-18 12:49:59 by panne]
[ghc-base.git] / Data / Set.hs
index b724d01..3c81002 100644 (file)
@@ -8,18 +8,26 @@
 -- Stability   :  provisional
 -- Portability :  portable
 --
--- This implementation of sets sits squarely upon Data.FiniteMap.
+-- An implementation of sets, based on the "Data.FiniteMap".
 --
 -----------------------------------------------------------------------------
 
 module Data.Set (
+       -- * The @Set@ type
        Set,            -- abstract, instance of: Eq
 
+       -- * Construction
        emptySet,       -- :: Set a
        mkSet,          -- :: Ord a => [a]  -> Set a
        setToList,      -- :: Set a -> [a] 
        unitSet,        -- :: a -> Set a
 
+       -- * Inspection
+       elementOf,      -- :: Ord a => a -> Set a -> Bool
+       isEmptySet,     -- :: Set a -> Bool
+       cardinality,    -- :: Set a -> Int
+
+       -- * Operations
        union,          -- :: Ord a => Set a -> Set a -> Set a
        unionManySets,  -- :: Ord a => [Set a] -> Set a
        minusSet,       -- :: Ord a => Set a -> Set a -> Set a
@@ -27,11 +35,6 @@ module Data.Set (
        intersect,      -- :: Ord a => Set a -> Set a -> Set a
        addToSet,       -- :: Ord a => Set a -> a -> Set a
        delFromSet,     -- :: Ord a => Set a -> a -> Set a
-
-       elementOf,      -- :: Ord a => a -> Set a -> Bool
-       isEmptySet,     -- :: Set a -> Bool
-       
-       cardinality     -- :: Set a -> Int
     ) where
 
 import Prelude
@@ -89,6 +92,9 @@ instance (Eq a) => Eq (Set a) where
   (MkSet set_1) == (MkSet set_2) = set_1 == set_2
   (MkSet set_1) /= (MkSet set_2) = set_1 /= set_2
 
+instance Show e => Show (Set e) where
+  showsPrec p s = showsPrec p (setToList s)
+
 -- but not so clear what the right thing to do is:
 {- NO:
 instance (Ord a) => Ord (Set a) where