-- TODO: consider adding support for a 'STPrimArray RealWorld Pinned Block', and a matching address type, that would enfoce the above requirements
-- However we would have to cast/view it as an array of Word8 later on.
-- | Array's size and start must be aligned on the block size, and the ByteAddr too.
fdReadArray :: Fd -> ByteAddr -> ArrayRange (STPrimArray RealWorld Pinned Word8) -> ExceptT String IO ()
fdReadArray fd start a = ExceptT $ fmap (boolEither "" () . (==) (toByteCount $ arrayLen a)) $
                         fdSeekLen fd start >> withArrayPtr (\ptr len -> fdReadBuf fd ptr $ toByteCount len) a
fdReadArray :: Fd -> ByteAddr -> ArrayRange (STPrimArray RealWorld Pinned Word8) -> ExceptT String IO ()
fdReadArray fd start a = ExceptT $ fmap (boolEither "" () . (==) (toByteCount $ arrayLen a)) $
                         fdSeekLen fd start >> withArrayPtr (\ptr len -> fdReadBuf fd ptr $ toByteCount len) a
fdReadArray fd start a = ExceptT $ fmap (boolEither "" () . (==) (toByteCount $ arrayLen a)) $
                         fdSeekLen fd start >> withArrayPtr (\ptr len -> fdReadBuf fd ptr $ toByteCount len) a