silently: Prevent or capture writing to stdout and other handles.

[ bsd3, library, system, testing ] [ Propose Tags ] [ Report a vulnerability ]

Prevent or capture writing to stdout, stderr, and other handles.


[Skip to Readme]

Modules

[Index] [Quick Jump]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

Versions [RSS] 0.0.1, 0.0.2, 0.0.3, 1.1.1, 1.1.2, 1.1.3, 1.1.4, 1.1.5, 1.2, 1.2.0.1, 1.2.0.2, 1.2.3, 1.2.4, 1.2.4.1, 1.2.5, 1.2.5.1, 1.2.5.2, 1.2.5.3
Change log CHANGELOG.md
Dependencies base (>=4.3 && <5), deepseq, directory [details]
Tested with ghc ==9.4.1, ghc ==9.2.4, ghc ==9.0.2, ghc ==8.10.7, ghc ==8.8.4, ghc ==8.6.5, ghc ==8.4.4, ghc ==8.2.2, ghc ==8.0.2, ghc ==7.10.3, ghc ==7.8.4, ghc ==7.6.3, ghc ==7.4.2, ghc ==7.2.2, ghc ==7.0.4
License BSD-3-Clause
Copyright (c) Trystan Spangler 2011
Author Trystan Spangler
Maintainer Sönke Hahn <soenkehahn@gmail.com>, Simon Hengel <sol@typeful.net>, Andreas Abel
Category System, Testing
Home page https://github.com/hspec/silently
Bug tracker https://github.com/hspec/silently/issues
Source repo head: git clone https://github.com/hspec/silently
Uploaded by AndreasAbel at 2022-08-21T17:20:10Z
Distributions Arch:1.2.5.3, Debian:1.2.5.1, Fedora:1.2.5.3, FreeBSD:1.2.5, LTSHaskell:1.2.5.3, NixOS:1.2.5.3, Stackage:1.2.5.3, openSUSE:1.2.5.3
Reverse Dependencies 13 direct, 653 indirect [details]
Downloads 90721 total (221 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2022-08-21 [all 1 reports]

Readme for silently-1.2.5.3

[back to package description]

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

Limitations

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

Examples: