Mutable arrays in Haskell 98
Malcolm Wallace
Malcolm.Wallace@cs.york.ac.uk
Wed, 27 Mar 2002 15:58:46 +0000
José Romildo Malaquias <romildo@uber.com.br> writes:
> I would like to use muttable arrays in Haskell 98, with the GHC
> _and_ NHC98 compilers. By muttable arrays I mean arrays with
> in-place updates, as with the MArray arrays (which are not
> Haskell 98 conformant) found in GHC. Is such array implmentation
> available?
Both compilers have libraries supporting the `IOArray' type,
implemented with in-place update, although obviously the operations
must be threaded through the IO monad.
module IOExtras -- called IOExts in ghc
( ...
, IOArray -- data IOArray ix elt -- mutable arrays
, newIOArray -- :: Ix ix => (ix,ix) -> elt -> IO (IOArray ix elt)
, boundsIOArray -- :: Ix ix => IOArray ix elt -> (ix, ix)
, readIOArray -- :: Ix ix => IOArray ix elt -> ix -> IO elt
, writeIOArray -- :: Ix ix => IOArray ix elt -> ix -> elt -> IO ()
, freezeIOArray -- :: Ix ix => IOArray ix elt -> IO (Array ix elt)
, module Ix -- re-export Ix for the benefit of IOArrays
-- instance Eq (IOArray ix elt)
)
Regards,
Malcolm