[project @ 2001-07-24 16:09:48 by simonpj]
[ghc-hetmet.git] / ghc / lib / std / Array.lhs
index 5ee94ff..cfeb648 100644 (file)
@@ -1,7 +1,8 @@
+% -----------------------------------------------------------------------------
+% $Id: Array.lhs,v 1.16 2001/04/14 22:27:00 qrczak Exp $
 %
-% (c) The AQUA Project, Glasgow University, 1994-1999
+% (c) The University of Glasgow, 1994-2000
 %
-
 \section[Array]{Module @Array@}
 
 \begin{code}
@@ -37,63 +38,43 @@ module  Array
     -- Implementation checked wrt. Haskell 98 lib report, 1/99.
 
     ) where
+\end{code}
 
 #ifndef __HUGS__
+
+\begin{code}
+       ------------ GHC --------------------
 import Ix
-import PrelList
-import PrelShow
 import PrelArr         -- Most of the hard work is done here
-import PrelBase
-#else
-import Prelude
-import privileged Prelude ( PrimArray
-                         , runST
-                         , primNewArray
-                         , primWriteArray
-                         , primReadArray
-                         , primUnsafeFreezeArray
-                         , primIndexArray
-                         )
-import Ix
-import List( (\\) )
-#endif
-
-infixl 9  !, //
+       ------------ End of GHC --------------------
 \end{code}
 
-#ifndef __HUGS__
-
-
-%*********************************************************
-%*                                                     *
-\subsection{Definitions of array, !, bounds}
-%*                                                     *
-%*********************************************************
+#else
 
 \begin{code}
+       ------------ HUGS (rest of file) --------------------
+import PrelPrim ( PrimArray
+               , runST
+               , primNewArray
+               , primWriteArray
+               , primReadArray
+               , primUnsafeFreezeArray
+               , primIndexArray
+               )
+import Ix
+import List( (\\) )
 
-
-{-# SPECIALISE listArray :: (Int,Int) -> [b] -> Array Int b #-}
-listArray            :: (Ix a) => (a,a) -> [b] -> Array a b
-listArray b vs       =  array b (zip (range b) vs)
-
-{-# INLINE elems #-}
-elems                :: (Ix a) => Array a b -> [b]
-elems a               =  [a!i | i <- indices a]
-
-ixmap                :: (Ix a, Ix b) => (a,a) -> (a -> b) -> Array b c -> Array a c
-ixmap b f a           =  array b [(i, a ! f i) | i <- range b]
+infixl 9  !, //
 \end{code}
 
 
 %*********************************************************
 %*                                                     *
-\subsection{Instance declarations for Array type}
+\subsection{The Array type}
 %*                                                     *
 %*********************************************************
 
 
-#else
 \begin{code}
 data Array ix elt = Array (ix,ix) (PrimArray elt)
 
@@ -127,7 +108,7 @@ assocs                :: Ix a => Array a b -> [(a,b)]
 assocs a          =  [(i, a!i) | i <- indices a]
 
 (//)              :: Ix a => Array a b -> [(a,b)] -> Array a b
-a // us           =  array (bounds a)
+(//) a us           =  array (bounds a)
                         ([(i,a!i) | i <- indices a \\ [i | (i,_) <- us]]
                          ++ us)