future-resource-0.4.0.0: realtime resource handling with manual concurrency

Safe HaskellSafe-Inferred
LanguageHaskell2010

Control.Future

Description

Similar to async package, however, suitable for manual threading and go without exceptions.

Synopsis

Documentation

data Progress a b Source

Constructors

Making 
Fixme a 
Finished b 

Instances

Functor (Progress a) 
(Show a, Show b) => Show (Progress a b) 

newtype Future a b Source

Two kinds of future is possible: (i) A pile of failures (Monoid a) and (ii) Successful result b.

Constructors

Future 

Fields

runFuture :: IO (Progress a b)
 

Instances

desire :: MonadIO m => Future a b -> (a -> IO b) -> m b Source

Wait until future comes, and modify failure history.

waitFor :: MonadIO m => Future a b -> m (Progress a b) Source

Just wait for the future honestly.

maybeChance :: MonadIO m => Future a b -> (a -> IO b) -> m (Maybe b) Source

Return Just when it is time. The history may be modified.

getProgress :: MonadIO m => Future a b -> m (Progress a b) Source

If it is too early, immediately returns Making.

mkFuture :: MonadIO m => ((Progress a b -> IO ()) -> IO ()) -> m (Future a b) Source

mkFuture $ \updateProgress -> forkIO (doSth >>= updateProgress)

expect :: Show a => Future a b -> IO b Source

Run Future action immediately.