[Haskell-cafe] Help needed for converting IOArray to ByteString

Henning Thielemann lemming at henning-thielemann.de
Thu Feb 17 23:59:52 CET 2011

On Tue, 8 Feb 2011, C K Kashyap wrote:

> I need to convert IOArray to bytestring as shown below - 
> import Data.Array.IO
> import Data.Binary.Put
> import qualified Data.ByteString.Lazy as BS
> import Data.Word
> main = do
> arr <- newArray (0,9) 0 :: IO (IOArray Int Int)
> let bs=toByteString arr
> return ()
> How can I implement the 'toByteString' function?

Why do you want to convert? If you process images you might consider one 
of the Vector libraries like storable-vector or vector. You can work on 
them in a mutable way, write them to disk, pass them to C libraries and so 

More information about the Haskell-Cafe mailing list