
12 Sep
2004
12 Sep
'04
2:20 p.m.
Abraham Egnor wrote:
Passing a Ptr isn't that onerous; it's easy enough to make functions that have the signature you'd like:
import System.IO import Data.Word (Word8) import Foreign.Marshal.Array
hPutBytes :: Handle -> [Word8] -> IO () hPutBytes h ws = withArray ws $ \p -> hPutBuf h p $ length ws
hGetBytes :: Handle -> Int -> IO [Word8] hGetBytes h c = allocaArray c $ \p -> do c' <- hGetBuf h p c peekArray c' p
The problem with this approach is that the entire array has to be held
in memory, which could be an issue if the amount of data involved is
large.
--
Glynn Clements