@@ -23,7 +23,6 @@ module Streamly.Internal.Data.Serialize.Type
2323import Control.Exception (assert)
2424#endif
2525
26−import Control.Monad (void)
2726import Data.List (foldl')
2827import Data.Proxy (Proxy (..))
2928import Streamly.Internal.Data.Unbox
@@ -240,13 +239,13 @@ instance forall a. Serialize a => Serialize [a] where
240239 -- Inlining this causes large compilation times for tests
241240 {-# INLINABLE serialize #-}
242241 serialize off arr val = do
243− void $ serialize off arr ((fromIntegral :: Int -> Int64) (length val))
244− let off1 = off + Unbox.sizeOf (Proxy :: Proxy Int)
245− let pokeList o [] = pure o
246− pokeList o (x:xs) = do
242+ let off1 = off + Unbox.sizeOf (Proxy :: Proxy Int64)
243+ let pokeList acc o [] =
244+ Unbox.pokeByteIndex off arr (acc :: Int64) >> pure o
245+ pokeList acc o (x:xs) = do
247246 o1 <- serialize o arr x
248− pokeList o1 xs
249− pokeList off1 val
247+ pokeList (acc + 1) o1 xs
248+ pokeList 0 off1 val
250249
251250instance Serialize (Array a) where
252251 {-# INLINE size #-}