
10 Dec
2012
10 Dec
'12
7:56 p.m.
On 28/11/2012 08:41, Judah Jacobson wrote:
How about something like this?
createFromHandle :: (Handle -> IO ()) -> IO ByteString
Of course, thanks! I've knocked something up at http://hub.darcs.net/ganesh/bytestring-handle The signatures are: readHandle :: Bool -> BL.ByteString -> IO Handle writeHandle :: Bool -> (Handle -> IO a) -> IO (BL.ByteString, a) I went for lazy bytestrings as they fit my use case and mostly generalise strict ones in this context - one exception is that writing directly to a strict one could avoid a copy if you know the max size up front. Comments etc welcome. I've written some tests but not very comprehensive ones and I wouldn't be at all surprised if the seek behaviour is completely broken. Cheers, Ganesh