Changes between Version 2 and Version 3 of monad-parallel

Show
Ignore:
Timestamp:
03/20/10 20:04:14 (5 years ago)
Author:
blamario (IP: 99.241.117.248)
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • monad-parallel

    v2 v3  
    11= monad-parallel = 
    22 
    3 The package ''monad-parallel'' defines classes of monads that are capable of: 
     3The low-level libraries available with GHC provide two completely different ways to execute tasks in parallel: [http://hackage.haskell.org/packages/archive/parallel/1.1.0.1/doc/html/Control-Parallel.html#v:par par] and [http://www.haskell.org/ghc/docs/latest/html/libraries/base-4.2.0.0/Control-Concurrent.html#v%3AforkIO forkIO]. The former can be applied to any pure computation, while the latter works only in the IO monad. 
     4 
     5The purpose of the ''monad-parallel'' library package is to unify the two approaches. For this purpose, it defines classes of monads that are capable of: 
    46 * splitting or forking monadic computations to be performed in parallel, and 
    57 * combining the results of those computations when they complete. 
     8 
     9The way these classes are implemented by the IO monad (as well as any MonadIO instance) is different from the way they're implemented by stateless monads, but the classes abstract these implementation details away. 
     10 
     11== Class `MonadFork` == 
     12 
     13A monad that's an instance of the `MonadFork` class supports method 
     14 
     15{{{ 
     16 forkExec :: MonadFork m => m a -> m (m a) 
     17}}} 
     18 
     19This function launches the argument computation in a parallel thread and returns a handle to it. The main thread is free to perform some other task and then obtain the result of the parallel computation: 
     20 
     21{{{ 
     22task1 :: Monad Int 
     23task2 :: Monad Int 
     24task3 :: Monad Int 
     25 
     26example = do handle1 <- forkExec task1 
     27             handle2 <- forkExec task2 
     28             result3 <- task3 
     29             result1 <- handle1 
     30             result2 <- handle2 
     31             return (result1 + result2 + result3) 
     32}}} 
     33 
     34== Class `MonadParallel` == 
     35 
     36A monad that's an instance of the `MonadParallel` class supports method 
     37 
     38{{{ 
     39 bindM2 :: MonadParallel m => (a -> b -> m c) -> m a -> m b -> m c 
     40}}} 
     41