Skip to content

Commit

Permalink
Merge pull request #283 from aol/migrateToFinal2CR
Browse files Browse the repository at this point in the history
Upgrade to cyclops-react 2.0.0-FINAL
  • Loading branch information
johnmcclean authored Jul 5, 2017
2 parents 1472e2d + 35a0336 commit c19baf7
Show file tree
Hide file tree
Showing 116 changed files with 10,328 additions and 1,493 deletions.
5 changes: 5 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ repositories {

test {
systemProperties 'property': 'value'
forkEvery = 1
//maxParallelForks = Runtime.runtime.availableProcessors()
testLogging {
events "started","passed", "skipped", "failed"//, "standardOut", "standardError"
}
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import java.util.stream.Stream;

import com.aol.cyclops2.data.collections.extensions.CollectionX;
import com.aol.cyclops2.data.collections.extensions.lazy.immutable.FoldToList;
import com.aol.cyclops2.data.collections.extensions.lazy.immutable.LazyLinkedListX;
import com.aol.cyclops2.types.Unwrapable;
import com.aol.cyclops2.types.foldable.Evaluation;
Expand All @@ -15,6 +16,7 @@
import cyclops.function.Reducer;
import cyclops.stream.ReactiveSeq;
import org.jooq.lambda.tuple.Tuple2;
import org.pcollections.ConsPStack;
import org.pcollections.PStack;


Expand All @@ -28,13 +30,19 @@
@AllArgsConstructor(access = AccessLevel.PRIVATE)
public class ClojureListX<T> extends AbstractList<T>implements PStack<T>, Unwrapable {

static final FoldToList gen = (it, i)-> ClojureListX.from(from(it,i));

public static <T> LinkedListX<T> listX(ReactiveSeq<T> stream){
return fromStream(stream);
}
public static <T> LinkedListX<T> copyFromCollection(CollectionX<T> vec) {
return fromPStack(new ClojureListX<T>(from(vec.iterator(),0)),toPStack());

}
public static <T> LazyLinkedListX<T> from(IPersistentList q) {
return fromPStack(new ClojureListX<>(q), toPStack());
}

private static <E> IPersistentList from(final Iterator<E> i, int depth) {

if(!i.hasNext())
Expand All @@ -55,7 +63,7 @@ public <R> R unwrap() {
public static <T> LazyLinkedListX<T> fromStream(Stream<T> stream) {
Reducer<PStack<T>> s = toPStack();
return new LazyLinkedListX<T>(null,
ReactiveSeq.fromStream(stream), s, Evaluation.LAZY);
ReactiveSeq.fromStream(stream), s,gen, Evaluation.LAZY);
}

/**
Expand Down Expand Up @@ -177,7 +185,7 @@ public static <T> LazyLinkedListX<T> PStack(List<T> q) {
}

private static <T> LazyLinkedListX<T> fromPStack(PStack<T> s, Reducer<PStack<T>> pStackReducer) {
return new LazyLinkedListX<T>(s,null, pStackReducer, Evaluation.LAZY);
return new LazyLinkedListX<T>(s,null, pStackReducer, gen,Evaluation.LAZY);
}

@SafeVarargs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import java.util.stream.Stream;

import com.aol.cyclops2.data.collections.extensions.CollectionX;
import com.aol.cyclops2.data.collections.extensions.lazy.immutable.FoldToList;
import com.aol.cyclops2.data.collections.extensions.lazy.immutable.LazyLinkedListX;
import com.aol.cyclops2.types.Unwrapable;
import com.aol.cyclops2.types.foldable.Evaluation;
Expand Down Expand Up @@ -35,6 +36,10 @@ public class DexxListX<T> extends AbstractList<T>implements PStack<T>, Unwrapabl
public static <T> LinkedListX<T> listX(ReactiveSeq<T> stream){
return fromStream(stream);
}
static final FoldToList gen = (it, i)-> DexxListX.from(from(it,i));
public static <T> LazyLinkedListX<T> from(List<T> q) {
return fromPStack(new DexxListX<>(q), toPStack());
}
@Override
public <R> R unwrap() {
return (R)list;
Expand All @@ -60,7 +65,7 @@ private static <E> List<E> from(final Iterator<E> i, int depth) {
*/
public static <T> LazyLinkedListX<T> fromStream(Stream<T> stream) {
Reducer<PStack<T>> r = toPStack();
return new LazyLinkedListX<T>(null, ReactiveSeq.fromStream(stream), r, Evaluation.LAZY);
return new LazyLinkedListX<T>(null, ReactiveSeq.fromStream(stream), r, gen,Evaluation.LAZY);
}

/**
Expand Down Expand Up @@ -189,7 +194,7 @@ public static <T> LazyLinkedListX<T> PStack(List<T> q) {
toPStack());
}
private static <T> LazyLinkedListX<T> fromPStack(PStack<T> s, Reducer<PStack<T>> pStackReducer) {
return new LazyLinkedListX<T>(s,null,pStackReducer, Evaluation.LAZY);
return new LazyLinkedListX<T>(s,null,pStackReducer,gen, Evaluation.LAZY);
}


Expand Down
2 changes: 1 addition & 1 deletion cyclops-functionaljava/readme.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Functional Java Integration

v8.0.0 of cyclops-functionaljava and above is built using v4.5 of FunctionalJava.


## Get cyclops-functionaljava

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@



import cyclops.companion.functionaljava.Eithers;
import cyclops.monads.FJ;
import cyclops.monads.FJWitness;
import cyclops.monads.FJWitness.either;
import cyclops.conversion.functionaljava.FromCyclopsReact;
import cyclops.conversion.functionaljava.ToCyclopsReact;
Expand Down Expand Up @@ -70,6 +72,8 @@ public <T> AnyM<either, T> unit(T o) {
return FJ.either(Either.right(o));
}



@Override
public <T, R> AnyM<either, R> map(AnyM<either, T> t, Function<? super T, ? extends R> fn) {
return Eithers.anyM(either(t).bimap(i->i, x->fn.apply(x)));
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.aol.cyclops.functionaljava.adapter;

import cyclops.monads.FJ;
import cyclops.monads.FJWitness;
import cyclops.monads.FJWitness.iterableW;
import com.aol.cyclops2.types.extensability.AbstractFunctionalAdapter;
import cyclops.monads.AnyM;
Expand Down Expand Up @@ -66,6 +68,8 @@ public <T> AnyM<iterableW, T> unit(T o) {
return anyM(IterableW.iterable(o));
}



@Override
public <T, R> AnyM<iterableW, R> map(AnyM<iterableW, T> t, Function<? super T, ? extends R> fn) {
return FJ.iterableW(iterableW(t).map(x->fn.apply(x)));
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.aol.cyclops.functionaljava.adapter;

import cyclops.monads.FJWitness;
import cyclops.monads.FJWitness.list;
import com.aol.cyclops2.types.extensability.AbstractFunctionalAdapter;
import cyclops.monads.AnyM;
Expand Down Expand Up @@ -66,5 +67,8 @@ public <T> AnyM<list, T> unit(T o) {
}



@Override
public <T, R> AnyM<list, R> map(AnyM<list, T> t, Function<? super T, ? extends R> fn) {
return anyM(stream(t).map(x->fn.apply(x)));
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.aol.cyclops.functionaljava.adapter;

import cyclops.monads.FJWitness;
import cyclops.monads.FJWitness.nonEmptyList;
import com.aol.cyclops2.types.extensability.AbstractFunctionalAdapter;
import cyclops.monads.AnyM;
Expand Down Expand Up @@ -65,6 +66,8 @@ public <T> AnyM<nonEmptyList, T> unit(T o) {
return anyM(NonEmptyList.nel(o));
}



@Override
public <T, R> AnyM<nonEmptyList, R> map(AnyM<nonEmptyList, T> t, Function<? super T, ? extends R> fn) {
return anyM(stream(t).map(x->fn.apply(x)));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@


import cyclops.monads.FJ;
import cyclops.monads.FJWitness;
import cyclops.monads.FJWitness.option;
import cyclops.conversion.functionaljava.FromCyclopsReact;
import com.aol.cyclops2.types.extensability.AbstractFunctionalAdapter;
Expand Down Expand Up @@ -66,6 +67,8 @@ public <T> AnyM<option, T> unit(T o) {
return FJ.option(Option.some(o));
}



@Override
public <T, R> AnyM<option, R> map(AnyM<option, T> t, Function<? super T, ? extends R> fn) {
return FJ.option(option(t).map(x->fn.apply(x)));
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.aol.cyclops.functionaljava.adapter;

import cyclops.companion.functionaljava.Streams;
import cyclops.monads.FJWitness;
import cyclops.monads.FJWitness.stream;
import com.aol.cyclops2.types.extensability.AbstractFunctionalAdapter;
import cyclops.monads.AnyM;
Expand Down Expand Up @@ -65,6 +67,8 @@ public <T> AnyM<stream, T> unit(T o) {
return anyM(Stream.stream(o));
}



@Override
public <T, R> AnyM<stream, R> map(AnyM<stream, T> t, Function<? super T, ? extends R> fn) {
return Streams.anyM(stream(t).map(x-> fn.apply(x)));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@


import cyclops.monads.FJ;
import cyclops.monads.FJWitness;
import cyclops.monads.FJWitness.validation;
import cyclops.conversion.functionaljava.FromCyclopsReact;
import cyclops.conversion.functionaljava.ToCyclopsReact;
Expand Down Expand Up @@ -69,6 +70,8 @@ public <T> AnyM<validation, T> unit(T o) {
return FJ.validation(Validation.success(o));
}



@Override
public <T, R> AnyM<validation, R> map(AnyM<validation, T> t, Function<? super T, ? extends R> fn) {
return FJ.validation(validation(t).map(x->fn.apply(x)));
}
}
Loading

0 comments on commit c19baf7

Please sign in to comment.