[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 14:42:36 UTC 2010


The following commit has been merged in the master branch:
commit 406fc380aca82cfff0571ace48d2f1264d3159d0
Author: John Goerzen <jgoerzen at complete.org>
Date:   Tue Oct 5 22:47:50 2004 +0100

    Finished block-based interaction
    
    Keywords:
    
    
    (jgoerzen at complete.org--projects/missingh--head--1.0--patch-19)

diff --git a/MissingH/IOutil.hs b/MissingH/IOutil.hs
index 1438b1b..a3dae1c 100644
--- a/MissingH/IOutil.hs
+++ b/MissingH/IOutil.hs
@@ -23,13 +23,19 @@ Written by John Goerzen, jgoerzen\@complete.org
 
 module MissingH.IOutil(-- * Line Processing Utilities
                        hPutStrLns, hGetLines,
-                       -- * Lazy Interaction
-                       hInteract, hLineInteract, lineInteract,
                        -- * Binary Single-Block I\/O
                        hPutBufStr, putBufStr, hGetBufStr, getBufStr,
                        hFullGetBufStr, fullGetBufStr,
                        -- * Binary Multi-Block I\/O
-                       hGetBlocks, getBlocks, hFullGetBlocks, fullGetBlocks
+                       hGetBlocks, getBlocks, hFullGetBlocks, fullGetBlocks,
+                       -- * Lazy Interaction
+                       -- ** Character-based
+                       hInteract,
+                       -- ** Line-based
+                       hLineInteract, lineInteract,
+                       -- ** Binary Block-based
+                       hBlockInteract, blockInteract,
+                       hFullBlockInteract, hFullBlockInteract
                         ) where
 
 import Foreign.Ptr
@@ -212,4 +218,33 @@ hGetBlocksUtil readfunc h count =
                           else do
                                remainder <- hGetBlocksUtil readfunc h count
                                return (block : remainder)
-                       )
\ No newline at end of file
+                       )
+
+{- | Binary block-based interaction.  This is useful for scenarios that
+take binary blocks, manipulate them in some way, and then write them
+out.  Take a look at 'hBlockCopy' for an example.  The integer argument
+is the size of input binary blocks.  This function uses 'hGetBlocks'
+internally.
+-}
+hBlockInteract :: Int -> Handle -> Handle -> ([String] -> [String]) -> IO ()
+hBlockInteract = hBlockInteractUtil hGetBlocks
+
+-- | An alias for 'hBlockInteract' over 'stdin' and 'stdout'
+blockInteract :: Int -> ([String] -> [String]) -> IO ()
+blockInteract x = hBlockInteract x stdin stdout
+
+{- | Same as 'hBlockInteract', but uses 'hFullGetBlocks' instead of
+'hGetBlocks' internally. -}
+hFullBlockInteract :: Int -> Handle -> Handle -> ([String] -> [String]) -> IO ()
+hFullBlockInteract = hBlockInteractUtil hFullGetBlocks
+
+-- | An alias for 'hFullBlockInteract' over 'stdin' and 'stdout'
+fullBlockInteract :: Int -> ([String] -> [String]) -> IO ()
+fullBlockInteract x = hFullBlockInteract x stdin stdout
+
+hBlockInteractUtil :: (Handle -> Int -> IO [String]) -> Int ->
+                      Handle -> Handle -> ([String] -> [String]) -> IO ()
+hBlockInteractUtil blockreader blocksize hin hout func =
+    do
+    blocks <- blockreader hin blocksize
+    hPutBlocks hout (func blocks)

-- 
haskell-testpack



More information about the Pkg-haskell-commits mailing list