[Haskell] ANNOUNCE: silently-0.0.1 (prevent IO actions from writing to stdout)

Trystan Spangler trystan.s at comcast.net
Mon Mar 7 02:28:27 CET 2011


Announcing Silently, a package with two simple functions to run an IO action while preventing it from writing to stdout (or the given handle):

  silently :: IO a -> IO a
  hSilently :: Handle -> IO a -> IO a

An example in GHCI:

Prelude> :m + System.IO.Silently
Prelude System.IO.Silently> let printFail s = undefined :: IO()
Prelude System.IO.Silently> let test1 = print 1 >> silently (print 2) >> print 3
Prelude System.IO.Silently> let test2 = print 1 >> silently (printFail 2) >> print 3
Prelude System.IO.Silently> test1
1
3
Prelude System.IO.Silently> test2
1
*** Exception: Prelude.undefined
Prelude System.IO.Silently> print "stdout still works after exceptions"
"stdout still works after exceptions"

http://hackage.haskell.org/package/silently
https://github.com/trystan/silently

Any advice, comments, or questions are welcome,
Trystan Spangler
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell/attachments/20110306/106f878c/attachment.htm>


More information about the Haskell mailing list