MArray and newSTUArray

Simon Peyton-Jones simonpj@microsoft.com
Fri, 14 Feb 2003 14:16:21 -0000


Excellent idea. This does indeed seem to be the cleanest way to explain
the necessary type constraints.  I think we (Simon M) may add it to the
library.

Simon

| -----Original Message-----
| From: Dean Herington [mailto:heringto@cs.unc.edu]
| Sent: 13 February 2003 15:21
| To: haskell-cafe@haskell.org
| Subject: MArray and newSTUArray
|=20
| 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:
|=20
| newSTUArray :: (MArray (STUArray s) e (ST s), Ix i)
|             =3D> (i, i) -> e -> ST s (STUArray s i e)
| newSTUArray =3D newArray
|=20
| so that I don't have to give a complicated type declaration for each
use
| of `newArray` that creates an STUArray.
|=20
| 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?
|=20
| -- Dean
|=20
| _______________________________________________
| Haskell-Cafe mailing list
| Haskell-Cafe@haskell.org
| http://www.haskell.org/mailman/listinfo/haskell-cafe