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.Base

  • 2 types
  • 1 class
  • 73 values
valueworkspaceWithConfig
  1. :: (HasCallStack, MonadCatch m, MonadBaseControl IO m, MonadResource m, MonadTest m, MonadAssertion m)
  2. => WorkspacePolicy

    Cleanup policy: PreserveWorkspace always preserves, CleanupOnSuccess deletes on success only

  3. -> FilePath
  4. -> (FilePath -> m ())
  5. -> m ()
#

Create a workspace directory with explicit configuration for cleanup behavior.

The directory will have the supplied prefix but contain a generated random suffix to prevent interference between tests

The directory will be deleted if the block succeeds, but left behind if the block fails (unless policy is PreserveWorkspace, in which case it's always preserved).

Create a workspace directory which will exist for at least the duration of the supplied block.

The directory will have the prefix as "$prefixPath/$moduleName" but contain a generated random suffix to prevent interference between tests

The directory will be deleted if the block succeeds, but left behind if the block fails.

The prefix argument should not contain directory delimeters.

valuenoteShowPretty :: (MonadTest m, HasCallStack, Show a) => a -> m a
#

Annotate the given value, pretty printing it with indentation. Note that large data structures will take a significant amount of vertical screen space.

valuenoteShowPrettyIO_
  1. :: (MonadTest m, MonadIO m, HasCallStack, Show a)
  2. => IO a
  3. -> m ()
#

Annotate the given value in IO returning unit, pretty printing it with indentation. Note that large data structures will take a significant amount of vertical screen space.

valuenoteShowPrettyM
  1. :: (MonadTest m, MonadCatch m, HasCallStack, Show a)
  2. => m a
  3. -> m a
#

Annotate the given value in a monadic context, pretty printing it with indentation. Note that large data structures will take a significant amount of vertical screen space.

valuenoteShowPrettyM_
  1. :: (MonadTest m, MonadCatch m, HasCallStack, Show a)
  2. => m a
  3. -> m ()
#

Annotate the given value in a monadic context returning unit, pretty printing it with indentation. Note that large data structures will take a significant amount of vertical screen space.

valuenoteShowPretty_ :: (MonadTest m, HasCallStack, Show a) => a -> m ()
#

Annotate the given value returning unit, pretty printing it with indentation. Note that large data structures will take a significant amount of vertical screen space.

valuenoteEachPretty
  1. :: (MonadTest m, HasCallStack, Show a, Traversable f)
  2. => f a
  3. -> m (f a)
#

Annotate the each value in the given traversable, pretty printing it with indentation. Note that large data structures will take a significant amount of vertical screen space.

valuenoteEachPrettyM
  1. :: (MonadTest m, HasCallStack, Show a, Traversable f)
  2. => m (f a)
  3. -> m (f a)
#

Annotate the each value in the given traversable in a monadic context, pretty printing it with indentation. Note that large data structures will take a significant amount of vertical screen space.

valuenoteEachPrettyM_
  1. :: (MonadTest m, HasCallStack, Show a, Traversable f)
  2. => m (f a)
  3. -> m ()
#

Annotate the each value in the given traversable in a monadic context returning unit, pretty printing it with indentation. Note that large data structures will take a significant amount of vertical screen space.

valuenoteEachPretty_
  1. :: (MonadTest m, HasCallStack, Show a, Traversable f)
  2. => f a
  3. -> m ()
#

Annotate the each value in the given traversable returning unit, pretty printing it with indentation. Note that large data structures will take a significant amount of vertical screen space.

valueassertByDeadlineMFinally
  1. :: (MonadTest m, MonadIO m, HasCallStack)
  2. => UTCTime
  3. -> m Bool
  4. -> m ()
  5. -> m ()
#

Run the operation f once a second until it returns True or the deadline expires.

The action g is run after expiration of the deadline, but before failure allowing for additional annotations to be presented.

Expiration of the deadline results in an assertion failure

valueassertByDeadlineIOFinally
  1. :: (MonadTest m, MonadIO m, HasCallStack)
  2. => UTCTime
  3. -> IO Bool
  4. -> m ()
  5. -> m ()
#

Run the operation f once a second until it returns True or the deadline expires.

The action g is run after expiration of the deadline, but before failure allowing for additional annotations to be presented.

Expiration of the deadline results in an assertion failure

classclass MonadBase b m => MonadBaseControl (b :: Type -> Type) (m :: Type -> Type) | m -> b where
#

Writing instances

The usual way to write a MonadBaseControl instance for a transformer stack over a base monad B is to write an instance MonadBaseControl B B for the base monad, and MonadTransControl T instances for every transformer T. Instances for MonadBaseControl are then simply implemented using ComposeSt, defaultLiftBaseWith, defaultRestoreM.

Instances25MonadBaseControl, …
valuebracket
  1. :: MonadBaseControl IO m
  2. => m a

    computation to run first ("acquire resource")

  3. -> (a -> m b)

    computation to run last ("release resource")

  4. -> (a -> m c)

    computation to run in-between

  5. -> m c
#

Generalized version of bracket.

Note:

  • When the "acquire" or "release" computations throw exceptions any monadic side effects in m will be discarded.

  • When the "in-between" computation throws an exception any monadic side effects in m produced by that computation will be discarded but the side effects of the "acquire" or "release" computations will be retained.

  • Also, any monadic side effects in m of the "release" computation will be discarded; it is run only for its side effects in IO.

Note that when your acquire and release computations are of type IO it will be more efficient to write:

liftBaseOp (bracket acquire release)
valuebracket_
  1. :: MonadBaseControl IO m
  2. => m a

    computation to run first ("acquire resource")

  3. -> m b

    computation to run last ("release resource")

  4. -> m c

    computation to run in-between

  5. -> m c
#

Generalized version of bracket_.

Note any monadic side effects in m of both the "acquire" and "release" computations will be discarded. To keep the monadic side effects of the "acquire" computation, use bracket with constant functions instead.

Note that when your acquire and release computations are of type IO it will be more efficient to write:

liftBaseOp_ (bracket_ acquire release)