joel reymont wrote: > 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))
Just use newArray, writeArray and readArray. Something (writeArray is probably the easiest) will need an explicit type signature to resolve the overloading. Also from the GHC docs: castSTUArray :: STUArray s ix a -> ST s (STUArray s ix b) Casts an STUArray with one element type into one with a different element type. All the elements of the resulting array are undefined (unless you know what you're doing...). Note the part in parentheses. This is Haskell, not C after all. A clean solution may not be that far away. Udo. -- I underthand that people theem to like it better now. That it ith written in thee pluth pluth inthtead of lithp.
signature.asc
Description: Digital signature
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe