To sum up here is the example
that can write two arrays in one file and then read this two arrays
back. To restore written data it just reads the file into bytestring,
then splits the bytestring into equal parts. The parts are decoded. I
suppose the method is suitable for decoding files with unboxed arrays
of equal size.
import Data.Array.Unboxed
import Data.Binary
import qualified Data.ByteString.Lazy as BL
import IO
a = listArray ((1,1),(3,2)) [3,4,5,6,7,8] :: UArray (Int, Int) Float
b = listArray ((1,1),(3,2)) [9,10,11,12,13,14] :: UArray (Int, Int) Float
encodeFile2 f = BL.appendFile f . encode
encoder = do
ššššššš encodeFile "Results.txt" a
ššššššš encodeFile2 "Results.txt" b
decoder = do
ššššššš contents <- BL.readFile "Results.txt"
ššššššš print $ (show (decode (fst (BL.splitAt 118 contents)) :: UArray (Int, Int) Float))
ššššššš print $ (show (decode (snd (BL.splitAt 118 contents)) :: UArray (Int, Int) Float))
P.S. I've already sent this letter to mailist several ours ago, but it wasn't published :-/