{-# LANGUAGE BangPatterns, CPP, MagicHash, UnboxedTuples #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
module Control.Parallel.Strategies (
Strategy
, using
, withStrategy
, usingIO
, withStrategyIO
, dot
, r0
, rseq
, rdeepseq
, rpar
, rparWith
, evalSeq
, SeqStrategy
, evalTraversable
, parTraversable
, evalList
, parList
, evalListN
, parListN
, evalListNth
, parListNth
, evalListSplitAt
, parListSplitAt
, parListChunk
, parMap
, evalBuffer
, parBuffer
, evalTuple2
, evalTuple3
, evalTuple4
, evalTuple5
, evalTuple6
, evalTuple7
, evalTuple8
, evalTuple9
, parTuple2
, parTuple3
, parTuple4
, parTuple5
, parTuple6
, parTuple7
, parTuple8
, parTuple9
, ($|)
, ($||)
, (.|)
, (.||)
, (-|)
, (-||)
, Eval
, parEval
, runEval
, runEvalIO
,
Done, demanding, sparking, (>|), (>||),
rwhnf, unEval,
seqTraverse, parTraverse,
seqList,
seqPair, parPair,
seqTriple, parTriple,
NFData
) where
#if !MIN_VERSION_base(4,8,0)
import Data.Traversable
import Control.Applicative
#endif
import Control.Parallel
import Control.DeepSeq (NFData(rnf))
import Control.Monad.Fix (MonadFix (..))
#if MIN_VERSION_base(4,4,0)
import System.IO.Unsafe (unsafeDupablePerformIO)
import Control.Exception (evaluate)
#else
import System.IO.Unsafe (unsafePerformIO)
import Control.Monad
#endif
import qualified Control.Seq
import GHC.Exts
import GHC.IO (IO (..))
infixr 9 `dot`
infixl 0 `using`
infixl 0 `usingIO`
#if __GLASGOW_HASKELL__ >= 702
newtype Eval a = Eval {forall a. Eval a -> IO a
unEval_ :: IO a}
deriving (forall a b. a -> Eval b -> Eval a
forall a b. (a -> b) -> Eval a -> Eval b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: forall a b. a -> Eval b -> Eval a
$c<$ :: forall a b. a -> Eval b -> Eval a
fmap :: forall a b. (a -> b) -> Eval a -> Eval b
$cfmap :: forall a b. (a -> b) -> Eval a -> Eval b
Functor, Functor Eval
forall a. a -> Eval a
forall a b. Eval a -> Eval b -> Eval a
forall a b. Eval a -> Eval b -> Eval b
forall a b. Eval (a -> b) -> Eval a -> Eval b
forall a b c. (a -> b -> c) -> Eval a -> Eval b -> Eval c
forall (f :: * -> *).
Functor f
-> (forall a. a -> f a)
-> (forall a b. f (a -> b) -> f a -> f b)
-> (forall a b c. (a -> b -> c) -> f a -> f b -> f c)
-> (forall a b. f a -> f b -> f b)
-> (forall a b. f a -> f b -> f a)
-> Applicative f
<* :: forall a b. Eval a -> Eval b -> Eval a
$c<* :: forall a b. Eval a -> Eval b -> Eval a
*> :: forall a b. Eval a -> Eval b -> Eval b
$c*> :: forall a b. Eval a -> Eval b -> Eval b
liftA2 :: forall a b c. (a -> b -> c) -> Eval a -> Eval b -> Eval c
$cliftA2 :: forall a b c. (a -> b -> c) -> Eval a -> Eval b -> Eval c
<*> :: forall a b. Eval (a -> b) -> Eval a -> Eval b
$c<*> :: forall a b. Eval (a -> b) -> Eval a -> Eval b
pure :: forall a. a -> Eval a
$cpure :: forall a. a -> Eval a
Applicative, Applicative Eval
forall a. a -> Eval a
forall a b. Eval a -> Eval b -> Eval b
forall a b. Eval a -> (a -> Eval b) -> Eval b
forall (m :: * -> *).
Applicative m
-> (forall a b. m a -> (a -> m b) -> m b)
-> (forall a b. m a -> m b -> m b)
-> (forall a. a -> m a)
-> Monad m
return :: forall a. a -> Eval a
$creturn :: forall a. a -> Eval a
>> :: forall a b. Eval a -> Eval b -> Eval b
$c>> :: forall a b. Eval a -> Eval b -> Eval b
>>= :: forall a b. Eval a -> (a -> Eval b) -> Eval b
$c>>= :: forall a b. Eval a -> (a -> Eval b) -> Eval b
Monad)
runEval :: Eval a -> a
# if MIN_VERSION_base(4,4,0)
runEval :: forall a. Eval a -> a
runEval = forall a. IO a -> a
unsafeDupablePerformIO forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Eval a -> IO a
unEval_
# else
runEval = unsafePerformIO . unEval_
# endif
runEvalIO :: Eval a -> IO a
runEvalIO :: forall a. Eval a -> IO a
runEvalIO = forall a. Eval a -> IO a
unEval_
instance MonadFix Eval where
mfix :: forall a. (a -> Eval a) -> Eval a
mfix a -> Eval a
k = forall a. IO a -> Eval a
Eval forall a b. (a -> b) -> a -> b
$ forall a. (State# RealWorld -> (# State# RealWorld, a #)) -> IO a
IO forall a b. (a -> b) -> a -> b
$ \ State# RealWorld
s ->
let ans :: Evret a
ans = forall a. Eval a -> State# RealWorld -> Evret a
liftEv (a -> Eval a
k a
r) State# RealWorld
s
Evret State# RealWorld
_ a
r = Evret a
ans
in
case Evret a
ans of Evret State# RealWorld
s' a
x -> (# State# RealWorld
s', a
x #)
data Evret a = Evret (State# RealWorld) a
liftEv :: Eval a -> State# RealWorld -> Evret a
liftEv :: forall a. Eval a -> State# RealWorld -> Evret a
liftEv (Eval (IO State# RealWorld -> (# State# RealWorld, a #)
m)) = \State# RealWorld
s -> case State# RealWorld -> (# State# RealWorld, a #)
m State# RealWorld
s of (# State# RealWorld
s', a
r #) -> forall a. State# RealWorld -> a -> Evret a
Evret State# RealWorld
s' a
r
#else
data Eval a = Done a
runEval :: Eval a -> a
runEval (Done x) = x
runEvalIO :: Eval a -> IO a
runEvalIO (Done x) = return x
instance Functor Eval where
fmap = liftM
instance Applicative Eval where
pure = Done
(<*>) = ap
instance Monad Eval where
return = pure
Done x >>= k = lazy (k x)
instance MonadFix Eval where
mfix f = let r = f (runEval r) in r
{-# RULES "lazy Done" forall x . lazy (Done x) = Done x #-}
#endif
type Strategy a = a -> Eval a
using :: a -> Strategy a -> a
a
x using :: forall a. a -> Strategy a -> a
`using` Strategy a
strat = forall a. Eval a -> a
runEval (Strategy a
strat a
x)
withStrategy :: Strategy a -> a -> a
withStrategy :: forall a. Strategy a -> a -> a
withStrategy = forall a b c. (a -> b -> c) -> b -> a -> c
flip forall a. a -> Strategy a -> a
using
usingIO :: a -> Strategy a -> IO a
a
x usingIO :: forall a. a -> Strategy a -> IO a
`usingIO` Strategy a
strat = forall a. Eval a -> IO a
runEvalIO (Strategy a
strat a
x)
withStrategyIO :: Strategy a -> a -> IO a
withStrategyIO :: forall a. Strategy a -> a -> IO a
withStrategyIO = forall a b c. (a -> b -> c) -> b -> a -> c
flip forall a. a -> Strategy a -> IO a
usingIO
dot :: Strategy a -> Strategy a -> Strategy a
Strategy a
strat2 dot :: forall a. Strategy a -> Strategy a -> Strategy a
`dot` Strategy a
strat1 = Strategy a
strat2 forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Eval a -> a
runEval forall b c a. (b -> c) -> (a -> b) -> a -> c
. Strategy a
strat1
evalSeq :: SeqStrategy a -> Strategy a
evalSeq :: forall a. SeqStrategy a -> Strategy a
evalSeq SeqStrategy a
strat a
x = SeqStrategy a
strat a
x forall a b. a -> b -> b
`pseq` forall (m :: * -> *) a. Monad m => a -> m a
return a
x
type SeqStrategy a = Control.Seq.Strategy a
r0 :: Strategy a
r0 :: forall a. a -> Eval a
r0 a
x = forall (m :: * -> *) a. Monad m => a -> m a
return a
x
rseq :: Strategy a
#if __GLASGOW_HASKELL__ >= 702
rseq :: forall a. a -> Eval a
rseq a
x = forall a. IO a -> Eval a
Eval (forall a. a -> IO a
evaluate a
x)
#else
rseq x = x `seq` return x
#endif
{-# NOINLINE [1] rseq #-}
rdeepseq :: NFData a => Strategy a
rdeepseq :: forall a. NFData a => Strategy a
rdeepseq a
x = do forall a. a -> Eval a
rseq (forall a. NFData a => a -> ()
rnf a
x); forall (m :: * -> *) a. Monad m => a -> m a
return a
x
rpar :: Strategy a
#if __GLASGOW_HASKELL__ >= 702
rpar :: forall a. a -> Eval a
rpar a
x = forall a. IO a -> Eval a
Eval forall a b. (a -> b) -> a -> b
$ forall a. (State# RealWorld -> (# State# RealWorld, a #)) -> IO a
IO forall a b. (a -> b) -> a -> b
$ \State# RealWorld
s -> forall a d. a -> State# d -> (# State# d, a #)
spark# a
x State# RealWorld
s
#else
rpar x = case (par# x) of { _ -> Done x }
#endif
{-# INLINE rpar #-}
rparWith :: Strategy a -> Strategy a
rparWith :: forall a. Strategy a -> Strategy a
rparWith Strategy a
strat = forall a. Eval a -> Eval a
parEval forall b c a. (b -> c) -> (a -> b) -> a -> c
. Strategy a
strat
parEval :: Eval a -> Eval a
parEval :: forall a. Eval a -> Eval a
parEval Eval a
m = do
Lift a
l <- forall a. a -> Eval a
rpar Lift a
r
forall (m :: * -> *) a. Monad m => a -> m a
return (case Lift a
l of Lift a
x -> a
x)
where
r :: Lift a
r = forall a. Eval a -> a
runEval (forall a. a -> Lift a
Lift forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Eval a
m)
data Lift a = Lift a
evalTraversable :: Traversable t => Strategy a -> Strategy (t a)
evalTraversable :: forall (t :: * -> *) a.
Traversable t =>
Strategy a -> Strategy (t a)
evalTraversable = forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse
{-# INLINE evalTraversable #-}
parTraversable :: Traversable t => Strategy a -> Strategy (t a)
parTraversable :: forall (t :: * -> *) a.
Traversable t =>
Strategy a -> Strategy (t a)
parTraversable Strategy a
strat = forall (t :: * -> *) a.
Traversable t =>
Strategy a -> Strategy (t a)
evalTraversable (forall a. Strategy a -> Strategy a
rparWith Strategy a
strat)
{-# INLINE parTraversable #-}
evalList :: Strategy a -> Strategy [a]
evalList :: forall a. Strategy a -> Strategy [a]
evalList = forall (t :: * -> *) a.
Traversable t =>
Strategy a -> Strategy (t a)
evalTraversable
parList :: Strategy a -> Strategy [a]
parList :: forall a. Strategy a -> Strategy [a]
parList = forall (t :: * -> *) a.
Traversable t =>
Strategy a -> Strategy (t a)
parTraversable
evalListSplitAt :: Int -> Strategy [a] -> Strategy [a] -> Strategy [a]
evalListSplitAt :: forall a. Int -> Strategy [a] -> Strategy [a] -> Strategy [a]
evalListSplitAt Int
n Strategy [a]
stratPref Strategy [a]
stratSuff [a]
xs
= let ([a]
ys,[a]
zs) = forall a. Int -> [a] -> ([a], [a])
splitAt Int
n [a]
xs in
Strategy [a]
stratPref [a]
ys forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \[a]
ys' ->
Strategy [a]
stratSuff [a]
zs forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \[a]
zs' ->
forall (m :: * -> *) a. Monad m => a -> m a
return ([a]
ys' forall a. [a] -> [a] -> [a]
++ [a]
zs')
parListSplitAt :: Int -> Strategy [a] -> Strategy [a] -> Strategy [a]
parListSplitAt :: forall a. Int -> Strategy [a] -> Strategy [a] -> Strategy [a]
parListSplitAt Int
n Strategy [a]
stratPref Strategy [a]
stratSuff = forall a. Int -> Strategy [a] -> Strategy [a] -> Strategy [a]
evalListSplitAt Int
n (forall a. Strategy a -> Strategy a
rparWith Strategy [a]
stratPref) (forall a. Strategy a -> Strategy a
rparWith Strategy [a]
stratSuff)
evalListN :: Int -> Strategy a -> Strategy [a]
evalListN :: forall a. Int -> Strategy a -> Strategy [a]
evalListN Int
n Strategy a
strat = forall a. Int -> Strategy [a] -> Strategy [a] -> Strategy [a]
evalListSplitAt Int
n (forall a. Strategy a -> Strategy [a]
evalList Strategy a
strat) forall a. a -> Eval a
r0
parListN :: Int -> Strategy a -> Strategy [a]
parListN :: forall a. Int -> Strategy a -> Strategy [a]
parListN Int
n Strategy a
strat = forall a. Int -> Strategy a -> Strategy [a]
evalListN Int
n (forall a. Strategy a -> Strategy a
rparWith Strategy a
strat)
evalListNth :: Int -> Strategy a -> Strategy [a]
evalListNth :: forall a. Int -> Strategy a -> Strategy [a]
evalListNth Int
n Strategy a
strat = forall a. Int -> Strategy [a] -> Strategy [a] -> Strategy [a]
evalListSplitAt Int
n forall a. a -> Eval a
r0 (forall a. Int -> Strategy a -> Strategy [a]
evalListN Int
1 Strategy a
strat)
parListNth :: Int -> Strategy a -> Strategy [a]
parListNth :: forall a. Int -> Strategy a -> Strategy [a]
parListNth Int
n Strategy a
strat = forall a. Int -> Strategy a -> Strategy [a]
evalListNth Int
n (forall a. Strategy a -> Strategy a
rparWith Strategy a
strat)
parListChunk :: Int -> Strategy a -> Strategy [a]
parListChunk :: forall a. Int -> Strategy a -> Strategy [a]
parListChunk Int
n Strategy a
strat [a]
xs
| Int
n forall a. Ord a => a -> a -> Bool
<= Int
1 = forall a. Strategy a -> Strategy [a]
parList Strategy a
strat [a]
xs
| Bool
otherwise = forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
`fmap` forall a. Strategy a -> Strategy [a]
parList (forall a. Strategy a -> Strategy [a]
evalList Strategy a
strat) (forall a. Int -> [a] -> [[a]]
chunk Int
n [a]
xs)
chunk :: Int -> [a] -> [[a]]
chunk :: forall a. Int -> [a] -> [[a]]
chunk Int
_ [] = []
chunk Int
n [a]
xs = [a]
as forall a. a -> [a] -> [a]
: forall a. Int -> [a] -> [[a]]
chunk Int
n [a]
bs where ([a]
as,[a]
bs) = forall a. Int -> [a] -> ([a], [a])
splitAt Int
n [a]
xs
parMap :: Strategy b -> (a -> b) -> [a] -> [b]
parMap :: forall b a. Strategy b -> (a -> b) -> [a] -> [b]
parMap Strategy b
strat a -> b
f = (forall a. a -> Strategy a -> a
`using` forall a. Strategy a -> Strategy [a]
parList Strategy b
strat) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. (a -> b) -> [a] -> [b]
map a -> b
f
evalBufferWHNF :: Int -> Strategy [a]
evalBufferWHNF :: forall a. Int -> Strategy [a]
evalBufferWHNF Int
n0 [a]
xs0 = forall (m :: * -> *) a. Monad m => a -> m a
return (forall {a} {a}. [a] -> [a] -> [a]
ret [a]
xs0 (forall {t} {a}. (Eq t, Num t) => t -> [a] -> [a]
start Int
n0 [a]
xs0))
where
ret :: [a] -> [a] -> [a]
ret (a
x:[a]
xs) (a
y:[a]
ys) = a
y forall a b. a -> b -> b
`pseq` (a
x forall a. a -> [a] -> [a]
: [a] -> [a] -> [a]
ret [a]
xs [a]
ys)
ret [a]
xs [a]
_ = [a]
xs
start :: t -> [a] -> [a]
start t
0 [a]
ys = [a]
ys
start !t
_n [] = []
start !t
n (a
y:[a]
ys) = a
y forall a b. a -> b -> b
`pseq` t -> [a] -> [a]
start (t
nforall a. Num a => a -> a -> a
-t
1) [a]
ys
evalBuffer :: Int -> Strategy a -> Strategy [a]
evalBuffer :: forall a. Int -> Strategy a -> Strategy [a]
evalBuffer Int
n Strategy a
strat = forall a. Int -> Strategy [a]
evalBufferWHNF Int
n forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. (a -> b) -> [a] -> [b]
map (forall a. Strategy a -> a -> a
withStrategy Strategy a
strat)
parBufferWHNF :: Int -> Strategy [a]
parBufferWHNF :: forall a. Int -> Strategy [a]
parBufferWHNF Int
n0 [a]
xs0 = forall (m :: * -> *) a. Monad m => a -> m a
return (forall {a} {a}. [a] -> [a] -> [a]
ret [a]
xs0 (forall {t} {a}. (Eq t, Num t) => t -> [a] -> [a]
start Int
n0 [a]
xs0))
where
ret :: [a] -> [a] -> [a]
ret (a
x:[a]
xs) (a
y:[a]
ys) = a
y forall a b. a -> b -> b
`par` (a
x forall a. a -> [a] -> [a]
: [a] -> [a] -> [a]
ret [a]
xs [a]
ys)
ret [a]
xs [a]
_ = [a]
xs
start :: t -> [a] -> [a]
start t
0 [a]
ys = [a]
ys
start !t
_n [] = []
start !t
n (a
y:[a]
ys) = a
y forall a b. a -> b -> b
`par` t -> [a] -> [a]
start (t
nforall a. Num a => a -> a -> a
-t
1) [a]
ys
parBuffer :: Int -> Strategy a -> Strategy [a]
parBuffer :: forall a. Int -> Strategy a -> Strategy [a]
parBuffer Int
n Strategy a
strat = forall a. Int -> Strategy [a]
parBufferWHNF Int
n forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. (a -> b) -> [a] -> [b]
map (forall a. Strategy a -> a -> a
withStrategy Strategy a
strat)
{-# NOINLINE [1] evalBuffer #-}
{-# NOINLINE [1] parBuffer #-}
{-# RULES
"evalBuffer/rseq" forall n . evalBuffer n rseq = evalBufferWHNF n
"parBuffer/rseq" forall n . parBuffer n rseq = parBufferWHNF n
#-}
evalTuple2 :: Strategy a -> Strategy b -> Strategy (a,b)
evalTuple2 :: forall a b. Strategy a -> Strategy b -> Strategy (a, b)
evalTuple2 Strategy a
strat1 Strategy b
strat2 (a
x1,b
x2) =
forall (f :: * -> *) a. Applicative f => a -> f a
pure (,) forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Strategy a
strat1 a
x1 forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Strategy b
strat2 b
x2
evalTuple3 :: Strategy a -> Strategy b -> Strategy c -> Strategy (a,b,c)
evalTuple3 :: forall a b c.
Strategy a -> Strategy b -> Strategy c -> Strategy (a, b, c)
evalTuple3 Strategy a
strat1 Strategy b
strat2 Strategy c
strat3 (a
x1,b
x2,c
x3) =
forall (f :: * -> *) a. Applicative f => a -> f a
pure (,,) forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Strategy a
strat1 a
x1 forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Strategy b
strat2 b
x2 forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Strategy c
strat3 c
x3
evalTuple4 :: Strategy a -> Strategy b -> Strategy c -> Strategy d -> Strategy (a,b,c,d)
evalTuple4 :: forall a b c d.
Strategy a
-> Strategy b -> Strategy c -> Strategy d -> Strategy (a, b, c, d)
evalTuple4 Strategy a
strat1 Strategy b
strat2 Strategy c
strat3 Strategy d
strat4 (a
x1,b
x2,c
x3,d
x4) =
forall (f :: * -> *) a. Applicative f => a -> f a
pure (,,,) forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Strategy a
strat1 a
x1 forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Strategy b
strat2 b
x2 forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Strategy c
strat3 c
x3 forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Strategy d
strat4 d
x4
evalTuple5 :: Strategy a -> Strategy b -> Strategy c -> Strategy d -> Strategy e -> Strategy (a,b,c,d,e)
evalTuple5 :: forall a b c d e.
Strategy a
-> Strategy b
-> Strategy c
-> Strategy d
-> Strategy e
-> Strategy (a, b, c, d, e)
evalTuple5 Strategy a
strat1 Strategy b
strat2 Strategy c
strat3 Strategy d
strat4 Strategy e
strat5 (a
x1,b
x2,c
x3,d
x4,e
x5) =
forall (f :: * -> *) a. Applicative f => a -> f a
pure (,,,,) forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Strategy a
strat1 a
x1 forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Strategy b
strat2 b
x2 forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Strategy c
strat3 c
x3 forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Strategy d
strat4 d
x4 forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Strategy e
strat5 e
x5
evalTuple6 :: Strategy a -> Strategy b -> Strategy c -> Strategy d -> Strategy e -> Strategy f -> Strategy (a,b,c,d,e,f)
evalTuple6 :: forall a b c d e f.
Strategy a
-> Strategy b
-> Strategy c
-> Strategy d
-> Strategy e
-> Strategy f
-> Strategy (a, b, c, d, e, f)
evalTuple6 Strategy a
strat1 Strategy b
strat2 Strategy c
strat3 Strategy d
strat4 Strategy e
strat5 Strategy f
strat6 (a
x1,b
x2,c
x3,d
x4,e
x5,f
x6) =
forall (f :: * -> *) a. Applicative f => a -> f a
pure (,,,,,) forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Strategy a
strat1 a
x1 forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Strategy b
strat2 b
x2 forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Strategy c
strat3 c
x3 forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Strategy d
strat4 d
x4 forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Strategy e
strat5 e
x5 forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Strategy f
strat6 f
x6
evalTuple7 :: Strategy a -> Strategy b -> Strategy c -> Strategy d -> Strategy e -> Strategy f -> Strategy g -> Strategy (a,b,c,d,e,f,g)
evalTuple7 :: forall a b c d e f g.
Strategy a
-> Strategy b
-> Strategy c
-> Strategy d
-> Strategy e
-> Strategy f
-> Strategy g
-> Strategy (a, b, c, d, e, f, g)
evalTuple7 Strategy a
strat1 Strategy b
strat2 Strategy c
strat3 Strategy d
strat4 Strategy e
strat5 Strategy f
strat6 Strategy g
strat7 (a
x1,b
x2,c
x3,d
x4,e
x5,f
x6,g
x7) =
forall (f :: * -> *) a. Applicative f => a -> f a
pure (,,,,,,) forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Strategy a
strat1 a
x1 forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Strategy b
strat2 b
x2 forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Strategy c
strat3 c
x3 forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Strategy d
strat4 d
x4 forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Strategy e
strat5 e
x5 forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Strategy f
strat6 f
x6 forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Strategy g
strat7 g
x7
evalTuple8 :: Strategy a -> Strategy b -> Strategy c -> Strategy d -> Strategy e -> Strategy f -> Strategy g -> Strategy h -> Strategy (a,b,c,d,e,f,g,h)
evalTuple8 :: forall a b c d e f g h.
Strategy a
-> Strategy b
-> Strategy c
-> Strategy d
-> Strategy e
-> Strategy f
-> Strategy g
-> Strategy h
-> Strategy (a, b, c, d, e, f, g, h)
evalTuple8 Strategy a
strat1 Strategy b
strat2 Strategy c
strat3 Strategy d
strat4 Strategy e
strat5 Strategy f
strat6 Strategy g
strat7 Strategy h
strat8 (a
x1,b
x2,c
x3,d
x4,e
x5,f
x6,g
x7,h
x8) =
forall (f :: * -> *) a. Applicative f => a -> f a
pure (,,,,,,,) forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Strategy a
strat1 a
x1 forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Strategy b
strat2 b
x2 forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Strategy c
strat3 c
x3 forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Strategy d
strat4 d
x4 forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Strategy e
strat5 e
x5 forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Strategy f
strat6 f
x6 forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Strategy g
strat7 g
x7 forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Strategy h
strat8 h
x8
evalTuple9 :: Strategy a -> Strategy b -> Strategy c -> Strategy d -> Strategy e -> Strategy f -> Strategy g -> Strategy h -> Strategy i -> Strategy (a,b,c,d,e,f,g,h,i)
evalTuple9 :: forall a b c d e f g h i.
Strategy a
-> Strategy b
-> Strategy c
-> Strategy d
-> Strategy e
-> Strategy f
-> Strategy g
-> Strategy h
-> Strategy i
-> Strategy (a, b, c, d, e, f, g, h, i)
evalTuple9 Strategy a
strat1 Strategy b
strat2 Strategy c
strat3 Strategy d
strat4 Strategy e
strat5 Strategy f
strat6 Strategy g
strat7 Strategy h
strat8 Strategy i
strat9 (a
x1,b
x2,c
x3,d
x4,e
x5,f
x6,g
x7,h
x8,i
x9) =
forall (f :: * -> *) a. Applicative f => a -> f a
pure (,,,,,,,,) forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Strategy a
strat1 a
x1 forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Strategy b
strat2 b
x2 forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Strategy c
strat3 c
x3 forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Strategy d
strat4 d
x4 forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Strategy e
strat5 e
x5 forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Strategy f
strat6 f
x6 forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Strategy g
strat7 g
x7 forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Strategy h
strat8 h
x8 forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Strategy i
strat9 i
x9
parTuple2 :: Strategy a -> Strategy b -> Strategy (a,b)
parTuple2 :: forall a b. Strategy a -> Strategy b -> Strategy (a, b)
parTuple2 Strategy a
strat1 Strategy b
strat2 =
forall a b. Strategy a -> Strategy b -> Strategy (a, b)
evalTuple2 (forall a. Strategy a -> Strategy a
rparWith Strategy a
strat1) (forall a. Strategy a -> Strategy a
rparWith Strategy b
strat2)
parTuple3 :: Strategy a -> Strategy b -> Strategy c -> Strategy (a,b,c)
parTuple3 :: forall a b c.
Strategy a -> Strategy b -> Strategy c -> Strategy (a, b, c)
parTuple3 Strategy a
strat1 Strategy b
strat2 Strategy c
strat3 =
forall a b c.
Strategy a -> Strategy b -> Strategy c -> Strategy (a, b, c)
evalTuple3 (forall a. Strategy a -> Strategy a
rparWith Strategy a
strat1) (forall a. Strategy a -> Strategy a
rparWith Strategy b
strat2) (forall a. Strategy a -> Strategy a
rparWith Strategy c
strat3)
parTuple4 :: Strategy a -> Strategy b -> Strategy c -> Strategy d -> Strategy (a,b,c,d)
parTuple4 :: forall a b c d.
Strategy a
-> Strategy b -> Strategy c -> Strategy d -> Strategy (a, b, c, d)
parTuple4 Strategy a
strat1 Strategy b
strat2 Strategy c
strat3 Strategy d
strat4 =
forall a b c d.
Strategy a
-> Strategy b -> Strategy c -> Strategy d -> Strategy (a, b, c, d)
evalTuple4 (forall a. Strategy a -> Strategy a
rparWith Strategy a
strat1) (forall a. Strategy a -> Strategy a
rparWith Strategy b
strat2) (forall a. Strategy a -> Strategy a
rparWith Strategy c
strat3) (forall a. Strategy a -> Strategy a
rparWith Strategy d
strat4)
parTuple5 :: Strategy a -> Strategy b -> Strategy c -> Strategy d -> Strategy e -> Strategy (a,b,c,d,e)
parTuple5 :: forall a b c d e.
Strategy a
-> Strategy b
-> Strategy c
-> Strategy d
-> Strategy e
-> Strategy (a, b, c, d, e)
parTuple5 Strategy a
strat1 Strategy b
strat2 Strategy c
strat3 Strategy d
strat4 Strategy e
strat5 =
forall a b c d e.
Strategy a
-> Strategy b
-> Strategy c
-> Strategy d
-> Strategy e
-> Strategy (a, b, c, d, e)
evalTuple5 (forall a. Strategy a -> Strategy a
rparWith Strategy a
strat1) (forall a. Strategy a -> Strategy a
rparWith Strategy b
strat2) (forall a. Strategy a -> Strategy a
rparWith Strategy c
strat3) (forall a. Strategy a -> Strategy a
rparWith Strategy d
strat4) (forall a. Strategy a -> Strategy a
rparWith Strategy e
strat5)
parTuple6 :: Strategy a -> Strategy b -> Strategy c -> Strategy d -> Strategy e -> Strategy f -> Strategy (a,b,c,d,e,f)
parTuple6 :: forall a b c d e f.
Strategy a
-> Strategy b
-> Strategy c
-> Strategy d
-> Strategy e
-> Strategy f
-> Strategy (a, b, c, d, e, f)
parTuple6 Strategy a
strat1 Strategy b
strat2 Strategy c
strat3 Strategy d
strat4 Strategy e
strat5 Strategy f
strat6 =
forall a b c d e f.
Strategy a
-> Strategy b
-> Strategy c
-> Strategy d
-> Strategy e
-> Strategy f
-> Strategy (a, b, c, d, e, f)
evalTuple6 (forall a. Strategy a -> Strategy a
rparWith Strategy a
strat1) (forall a. Strategy a -> Strategy a
rparWith Strategy b
strat2) (forall a. Strategy a -> Strategy a
rparWith Strategy c
strat3) (forall a. Strategy a -> Strategy a
rparWith Strategy d
strat4) (forall a. Strategy a -> Strategy a
rparWith Strategy e
strat5) (forall a. Strategy a -> Strategy a
rparWith Strategy f
strat6)
parTuple7 :: Strategy a -> Strategy b -> Strategy c -> Strategy d -> Strategy e -> Strategy f -> Strategy g -> Strategy (a,b,c,d,e,f,g)
parTuple7 :: forall a b c d e f g.
Strategy a
-> Strategy b
-> Strategy c
-> Strategy d
-> Strategy e
-> Strategy f
-> Strategy g
-> Strategy (a, b, c, d, e, f, g)
parTuple7 Strategy a
strat1 Strategy b
strat2 Strategy c
strat3 Strategy d
strat4 Strategy e
strat5 Strategy f
strat6 Strategy g
strat7 =
forall a b c d e f g.
Strategy a
-> Strategy b
-> Strategy c
-> Strategy d
-> Strategy e
-> Strategy f
-> Strategy g
-> Strategy (a, b, c, d, e, f, g)
evalTuple7 (forall a. Strategy a -> Strategy a
rparWith Strategy a
strat1) (forall a. Strategy a -> Strategy a
rparWith Strategy b
strat2) (forall a. Strategy a -> Strategy a
rparWith Strategy c
strat3) (forall a. Strategy a -> Strategy a
rparWith Strategy d
strat4) (forall a. Strategy a -> Strategy a
rparWith Strategy e
strat5) (forall a. Strategy a -> Strategy a
rparWith Strategy f
strat6) (forall a. Strategy a -> Strategy a
rparWith Strategy g
strat7)
parTuple8 :: Strategy a -> Strategy b -> Strategy c -> Strategy d -> Strategy e -> Strategy f -> Strategy g -> Strategy h -> Strategy (a,b,c,d,e,f,g,h)
parTuple8 :: forall a b c d e f g h.
Strategy a
-> Strategy b
-> Strategy c
-> Strategy d
-> Strategy e
-> Strategy f
-> Strategy g
-> Strategy h
-> Strategy (a, b, c, d, e, f, g, h)
parTuple8 Strategy a
strat1 Strategy b
strat2 Strategy c
strat3 Strategy d
strat4 Strategy e
strat5 Strategy f
strat6 Strategy g
strat7 Strategy h
strat8 =
forall a b c d e f g h.
Strategy a
-> Strategy b
-> Strategy c
-> Strategy d
-> Strategy e
-> Strategy f
-> Strategy g
-> Strategy h
-> Strategy (a, b, c, d, e, f, g, h)
evalTuple8 (forall a. Strategy a -> Strategy a
rparWith Strategy a
strat1) (forall a. Strategy a -> Strategy a
rparWith Strategy b
strat2) (forall a. Strategy a -> Strategy a
rparWith Strategy c
strat3) (forall a. Strategy a -> Strategy a
rparWith Strategy d
strat4) (forall a. Strategy a -> Strategy a
rparWith Strategy e
strat5) (forall a. Strategy a -> Strategy a
rparWith Strategy f
strat6) (forall a. Strategy a -> Strategy a
rparWith Strategy g
strat7) (forall a. Strategy a -> Strategy a
rparWith Strategy h
strat8)
parTuple9 :: Strategy a -> Strategy b -> Strategy c -> Strategy d -> Strategy e -> Strategy f -> Strategy g -> Strategy h -> Strategy i -> Strategy (a,b,c,d,e,f,g,h,i)
parTuple9 :: forall a b c d e f g h i.
Strategy a
-> Strategy b
-> Strategy c
-> Strategy d
-> Strategy e
-> Strategy f
-> Strategy g
-> Strategy h
-> Strategy i
-> Strategy (a, b, c, d, e, f, g, h, i)
parTuple9 Strategy a
strat1 Strategy b
strat2 Strategy c
strat3 Strategy d
strat4 Strategy e
strat5 Strategy f
strat6 Strategy g
strat7 Strategy h
strat8 Strategy i
strat9 =
forall a b c d e f g h i.
Strategy a
-> Strategy b
-> Strategy c
-> Strategy d
-> Strategy e
-> Strategy f
-> Strategy g
-> Strategy h
-> Strategy i
-> Strategy (a, b, c, d, e, f, g, h, i)
evalTuple9 (forall a. Strategy a -> Strategy a
rparWith Strategy a
strat1) (forall a. Strategy a -> Strategy a
rparWith Strategy b
strat2) (forall a. Strategy a -> Strategy a
rparWith Strategy c
strat3) (forall a. Strategy a -> Strategy a
rparWith Strategy d
strat4) (forall a. Strategy a -> Strategy a
rparWith Strategy e
strat5) (forall a. Strategy a -> Strategy a
rparWith Strategy f
strat6) (forall a. Strategy a -> Strategy a
rparWith Strategy g
strat7) (forall a. Strategy a -> Strategy a
rparWith Strategy h
strat8) (forall a. Strategy a -> Strategy a
rparWith Strategy i
strat9)
($|) :: (a -> b) -> Strategy a -> a -> b
a -> b
f $| :: forall a b. (a -> b) -> Strategy a -> a -> b
$| Strategy a
s = \ a
x -> let z :: a
z = a
x forall a. a -> Strategy a -> a
`using` Strategy a
s in a
z forall a b. a -> b -> b
`pseq` a -> b
f a
z
($||) :: (a -> b) -> Strategy a -> a -> b
a -> b
f $|| :: forall a b. (a -> b) -> Strategy a -> a -> b
$|| Strategy a
s = \ a
x -> let z :: a
z = a
x forall a. a -> Strategy a -> a
`using` Strategy a
s in a
z forall a b. a -> b -> b
`par` a -> b
f a
z
(.|) :: (b -> c) -> Strategy b -> (a -> b) -> (a -> c)
.| :: forall b c a. (b -> c) -> Strategy b -> (a -> b) -> a -> c
(.|) b -> c
f Strategy b
s a -> b
g = \ a
x -> let z :: b
z = a -> b
g a
x forall a. a -> Strategy a -> a
`using` Strategy b
s in
b
z forall a b. a -> b -> b
`pseq` b -> c
f b
z
(.||) :: (b -> c) -> Strategy b -> (a -> b) -> (a -> c)
.|| :: forall b c a. (b -> c) -> Strategy b -> (a -> b) -> a -> c
(.||) b -> c
f Strategy b
s a -> b
g = \ a
x -> let z :: b
z = a -> b
g a
x forall a. a -> Strategy a -> a
`using` Strategy b
s in
b
z forall a b. a -> b -> b
`par` b -> c
f b
z
(-|) :: (a -> b) -> Strategy b -> (b -> c) -> (a -> c)
-| :: forall a b c. (a -> b) -> Strategy b -> (b -> c) -> a -> c
(-|) a -> b
f Strategy b
s b -> c
g = \ a
x -> let z :: b
z = a -> b
f a
x forall a. a -> Strategy a -> a
`using` Strategy b
s in
b
z forall a b. a -> b -> b
`pseq` b -> c
g b
z
(-||) :: (a -> b) -> Strategy b -> (b -> c) -> (a -> c)
-|| :: forall a b c. (a -> b) -> Strategy b -> (b -> c) -> a -> c
(-||) a -> b
f Strategy b
s b -> c
g = \ a
x -> let z :: b
z = a -> b
f a
x forall a. a -> Strategy a -> a
`using` Strategy b
s in
b
z forall a b. a -> b -> b
`par` b -> c
g b
z
{-# DEPRECATED Done "The Strategy type is now a -> Eval a, not a -> Done" #-}
type Done = ()
{-# DEPRECATED demanding "Use pseq or $| instead" #-}
demanding :: a -> Done -> a
demanding :: forall a. a -> () -> a
demanding = forall a b c. (a -> b -> c) -> b -> a -> c
flip forall a b. a -> b -> b
pseq
{-# DEPRECATED sparking "Use par or $|| instead" #-}
sparking :: a -> Done -> a
sparking :: forall a. a -> () -> a
sparking = forall a b c. (a -> b -> c) -> b -> a -> c
flip forall a b. a -> b -> b
par
{-# DEPRECATED (>|) "Use pseq or $| instead" #-}
(>|) :: Done -> Done -> Done
>| :: () -> () -> ()
(>|) = seq :: forall a b. a -> b -> b
Prelude.seq
{-# DEPRECATED (>||) "Use par or $|| instead" #-}
(>||) :: Done -> Done -> Done
>|| :: () -> () -> ()
(>||) = forall a b. a -> b -> b
par
{-# DEPRECATED rwhnf "renamed to rseq" #-}
rwhnf :: Strategy a
rwhnf :: forall a. a -> Eval a
rwhnf = forall a. a -> Eval a
rseq
{-# DEPRECATED seqTraverse "renamed to evalTraversable" #-}
seqTraverse :: Traversable t => Strategy a -> Strategy (t a)
seqTraverse :: forall (t :: * -> *) a.
Traversable t =>
Strategy a -> Strategy (t a)
seqTraverse = forall (t :: * -> *) a.
Traversable t =>
Strategy a -> Strategy (t a)
evalTraversable
{-# DEPRECATED parTraverse "renamed to parTraversable" #-}
parTraverse :: Traversable t => Strategy a -> Strategy (t a)
parTraverse :: forall (t :: * -> *) a.
Traversable t =>
Strategy a -> Strategy (t a)
parTraverse = forall (t :: * -> *) a.
Traversable t =>
Strategy a -> Strategy (t a)
parTraversable
{-# DEPRECATED seqList "renamed to evalList" #-}
seqList :: Strategy a -> Strategy [a]
seqList :: forall a. Strategy a -> Strategy [a]
seqList = forall a. Strategy a -> Strategy [a]
evalList
{-# DEPRECATED seqPair "renamed to evalTuple2" #-}
seqPair :: Strategy a -> Strategy b -> Strategy (a,b)
seqPair :: forall a b. Strategy a -> Strategy b -> Strategy (a, b)
seqPair = forall a b. Strategy a -> Strategy b -> Strategy (a, b)
evalTuple2
{-# DEPRECATED parPair "renamed to parTuple2" #-}
parPair :: Strategy a -> Strategy b -> Strategy (a,b)
parPair :: forall a b. Strategy a -> Strategy b -> Strategy (a, b)
parPair = forall a b. Strategy a -> Strategy b -> Strategy (a, b)
parTuple2
{-# DEPRECATED seqTriple "renamed to evalTuple3" #-}
seqTriple :: Strategy a -> Strategy b -> Strategy c -> Strategy (a,b,c)
seqTriple :: forall a b c.
Strategy a -> Strategy b -> Strategy c -> Strategy (a, b, c)
seqTriple = forall a b c.
Strategy a -> Strategy b -> Strategy c -> Strategy (a, b, c)
evalTuple3
{-# DEPRECATED parTriple "renamed to parTuple3" #-}
parTriple :: Strategy a -> Strategy b -> Strategy c -> Strategy (a,b,c)
parTriple :: forall a b c.
Strategy a -> Strategy b -> Strategy c -> Strategy (a, b, c)
parTriple = forall a b c.
Strategy a -> Strategy b -> Strategy c -> Strategy (a, b, c)
parTuple3
{-# DEPRECATED unEval "renamed to runEval" #-}
unEval :: Eval a -> a
unEval :: forall a. Eval a -> a
unEval = forall a. Eval a -> a
runEval