[project @ 2002-08-01 12:50:31 by simonpj]
[ghc-base.git] / GHC / Arr.lhs
index cb962dd..a024b6f 100644 (file)
@@ -278,6 +278,16 @@ instance  (Ix a1, Ix a2, Ix a3, Ix a4, Ix a5) => Ix (a1,a2,a3,a4,a5)  where
 type IPr = (Int, Int)
 
 data Ix i => Array     i e = Array   !i !i (Array# e)
+
+-- | Mutable, boxed, non-strict arrays in the 'ST' monad.  The type
+-- arguments are as follows:
+--
+--  * @s@: the state variable argument for the 'ST' type
+--
+--  * @i@: the index type of the array (should be an instance of @Ix@)
+--
+--  * @e@: the element type of the array.
+--
 data         STArray s i e = STArray !i !i (MutableArray# s e)
        -- No Ix context for STArray.  They are stupid,
        -- and force an Ix context on the equality instance.
@@ -466,19 +476,14 @@ instance (Ix i, Ord e) => Ord (Array i e) where
 
 instance (Ix a, Show a, Show b) => Show (Array a b) where
     showsPrec p a =
-        showParen (p > 9) $
+        showParen (p > appPrec) $
         showString "array " .
-        shows (bounds a) .
+        showsPrec appPrec1 (bounds a) .
         showChar ' ' .
-        shows (assocs a)
-
-{-
-instance  (Ix a, Read a, Read b) => Read (Array a b)  where
-    readsPrec p = readParen (p > 9)
-          (\r -> [(array b as, u) | ("array",s) <- lex r,
-                                    (b,t)       <- reads s,
-                                    (as,u)      <- reads t   ])
--}
+        showsPrec appPrec1 (assocs a)
+       -- Precedence of 'array' is the precedence of application
+
+-- The Read instance is in GHC.Read
 \end{code}