packages feed

monad-par-extras 0.3.2 → 0.3.3

raw patch · 2 files changed

+36/−30 lines, 2 filesdep ~abstract-parPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: abstract-par

API changes (from Hackage documentation)

Files

Control/Monad/Par/State.hs view
@@ -1,12 +1,13 @@-{-# LANGUAGE ScopedTypeVariables, FlexibleInstances, -     MultiParamTypeClasses, UndecidableInstances, CPP-  #-}+{-# LANGUAGE ScopedTypeVariables, FlexibleInstances,+             MultiParamTypeClasses, UndecidableInstances, CPP #-}  -- | This module provides a notion of (Splittable) State that is --   compatible with any Par monad.-+--+--   This module provides instances that make StateT-transformed+--   monads into valid Par monads. -module Control.Monad.Par.State +module Control.Monad.Par.State   (    SplittableState(..)   )@@ -22,14 +23,19 @@ --- Make Par computations with state work. --- (TODO: move these instances to a different module.) --- | A type in `SplittableState` is meant to be added as to a Par monad+-- | A type in `SplittableState` is meant to be added to a Par monad --   using StateT.  It works like any other state except at `fork` --   points, where the runtime system splits the state using `splitState`.--- +-- --   Common examples for applications of `SplittableState` would --   include (1) routing a splittable random number generator through --   a parallel computation, and (2) keeping a tree-index that locates --   the current computation within the binary tree of `fork`s.+--   Also, it is possible to simply duplicate the state at all fork points,+--   enabling "thread local" copies of the state.+--+--   The limitation of this approach is that the splitting method is+--   fixed, and the same at all `fork` points. class SplittableState a where   splitState :: a -> (a,a) @@ -37,22 +43,22 @@ -- Strict State:  -- | Adding State to a `ParFuture` monad yields another `ParFuture` monad.-instance (SplittableState s, PC.ParFuture fut p) -      =>  PC.ParFuture fut (S.StateT s p) +instance (SplittableState s, PC.ParFuture fut p)+      =>  PC.ParFuture fut (S.StateT s p)  where   get = lift . PC.get-  spawn_ (task :: S.StateT s p ans) = -    do s <- S.get +  spawn_ (task :: S.StateT s p ans) =+    do s <- S.get        let (s1,s2) = splitState s        S.put s2                               -- Parent comp. gets one branch.        lift$ PC.spawn_ $ S.evalStateT task s1   -- Child the other.  -- | Likewise, adding State to a `ParIVar` monad yield s another `ParIVar` monad.-instance (SplittableState s, PC.ParIVar iv p) -      =>  PC.ParIVar iv (S.StateT s p) +instance (SplittableState s, PC.ParIVar iv p)+      =>  PC.ParIVar iv (S.StateT s p)  where-  fork (task :: S.StateT s p ()) = -              do s <- S.get +  fork (task :: S.StateT s p ()) =+              do s <- S.get                  let (s1,s2) = splitState s                  S.put s2                  lift$ PC.fork $ do S.runStateT task s1; return ()@@ -64,8 +70,8 @@ -- ParChan not released yet: #if 0 -- | Likewise, adding State to a `ParChan` monad yield s another `ParChan` monad.-instance (SplittableState s, PC.ParChan snd rcv p) -      =>  PC.ParChan snd rcv (S.StateT s p) +instance (SplittableState s, PC.ParChan snd rcv p)+      =>  PC.ParChan snd rcv (S.StateT s p)  where    newChan  = lift   PC.newChan    recv   r = lift $ PC.recv r@@ -79,22 +85,22 @@ -- <DUPLICATE_CODE>  -- | Adding State to a `ParFuture` monad yield s another `ParFuture` monad.-instance (SplittableState s, PC.ParFuture fut p) -      =>  PC.ParFuture fut (SL.StateT s p) +instance (SplittableState s, PC.ParFuture fut p)+      =>  PC.ParFuture fut (SL.StateT s p)  where   get = lift . PC.get-  spawn_ (task :: SL.StateT s p ans) = -    do s <- SL.get +  spawn_ (task :: SL.StateT s p ans) =+    do s <- SL.get        let (s1,s2) = splitState s        SL.put s2                               -- Parent comp. gets one branch.        lift$ PC.spawn_ $ SL.evalStateT task s1   -- Child the other.  -- | Likewise, adding State to a `ParIVar` monad yield s another `ParIVar` monad.-instance (SplittableState s, PC.ParIVar iv p) -      =>  PC.ParIVar iv (SL.StateT s p) +instance (SplittableState s, PC.ParIVar iv p)+      =>  PC.ParIVar iv (SL.StateT s p)  where-  fork (task :: SL.StateT s p ()) = -              do s <- SL.get +  fork (task :: SL.StateT s p ()) =+              do s <- SL.get                  let (s1,s2) = splitState s                  SL.put s2                  lift$ PC.fork $ do SL.runStateT task s1; return ()@@ -105,7 +111,7 @@  #if 0 -- | Likewise, adding State to a `ParChan` monad yield s another `ParChan` monad.-instance (SplittableState s, PC.ParChan snd rcv p) +instance (SplittableState s, PC.ParChan snd rcv p)       =>  PC.ParChan snd rcv (SL.StateT s p)  where    newChan  = lift   PC.newChan
monad-par-extras.cabal view
@@ -1,5 +1,5 @@ Name:                monad-par-extras-Version:             0.3.2+Version:             0.3.3 Synopsis:            Combinators and extra features for Par monads  @@ -13,8 +13,8 @@                      data structures, and other added capabilities                      layered on top of the 'Par' monad. -                       * Finish These-                       * Module Descriptions+                       -- * Finish These+                       -- * Module Descriptions  Homepage:            https://github.com/simonmar/monad-par License:             BSD3@@ -51,7 +51,7 @@    Build-depends: base >= 4 && < 5                -- This provides the interface which monad-par implements:-               , abstract-par >= 0.3+               , abstract-par >= 0.3 && < 0.4                , cereal       >= 0.3                , deepseq      >= 1.3                , random       >= 1.0