[Haskell] ANNOUNCE: silently-1.1.1 (api changes and fewer temp files)
Trystan Spangler
trystan.s at comcast.net
Mon Apr 11 06:29:21 CEST 2011
Silently, a package to prevent or capture output to handles, has undergone some api changes for version 1.1.1.
silently and hSilently have been renamed to silence and hSilence.
hSilence and hCapture now take a list of handles instead of just one.
silence :: IO a -> IO a
hSilence :: [Handle] -> IO a -> IO a
capture :: IO a -> IO (String, a)
hCapture :: [Handle] -> IO a -> IO (String, a)
The 'capture' and 'hCapture' functions still use temp files behind the scenes. The 'silence' and 'hSilence' functions will write to the NUL device on Windows, to /dev/null on OSX and Linux, and use a temp file on other operating systems. Any temp files will be created in the temp folder if your system has one or the current directory if not.
http://hackage.haskell.org/package/silently
https://github.com/trystan/silently
Another big thanks to everyone who had comments and suggestions,
Trystan Spangler
As an example, the program
import System.IO.Silently
main = do
putStr "putStrLn: " >> putStrLn "puppies!"
putStr "silenced: " >> silence (putStrLn "kittens!")
putStrLn ""
(captured, result) <- capture (putStr "wookies!" >> return 123)
putStr "captured: " >> putStrLn captured
putStr "returned: " >> putStrLn (show result)
will print
putStrLn: puppies!
silenced:
captured: wookies!
returned: 123
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell/attachments/20110410/396b5d20/attachment.htm>
More information about the Haskell
mailing list