[project @ 2005-09-29 09:31:58 by ross]
authorross <unknown>
Thu, 29 Sep 2005 09:31:58 +0000 (09:31 +0000)
committerross <unknown>
Thu, 29 Sep 2005 09:31:58 +0000 (09:31 +0000)
Tweak Read instance: allow optional parentheses around the outside
(for consistency), and don't propagate precedence to elements.

libraries/base/Data/Set.hs

index 99ba4a1..33641de 100644 (file)
@@ -527,13 +527,15 @@ showSet (x:xs)
   Read
 --------------------------------------------------------------------}
 instance (Read a, Ord a) => Read (Set a) where
-  readsPrec i r = [ (fromList xs, t) | ("{",s) <- lex r,  (xs,t) <- readl s ]
+  readsPrec _ = readParen False $ \ r ->
+            [(fromList xs,t)     | ("{",s) <- lex r,
+                                   (xs,t)  <- readl s]
       where readl s  = [([],t)   | ("}",t) <- lex s] ++
-                       [(x:xs,u) | (x,t)   <- readsPrec i s
+                       [(x:xs,u) | (x,t)   <- reads s
                                  , (xs,u)  <- readl' t]
             readl' s = [([],t)   | ("}",t) <- lex s] ++
                        [(x:xs,v) | (",",t) <- lex s
-                                 , (x,u)   <- readsPrec i t
+                                 , (x,u)   <- reads t
                                  , (xs,v)  <- readl' u]
     
 {--------------------------------------------------------------------