HORIZON HASKELLDocslts/ghc-9.10.xc74966e2026-09-27Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27

Modulesydtest-0.22.0.0Haskell2010

Test.Syd.Def.Around

  • 10 values
  • Packagesydtest-0.22.0.0
  • Exports10
  • LanguageHaskell2010
  • LicenceLicenseRef-OtherLicense
  • SourceAround.hs
valuearound_
  1. :: (IO () -> IO ())

    The function to wrap every test with

  2. -> TestDefM outers inner result
  3. -> TestDefM outers inner result
#

Run a custom action before and/or after every spec item without accessing any inner resources.

It is important that the wrapper function that you provide runs the action that it gets _exactly once_.

FOOTGUN

This combinator gives the programmer a lot of power. In fact, it gives the programmer enough power to break the test framework. Indeed, you can provide a wrapper function that just _doesn't_ run the function like this:

spec :: Spec
spec = do
   let don'tDo :: IO () -> IO ()
       don'tDo _ = pure ()
   around_ don'tDo $ do
     it "should pass" True

During execution, you'll then get an error like this:

thread blocked indefinitely in an MVar operation

The same problem exists when using Test.Syd.Def.Around.aroundAll_.

The same thing will go wrong if you run the given action more than once like this:

spec :: Spec
spec = do
   let doTwice :: IO () -> IO ()
       doTwice f = f >> f
   around_ doTwice $ do
     it "should pass" True

Note: If you're interested in fixing this, talk to me, but only after GHC has gotten impredicative types because that will likely be a requirement.

Note that this function turns off shrinking. See https://github.com/nick8325/quickcheck/issues/331

valuearoundWith'
  1. :: HContains outers outer
  2. => ((outer -> newInner -> IO ()) -> outer -> oldInner -> IO ())

    The function that provides the new inner resource using the old resource. It can also use and modify the outer resource

  3. -> TestDefM outers newInner result
  4. -> TestDefM outers oldInner result
#

Run a custom action around every spec item, to provide access to an inner resource newInner while using the inner resource oldInner and any outer resource available.

Note that this function turns off shrinking. See https://github.com/nick8325/quickcheck/issues/331