Git Product home page Git Product logo

cyclops-integration's People

Contributors

0xflotus avatar awturner avatar bigkahuna1uk avatar c0nscience avatar earlzero avatar gitter-badger avatar greg2001 avatar h3xstream avatar jbgi avatar johnmcclean avatar lukaseder avatar scr-oath avatar seanf avatar slnowak avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cyclops-integration's Issues

More strongly typed for comprehensions

Once AnyM work is complete (move to first class citizen, and add comprehension support), which can wrap any monad type (such as Stream, Optional, CompletableFuture, Try, Switch and others), with a single type parameter - it should be possible to fully an correctly infer types for comprehensions.

e.g.

Collection<Integer> col = Arrays.asList(2,3,4); 
AnyM<String> opt = anyM(Optional.of("hello world"));

Do.with(col)
 .and(i -> opt)    //i is of type integer
 .yield( (i,j) ->  j.length()+ i);  //i is of type integer, j is of type String

This compares with current implementation which would look like this

 Do.with(col)
   .and((Integer i) -> opt)    //i is of type integer
   .yield( (Intger i,String j) ->  j.length()+ i);  //i is of type integer, j is of type String

master branch fails compilation on Windows

On Windows 7 using Java 8 using the master branch I get the error:

:cyclops-base:compileJava
E:\repositories\cyclops\cyclops-base\src\main\java\com\aol\cyclops\lambda\utils\
Lambda.java:51: error: illegal character: '\u00bb'
        public static <T1,T2,T3,R> Function<T1,Function<T2,Function<T3,R>>> ╬╗3(
Function<T1,Function<T2,Function<T3,R>>> triFunc){
                                                                             ^
E:\repositories\cyclops\cyclops-base\src\main\java\com\aol\cyclops\lambda\utils\
Lambda.java:51: error: ';' expected
        public static <T1,T2,T3,R> Function<T1,Function<T2,Function<T3,R>>> ╬╗3(
Function<T1,Function<T2,Function<T3,R>>> triFunc){

                                                ^
2 errors
:cyclops-base:compileJava FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':cyclops-base:compileJava'.
> Compilation failed; see the compiler error output for details.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug
option to get more log output.

BUILD FAILED

Total time: 4.919 secs

ClassCastException when trying to create a monad instance with AnyM#unit()

The following unit tests fail with a ClassCastException. I would expect unit() to create an instance of the underlying monad (an Optional or a List) in each case, but that does not seem to happen.

@Test
public void unitOptional() {
    AnyM<Integer> empty = AnyMonads.anyM(Optional.empty());
    AnyM<Integer> unit = empty.unit(1);
    Optional<Integer> unwrapped = unit.unwrap();
    assertEquals(Integer.valueOf(1), unwrapped.get());
}

@Test
public void unitList() {
    AnyM<Integer> empty = AnyMonads.anyM(Collections.emptyList());
    AnyM<Integer> unit = empty.unit(1);
    List<Integer> unwrapped = unit.asSequence().toList();
    assertEquals(Integer.valueOf(1), unwrapped.get(0));
}

Multiple Matchers in the same isMatch method.

in the ElementCase
is possible to add a method :
public InMatchOfBuilder<V,X> isMatch(Matcher... matches) ?
so that i can do something like :
.when().isMatch(startsWith("ERROR") && containsString("NullPointerException"))

I can achieve the same at the moment using the org.hamcrest.core.AllOf.allOf

isMatch(allOf(startsWith("ERROR"), containsString("NullPointerException")))

but I think It would be nice and helpful to have it as native feature in cyclops

Create a JAVASLANG Integration module

  • Most of the converters in the converters module are for JAVASLANG
  • These can be moved to the new module
  • 3rd party dependencies (e.g. Guava, JOOL, TotallyLazy, Functional Java) can be made provided scope
  • Create Cyclops comprehenders for JAVASLANG monads.

AnyM Type Safety enhancements

Remove monad() method

reduceM and simpleFilter type safety

replicateM implementation that uses AnyM for replication would allow the return type to be full type safe,

Separate AnyM and StreamBased Functions

It is probably confusing to have Stream specific functions inside AnyM.

Add stream() and streamedMonad() equivalent functions to AnyM (these return a wrapped Stream, the first takes the raw value from the monad in AnyM currently, the second takes the raw value and attempts to turn it into a Stream). i.e. in the first case AnyM<Optional<List>> becomes AnyM<List> and in the second it becomes AnyM.

Create a class, similar to AnyM that implements StreamBasedFunctions, that is returned after
stream() and streamedMonad()

ClassCasrException

The following unit tests fail with a ClassCastException. As I understand unit(), they should instead succeed.

Surprising behaviour of convertToAnyM with List

I have seen you have added a new ListComprehender - thank you very much. However, there still seems to be no uniform way of converting Optional or List to AnyM and unwrapping to what one put in.AsAnyM.convertToAnyM (and AnyMonads.anyM) will still convert a List to a Stream (SequenceImpl).

I would find it more natural if they kept the List, because there is a Comprehender for it. However, the behavior may be more efficient, as you note in your 6.1.0 release comments. I'd still prefer it to be changed. What do you think?

NoSuchElementException when flat-mapping Monad based on list

The following test fails with a NoSuchElementException while flatMapping.

 @Test
 public void test() {
    List<Integer> list = Arrays.asList(1,2,3);
    Monad<List<Integer>, Integer> m = Monad.of(list);
    AnyM<Integer> any = m.anyM();
    AnyM<Integer> mapped = any.flatMap(e -> any.unit(e));
    List<Integer> unwrapped = mapped.asSequence().toList();
    assertEquals(list, unwrapped);
}

Now I'm aware that Monad.of(list).anyM() is a non-standard way of constructing a monad, using an internal API. However, think of the method as being parametrized by two type parameters E and M, such that I need to construct a monad with element type E and container type M. And of course M e = ...; AnyM<S> any = AnyMonads.anyM(e); won't compile.

So my questions are: 1) How can I generically construct a monad (e. g. based on M = Optional or M = List) without using an internal API. And 2) is there something wrong with my usage of Monad in the above test, or is it a bug?

flatMap does not work as expected with ListComprehender

Monad wrappers around lists with the new factory methods involving the native ListComprehender do not flatMap as expected. The follwoing test fails with

java.lang.ClassCastException: java.util.stream.ReferencePipeline$Head cannot be cast to java.util.List at com.aol.cyclops.comprehensions.comprehenders.ListComprehender.lambda$executeflatMap$29(ListComprehender.java:30)

@Test
public void flatMapWithListComprehender() {
    List<Integer> list = Arrays.asList(1,2,3);
    AnyM<Integer> any = AsAnyM.anyMList(list); 
    AnyM<Integer> mapped = any.flatMap(e -> any.unit(e));
    List<Integer> unwrapped = mapped.unwrap();
    assertEquals(list, unwrapped);
}

Memoisation for common primitive types

IntFunction, DoubleFunction, LongFunction
IntSupplier, DoubleSupplier, LongSupplier

IntUnaryFunction, DoubleUnaryFunction, LongUnaryFunction

Also generic UnaryFunction could be good too.

Memoisation with Time To Live

For functions that perform I/O, or produce a result that may depend on some global state, having a TTL may enable memoisiation / caching to be useful.

Should be implemented as a new class TTLMemoise or similar.

Create a FunctionalJava Integration module

  • Move FunctionalJava converters to new module (and finish the set)
  • Make 3rd party libraries provided scope dependencies
  • Cyclops Comprehenders for FunctionalJava monads.

ExceptionSoftener can lead to ClassCastException

Right now ExceptionSoftener in cyclops-invokedynamic always trying to cast any exception to RuntimeException in method ExceptionSoftener.uncheck. In case that any exception, that is "softened" is not subclass of RuntimeException it will lead to ClassCastException between this exception class and RuntimeException. Possible fix is to change implementation of throwSoftenedException
to something like
throw new RuntimeException(e);

Rename Simplex type view on a Generic Monad, AnyM

Simplex doesn't convey what the type is.

             val lifted = Monad.liftM((Integer a)->a+3);
    AnyM<Integer> result = lifted.apply(anyM(Optional.of(3)));
    assertThat(result.<Optional<Integer>>monad().get(),equalTo(6))

Create Consumer interfaces up to 8 parameters

Currently Consumers stop at 5 (in practice this is probably enough), but we have functions that support 8 parameters so it may be a good idea to have consumers which support 8 also. Use cases are likely to be around Method Reference creation for legacy code that is badly in need of refactoring!

Would facilitate 'currying' and partial application for consumers with up to 8 parameters.

Create static methods for partial application of functions / method refs

Similar to the Curry class, except partially apply rather than Curry.

E.g.

  public static <T1,T2,T3,T4,R> BiFunction<T3,T4,R>>>>  partial4(T1 t1, T2 t2, QuadFunction<T1,T2,T3,T4,R> quadFunc){
    return   ( t3 ,t4) -> quadFunc.apply(t1,t2,t3,t4);
}

Update : Is this better? Or worse?

  public static <T1,T2,T3,T4,R>  BiFunction<T1,T2,BiFunction<T3,T4,R>>>>>  partial4(  QuadFunction<T1,T2,T3,T4,R> quadFunc){
    return   ( t3 ,t4) -> quadFunc.apply(t1,t2,t3,t4);
}

I think the first way may be better, as in terms of method naming and variable signatures it is simpler.

Try extends instead of Super

Hi,
the onFail method in the Try class, I think, should extends the generic exception instead of using super.

In this way it will be possible to have a more generic way to act based on specific exceptions.

Thanks

Create Monads module?

Move Generic Monad related classes to new Monads module that depends on both Cyclops base and Cyclops Functions.

This way Monad interface (or a MonadFunctions interface) can provide liftM1-8.

Some maven repositories not accessible

Hey
I'm running IntelliJ Ultimate Edition on Ubuntu 15.04 and I came across errors when trying to download test dependencies.

It appears that cmmaven.aol.com is being declared in the cyclops-core package and http://repo.bodar.com is being declared in cyclops-converters.
Both of the above sources are not accessible

AnyM monad wrapper should become primary monad wrapper

Using AnyM results in much more readable code with a lot less generics , particularly when using more advanced functions that operate of Monads : compare

AnyM<Integer> result = lifted.apply(anyM(Optional.of(3)),anyM(Optional.of(4)));
 Monad<Optional<Integer>, Integer> result = lifted.apply(monad(Optional.of(3)),monad(Optional.of(3)));

When operating on a Monad via the Monad wrapper, the underlying Monad is abstracted away.

The interfaces should operate at minimum like Stream and BaseStream in the JDK, which have a similar declaration pattern

public interface Stream<T> extends BaseStream<T,Stream<T>>

public interface AnyM<T> extends Monad<Object,T>

But currently methods where a type conflict occur are resolved by creating a new method with an anyM suffix. This is confusing.

Either the conflict should be resolved by a suffix in the Monad interface, or AnyM should not extend Monad, but implementations could delegate to Monad.

Simplify Pattern Matcher

Merge

   Matching.when().isType() 

to

   Matching.whenIsType()
   Matching.whenIsValue() 

or

   MatchingType.when( typeInfo )
   MatchingValue.when (  prototype )
   MatchingValues.when( _ ,10, _ ).thenApply ( )
   MatchingHamcrest.when(matcher).thenApply(  )
   MatchingIterables.when(   )

etc

Or to keep them under the same class hierarchy - static inner classes ->

   Matching.Type.when(   )
   Matching.Values.when( __,10,__).thenApply ( )

and return Matching Intance of the same type.

This would be a backwards incompatible change, so can't done until Cyclops 6.

Create Guava Integration module

Comprehenders for FluentIterable and Guava's Optional. Converters for Guava Functions and Predicates.

Can be released under 5.0.0

Support Lazy PTuple instantiation

Allow the creation of Lazily populated PTuples with elements populated by suppliers (use a similar mechanism to the LazyMap static methods)

Add a ListComprehender implementation

The cyclops-monad-api currently handles Collections by converting them into Streams, adding a specific Comprehender for Lists would mean less surprising behaviour when using AnyM wrapped Lists.

We should also make sure that Lists are no longer implicity or explicitly converted into Streams. This would mean updating appropriate AsAnyM methods, and also CollectionsConverter.

Back SequenceM with LazySeq

LazySeq datastructure allows new entries to be added, separate playing of 'stream' (e.g. recursive processing of the head and tail becomes possible, unlike with JDK 8 Streams).

    recursive(sequenceM.head(),sequenceM.tail());

Create cyclops-streams module

Make Streaming a first class citizen of cyclops.

SequenceM is the cyclops Sequential Stream implementation

SequenceM should extend jooλ.Seq (and java.util.Stream)
SequenceM should also provide the same functionality as simple-react's LazyFutureStream (for sequential Streams versus parallel Streaming with LazyFutureStream).

              FutureOperations (async terminal operations)
              Time operations (xPer, onePer, jitter, debounce etc)
              Windowing / batching (batchBySizeAndTime etc)
              Error recovery / failure handling
              Hotstreams (connectable active streams)
              reactive-streams support

LazyFutureStream in simple-react will the extends SequenceM
simple-react to provide reactive mixin / plugin support for SequenceM.

Create Cyclops-all module

  • To include everything except integration / converter modules
  • Should provide a single API class for all static utility methods (called Cyclops.java should extend Core.java in Core)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.