[Haskell-cafe] Examples of using STUArray + help with converting code

joel reymont joelr1 at gmail.com
Thu Oct 13 12:29:17 EDT 2005


Are there any examples on using STUArray and friends? I'm trying to
convert the following bit of code which uses deprecated features.

I don't understand the syntax needed to create a new double or float
array with newArray from Data.Array.MArray. I also don't yet
understand how to cast that double array to read ints from it.

doubleToInts d = runST (
    do arr <- newDoubleArray (1,2)
       writeDoubleArray arr 1 d
       i1 <- readIntArray arr 1
       i2 <- readIntArray arr 2
       return (i1,i2))

    Thanks, Joel



More information about the Haskell-Cafe mailing list