[Pkg-haskell-commits] [SCM] haskell-testpack branch, master, updated. debian/1.0.2-1-4-gb0d6b36
John Goerzen
jgoerzen at complete.org
Fri Apr 23 15:02:58 UTC 2010
The following commit has been merged in the master branch:
commit 817678c253568bb0988dd2c026f5008478478d5c
Author: John Goerzen <jgoerzen at complete.org>
Date: Mon Oct 10 07:42:44 2005 +0100
Start of adapting for getBufStr
diff --git a/MissingH/IO/Binary.hs b/MissingH/IO/Binary.hs
index 2ef5e1f..5862422 100644
--- a/MissingH/IO/Binary.hs
+++ b/MissingH/IO/Binary.hs
@@ -93,7 +93,7 @@ import MissingH.IO.HVIO
types. -}
class BinaryConvertable a where
toBuf :: a -> (Ptr CChar -> IO c) -> IO c
- fromBuf :: Int -> (Ptr CChar -> IO a) -> IO a
+ fromBuf :: Int -> (Ptr CChar -> IO Int) -> IO a
byteSize :: a -> Int
instance BinaryConvertable String where
@@ -131,14 +131,16 @@ hPutBufStr f s = toBuf s (\cs -> vPutBuf f cs (byteSize s))
putBufStr :: (BinaryConvertable b) => b -> IO ()
putBufStr = hPutBufStr stdout
-{- | As a wrapper around the standard function 'System.IO.hGetBuf',
-this function returns a standard Haskell string instead of modifying
+{- | Acts a wrapper around the standard function 'System.IO.hGetBuf',
+this function returns a standard Haskell String (or Word8) instead of modifying
a 'Ptr a' buffer. The length is the maximum length to read and the
semantice are the same as with 'hGetBuf'; namely, the empty string
is returned with EOF is reached, and any given read may read fewer
-bytes than the given length. -}
-hGetBufStr :: Handle -> Int -> IO String
-hGetBufStr f count = do
+bytes than the given length.
+
+(Actually, it's a wrapper around "MissingH.IO.HVIO.vGetBuf") -}
+hGetBufStr :: (HVIO a, BinaryConvertable b) => a -> Int -> IO b
+hGetBufStr f count = fromBuf count (
fbuf <- mallocForeignPtrArray (count + 1)
withForeignPtr fbuf (\buf -> do
bytesread <- hGetBuf f buf count
--
haskell-testpack
More information about the Pkg-haskell-commits
mailing list