X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=Data%2FSet.hs;h=3c81002a5c130659dc042c2ffb3b6061430efd40;hb=d429a873fa0b6c1c071c486ba18e5dc7a73a1bb3;hp=11f4b611f3b11e54cc2f8b5ac3842ce1e45c8aa4;hpb=64f39ef535b684bad6196efffa16e523c69f8fa2;p=haskell-directory.git diff --git a/Data/Set.hs b/Data/Set.hs index 11f4b61..3c81002 100644 --- a/Data/Set.hs +++ b/Data/Set.hs @@ -1,28 +1,33 @@ ----------------------------------------------------------------------------- --- +-- | -- Module : Data.Set -- Copyright : (c) The University of Glasgow 2001 --- License : BSD-style (see the file libraries/core/LICENSE) +-- License : BSD-style (see the file libraries/base/LICENSE) -- -- Maintainer : libraries@haskell.org -- Stability : provisional -- Portability : portable -- --- $Id: Set.hs,v 1.1 2001/09/13 11:50:35 simonmar Exp $ --- --- 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 - singletonSet, -- :: 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 @@ -30,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 @@ -51,9 +51,6 @@ emptySet = MkSet emptyFM unitSet :: a -> Set a unitSet x = MkSet (unitFM x ()) -{-# DEPRECATED singletonSet "use Set.unitSet" #-} -singletonSet = unitSet -- old;deprecated. - setToList :: Set a -> [a] setToList (MkSet set) = keysFM set @@ -95,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