castIOUArray and hPutArray redux

hi haskellers, have the issues with castIOUArray (and thus hGetArray, hPutArray) in Data.Array.IO discussed below been resolved? http://www.haskell.org/pipermail/libraries/2003-January/thread.html here is a (trivial) program which has rather unexpected behavior. (i'm switching to Data.Binary in the meantime.) import Data.Array.IO import System.IO (IOMode(..), openBinaryFile, hClose) dumpArray arr name = do h <- openBinaryFile name WriteMode w <- castIOUArray arr (l,u) <- getBounds w let len = u-1+1 hPutArray h w len hClose h return len loadArray name num = do arr <- newArray_ (1, num) h <- openBinaryFile name ReadMode read <- hGetArray h arr num if not(read == num) then error "Incorrect number of bytes read in from array!" else return arr len = 20 main = do arr <- newArray (1, len) 1::IO(IOUArray Int Int) size <- dumpArray arr "foo" arr2' <- loadArray "foo" size arr2 <- (castIOUArray arr2')::IO(IOUArray Int Int) e1 <- getElems arr e2 <- getElems arr2 print e1 print e2 print size print $ show (arr == arr2) best, b

midfield:
hi haskellers,
have the issues with castIOUArray (and thus hGetArray, hPutArray) in Data.Array.IO discussed below been resolved?
http://www.haskell.org/pipermail/libraries/2003-January/thread.html
here is a (trivial) program which has rather unexpected behavior. (i'm switching to Data.Binary in the meantime.)
Could you clarify what benefit the low level direct array IO has over Data.Binary? -- Don (thinking about how to best do IO for a new arrays library)

hi there,
i assume you're asking about benefits with respect to serialization?
other than some performance hacks, probably none. there was no good
reason for me to use hPutArray and the like, i just saw them in the
API docs and decided to try them out -- and got burned! Data.Binary
has worked great for me so far.
take care, ben
On 5/2/08, Don Stewart
midfield:
hi haskellers,
have the issues with castIOUArray (and thus hGetArray, hPutArray) in Data.Array.IO discussed below been resolved?
http://www.haskell.org/pipermail/libraries/2003-January/thread.html
here is a (trivial) program which has rather unexpected behavior. (i'm switching to Data.Binary in the meantime.)
Could you clarify what benefit the low level direct array IO has over Data.Binary?
-- Don (thinking about how to best do IO for a new arrays library)

Hello Ben, Saturday, May 3, 2008, 5:13:48 AM, you wrote:
have the issues with castIOUArray (and thus hGetArray, hPutArray) in Data.Array.IO discussed below been resolved?
there is alternative arrays library [1], where bounds are recalculated when casting [1] http://haskell.org/haskellwiki/Library/ArrayRef -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com
participants (3)
-
Ben
-
Bulat Ziganshin
-
Don Stewart