HORIZON HASKELLDocslts/ghc-9.14.xd82dee82026-10-12Search names, modules, packages, or :: a typeCtrl K

GHC 9.14.1 · lts/ghc-9.14.x · d82dee8 · 2026-10-12

Modulehedgehog-extras-0.10.1.0Haskell2010

Hedgehog.Extras.Test.Concurrent

This modules provides concurrency abstractions for hedgehog tests. Using "lifted-base" one can execute expensive test actions concurrently.

For example, the actions invoked inside mapConcurrently_ are invoked in the same MonadTest as the outer monad of mapConcurrently_.

import qualified Hedgehog.Extras.Test.Concurrent as H

setUpEnvironment = H.mapConcurrently_ id
  [ H.threadDelay 100 >> pure 1
  , H.threadDelay 200 >> pure 2
  , H.threadDelay 300 >> pure 3
  ]

Warning: Do not use this module for running concurrent checks! The MonadBaseControl instance does not aggregate effects for PropertyT. Consider the following code:

  LA.mapConcurrently_ id
    [ do
      H.note_ "FAIL1"
      success
    , do
      IO.threadDelay 1_000_000
      H.note_ "FAIL2"
      failure
    , do
      H.note_ "FAIL3"
      failure
    ]

Executing this code will give you the following output in the test report:

66 ┃   LA.mapConcurrently_ id
67 ┃     [ do
68 ┃       H.note_ "FAIL1"
   ┃       │ FAIL1
69 ┃       success
70 ┃     , do
71 ┃       IO.threadDelay 1_000_000
72 ┃       H.note_ "FAIL2"
   ┃       │ FAIL2
73 ┃       failure
   ┃       ^^^^^^^
74 ┃     , do
75 ┃       H.note_ "FAIL3"
76 ┃       failure
77 ┃     ]

Please note that only FAIL1 and FAIL2 annotations were reported - FAIL3 annotation and the failure below was swallowed without any information.

Don't use concurrency abstractions from this module, when you need to aggregate and report failures!

  • 5 types
  • 69 values

Re-exports of concurrency abstractions from lifted-base

72 declarations
valuerace_ :: MonadBaseControl IO m => m a -> m b -> m ()
#

Generalized version of race_.

NOTE: This function discards the monadic effects besides IO in the forked computation.

datadata Async a
#

An asynchronous action spawned by async or withAsync. Asynchronous actions are executed in a separate thread, and operations are provided for waiting for asynchronous actions to complete and obtaining their results (see e.g. wait).

Instances4Functor, Eq, Ord, Hashable
  • Functor AsyncDefined in async-2.2.6 · Control.Concurrent.Async.Internal
  • Eq (Async a)Defined in async-2.2.6 · Control.Concurrent.Async.Internal
  • Ord (Async a)Defined in async-2.2.6 · Control.Concurrent.Async.Internal
  • Hashable (Async a)Defined in async-2.2.6 · Control.Concurrent.Async.Internal
newtypenewtype Concurrently (m :: Type -> Type) a
#

Generalized version of Concurrently.

A value of type Concurrently m a is an IO-based operation that can be composed with other Concurrently values, using the Applicative and Alternative instances.

Calling runConcurrently on a value of type Concurrently m a will execute the IO-based lifted operations it contains concurrently, before delivering the result of type a.

For example

  (page1, page2, page3) <- runConcurrently $ (,,)
    <$> Concurrently (getURL "url1")
    <*> Concurrently (getURL "url2")
    <*> Concurrently (getURL "url3")

Constructors

Instances5Functor, Applicative, Alternative, Semigroup, Monoid
datadata MVar a
#

An MVar (pronounced "em-var") is a synchronising variable, used for communication between concurrent threads. It can be thought of as a box, which may be empty or full.

Instances3NFData1, Eq, NFData
  • NFData1 MVarDefined in deepseq-1.5.1.0 · Control.DeepSeq
  • Eq (MVar a)Defined in ghc-internal-9.1401.0 · GHC.Internal.MVar

    Compares the underlying pointers.

  • NFData (MVar a)Defined in deepseq-1.5.1.0 · Control.DeepSeq

    NOTE: Only strict in the reference and not the referenced value.

valuetimeout :: MonadBaseControl IO m => Int -> m a -> m (Maybe a)
#

Generalized version of timeout.

Note that when the given computation times out any side effects of m are discarded. When the computation completes within the given time the side-effects are restored on return.