futures-0.1: Simple and fast implementation of Future

Safe HaskellNone
LanguageHaskell2010

Futures

Synopsis

Documentation

data Future a Source #

Abstraction over a pattern where you delegate an IO action to be executed on another thread, but are still interested in processing its result some time later on. In the meantime you can execute other actions. IOW, it is an implementation of asynchronous programming pattern.

Another way to look at future is as on an evaluate-once computation.

Instances
Monad Future Source # 
Instance details

Defined in Futures

Methods

(>>=) :: Future a -> (a -> Future b) -> Future b #

(>>) :: Future a -> Future b -> Future b #

return :: a -> Future a #

fail :: String -> Future a #

Functor Future Source # 
Instance details

Defined in Futures

Methods

fmap :: (a -> b) -> Future a -> Future b #

(<$) :: a -> Future b -> Future a #

MonadFail Future Source # 
Instance details

Defined in Futures

Methods

fail :: String -> Future a #

Applicative Future Source # 
Instance details

Defined in Futures

Methods

pure :: a -> Future a #

(<*>) :: Future (a -> b) -> Future a -> Future b #

liftA2 :: (a -> b -> c) -> Future a -> Future b -> Future c #

(*>) :: Future a -> Future b -> Future b #

(<*) :: Future a -> Future b -> Future a #

MonadIO Future Source # 
Instance details

Defined in Futures

Methods

liftIO :: IO a -> Future a #

fork :: IO a -> IO (Future a) Source #

Fork a thread to execute the computation on and produce a future, which will provide its results.

The IO action must not throw exceptions! If you want to transfer them, wrap it in try.

block :: Future a -> IO a Source #

Block waiting until the future result is available.