[project @ 2005-10-22 00:28:21 by ross]
[ghc-base.git] / Data / IntSet.hs
index a3cb766..6220827 100644 (file)
@@ -94,7 +94,6 @@ import Data.Bits
 import Data.Int
 
 import qualified Data.List as List
-import Data.Monoid
 import Data.Typeable
 
 {-
@@ -105,6 +104,7 @@ import qualified List
 -}
 
 #if __GLASGOW_HASKELL__
+import Text.Read
 import Data.Generics.Basics
 import Data.Generics.Instances
 #endif
@@ -580,19 +580,11 @@ instance Ord IntSet where
     -- tentative implementation. See if more efficient exists.
 
 {--------------------------------------------------------------------
-  Monoid 
---------------------------------------------------------------------}
-
-instance Monoid IntSet where
-    mempty = empty
-    mappend = union
-    mconcat = unions
-
-{--------------------------------------------------------------------
   Show
 --------------------------------------------------------------------}
 instance Show IntSet where
-  showsPrec d s  = showSet (toList s)
+  showsPrec p xs = showParen (p > 10) $
+    showString "fromList " . shows (toList xs)
 
 showSet :: [Int] -> ShowS
 showSet []     
@@ -604,6 +596,24 @@ showSet (x:xs)
     showTail (x:xs) = showChar ',' . shows x . showTail xs
 
 {--------------------------------------------------------------------
+  Read
+--------------------------------------------------------------------}
+instance Read IntSet where
+#ifdef __GLASGOW_HASKELL__
+  readPrec = parens $ prec 10 $ do
+    Ident "fromList" <- lexP
+    xs <- readPrec
+    return (fromList xs)
+
+  readListPrec = readListPrecDefault
+#else
+  readsPrec p = readParen (p > 10) $ \ r -> do
+    ("fromList",s) <- lex r
+    (xs,t) <- reads s
+    return (fromList xs,t)
+#endif
+
+{--------------------------------------------------------------------
   Typeable
 --------------------------------------------------------------------}