timeout-with-results-0.1.1: Runs a time-limited computation alowing it to return intermediate results.

Safe HaskellSafe-Inferred

System.Timeout.Returning

Synopsis

Documentation

class Monad m => MonadTimeout w m | m -> w whereSource

Monad for computations that can save partial results of type w during their evaluation.

Methods

tell :: w -> m ()Source

Save an intermediate result of the computation.

tellWith :: (Maybe w -> w) -> m ()Source

Combine an intermediate result of the computation with the current saved result (if any) and save it.

yield :: m ()Source

Explicitly allow interrupting the computation at this point. Experimental.

Instances

data Timeout w a Source

An IO-based implementation of MonadTimeout.

Instances

runTimeoutSource

Arguments

:: Strategy w

Evaluate values passed to tell using this strategy.

-> Int

Timeout in microseconds.

-> Timeout w ()

The computation.

-> IO (Maybe w)

The result, or Nothing if no tell was called by the computation.

Execute the given computation with a timeout limit and force the result to the form defined by the given Strategy. In most cases, the strategy will be either rseq or rdeepseq. This ensures that the computation is actually performed by the given computation, not by the consuming thread.

returning :: MonadTimeout w m => m w -> m ()Source

Convert a monadic computation returning a value of the result type into 'm ()' so that it can be used with runTimeout. Calling 'returning k' is equivalent to 'k >>= tell'.

rseq :: Strategy a

rseq evaluates its argument to weak head normal form.