safe array freezing?

Simon Marlow simonmar at
Mon Jan 5 14:35:28 EST 2004

> so, A common idiom when using Control.Monad.ST is to do some
> complicated, state using computation to compute a big array which is
> then used purely functionally as a read-only array in the rest of the
> program. 
> to avoid the cost of copying the array at the end, we are 
> forced to use
> 'unsafeFreeze'. it occurs to me that this particular idiom 
> can actually
> be done safely, by adding the following...
> runSTArray :: (forall s . (ST s (STArray s i e))) -> Array i e
> runSTUArray :: (forall s . (ST s (STUArray s i e))) -> UArray i e

Good idea.  I'll add these to Data.Array.ST.


More information about the Haskell mailing list