Skip to content

Commit c94818a

Browse files
LukaJCBpaf31
LukaJCB
authored andcommitted
Add parallel apply (#20)
* Add parallel apply * Add doc comment and refactor * Remove parAp operator
1 parent 2bfbc35 commit c94818a

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/Control/Parallel.purs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ module Control.Parallel
55
, parSequence_
66
, parOneOf
77
, parOneOfMap
8+
, parApply
89
, module Control.Parallel.Class
910
) where
1011

@@ -16,6 +17,16 @@ import Control.Parallel.Class (class Parallel, parallel, sequential, ParCont(..)
1617
import Data.Foldable (class Foldable, traverse_, oneOfMap)
1718
import Data.Traversable (class Traversable, traverse)
1819

20+
-- | Apply a function to an arguement under a type constructor in parallel.
21+
parApply
22+
:: forall f m a b
23+
. Parallel f m
24+
=> m (a -> b)
25+
-> m a
26+
-> m b
27+
parApply mf ma = sequential(apply (parallel mf) (parallel ma))
28+
29+
1930
-- | Traverse a collection in parallel.
2031
parTraverse
2132
:: forall f m t a b

0 commit comments

Comments
 (0)