My sample code to define and fill up then output an (Integer) IOArray:
{-# OPTIONS_GHC -O2 #-}
{-# LANGUAGE BangPatterns #-}
import Data.Array
import Data.Array.IO
for_ xs f = mapM_ f xs
a_size = 10000 :: Int
main :: IO()
main = do
a <- newArray (0,a_size-1) 1 :: IO (IOArray Int Integer)
for_ [3,4..(a_size-1)] $ \i -> do -- generate the a array
t1 <- readArray a (i-3)
t2 <- readArray a (i-2)
t3 <- readArray a (i-1)
writeArray a i (4*t1+t2+2*t3)
for_ [0,1..(a_size-1)] $ \i -> do -- print the terms of array
temp <- readArray a i
print(temp)
return()
Obviously my real code is longer to compute (another) 'a' Integer array. I would like to speedup the output section using bytestring, but don't know how to do it.