HORIZON HASKELLDocslts/ghc-9.10.x248f8f02026-10-05Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05

ModuleChasingBottoms-1.3.1.16Haskell2010

Test.ChasingBottoms.TimeOut

When dealing with "hard bottoms", i.e. non-terminating computations that do not result in exceptions, the following functions may be handy.

Note that a computation is considered to have terminated when it has reached weak head normal form (i.e. something distinct from bottom).

  • 1 type
  • 4 values
valuetimeOut :: Int -> IO a -> IO (Result a)
#

timeOut n c runs c for at most n seconds (modulo scheduling issues).

  • If the computation terminates before that, then Value v is returned, where v is the resulting value. Note that this value may be equal to bottom, e.g. if c = return bottom.

  • If the computation does not terminate, then NonTermination is returned.

  • If the computation raises an exception, then Exception e is returned, where e is the exception.

Note that a user-defined exception is used to terminate the computation, so if c catches all exceptions, or blocks asynchronous exceptions, then timeOut may fail to function properly.

valuetimeOutMicro :: Int -> IO a -> IO (Result a)
#

timeOutMicro takes a delay in microseconds. Note that the resolution is not necessarily very high (the last time I checked it was 0.02 seconds when using the standard runtime system settings for GHC).