On 06-Jun-2000, Bjarke Dahl Ebert <[EMAIL PROTECTED]> wrote:
> Has anyone made a generalization of accumArray, which allows users to
> implement a pure function using imperative features?

Yes.  See the documentation for the `ST' module in the Hugs/ghc extension
libraries.  I enclose a brief extract.

 | 3.16. ST
 | 
 |    This library provides support for strict state threads, as described
 |    in the PLDI '94 paper by John Launchbury and Simon Peyton Jones
 |    [LazyStateThreads]. In addition to the monad ST, it also provides
 |    mutable variables STRef and mutable arrays STArray.
...
 | data ST s a        -- abstract type
 | runST              :: forall a. (forall s. ST s a) -> a
...
 | data STArray s ix elt -- mutable arrays in state thread s
 |                       -- indexed by values of type ix
 |                       -- containing values of type a.
 | newSTArray          :: Ix ix => (ix,ix) -> elt -> ST s (STArray s ix elt)
 | boundsSTArray       :: Ix ix => STArray s ix elt -> (ix, ix)
 | readSTArray         :: Ix ix => STArray s ix elt -> ix -> ST s elt
 | writeSTArray        :: Ix ix => STArray s ix elt -> ix -> elt -> ST s ()
 | thawSTArray         :: Ix ix => Array ix elt -> ST s (STArray s ix elt)
 | freezeSTArray       :: Ix ix => STArray s ix elt -> ST s (Array ix elt)
 | unsafeFreezeSTArray :: Ix ix => STArray s ix elt -> ST s (Array ix elt)

-- 
Fergus Henderson <[EMAIL PROTECTED]>  |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>  |  of excellence is a lethal habit"
PGP: finger [EMAIL PROTECTED]        |     -- the last words of T. S. Garp.

Reply via email to