BSD-3-Clause licensed by Trystan Spangler
Maintained by Simon Hengel, Andreas Abel
This version can be pinned in stack with:silently-1.2.5.4@sha256:49cb6f68f52e4e3bac726cd9429a7fa28c6280f0ddb544bd924b7490cc6793a6,2358

Module documentation for 1.2.5.4

Used by 4 packages in nightly-2024-12-11(full list with versions):

Hackage version silently on Stackage Nightly Stackage LTS version Cabal build

silently

Silently is a package that allows you to run an IO action and prevent it from writing to stdout, or any other handle, by using silence. Or you can capture the output for yourself using capture.

For 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

Not thread-safe

Since all threads of a process share the standard output handles stdout and stderr, capturing output to these handle will capture the output of all threads, not just the one running the action under capture.

In essence, this library does not work in a situation where multiple threads are writing to the handle whose output produced by the given action we want to capture.

See:

Further limitations

Capturing/silencing might not work as expected if the action uses the FFI or conceals output under unsafePerformIO or similar unsafe operations.

Examples:

Changes

1.2.5.4 November 2024

  • Bump cabal-version to 1.18.
  • README: alert of malfunction in multi-threaded settings.
  • Tested with GHC 8.0 - 9.12.0.

1.2.5.3 August 2022

  • Tested with GHC 7.0 - 9.4.1.
  • Remove remnants of GHC 6.x support.
  • Silence incomplete pattern matching warning, refactor code.
  • Add section about limitations to README.

1.2.5.2 November 2021

  • Tested with GHC 7.0 - 9.2.
  • Silence warning caused by missing other-modules in cabal file.
  • Add README and CHANGELOG to dist.

1.2.5.1 July 2019

No changelog for this and earlier versions.