Modified transpose code:
transpose :: [[a]] -> [[a]]
transpose [] = []
transpose ([] : xss) = transpose xss
transpose ((x : xs) : xss) = combine x hds xs tls
where
-- We tie the calculations of heads and tails together
-- to prevent heads from leaking into tails and vice versa.
-- unzip makes the selector thunk arrangements we need to
-- ensure everything gets cleaned up properly.
(hds, tls) = unzip [(hd, tl) | hd : tl <- xss]
prefetchTails :: IO ()
prefetchTails = mapM_ (\tl -> prefetchElem3 tl 0) tls
combine y h ys t = (y:h) : transpose (ys:t)
{-# NOINLINE combine #-}
But I am not sure ho to invoke prefetchTails in the actual main.