% -----------------------------------------------------------------------------
-% $Id: Array.lhs,v 1.13 2000/06/30 13:39:35 simonmar Exp $
+% $Id: Array.lhs,v 1.16 2001/04/14 22:27:00 qrczak Exp $
%
% (c) The University of Glasgow, 1994-2000
%
-- 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
+ ------------ End of GHC --------------------
+\end{code}
+
#else
+
+\begin{code}
+ ------------ HUGS (rest of file) --------------------
import PrelPrim ( PrimArray
, runST
, primNewArray
)
import Ix
import List( (\\) )
-#endif
infixl 9 !, //
\end{code}
-#ifndef __HUGS__
-
-
-%*********************************************************
-%* *
-\subsection{Definitions of array, !, bounds}
-%* *
-%*********************************************************
-
-\begin{code}
-
-
-{-# 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]
-\end{code}
-
%*********************************************************
%* *
-\subsection{Instance declarations for Array type}
+\subsection{The Array type}
%* *
%*********************************************************
-#else
\begin{code}
data Array ix elt = Array (ix,ix) (PrimArray elt)
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)