MArray and newSTUArray

Dean Herington heringto@cs.unc.edu
Thu, 13 Feb 2003 10:20:59 -0500


The MArray class in Data.Array.MArray is a very nice abstraction.
However, when creating an array whose type partakes of MArray, say
STUArray, I find myself defining and using a type-specific creation
function, such as:

newSTUArray :: (MArray (STUArray s) e (ST s), Ix i)
            => (i, i) -> e -> ST s (STUArray s i e)
newSTUArray = newArray

so that I don't have to give a complicated type declaration for each use
of `newArray` that creates an STUArray.

1. Is there a better (more concise/convenient) way to provide the
necessary type information?
2. If not, should functions such as `newSTUArray` be provided in the
libraries?

-- Dean