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
_______________________________________________
Haskell mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell