ParFuture captures the class of Par monads which support
futures. This level of functionality subsumes par/pseq and is
similar to the Control.Parallel.Strategies.Eval monad.
A minimal implementation consists of spawn_ and get. However, for monads that are also a member of ParIVar it is typical to simply define spawn in terms of fork, new, and put.
Methods
spawn :: NFData a => m a -> m (future a)Create a potentially-parallel computation, and return a future (or promise) that can be used to query the result of the forked computataion.
spawn p = do r <- new fork (p >>= put r) return rspawn_ :: m a -> m (future a)Like spawn, but the result is only head-strict, not fully-strict.
get :: future a -> m aWait for the result of a future, and then return it.
spawnP :: NFData a => a -> m (future a)Spawn a pure (rather than monadic) computation. Fully-strict.
spawnP = spawn . return