Package fj.control.parallel
Class ParModule
java.lang.Object
fj.control.parallel.ParModule
A module of higher-order concurrency features.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionactor()
A first-class constructor of actors.<A> Actor
<A> Creates a concurrent actor that is guaranteed to process only one message at a time.effect()
A first-class constructor of concurrent effects, as actors that don't guarantee ordering of messages.<A> Actor
<A> Creates a very fast concurrent effect, as an actor that does not guarantee ordering of its messages.mapList()
First-class function that maps a concurrent function over a List inside a promise.Takes a Promise-valued function and applies it to each element in the given List, yielding a promise of a List of results.Takes a Promise-valued function and applies it to each element in the given Stream, yielding a promise of a Stream of results.Maps a concurrent function over a Product-1 inside a Promise.First-class function that maps a concurrent function over a Stream inside a promise.<A,
B> Promise <NonEmptyList<B>> parExtend
(NonEmptyList<A> as, F<NonEmptyList<A>, B> f) Maps the given function across all sublists of the given NonEmptyList in parallel.Maps the given function across all subtrees of the given Tree in parallel.<A,
B> Promise <TreeZipper<B>> parExtend
(TreeZipper<A> za, F<TreeZipper<A>, B> f) Maps the given function across all positions of the given TreeZipper in parallel.Maps the given function across all positions of the given zipper in parallel.parFlatMap
(Array<A> as, F<A, Array<B>> f) Binds an Array-valued function across an Array in parallel, concatenating the results into a new Array.parFlatMap
(List<A> as, F<A, List<B>> f) Binds a list-valued function across a list in parallel, concatenating the results into a new list.parFlatMap
(Stream<A> as, F<A, Stream<B>> f) Binds a Stream-valued function across a Stream in parallel, concatenating the results into a new Stream.parFlatMap
(Iterable<A> as, F<A, Iterable<B>> f) Binds an Iterable-valued function across an Iterable in parallel, concatenating the results into a new Iterable.<A,
B> Promise <B> parFoldMap
(Stream<A> as, F<A, B> map, Monoid<B> reduce) Maps with the given function across the given stream in parallel, while folding with the given monoid.<A,
B> Promise <B> parFoldMap
(Stream<A> as, F<A, B> map, Monoid<B> reduce, F<Stream<A>, P2<Stream<A>, Stream<A>>> chunking) Maps with the given function across chunks of the given stream in parallel, while folding with the given monoid.<A,
B> Promise <B> parFoldMap
(Iterable<A> as, F<A, B> map, Monoid<B> reduce) Maps with the given function across the given iterable in parallel, while folding with the given monoid.<A,
B> Promise <B> parFoldMap
(Iterable<A> as, F<A, B> map, Monoid<B> reduce, F<Iterable<A>, P2<Iterable<A>, Iterable<A>>> chunking) Maps with the given function across chunks of the given Iterable in parallel, while folding with the given monoid.Maps across an Array in parallel.Maps across a list in parallel.<A,
B> Promise <NonEmptyList<B>> parMap
(NonEmptyList<A> as, F<A, B> f) Maps across a nonempty list in parallel.Maps across a Stream in parallel.Maps a function across a Tree in parallel.<A,
B> Promise <TreeZipper<B>> parMap
(TreeZipper<A> za, F<A, B> f) Maps a function across a TreeZipper in parallel.Maps a function across a Zipper in parallel.Maps across an Iterable in parallel.A first-class function that maps another function across an array in parallel.A first-class function that maps another function across an iterable in parallel.A first-class function that maps another function across a list in parallel.A first-class function that maps another function across a stream in parallel.A first-class function that maps across a Tree in parallel.static ParModule
Constructor method for ParModuleparZipWith
(Array<A> as, Array<B> bs, F<A, F<B, C>> f) Zips two arrays together with a given function, in parallel.parZipWith
(List<A> as, List<B> bs, F<A, F<B, C>> f) Zips two lists together with a given function, in parallel.parZipWith
(Stream<A> as, Stream<B> bs, F<A, F<B, C>> f) Zips two streams together with a given function, in parallel.parZipWith
(Iterable<A> as, Iterable<B> bs, F<A, F<B, C>> f) Zips two iterables together with a given function, in parallel.promise()
Returns a function that evaluates a given product concurrently and returns a Promise of the result.Promotes the given function to a concurrent function that returns a Promise.Promotes the given function to a concurrent function that returns a Promise.<A> Promise
<A> Evaluates the given product concurrently and returns a Promise of the result.Returns a function that promotes a given function to a concurrent function that returns a Promise.List iteration inside a Promise.Stream iteration inside a Promise.Traverses a product-1 inside a promise.A first-class function that traverses a list inside a promise.A first-class function that traverses a stream inside a promise.
-
Field Details
-
strategy
-
-
Constructor Details
-
ParModule
-
-
Method Details
-
parModule
Constructor method for ParModule- Parameters:
u
- A parallel strategy for the module.- Returns:
- A ParModule that uses the given strategy for parallelism.
-
promise
Evaluates the given product concurrently and returns a Promise of the result.- Parameters:
p
- A product to evaluate concurrently.- Returns:
- A Promise of the value of the given product, that can be claimed in the future.
-
promise
Returns a function that evaluates a given product concurrently and returns a Promise of the result.- Returns:
- a function that evaluates a given product concurrently and returns a Promise of the result.
-
promise
Promotes the given function to a concurrent function that returns a Promise.- Parameters:
f
- A given function to promote to a concurrent function.- Returns:
- A function that is applied concurrently when given an argument, yielding a Promise of the result that can be claimed in the future.
-
promisePure
Returns a function that promotes a given function to a concurrent function that returns a Promise. The pure Kleisli arrow of Promise.- Returns:
- A higher-order function that takes pure functions to promise-valued functions.
-
promise
Promotes the given function to a concurrent function that returns a Promise.- Parameters:
f
- A given function to promote to a concurrent function.- Returns:
- A function that is applied concurrently when given an argument, yielding a Promise of the result that can be claimed in the future.
-
effect
Creates a very fast concurrent effect, as an actor that does not guarantee ordering of its messages. Such an actor is not thread-safe unless the given Effect is.- Parameters:
e
- The effect that the actor should have on its messages.- Returns:
- A concurrent actor that does not guarantee ordering of its messages.
-
effect
A first-class constructor of concurrent effects, as actors that don't guarantee ordering of messages. Such an actor is not thread-safe unless the given Effect is.- Returns:
- A function that takes an effect and returns a concurrent effect.
-
actor
Creates a concurrent actor that is guaranteed to process only one message at a time.- Parameters:
e
- The effect that the actor should have on its messages.- Returns:
- A concurrent actor that is guaranteed to process its messages in order.
-
actor
A first-class constructor of actors.- Returns:
- A function that takes an effect and returns an actor that processes messages in some order.
-
sequence
List iteration inside a Promise. Traverses a List of Promises yielding a Promise of a List.- Parameters:
ps
- A list of promises to sequence.- Returns:
- A promise of the List of values promised by the list of promises.
-
sequenceList
A first-class function that traverses a list inside a promise.- Returns:
- A first-class function that traverses a list inside a promise.
-
sequence
Stream iteration inside a Promise. Traverses a Stream of Promises yielding a Promise of a Stream.- Parameters:
ps
- A Stream of promises to sequence.- Returns:
- A promise of the Stream of values promised by the Stream of promises.
-
sequenceStream
A first-class function that traverses a stream inside a promise.- Returns:
- A first-class function that traverses a stream inside a promise.
-
sequence
Traverses a product-1 inside a promise.- Parameters:
p
- A product-1 of a promised value.- Returns:
- A promise of a product of the value promised by the argument.
-
mapM
Takes a Promise-valued function and applies it to each element in the given List, yielding a promise of a List of results.- Parameters:
as
- A list to map across.f
- A promise-valued function to map across the list.- Returns:
- A Promise of a new list with the given function applied to each element.
-
mapList
First-class function that maps a concurrent function over a List inside a promise.- Returns:
- a function that maps a concurrent function over a List inside a promise.
-
mapM
Takes a Promise-valued function and applies it to each element in the given Stream, yielding a promise of a Stream of results.- Parameters:
as
- A Stream to map across.f
- A promise-valued function to map across the Stream.- Returns:
- A Promise of a new Stream with the given function applied to each element.
-
mapStream
First-class function that maps a concurrent function over a Stream inside a promise.- Returns:
- a function that maps a concurrent function over a Stream inside a promise.
-
mapM
Maps a concurrent function over a Product-1 inside a Promise.- Parameters:
a
- A product-1 across which to map.f
- A concurrent function to map over the product inside a promise.- Returns:
- A promised product of the result of mapping the given function over the given product.
-
parMap
Maps across a list in parallel.- Parameters:
as
- A list to map across in parallel.f
- A function to map across the given list.- Returns:
- A Promise of a new list with the given function applied to each element.
-
parMapList
A first-class function that maps another function across a list in parallel.- Returns:
- A function that maps another function across a list in parallel.
-
parMap
Maps across a nonempty list in parallel.- Parameters:
as
- A NonEmptyList to map across in parallel.f
- A function to map across the given NonEmptyList.- Returns:
- A Promise of a new NonEmptyList with the given function applied to each element.
-
parMap
Maps across a Stream in parallel.- Parameters:
as
- A Stream to map across in parallel.f
- A function to map across the given Stream.- Returns:
- A Promise of a new Stream with the given function applied to each element.
-
parMapStream
A first-class function that maps another function across a stream in parallel.- Returns:
- A function that maps another function across a stream in parallel.
-
parMap
Maps across an Iterable in parallel.- Parameters:
as
- An Iterable to map across in parallel.f
- A function to map across the given Iterable.- Returns:
- A Promise of a new Iterable with the given function applied to each element.
-
parMapIterable
A first-class function that maps another function across an iterable in parallel.- Returns:
- A function that maps another function across an iterable in parallel.
-
parMap
Maps across an Array in parallel.- Parameters:
as
- An array to map across in parallel.f
- A function to map across the given Array.- Returns:
- A Promise of a new Array with the given function applied to each element.
-
parMapArray
A first-class function that maps another function across an array in parallel.- Returns:
- A function that maps another function across an array in parallel.
-
parMap
Maps a function across a Zipper in parallel.- Parameters:
za
- A Zipper to map across in parallel.f
- A function to map across the given Zipper.- Returns:
- A promise of a new Zipper with the given function applied to each element.
-
parMap
Maps a function across a Tree in parallel.- Parameters:
ta
- A Tree to map across in parallel.f
- A function to map across the given Tree.- Returns:
- A promise of a new Tree with the given function applied to each element.
-
parMapTree
A first-class function that maps across a Tree in parallel.- Returns:
- A function that maps a given function across a Tree in parallel.
-
parMap
Maps a function across a TreeZipper in parallel.- Parameters:
za
- A TreeZipper to map across in parallel.f
- A function to map across the given TreeZipper.- Returns:
- A promise of a new TreeZipper with the given function applied to each element of the tree.
-
parFlatMap
Binds a list-valued function across a list in parallel, concatenating the results into a new list.- Parameters:
as
- A list to bind across in parallel.f
- A function to bind across the given list in parallel.- Returns:
- A promise of a new List with the given function bound across its elements.
-
parFlatMap
Binds a Stream-valued function across a Stream in parallel, concatenating the results into a new Stream.- Parameters:
as
- A Stream to bind across in parallel.f
- A function to bind across the given Stream in parallel.- Returns:
- A promise of a new Stream with the given function bound across its elements.
-
parFlatMap
Binds an Array-valued function across an Array in parallel, concatenating the results into a new Array.- Parameters:
as
- An Array to bind across in parallel.f
- A function to bind across the given Array in parallel.- Returns:
- A promise of a new Array with the given function bound across its elements.
-
parFlatMap
Binds an Iterable-valued function across an Iterable in parallel, concatenating the results into a new Iterable.- Parameters:
as
- A Iterable to bind across in parallel.f
- A function to bind across the given Iterable in parallel.- Returns:
- A promise of a new Iterable with the given function bound across its elements.
-
parZipWith
Zips two lists together with a given function, in parallel.- Parameters:
as
- A list to zip with another in parallel.bs
- A list to zip with another in parallel.f
- A function with which to zip two lists in parallel.- Returns:
- A Promise of a new list with the results of applying the given function across the two lists in lockstep.
-
parZipWith
Zips two streams together with a given function, in parallel.- Parameters:
as
- A stream to zip with another in parallel.bs
- A stream to zip with another in parallel.f
- A function with which to zip two streams in parallel.- Returns:
- A Promise of a new stream with the results of applying the given function across the two streams, stepwise.
-
parZipWith
Zips two arrays together with a given function, in parallel.- Parameters:
as
- An array to zip with another in parallel.bs
- An array to zip with another in parallel.f
- A function with which to zip two arrays in parallel.- Returns:
- A Promise of a new array with the results of applying the given function across the two arrays, stepwise.
-
parZipWith
Zips two iterables together with a given function, in parallel.- Parameters:
as
- An iterable to zip with another in parallel.bs
- An iterable to zip with another in parallel.f
- A function with which to zip two iterables in parallel.- Returns:
- A Promise of a new iterable with the results of applying the given function across the two iterables, stepwise.
-
parFoldMap
Maps with the given function across the given stream in parallel, while folding with the given monoid.- Parameters:
as
- A stream to map over and reduce.map
- The function to map over the given stream.reduce
- The monoid with which to sum the results.- Returns:
- A promise of a result of mapping and folding in parallel.
-
parFoldMap
public <A,B> Promise<B> parFoldMap(Stream<A> as, F<A, B> map, Monoid<B> reduce, F<Stream<A>, P2<Stream<A>, Stream<A>>> chunking) Maps with the given function across chunks of the given stream in parallel, while folding with the given monoid. The stream is split into chunks according to the given chunking function, the given map function is mapped over all chunks simultaneously, but over each chunk sequentially. All chunks are summed concurrently and the sums are then summed sequentially.- Parameters:
as
- A stream to chunk, then map over and reduce.map
- The function to map over the given stream.reduce
- The monoid with which to sum the results.chunking
- A function describing how the stream should be split into chunks. Should return the first chunk and the rest of the stream.- Returns:
- A promise of a result of mapping and folding in parallel.
-
parFoldMap
public <A,B> Promise<B> parFoldMap(Iterable<A> as, F<A, B> map, Monoid<B> reduce, F<Iterable<A>, P2<Iterable<A>, Iterable<A>>> chunking) Maps with the given function across chunks of the given Iterable in parallel, while folding with the given monoid. The Iterable is split into chunks according to the given chunking function, the given map function is mapped over all chunks simultaneously, but over each chunk sequentially. All chunks are summed concurrently and the sums are then summed sequentially.- Parameters:
as
- An Iterable to chunk, then map over and reduce.map
- The function to map over the given Iterable.reduce
- The monoid with which to sum the results.chunking
- A function describing how the Iterable should be split into chunks. Should return the first chunk and the rest of the Iterable.- Returns:
- A promise of a result of mapping and folding in parallel.
-
parFoldMap
Maps with the given function across the given iterable in parallel, while folding with the given monoid.- Parameters:
as
- An Iterable to map over and reduce.map
- The function to map over the given Iterable.reduce
- The Monoid with which to sum the results.- Returns:
- A promise of a result of mapping and folding in parallel.
-
parExtend
Maps the given function across all positions of the given zipper in parallel.- Parameters:
za
- A zipper to extend the given function across.f
- A function to extend across the given zipper.- Returns:
- A promise of a new zipper of the results of applying the given function to all positions of the given zipper.
-
parExtend
Maps the given function across all subtrees of the given Tree in parallel.- Parameters:
ta
- A tree to extend the given function across.f
- A function to extend across the given Tree.- Returns:
- A promise of a new Tree of the results of applying the given function to all subtrees of the given Tree.
-
parExtend
Maps the given function across all positions of the given TreeZipper in parallel.- Parameters:
za
- A TreeZipper to extend the given function across.f
- A function to extend across the given TreeZipper.- Returns:
- A promise of a new TreeZipper of the results of applying the given function to all positions of the given TreeZipper.
-
parExtend
Maps the given function across all sublists of the given NonEmptyList in parallel.- Parameters:
as
- A NonEmptyList to extend the given function across.f
- A function to extend across the given NonEmptyList- Returns:
- A promise of a new NonEmptyList of the results of applying the given function to all sublists of the given NonEmptyList.
-