monad-par 0.3.4.6 → 0.3.4.7
raw patch · 5 files changed
+28/−18 lines, 5 filesdep ~basedep ~mtl
Dependency ranges changed: base, mtl
Files
- Control/Monad/Par.hs +5/−5
- Control/Monad/Par/Scheds/Direct.hs +1/−6
- Control/Monad/Par/Scheds/DirectInternal.hs +1/−1
- monad-par.cabal +9/−6
- tests/ParTests_shared.hs +12/−0
Control/Monad/Par.hs view
@@ -13,11 +13,11 @@ @(f x)@ and @(g x)@ in parallel, and returns a pair of their results: > runPar $ do- > fx <- spawn (return (f x)) -- start evaluating (f x)- > gx <- spawn (return (g x)) -- start evaluating (g x)- > a <- get fx -- wait for fx- > b <- get gx -- wait for gx- > return (a,b) -- return results+ > fx <- spawnP (f x) -- start evaluating (f x)+ > gx <- spawnP (g x) -- start evaluating (g x)+ > a <- get fx -- wait for fx+ > b <- get gx -- wait for gx+ > return (a,b) -- return results @Par@ can be used for specifying pure parallel computations in which the order of the computation is not known beforehand.
Control/Monad/Par/Scheds/Direct.hs view
@@ -809,12 +809,7 @@ unsafeParIO = unsafeParIO #endif -instance Functor Par where- fmap f xs = xs >>= return . f -instance Applicative Par where- (<*>) = ap- pure = return #ifdef NEW_GENERIC instance PU.ParMonad Par where@@ -873,7 +868,7 @@ doDebugStuff = do printf "This takeMVar blocked indefinitely!: %s\n" msg error "failed" --- | For debugging purposes. This can help us figure out (but an ugly+-- | For debugging purposes. This can help us figure out (by an ugly -- process of elimination) which MVar reads are leading to a "Thread -- blocked indefinitely" exception. {-
Control/Monad/Par/Scheds/DirectInternal.hs view
@@ -41,7 +41,7 @@ -- computations return nothing. -- newtype Par a = Par { unPar :: C.ContT () ROnly a }- deriving (Monad, MonadCont, RD.MonadReader Sched)+ deriving (Functor, Applicative, Monad, MonadCont, RD.MonadReader Sched) type ROnly = RD.ReaderT Sched IO type SessionID = Word64
monad-par.cabal view
@@ -1,5 +1,5 @@ Name: monad-par-Version: 0.3.4.6+Version: 0.3.4.7 Synopsis: A library for parallel programming based on a monad @@ -24,6 +24,7 @@ -- 0.3.4.4 : Use the Trace scheduler in Control.Monad.Par.IO too -- 0.3.4.5 : Extremely minor, fix to unit tests. -- 0.3.4.6 : Add newgeneric flag, supporting the par-classes module.+-- 0.3.4.7 : bugfix #38 for GHC 7.10 Description: The 'Par' monad offers a simple API for parallel programming. The@@ -85,11 +86,11 @@ Description: Provide instances for the new par-classes generic Par programming interface. Default: False -Library- Source-repository head- type: git- location: https://github.com/simonmar/monad-par+Source-repository head+ type: git+ location: https://github.com/simonmar/monad-par +Library Exposed-modules: -- The classic, simple monad-par interface: Control.Monad.Par@@ -161,7 +162,9 @@ Test-Suite test-monad-par type: exitcode-stdio-1.0 main-is: tests/AllTests.hs- ghc-options: -itests -rtsopts -threaded+ hs-source-dirs: tests/ ./ + -- Run tests in parallel:+ ghc-options: -O2 -threaded -rtsopts -with-rtsopts=-N4 build-depends: base >= 4 && < 5 , abstract-par, monad-par-extras , array >= 0.3
@@ -25,6 +25,18 @@ par :: (Eq a, Show a) => a -> Par a -> Assertion par res m = res @=? runPar m +-- | Make sure there's no problem with bringing the worker threads up and down many+-- times. 10K runPar's takes about 6.3 seconds.+case_lotsaRunPar :: Assertion+case_lotsaRunPar = loop 2000+ where + loop 0 = putStrLn ""+ loop i = do+ -- We need to do runParIO to make sure the compiler does the runPar each time.+ runParIO (return ())+ putStr "."+ loop (i-1)+ case_justReturn :: Assertion case_justReturn = par three (return 3)