Releases: aol/cyclops-integration
v8.20 of cyclops: Lazy extended collections, Streaming utilities and more for Project Reactor
8.2.0 Release of Cyclops
Integration module enhancements
Reactor
- Lazy extended Collections
- Lazy persistent extended Collections
- Streaming Utilities - Pipes and FluxSource for 'pushable' Streams
- For comprehension syntax / API enhancement
- Native Monad Transformers for Monos
- Native for comprehensions for MonoT types
- Version bump to Reactor 3!
RxJava
- For comprehension syntax / API enhancement
Lazy extended Collections
Standard JDK collections
- LazyListX
- LazyDequeX
- LazyQueueX
- LazySetX
- LazySortedX
Persistent collections
- LazyPStackX (A persistent LinkedList)
- LazyPVectorX (A persistent Vector - an ArrayList analogue)
- LazyPQueueX (A persistent Queue)
- LazyPSetX (A persistent Set)
- LazyPOrderedSetX (A persistent OrderedSet)
- LazyPBagX (A persistent Bag)
Notes :
- Lazy collections can not contain nulls (extended operations will result in NullPointerException), use ListX from cyclops-react for an extended List that can contain nulls
- Data access / modifications operations are eager (transformations are lazy)
- A Lazy Collection is not a Stream, eager operations result in the materialization of the entire list (there is no short circuiting, for example)
LazyListX
LazyListX extends ListX from cyclops-react (and JDK java.util.List).
ListX<Integer> lazy = LazyListX.fromIterable(myIterable);
//lazily define operations
ListX<ListX<Integer>> transformed = lazy.map(i->i*2)
.filter(i->i<100)
.grouped(2);
//operations performed when data is accessed
transformed.get(0).reduce(0,(a,b)->a+b);
Notes : (repeated for LazyListX only - holds for all)
- LazyListX can not contain nulls (extended operations will result in NullPointerException), use ListX from cyclops-react for an extended List that can contain nulls
- Data access / modifications operations are eager (transformations are lazy)
- A LazyList is not a Stream, eager operations result in the materialization of the entire list (there is no short circuiting, for example)
LazyDequeX
LazyDequeX extends DequeX from cyclops-react (and JDK java.util.Deque).
DequeX<Integer> lazy = LazyDequeX.fromIterable(myIterable);
//lazily define operations
DequeX<ListX<Integer>> transformed = lazy.map(i->i*2)
.filter(i->i<100)
.grouped(2);
//operations performed when data is accessed
transformed.get(0).reduce(0,(a,b)->a+b);
LazyQueueX
LazyQueueX extends QueueX from cyclops-react (and JDK java.util.Deque).
QueueX<Integer> lazy = LazyQueueX.fromIterable(myIterable);
//lazily define operations
LazyQueueX<ListX<Integer>> transformed = lazy.map(i->i*2)
.filter(i->i<100)
.sliding(2,1);
//operations performed when data is accessed
transformed.get(0).reduce(0,(a,b)->a+b);
FluxSource
For pushing data into Flux and Mono types
PushableFlux<Integer> pushable = FluxSource.ofUnbounded();
pushable.getQueue()
.offer(1);
//on a separate thread
pushable.getFlux()
.map(i->i*2)
.subscribe(System.out::println);
//then push data into your Flux
pushable.getQueue()
.offer(2);
//close the transfer Queue
pushable.getQueue()
.close();
Documentation for StreamSource (cyclops-react / extended JDK analogue of FluxSource)
Blog post on pushing data into Java 8 Streams
Documentation for working with Queues
Joining Streams with ReactorPipes
ReactorPipes provides an API for flexible joining of multple different Stream types.
ReactorPipes<String,Integer> pipes = ReactorPipes.of();
//store a transfer Queue with a max size of 1,000 entries
pipes.register("transfer1",QueueFactories.boundedQueue(1_000));
//connect a Flux to transfer1
Maybe<Flux<Integer>> connected = pipes.flux("transfer1");
Flux<Integer> stream = connected.get();
//Setup a producing Stream
ReactiveSeq seq = ReactiveSeq.generate(this::loadData)
.map(this::processData);
pipes.publishToAsync("transfer1",seq);
stream.map(e->handleNextElement(e))
.subscribe(this::save);
Example for comprehensions with Flux
import static com.aol.cyclops.reactor.Fluxes.forEach;
Flux<Integer> result = forEach(Flux.just(10,20),a->Flux.<Integer>just(a+10)
,(a,b)->a+b);
//Flux[30,50]
Example for comprehensions with Mono
import static com.aol.cyclops.reactor.Monos.forEach;
Mono<Integer> result = forEach(Mono.just(10),a->Mono.<Integer>just(a+10)
,(a,b)->a+b);
//Mono[30]
FluxT monad transformer
import static com.aol.cyclops.reactor.FluxTs.fluxT;
FluxTSeq<Integer> nested = fluxT(Flux.just(Flux.just(1,2,3),Flux.just(10,20,30)));
FluxTSeq<Integer> mapped = nested.map(i->i*3);
//mapped = [Flux[Flux[3,6,9],Flux30,60,90]]
MonoT monad transformer
import static com.aol.cyclops.reactor.MonoTs.monoT;
MonoTSeq<Integer> nestedFuture = monoT(Flux.just(Mono.just(1),Mono.just(10)));
mapped = nested.map(i->i*3);
//mapped = [Flux[Mono[3],Mono[30]]
Getting Cyclops 8.2.0
MODULE_NAMES : cyclops-rx, cyclops-reactor, cyclops-guava, cyclops-functionaljava, cyclops-javaslang
Gradle
compile 'com.aol.cyclops:MODULE_NAME:8.2.0’
Maven
<dependency>
<groupId>com.aol.cyclops</groupId>
<artifactId>MODULE_NAME</artifactId>
<version>8.2.0</version>
</dependency>
Javadoc
http://www.javadoc.io/doc/com.aol.cyclops/cyclops-rx/8.2.0
http://www.javadoc.io/doc/com.aol.cyclops/cyclops-reactor/8.2.0
http://www.javadoc.io/doc/com.aol.cyclops/cyclops-javaslang/8.2.0
http://www.javadoc.io/doc/com.aol.cyclops/cyclops-functionaljava/8.2.0
http://www.javadoc.io/doc/com.aol.cyclops/cyclops-guava/8.2.0
v8.1.0 of cyclops : Upgrade to cyclops-react : 1.0.0-FINAL
8.1.0 Release of Cyclops
Upgrade to cyclops-react v1.0.0-FINAL : https://github.com/aol/cyclops-react
Getting Cyclops 8.1.0
MODULE_NAMES : cyclops-rx, cyclops-reactor, cyclops-guava, cyclops-functionaljava, cyclops-javaslang
Gradle
compile 'com.aol.cyclops:MODULE_NAME:8.1.0’
Maven
<dependency>
<groupId>com.aol.cyclops</groupId>
<artifactId>MODULE_NAME</artifactId>
<version>8.1.0</version>
</dependency>
Javadoc
http://www.javadoc.io/doc/com.aol.cyclops/cyclops-rx/8.1.0
http://www.javadoc.io/doc/com.aol.cyclops/cyclops-reactor/8.1.0
http://www.javadoc.io/doc/com.aol.cyclops/cyclops-javaslang/8.1.0
http://www.javadoc.io/doc/com.aol.cyclops/cyclops-functionaljava/8.1.0
http://www.javadoc.io/doc/com.aol.cyclops/cyclops-guava/8.1.0
v8.0.1 of cyclops : cyclops-react version 1.0.0-RC4 : Native Monad Transformers and comprehensions for Observable and Flux
8.0.1 Release of Cyclops
Upgrade to cyclops-react v1.0.0-RC4 : https://github.com/aol/cyclops-react
Integration modules enhancements
RxJava
- Native Monad Transformers for Observable
- Native for comprehensions for ObservableT types
Reactor
- Native Monad Transformers for Flux
- Native for comprehensions for FluxT types
- Version bump
Getting Cyclops 8.0.1
MODULE_NAMES : cyclops-rx, cyclops-reactor, cyclops-guava, cyclops-functionaljava, cyclops-javaslang
Gradle
compile 'com.aol.cyclops:MODULE_NAME:8.0.1’
Maven
<dependency>
<groupId>com.aol.cyclops</groupId>
<artifactId>MODULE_NAME</artifactId>
<version>8.0.1</version>
</dependency>
Javadoc
http://www.javadoc.io/doc/com.aol.cyclops/cyclops-rx/8.0.1
http://www.javadoc.io/doc/com.aol.cyclops/cyclops-reactor/8.0.1
http://www.javadoc.io/doc/com.aol.cyclops/cyclops-javaslang/8.0.1
http://www.javadoc.io/doc/com.aol.cyclops/cyclops-functionaljava/8.0.1
http://www.javadoc.io/doc/com.aol.cyclops/cyclops-guava/8.0.1
v8.0.0 of cyclops : Upgrade to cyclops-react 1.0.0 : RxJava, Reactor, FunctionalJava,Guava, Javaslang
8.0.0 Release of Cyclops
Upgrade to cyclops-react v1.0.0-RC3 : https://github.com/aol/cyclops-react
8.0.0 Brings back the Cyclops integration modules
- RxJava, Reactor, Guava, FunctionalJava, Javaslang
- Full for-comprehension support for each type
- AnyM support for types : wrap any datatype for RxJava, Reactor, Guava, FunctionalJava, Javaslang in a common interface and have it behave as monad, applicative functor, comonad (for values) or ReactiveStream. Usable inside cyclops-react MonadTransformers.
Examples
For Comprehensions
import static com.aol.cyclops.reactor.Reactor.ForFlux;
Flux<Tuple2<Integer,Integer>> stream = ForFlux.each2(Flux.range(1,10), i->Flux.range(i, 10), Tuple::tuple);
Applicative Functor
import static com.aol.cyclops.functionaljava.FJ.option;
option(some(2)).ap(Semigroups.intMult)
.ap(option(some(10));
//Some[20]
Comonad
import static com.aol.cyclops.javaslang.Javaslang.value;
value(Option.none())
.coflatMap(v->v.isPresent()? v.get() : 10);
//Option[10]
reactive-streams
import static com.aol.cyclops.javaslang.Javaslang.traversable;
SeqSubscriber<Integer> sub = SeqSubscriber.subscriber();
traversable(List.of(1,2,3)).subscribe(sub);
sub.stream()
.forEachWithError(System.out::println, System.err::println);
Getting Cyclops 8.0.0
MODULE_NAMES : cyclops-rx, cyclops-reactor, cyclops-guava, cyclops-functionaljava, cyclops-javaslang
Gradle
compile 'com.aol.cyclops:MODULE_NAME:8.0.0’
Maven
<dependency>
<groupId>com.aol.cyclops</groupId>
<artifactId>MODULE_NAME</artifactId>
<version>8.0.0</version>
</dependency>
Javadoc
http://www.javadoc.io/doc/com.aol.cyclops/cyclops-rx/8.0.0
http://www.javadoc.io/doc/com.aol.cyclops/cyclops-reactor/8.0.0
http://www.javadoc.io/doc/com.aol.cyclops/cyclops-javaslang/8.0.0
http://www.javadoc.io/doc/com.aol.cyclops/cyclops-functionaljava/8.0.0
http://www.javadoc.io/doc/com.aol.cyclops/cyclops-guava/8.0.0
v7.3.0 of Cyclops : Collection eXtensions, FluentFunctions, PausableHotStreams, jooλ upgrade, javaslang ReactiveStream
7.3.0 Release of Cyclops
7.3.0 is a bumper release featuring
- Fluent Collection eXtensions : Adds a large number of operators to JDK collections, and JDK compatible persistent pCollections.
- Fluent Functions : aop, caching, logging, exception handling and more
- Stream enhancements - pausable hotstreams, trampoline operator
- Module reorganisation - don’t worry all the existing functionality is still here!
- jooλ upgrade - awesome new Stream Windowing operators and Collectors
- javaslang - a javaslang ReactiveStream (and LazyStream) implementation
Examples
Collection eXtensions
Java List (X)
ListX.of(1,2,3)
.map(i->i+2)
.plus(5)
.map(i->"hello" + i)
.forEach(System.out::println);
//prints
hello2
hello4
hello5
hello5
pCollections PStackX
PStackX.of(1,2,3,4,10)
.map(i->i+2)
.dropRight(2)
.plus(5)
.map(i->"hello" + i)
.forEach(System.out::println);
//prints
hello2
hello4
hello5
hello5
FluentFunctions
Retry
FluentFunctions.ofChecked(this::exceptionalFirstTime)
.println()
.retry(2,500)
.apply("hello");
(fluent-function-Parameter[hello])
java.io.IOException
at com.aol.cyclops.functions.fluent.FunctionsTest.exceptionalFirstTime(FunctionsTest.java:95)
...
(fluent-function-Parameter[hello])
(fluent-function-Result[hello world])
Caching
Cache<Object, Integer> cache = CacheBuilder.newBuilder()
.maximumSize(1000)
.expireAfterWrite(10, TimeUnit.MINUTES)
.build();
called=0;
Function<Integer,Integer> fn = FluentFunctions.of(this::addOne)
.name("myFunction")
.memoize((key,f)->cache.get(key,()->f.apply(key)));
fn.apply(10);
fn.apply(10);
fn.apply(10);
assertThat(called,equalTo(1));
Javaslang ReactiveStream
ReactiveStream.generate(this::load)
.map(this::process)
.forEachWithError(this::save,this::logError);
jooλ 0.9.10 features
Example 27. jOOλ windowing with pretty print
An example from jOOλ windowing blog entry.
System.out.println(
SequenceM.of("a", "a", "a", "b", "c", "c", "d", "e")
//create a window
.window(naturalOrder())
//produce a table from the window
.map(w -> tuple(
w.value(), // v0
w.count(), // v1
w.median(), // v2
w.lead(), // v3
w.lag(), // v4
w.toString() // v5
))
.format()
);
+----+----+----+---------+---------+----------+
| v0 | v1 | v2 | v3 | v4 | v5 |
+----+----+----+---------+---------+----------+
| a | 1 | a | a | {empty} | a |
| a | 2 | a | a | a | aa |
| a | 3 | a | b | a | aaa |
| b | 4 | a | c | a | aaab |
| c | 5 | a | c | b | aaabc |
| c | 6 | a | d | c | aaabcc |
| d | 7 | b | e | c | aaabccd |
| e | 8 | b | {empty} | d | aaabccde |
+----+----+----+---------+---------+----------+
Feature Tracking
- Module reorg enhancement #179 opened 28 minutes ago by johnmcclean-aol 7.3.0
- forEachWithErrors stopping after first error bug cyclops-javaslang cyclops-streams #178 opened a day ago by johnmcclean-aol 7.3.0
- Add forEachX, forEachWithErrors to javaslang ReactiveStream cyclops-javaslang enhancement #177 opened a day ago by johnmcclean-aol 7.3.0
- Create an Eval datatype enhancement #176 opened 2 days ago by johnmcclean-aol 7.3.0
- Javaslang sequence enhancement #174 opened 3 days ago by johnmcclean-aol 7.3.0
- Collectionx tests enhancement #173 opened 3 days ago by johnmcclean-aol 7.3.0
- Add map / flatMap methods to FluentFunction would turn it into a Reader monad implementation enhancement fluent-functions #172 opened 3 days ago by johnmcclean-aol 7.3.0
- Upgrade to jOOλ 0.9.10 enhancement #170 opened 3 days ago by johnmcclean-aol 7.3.0
- Add extensions for JDK and PCollection collections enhancement #169 opened 3 days ago by johnmcclean-aol 7.3.0
- Collection eXtensions enhancement #168 opened 3 days ago by johnmcclean-aol 7.3.0
- Fluent functions enhancement #166 opened 6 days ago by johnmcclean-aol 7.3.0
- Cacheable should soften CheckedExceptions enhancement #165 opened 6 days ago by johnmcclean-aol 7.3.0
- onePer and xPer deliverying impressions immediately bug cyclops-streams #164 opened 6 days ago by johnmcclean-aol 7.3.0
- Javaslang sequence enhancement #163 opened 7 days ago by johnmcclean-aol 7.3.0
- Variance matchable bug pattern matching #161 opened 10 days ago by johnmcclean-aol 7.3.0
- Pausable hot stream cyclops-streams enhancement HotStream #160 opened 10 days ago by johnmcclean-aol 7.3.0
- Jool0.9.9 cyclops-streams enhancement #159 opened 11 days ago by johnmcclean-aol 7.3.0
- lazy-head-and-tail and trampoline operator cyclops-streams enhancement #158 opened 12 days ago by johnmcclean-aol 7.3.0
- Make headAndTail Lazy cyclops-streams enhancement #157 opened 12 days ago by johnmcclean-aol 7.3.0
- Create pausable HotStreams cyclops-streams enhancement HotStream #155 opened 12 days ago by johnmcclean-aol 7.3.0
- Create a trampoline operator for stack based recursion within a stream cyclops-streams enhancement #154 opened 13 days ago by johnmcclean-aol 7.3.0
- Apply co/contra-variance correctly in Matchable interface bug pattern matching #151 opened 14 days ago by johnmcclean-aol 7.3.0
- Add a delayedHotStream operator that only starts the hotStream when another Stream connects cyclops-streams HotStream #148 opened 18 days ago by johnmcclean-aol 7.3.0
- Correctly apply covariance (? extends C) and contravariance (? super C) on generic method type usage bug #143 opened 20 days ago by lukaseder 7.3.0
- Should cyclops modules merge? enhancement question #135 opened 25 days ago by johnmcclean-aol 7.3.0
- dependency upgrade : jOOλ to 0.9.9 enhancement #132 opened 25 days ago by johnmcclean-aol 7.3.0
- dependency upgrade : upgrade to agron 0.4.9 enhancement #131 opened 26 days ago by johnmcclean-aol 7.3.0
- Merge the 3 pattern matching modules enhancement pattern matching #114 opened on Jan 1 by johnmcclean-aol 7.3.0
- cyclops-functions - fluent api for working with functions enhancement #107 opened on Dec 30, 2015 by johnmcclean-aol 7.3.0
Getting Cyclops 7.3.0
cyclops-core has all non-integration modules, but each module can be used / added individually (subject to it's own dependencies). Instructions for each module are in it's own readme.md.
Gradle
compile 'com.aol.cyclops:cyclops-core:7.3.0’
Maven
<dependency>
<groupId>com.aol.cyclops</groupId>
<artifactId>cyclops-core</artifactId>
<version>7.3.0</version>
</dependency>
http://www.javadoc.io/doc/com.aol.cyclops/cyclops-core/7.3.0
http://www.javadoc.io/doc/com.aol.cyclops/cyclops-streams/7.3.0
http://www.javadoc.io/doc/com.aol.cyclops/cyclops-functions/7.3.0
http://www.javadoc.io/doc/com.aol.cyclops/cyclops-pattern-matching/7.3.0
Integration modules
http://www.javadoc.io/doc/com.aol.cyclops/cyclops-javaslang/7.3.0
http://www.javadoc.io/doc/com.aol.cyclops/cyclops-functionaljava/7.3.0
http://www.javadoc.io/doc/com.aol.cyclops/cyclops-guava/7.3.0
v7.2.0 of cyclops
7.2.0 Release of Cyclops
Stream operators
forEachX Operators
Controlled forEach behaviour - synchronously and asynchronously (via FutureOperators). For SequenceM and JDK Streams
See also forEachXEvents, and forEachXWithErrors
<X extends Throwable> Subscription forEachX(long numberOfElements);
Subscription sub = SequenceM.of(1,2,3).forEachX(2,System.out::println);
//prints
1
2
sub.request(1);
//prints
3
ReactiveTask next = SequenceM.of(1,2,3,4)
.futureOperations(exec)
.forEachX(2,System.out::println)
.join();
System.out.println("First batch processed!");
next.request(2);
System.out.println("Second batch processed!");
//prints
1
2
First batch processed!
3
4
Second batch processed!
### forEachWithError Operator
Recieve errors and elements - synchronously and asynchronously (via FutureOperators). For SequenceM and JDK Streams
See also forEachEvent
```java
<X extends Throwable> void forEachWithError(Consumer<? super T> consumerElement,
Consumer<? super Throwable> consumerError);
SequenceM.of(1,2,3)
.map(this::loadById)
.forEachWithError(t->process(t),error->log(error));
Nested loops over multiple Streams
Feature Tracking
- cyclops-monad-api :SetT monad transformer
- cyclops-streams : HotStream closes connected Streams when transfer queue is empty
- cyclops-streams : Debounce returns last value in stream even if a value already sent for this time period
- TryT monad transformer
- cyclops-monad-api : Correctly handling primitive Streams
- cyclops-closures : Allow mutable to lazily modify / map inputs and outputs
- cyclops-invokde-dynamic : ExceptionSoftener add softenCallable method
- cyclops-closures : Add a Convertable mixin that allows a Supplier to be converted into a Stream, Optional, List, CompletableFuture, AtomicReference etc
- cyclops-moad-api : javadoc monad transformers
- Create primitive versions of Mutable
- cyclops-streams :- add scheduling capabilities for HotStreams
- cyclops-monad-api : New AnyM operators for-comprehensions
- cyclops-streams : singleOptional operator for SequenceM
- cyclops-streams : for-comprehension operators for SequenceM
- cyclops-streams : add scheduling operators to StreamUtils
- cyclops-javaslang : add scheduling for Javaslang Streams to Javaslang - StreamUtils
- cyclops-streams : HotStream closes connected Streams when transfer queue is empty
Getting Cyclops 7.2.0
cyclops-all has all non-integration modules, but each module can be used / added individually (subject to it's own dependencies). Instructions for each module are in it's own readme.md.
Gradle
compile 'com.aol.cyclops:cyclops-all:7.2.0'
Maven
<dependency>
<groupId>com.aol.cyclops</groupId>
<artifactId>cyclops-all</artifactId>
<version>7.2.0</version>
</dependency>
http://www.javadoc.io/doc/com.aol.cyclops/cyclops-sequence-api/7.2.0
http://www.javadoc.io/doc/com.aol.cyclops/cyclops-streams/7.2.0
http://www.javadoc.io/doc/com.aol.cyclops/cyclops-monad-api/7.2.0
http://www.javadoc.io/doc/com.aol.cyclops/cyclops-monad-functions/7.2.0
http://www.javadoc.io/doc/com.aol.cyclops/cyclops-mixins/7.2.0
http://www.javadoc.io/doc/com.aol.cyclops/cyclops-invokedynamic/7.2.0
http://www.javadoc.io/doc/com.aol.cyclops/cyclops-for-comprehensions/7.2.0
http://www.javadoc.io/doc/com.aol.cyclops/cyclops-functions/7.2.0
http://www.javadoc.io/doc/com.aol.cyclops/cyclops-try/7.2.0
http://www.javadoc.io/doc/com.aol.cyclops/pattern-matching/7.2.0
http://www.javadoc.io/doc/com.aol.cyclops/cyclops-trampoline/7.2.0
http://www.javadoc.io/doc/com.aol.cyclops/cyclops-feature-toggle/7.2.0
http://www.javadoc.io/doc/com.aol.cyclops/cyclops-core/7.2.0
http://www.javadoc.io/doc/com.aol.cyclops/cyclops-tuples/7.2.0
http://www.javadoc.io/doc/com.aol.cyclops/cyclops-all/7.2.0
http://www.javadoc.io/doc/com.aol.cyclops/cyclops-javaslang/7.2.0
http://www.javadoc.io/doc/com.aol.cyclops/cyclops-functionaljava/7.2.0
http://www.javadoc.io/doc/com.aol.cyclops/cyclops-guava/7.2.0
v7.1.0 of Cyclops : Streams - Scheduling & for-comprehensions, singleOptional operator, new monad transformers, Mutable enhancements
7.1.0 Release of Cyclops
Stream enhandements
Scheduling Streams
Run a job every minute and log to the db once per day.
SequenceM.generate( () -> "new job")
.map(this::process)
.schedule("0 * * * * ?", ex)
.connect()
.debounce(1,TimeUnit.DAYS)
.forEach(this::logToDb);
Available as a static method in StreamUtils for JDK and java slang Streams
Stream for-comprehensions
Nested loops over multiple Streams
SequenceM.of(1,2,3)
.forEach2(a->IntStream.range(0,10),
a->b-> a+b)
.toList()
//List[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 2, 3, 4, 5, 6, 7, 8,
9, 10, 11, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12)]
With the (optional) ability to filter
SequenceM.of(2,3)
.forEach3(a->IntStream.range(6,9),
a->b->IntStream.range(100,105),
a->b->c -> a==3,
a->b->c-> a+b+c)
//List[109, 110, 111, 112, 113, 110, 111, 112, 113, 114, 111, 112, 113, 114, 115]
Or use any monad type (via AnyM)
AnyM.streamOf(1,null,2,null,3)
.forEach2(a->AnyM.<Integer>fromOptional(Optional.ofNullable(a)),
a->b-> a+b)
//AnyM[Stream[1,2,3]]
singleOptional operator
//Optional[1]
SequenceM.of(1).singleOptional();
//Optional.empty
SequenceM.of().singleOpional();
//Optional.empty
SequenceM.of(1,2,3).singleOptional();
New Mutable methods and types
Mutable provides an API for encapsulated, or external, mutable values, for example, for mutating local variables inside Lambda Expressions.
New Mutable types
- MutableBoolean
- MutableByte
- MutableShort
- MutableFloat
- MutableChar
- MutableShort
Mutable<String> var = Mutable.of("hello");
Runnable r = () -> var.set("world");
String value = "world";
Mutable<String> ext = Mutable.fromExternal(()->value,v->this.value=v);
ext.set("hello");
MutableFloat myFloat = new MutableFloat(zero);
Function<Integer,Function<Integer,MutableFloat>> fn = ((Integer i)-> (Integer j)-> myFloatset(new Float((float)(i*j))));
fn.apply(10).apply(20);
//myFloat 200
Mutable<String> ext = Mutable.fromExternal(()->value,v->this.value=v)
.mapInput(s->s+"!");
ext.set("hello");
//value == "hello!"
New Monad Transformers
- TryT
- SetT
javadoc added for
- OptionalT
- StreamT
- StreamableT
- ListT
- CompletableFutureT
Function<Integer,Integer> add2 = i -> i+2;
Function<OptionalT<Integer>, OptionalT<Integer>> optTAdd2 = OptionalT.lift(add2);
Stream<Integer> withNulls = Stream.of(1,2,null);
AnyM<Integer> stream = AnyM.ofMonad(withNulls);
AnyM<Optional<Integer>> streamOpt = stream.map(Optional::ofNullable);
List<Integer> results = unwrapOptional(optTAdd2.apply(OptionalT.of(streamOpt)))
.filter(Optional::isPresent)
.map(Optional::get)
.collect(Collectors.toList());
//List(3,4);
New convertable mixin
Convertable.fromSupplier(()->null).orElse(11)
//11
Convertable.fromSupplier(()->10).toAtomicReference()
//AtomicReference[10]
Convertable.fromSupplier(()->10).toList()
//List(10)
etc.
Feature Tracking
- cyclops-monad-api :SetT monad transformer
- cyclops-streams : HotStream closes connected Streams when transfer queue is empty
- cyclops-streams : Debounce returns last value in stream even if a value already sent for this time period
- TryT monad transformer
- cyclops-monad-api : Correctly handling primitive Streams
- cyclops-closures : Allow mutable to lazily modify / map inputs and outputs
- cyclops-invokde-dynamic : ExceptionSoftener add softenCallable method
- cyclops-closures : Add a Convertable mixin that allows a Supplier to be converted into a Stream, Optional, List, CompletableFuture, AtomicReference etc
- cyclops-moad-api : javadoc monad transformers
- Create primitive versions of Mutable
- cyclops-streams :- add scheduling capabilities for HotStreams
- cyclops-monad-api : New AnyM operators for-comprehensions
- cyclops-streams : singleOptional operator for SequenceM
- cyclops-streams : for-comprehension operators for SequenceM
- cyclops-streams : add scheduling operators to StreamUtils
- cyclops-javaslang : add scheduling for Javaslang Streams to Javaslang - StreamUtils
- cyclops-streams : HotStream closes connected Streams when transfer queue is empty
Getting Cyclops 7.1.0
cyclops-all has all non-integration modules, but each module can be used / added individually (subject to it's own dependencies). Instructions for each module are in it's own readme.md.
Gradle
compile 'com.aol.cyclops:cyclops-all:7.1.0'
Maven
<dependency>
<groupId>com.aol.cyclops</groupId>
<artifactId>cyclops-all</artifactId>
<version>7.1.0</version>
</dependency>
http://www.javadoc.io/doc/com.aol.cyclops/cyclops-sequence-api/7.1.0
http://www.javadoc.io/doc/com.aol.cyclops/cyclops-streams/7.1.0
http://www.javadoc.io/doc/com.aol.cyclops/cyclops-monad-api/7.1.0
http://www.javadoc.io/doc/com.aol.cyclops/cyclops-monad-functions/7.1.0
http://www.javadoc.io/doc/com.aol.cyclops/cyclops-mixins/7.1.0
http://www.javadoc.io/doc/com.aol.cyclops/cyclops-invokedynamic/7.1.0
http://www.javadoc.io/doc/com.aol.cyclops/cyclops-for-comprehensions/7.1.0
http://www.javadoc.io/doc/com.aol.cyclops/cyclops-functions/7.1.0
http://www.javadoc.io/doc/com.aol.cyclops/cyclops-try/7.1.0
http://www.javadoc.io/doc/com.aol.cyclops/pattern-matching/7.1.0
http://www.javadoc.io/doc/com.aol.cyclops/cyclops-trampoline/7.1.0
http://www.javadoc.io/doc/com.aol.cyclops/cyclops-feature-toggle/7.1.0
http://www.javadoc.io/doc/com.aol.cyclops/cyclops-core/7.1.0
http://www.javadoc.io/doc/com.aol.cyclops/cyclops-tuples/7.1.0
http://www.javadoc.io/doc/com.aol.cyclops/cyclops-all/7.1.0
http://www.javadoc.io/doc/com.aol.cyclops/cyclops-javaslang/7.1.0
http://www.javadoc.io/doc/com.aol.cyclops/cyclops-functionaljava/7.1.0
http://www.javadoc.io/doc/com.aol.cyclops/cyclops-guava/7.1.0
v7.0.0 of Cyclops - Matchable interface, Exception Softening, Streamable, Monad Transformers - enhanced!
7.0.0 Release of Cyclops
Enhanced pattern matching via the Matchable interface
Matchable.of(Optional.of(4))
.mayMatch(
o-> o.isEmpty().then(i->"empty"),
o-> o.hasValues(1).then(i->"one"),
o-> o.hasValues(2).then(i->"two"),
o-> o.hasValuesWhere(i->i>2).then(i->"many"),
).orElse("error")
Enhanced Streamable with 100’s of operators
Streamable<String> replayable = Streamable.fromStream(myStream)
.map(str->str.length())
.scanLeft(0, (u, t) -> u + t);
Enhanced Exception Handling
ExceptionSoftener.softenFunction(this::load)
.apply("input");
public String load(String file) throws IOException{
throw new IOException();
}
New Monad Transformers
- StreamT
- StreamableT
- ListT
- CompletableFutureT
Handling multi-valued return values when flatMapping cross-types
Cyclops adopts the same approach as Javaslang for flatMapping across types see
Feature Tracking
- Create Monad Transformers : StreamT, StreamableT, ListT, CompletableFutureT
- Document OptionalT monad transformer
- Add javadoc for all AnyM methods
- Add stream operators to Streamable
- Deprecate Untyped Do
- ExceptionSoftener : provide soften methods for Jool Checked interfaces
- Fix FeatureToggle documentation - still refers to it as Switch
- cyclops-pattern-matching : enhance Matchable interface
- Add a creational range(long start, long end) convenience method for SequenceM
- Investigate AnyM handling of single valued monads versus monads with multiple values
Getting Cyclops 7.0.0
cyclops-all has all non-integration modules, but each module can be used / added individually (subject to it's own dependencies). Instructions for each module are in it's own readme.md.
Gradle
compile 'com.aol.cyclops:cyclops-all:7.0.0'
Maven
<dependency>
<groupId>com.aol.cyclops</groupId>
<artifactId>cyclops-all</artifactId>
<version>7.0.0</version>
</dependency>
http://www.javadoc.io/doc/com.aol.cyclops/cyclops-sequence-api/7.0.0
http://www.javadoc.io/doc/com.aol.cyclops/cyclops-streams/7.0.0
http://www.javadoc.io/doc/com.aol.cyclops/cyclops-monad-api/7.0.0
http://www.javadoc.io/doc/com.aol.cyclops/cyclops-monad-functions/7.0.0
http://www.javadoc.io/doc/com.aol.cyclops/cyclops-mixins/7.0.0
http://www.javadoc.io/doc/com.aol.cyclops/cyclops-invokedynamic/7.0.0
http://www.javadoc.io/doc/com.aol.cyclops/cyclops-for-comprehensions/7.0.0
http://www.javadoc.io/doc/com.aol.cyclops/cyclops-functions/7.0.0
http://www.javadoc.io/doc/com.aol.cyclops/cyclops-try/7.0.0
http://www.javadoc.io/doc/com.aol.cyclops/pattern-matching/7.0.0
http://www.javadoc.io/doc/com.aol.cyclops/cyclops-trampoline/7.0.0
http://www.javadoc.io/doc/com.aol.cyclops/cyclops-feature-toggle/7.0.0
http://www.javadoc.io/doc/com.aol.cyclops/cyclops-core/7.0.0
http://www.javadoc.io/doc/com.aol.cyclops/cyclops-power-tuples/7.0.0
http://www.javadoc.io/doc/com.aol.cyclops/cyclops-all/7.0.0
http://www.javadoc.io/doc/com.aol.cyclops/cyclops-javaslang/7.0.0
http://www.javadoc.io/doc/com.aol.cyclops/cyclops-functionaljava/7.0.0
http://www.javadoc.io/doc/com.aol.cyclops/cyclops-guava/7.0.0
v6.2.3 of cyclops
6.2.3 Release of Cyclops
Getting Cyclops 6.2.3
cyclops-all has all non-integration modules, but each module can be used / added individually (subject to it's own dependencies). Instructions for each module are in it's own readme.md.
Gradle
compile 'com.aol.cyclops:cyclops-all:6.2.3'
Maven
<dependency>
<groupId>com.aol.cyclops</groupId>
<artifactId>cyclops-all</artifactId>
<version>6.2.3</version>
</dependency>
http://www.javadoc.io/doc/com.aol.cyclops/cyclops-sequence-api/6.2.3
http://www.javadoc.io/doc/com.aol.cyclops/cyclops-streams/6.2.3
http://www.javadoc.io/doc/com.aol.cyclops/cyclops-monad-api/6.2.3
http://www.javadoc.io/doc/com.aol.cyclops/cyclops-monad-functions/6.2.3
http://www.javadoc.io/doc/com.aol.cyclops/cyclops-mixins/6.2.3
http://www.javadoc.io/doc/com.aol.cyclops/cyclops-invokedynamic/6.2.3
http://www.javadoc.io/doc/com.aol.cyclops/cyclops-for-comprehensions/6.2.3
http://www.javadoc.io/doc/com.aol.cyclops/cyclops-functions/6.2.3
http://www.javadoc.io/doc/com.aol.cyclops/cyclops-try/6.2.3
http://www.javadoc.io/doc/com.aol.cyclops/pattern-matching/6.2.3
http://www.javadoc.io/doc/com.aol.cyclops/cyclops-trampoline/6.2.3
http://www.javadoc.io/doc/com.aol.cyclops/cyclops-feature-toggle/6.2.3
http://www.javadoc.io/doc/com.aol.cyclops/cyclops-core/6.2.3
http://www.javadoc.io/doc/com.aol.cyclops/cyclops-power-tuples/6.2.3
http://www.javadoc.io/doc/com.aol.cyclops/cyclops-all/6.2.3
http://www.javadoc.io/doc/com.aol.cyclops/cyclops-javaslang/6.2.3
http://www.javadoc.io/doc/com.aol.cyclops/cyclops-functionaljava/6.2.3
http://www.javadoc.io/doc/com.aol.cyclops/cyclops-guava/6.2.3
v6.2.2 of Cyclops
6.2.2 Release of Cyclops
- cyclops-all now includes cyclops-validation
- Constraint checks added to AnyM and SequenceM creational methods
- Try uses softened exceptions
Getting Cyclops 6.2.2
cyclops-all has all non-integration modules, but each module can be used / added individually (subject to it's own dependencies). Instructions for each module are in it's own readme.md.
Gradle
compile 'com.aol.cyclops:cyclops-all:6.2.2'
Maven
<dependency>
<groupId>com.aol.cyclops</groupId>
<artifactId>cyclops-all</artifactId>
<version>6.2.2</version>
</dependency>
http://www.javadoc.io/doc/com.aol.cyclops/cyclops-sequence-api/6.2.2
http://www.javadoc.io/doc/com.aol.cyclops/cyclops-streams/6.2.2
http://www.javadoc.io/doc/com.aol.cyclops/cyclops-monad-api/6.2.2
http://www.javadoc.io/doc/com.aol.cyclops/cyclops-monad-functions/6.2.2
http://www.javadoc.io/doc/com.aol.cyclops/cyclops-mixins/6.2.2
http://www.javadoc.io/doc/com.aol.cyclops/cyclops-invokedynamic/6.2.2
http://www.javadoc.io/doc/com.aol.cyclops/cyclops-for-comprehensions/6.2.2
http://www.javadoc.io/doc/com.aol.cyclops/cyclops-functions/6.2.2
http://www.javadoc.io/doc/com.aol.cyclops/cyclops-try/6.2.2
http://www.javadoc.io/doc/com.aol.cyclops/pattern-matching/6.2.2
http://www.javadoc.io/doc/com.aol.cyclops/cyclops-trampoline/6.2.2
http://www.javadoc.io/doc/com.aol.cyclops/cyclops-feature-toggle/6.2.2
http://www.javadoc.io/doc/com.aol.cyclops/cyclops-core/6.2.2
http://www.javadoc.io/doc/com.aol.cyclops/cyclops-power-tuples/6.2.2
http://www.javadoc.io/doc/com.aol.cyclops/cyclops-all/6.2.2
http://www.javadoc.io/doc/com.aol.cyclops/cyclops-javaslang/6.2.2
http://www.javadoc.io/doc/com.aol.cyclops/cyclops-functionaljava/6.2.2
http://www.javadoc.io/doc/com.aol.cyclops/cyclops-guava/6.2.2