├── .editorconfig ├── .github └── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md ├── .gitignore ├── .java-version ├── .travis.yml ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── build.gradle ├── cyclops-anym ├── README.MD ├── build.gradle ├── gradle.properties └── src │ ├── main │ └── java │ │ ├── com │ │ └── oath │ │ │ └── cyclops │ │ │ └── anym │ │ │ ├── AnyMSeq.java │ │ │ ├── AnyMValue.java │ │ │ ├── AnyMValue2.java │ │ │ ├── NestedCollectable.java │ │ │ ├── NestedFoldable.java │ │ │ ├── extensability │ │ │ ├── AbstractMonadAdapter.java │ │ │ ├── MonadAdapter.java │ │ │ └── ValueAdapter.java │ │ │ ├── internal │ │ │ ├── adapters │ │ │ │ ├── EitherAdapter.java │ │ │ │ ├── FutureAdapter.java │ │ │ │ ├── IdentityAdapter.java │ │ │ │ ├── IorAdapter.java │ │ │ │ ├── IterableXAdapter.java │ │ │ │ ├── LazyEither3Adapter.java │ │ │ │ ├── LazyEither4Adapter.java │ │ │ │ ├── LazyEither5Adapter.java │ │ │ │ ├── LazyEitherAdapter.java │ │ │ │ ├── MonadicValueAdapter.java │ │ │ │ ├── OptionalAdapter.java │ │ │ │ ├── ReactiveAdapter.java │ │ │ │ ├── StreamAdapter.java │ │ │ │ ├── StreamableAdapter.java │ │ │ │ └── TryAdapter.java │ │ │ └── monads │ │ │ │ ├── AnyMSeqImpl.java │ │ │ │ ├── AnyMValue2Impl.java │ │ │ │ ├── AnyMValueImpl.java │ │ │ │ └── BaseAnyMImpl.java │ │ │ └── transformers │ │ │ ├── FoldableTransformerSeq.java │ │ │ ├── NonEmptyTransformer.java │ │ │ ├── TransformerSeq.java │ │ │ ├── TransformerTraversable.java │ │ │ └── ValueTransformer.java │ │ └── cyclops │ │ └── monads │ │ ├── AnyM.java │ │ ├── AnyM2.java │ │ ├── AnyMs.java │ │ ├── CokleisliM.java │ │ ├── KleisliM.java │ │ ├── Witness.java │ │ ├── WitnessType.java │ │ ├── XorM.java │ │ ├── function │ │ ├── AnyMFunction0.java │ │ ├── AnyMFunction1.java │ │ ├── AnyMFunction2.java │ │ ├── AnyMFunction3.java │ │ ├── AnyMFunction4.java │ │ ├── AnyMFunction5.java │ │ ├── AnyMFunction6.java │ │ ├── AnyMFunction7.java │ │ ├── AnyMFunction8.java │ │ ├── BinaryAnyMFunction.java │ │ └── UnaryAnyMFunction.java │ │ └── transformers │ │ ├── EitherT.java │ │ ├── EvalT.java │ │ ├── FutureT.java │ │ ├── LazySeqT.java │ │ ├── ListT.java │ │ ├── MaybeT.java │ │ ├── OptionT.java │ │ ├── ReaderT.java │ │ ├── SeqT.java │ │ ├── StreamT.java │ │ ├── VectorT.java │ │ └── jdk │ │ ├── CompletableFutureT.java │ │ └── OptionalT.java │ └── test │ └── java │ └── cyclops │ └── monads │ ├── FlatMapSequenceMTest.java │ ├── KleisliMTest.java │ ├── Matchers.java │ ├── StreamTest.java │ ├── XorMTest.java │ ├── anym │ ├── AnyMSeqTest.java │ ├── AnyMTest.java │ ├── AnyMValueTest.java │ ├── FunctionsTest.java │ ├── StreamTest.java │ └── value │ │ ├── BaseAnyMValueTest.java │ │ ├── FutureAnyMValueTest.java │ │ ├── IorAnyMValueTest.java │ │ ├── MaybeAnyMValueTest.java │ │ ├── OptionAnyMValueTest.java │ │ ├── OptionalAnyMValueTest.java │ │ ├── TryAnyMValueTest.java │ │ └── XorAnyMValueTest.java │ ├── collections │ ├── AbstractAnyMSeqOrderedDependentTest.java │ ├── AbstractAnyMSeqTest.java │ ├── mutable │ │ ├── DequeXTest.java │ │ ├── FutureStreamTest.java │ │ ├── ListXTest.java │ │ ├── QueueXTest.java │ │ ├── ReactiveSeqTest.java │ │ ├── ReactiveStreamXTest.java │ │ ├── SetXTest.java │ │ ├── SortedSetXTest.java │ │ ├── StreamTest.java │ │ └── StreamableTest.java │ └── persistent │ │ ├── BagXTest.java │ │ ├── LinkedListXTest.java │ │ ├── OrderedSetXTest.java │ │ ├── PersistentQueueXTest.java │ │ ├── PersistentSetXTest.java │ │ └── VectorXTest.java │ ├── control │ ├── LiftTryTest.java │ └── TryMonadTest.java │ ├── data │ ├── BankersQueueTest.java │ ├── HashSetAnyMTest.java │ ├── LazySeqAnyMTest.java │ ├── SeqAnyMTest.java │ └── VectorAnyMTest.java │ ├── jdk │ ├── AnyMTest.java │ ├── AnyMValueTest.java │ ├── FlatMapTest.java │ ├── ForComprehensionsTest.java │ ├── LiftAndBindTest.java │ ├── MonadTest.java │ ├── UnitTest.java │ └── UnwrapTest.java │ └── transformers │ ├── AbstractNestedFoldableTest.java │ ├── CompletableFutureTTest.java │ ├── EvalTTest.java │ ├── FutureTTest.java │ ├── LazySeqTSeqTest.java │ ├── LazySeqTTest.java │ ├── ListTSeqTest.java │ ├── ListTTest.java │ ├── MaybeTTest.java │ ├── OptionTTest.java │ ├── OptionalTTest.java │ ├── SeqTSeqTest.java │ ├── SeqTTest.java │ ├── TransformersValuesTest.java │ ├── VectorTSeqTest.java │ ├── VectorTTest.java │ ├── XorTTest.java │ └── seq │ ├── ListTSeqTraversableTest.java │ ├── StreamTSeqTraversableTest.java │ ├── convertable │ ├── ListTSeqConvertableSequenceTest.java │ └── StreamTSeqConvertableSequenceTest.java │ └── nestedfoldable │ ├── ListTSeqNestedFoldableTest.java │ └── StreamTSeqNestedFoldableTest.java ├── cyclops-futurestream ├── README.MD ├── build.gradle ├── gradle.properties └── src │ ├── main │ └── java │ │ ├── com │ │ └── oath │ │ │ └── cyclops │ │ │ ├── internal │ │ │ ├── react │ │ │ │ ├── DelegateStream.java │ │ │ │ ├── FutureStreamImpl.java │ │ │ │ ├── SimpleReactStreamImpl.java │ │ │ │ ├── async │ │ │ │ │ └── future │ │ │ │ │ │ ├── CompletedException.java │ │ │ │ │ │ ├── ExecutionPipeline.java │ │ │ │ │ │ ├── FastFuture.java │ │ │ │ │ │ ├── FinalPipeline.java │ │ │ │ │ │ ├── FuturePool.java │ │ │ │ │ │ └── PipelineBuilder.java │ │ │ │ ├── exceptions │ │ │ │ │ ├── FilteredExecutionPathException.java │ │ │ │ │ └── SimpleReactCompletionException.java │ │ │ │ └── stream │ │ │ │ │ ├── BaseSimpleReact.java │ │ │ │ │ ├── CloseableIterator.java │ │ │ │ │ ├── EagerStreamWrapper.java │ │ │ │ │ ├── InfiniteClosingSpliterator.java │ │ │ │ │ ├── InfiniteClosingSpliteratorFromSupplier.java │ │ │ │ │ ├── InfiniteProcessingException.java │ │ │ │ │ ├── LazyStreamWrapper.java │ │ │ │ │ ├── MissingValue.java │ │ │ │ │ ├── ReactBuilder.java │ │ │ │ │ ├── Runner.java │ │ │ │ │ ├── StreamWrapper.java │ │ │ │ │ └── traits │ │ │ │ │ └── future │ │ │ │ │ └── operators │ │ │ │ │ ├── LazyFutureStreamUtils.java │ │ │ │ │ └── OperationsOnFuturesImpl.java │ │ │ └── stream │ │ │ │ └── FutureOpterationsImpl.java │ │ │ ├── react │ │ │ ├── SimpleReactFailedStageException.java │ │ │ ├── StageWithResults.java │ │ │ ├── Status.java │ │ │ ├── collectors │ │ │ │ └── lazy │ │ │ │ │ ├── BatchingCollector.java │ │ │ │ │ ├── Blocker.java │ │ │ │ │ ├── EmptyCollector.java │ │ │ │ │ ├── IncrementalReducer.java │ │ │ │ │ ├── LazyResultConsumer.java │ │ │ │ │ ├── MaxActive.java │ │ │ │ │ └── SamplingCollector.java │ │ │ └── threads │ │ │ │ ├── ParallelElasticPools.java │ │ │ │ ├── ReactPool.java │ │ │ │ └── SequentialElasticPools.java │ │ │ └── types │ │ │ ├── futurestream │ │ │ ├── BaseSimpleReactStream.java │ │ │ ├── BlockingStream.java │ │ │ ├── BlockingStreamHelper.java │ │ │ ├── ConfigurableStream.java │ │ │ ├── EagerFutureStreamFunctions.java │ │ │ ├── EagerToQueue.java │ │ │ ├── HasExec.java │ │ │ ├── HasFutureStream.java │ │ │ ├── LazyFutureStreamFunctions.java │ │ │ ├── LazySimpleReactStream.java │ │ │ ├── LazyStream.java │ │ │ ├── LazyToQueue.java │ │ │ ├── Locks.java │ │ │ ├── NonCollector.java │ │ │ ├── NullValue.java │ │ │ ├── OperationsOnFutures.java │ │ │ ├── RepeatableStream.java │ │ │ ├── SimpleReactStream.java │ │ │ ├── ToQueue.java │ │ │ └── Val.java │ │ │ └── reactive │ │ │ ├── FutureStreamSynchronousPublisher.java │ │ │ └── QueueBasedSubscriber.java │ │ └── cyclops │ │ ├── companion │ │ ├── FutureStreamMonoids.java │ │ ├── FutureStreamSemigroups.java │ │ └── Futures.java │ │ ├── futurestream │ │ ├── FutureStream.java │ │ ├── FutureStreamIO.java │ │ ├── LazyReact.java │ │ ├── Pipes.java │ │ └── SimpleReact.java │ │ └── stream │ │ ├── StreamSource.java │ │ └── pushable │ │ ├── AbstractPushableStream.java │ │ ├── MultipleStreamSource.java │ │ ├── PushableFutureStream.java │ │ ├── PushableReactiveSeq.java │ │ └── PushableStream.java │ └── test │ └── java │ ├── com │ └── oath │ │ └── cyclops │ │ ├── async │ │ └── adapters │ │ │ ├── DirectWaitStrategyTest.java │ │ │ ├── ExponentialBackofWaitStrategyTest.java │ │ │ ├── NoWaitRetryTest.java │ │ │ ├── QueueTest.java │ │ │ ├── SignalTest.java │ │ │ ├── SpinWaitTest.java │ │ │ ├── TopicTest.java │ │ │ └── YieldWaitTest.java │ │ └── react │ │ └── collectors │ │ └── lazy │ │ ├── BatchingCollectorTest.java │ │ ├── EmptyCollectorTest.java │ │ └── SamplingCollectorTest.java │ └── cyclops │ └── futurestream │ ├── FutureStreamIOTest.java │ ├── FutureStreamImplTest.java │ ├── FutureStreamManagedTest.java │ ├── FutureStreamReactiveSeqTest.java │ ├── HibernateManagedTest.java │ ├── Javaone.java │ ├── react │ ├── FutureSequentialTest.java │ ├── MiscTest.java │ ├── async │ │ ├── future │ │ │ └── FastFutureTest.java │ │ ├── pipes │ │ │ └── PipesTest.java │ │ └── vertx │ │ │ ├── Starter.java │ │ │ ├── VertxExecutor.java │ │ │ └── VertxTest.java │ ├── base │ │ ├── BaseJDKStreamTest.java │ │ ├── BaseLazyNumberOperationsTest.java │ │ ├── BaseNumberOperationsTest.java │ │ ├── BaseSeqFutureTest.java │ │ ├── BaseSeqLazyTest.java │ │ ├── BaseSeqTest.java │ │ ├── BaseSequentialSQLTest.java │ │ └── BaseSequentialSeqTest.java │ ├── completablefuture │ │ ├── CompletableFutureTest.java │ │ └── RxJavaConversionTest.java │ ├── examples │ │ └── FilesExamplesTest.java │ ├── lazy │ │ ├── AutoMemoizationTest.java │ │ ├── AutoclosingTest.java │ │ ├── BatchingInvestigationsTest.java │ │ ├── DuplicationTest.java │ │ ├── FastFutureConversionTest.java │ │ ├── FlatMapTest.java │ │ ├── ForComprehensionsTest.java │ │ ├── ForEachParallelTest.java │ │ ├── JDKLazyStreamTest.java │ │ ├── LazyFutureNumberOperationsTest.java │ │ ├── LazyNumberOperationsTest.java │ │ ├── LazySeqAgronaTest.java │ │ ├── LazySeqAutoOptimizeTest.java │ │ ├── LazySeqFutureTest.java │ │ ├── LazySeqLazyTest.java │ │ ├── LazySeqNoAutoOptimizeTest.java │ │ ├── LazySeqObjectPoolingTest.java │ │ ├── LazySeqTest.java │ │ ├── LazySequentialSQLTest.java │ │ ├── LazySequentialSeqAgronaTest.java │ │ ├── LazySequentialSeqObjectPoolsTest.java │ │ ├── LazySequentialSeqTest.java │ │ ├── LazyTest.java │ │ ├── OnFailTest.java │ │ ├── ParallelTest.java │ │ ├── ToOptionalCompletableFutureTest.java │ │ ├── Tutorial.java │ │ ├── futures │ │ │ ├── AccessTest.java │ │ │ ├── ConcatTest.java │ │ │ ├── DuplicationTest.java │ │ │ ├── OperationsOnFuturesTest.java │ │ │ ├── PartitionAndSplittingTest.java │ │ │ ├── SkipTest.java │ │ │ └── ZippingFuturesTest.java │ │ ├── reactive │ │ │ ├── ForEachLFSTest.java │ │ │ └── ForEachTest.java │ │ └── sequence │ │ │ ├── BaseSequentialTest.java │ │ │ ├── BatchingTest.java │ │ │ ├── FlatMapSequenceMTest.java │ │ │ ├── FutureStreamCollectableTest.java │ │ │ ├── LFSNoOrderTest.java │ │ │ ├── LiftAndBindSequenceMTest.java │ │ │ ├── LiftAndBindStreamUtilsTest.java │ │ │ ├── PartitionAndSplittingTest.java │ │ │ ├── ReductionTest.java │ │ │ ├── RetryTest.java │ │ │ ├── ReverseTest.java │ │ │ ├── ScanningTest.java │ │ │ ├── SequentialTest.java │ │ │ ├── WindowingTest.java │ │ │ ├── ZippingTest.java │ │ │ └── hotstream │ │ │ ├── ConnectableTest.java │ │ │ └── SchedulingTest.java │ ├── mixins │ │ └── LazyReactiveTest.java │ ├── reactivestreams │ │ └── jdk │ │ │ ├── TckSynchronousPublisherTest.java │ │ │ ├── TckSynchronousPublisherTraversableTest.java │ │ │ └── ValueSubscriberTckBlackBoxSubscriberTest2.java │ ├── simple │ │ ├── AlgorithmCompareTest.java │ │ ├── AllOfTest.java │ │ ├── AnyOfTest.java │ │ ├── BlockingTest.java │ │ ├── CaptureTest.java │ │ ├── FilterTest.java │ │ ├── FlatMapTest.java │ │ ├── GeneratorTest.java │ │ ├── IterationTest.java │ │ ├── LazyReactTest.java │ │ ├── MergeTest.java │ │ ├── OnFailTest.java │ │ ├── PeekTest.java │ │ ├── ResultCollectionTest.java │ │ ├── SimpleReactTest.java │ │ ├── SimpleTimerTest.java │ │ ├── StreamTest.java │ │ └── TakeSkipSliceTest.java │ ├── stream │ │ ├── StatusTest.java │ │ ├── async │ │ │ └── AsyncTest.java │ │ └── pushable │ │ │ └── PushableStreamTest.java │ └── threads │ │ ├── ReactPoolTest.java │ │ └── ReactToList.java │ └── reactivestreams │ ├── TckAsynchronousPublisherTest.java │ └── TckSynchronousPublisherTest.java ├── cyclops-jackson-integration ├── README.md ├── build.gradle ├── gradle.properties └── src │ ├── main │ └── java │ │ └── com │ │ └── oath │ │ └── cyclops │ │ └── jackson │ │ ├── CyclopsModule.java │ │ ├── CyclopsTypeModifier.java │ │ ├── deserializers │ │ ├── CyclopsDeserializers.java │ │ ├── EitherDeserializer.java │ │ ├── EvalDeserializer.java │ │ ├── FutureDeserializer.java │ │ ├── IorDeserializer.java │ │ ├── IterableXDeserializer.java │ │ ├── LazyEither3Deserializer.java │ │ ├── LazyEither4Deserializer.java │ │ ├── LazyEither5Deserializer.java │ │ ├── LazyEitherDeserializer.java │ │ ├── MaybeDeserializer.java │ │ ├── OptionDeserializer.java │ │ ├── PersistentMapDeserializer.java │ │ ├── TrampolineDeserializer.java │ │ ├── TupleDeserializer.java │ │ └── UnrestrictedDeserializer.java │ │ └── serializers │ │ ├── CyclopsSerializers.java │ │ ├── EvalSerializer.java │ │ ├── IorSerializer.java │ │ ├── IterableXSerializer.java │ │ ├── OptionSerializer.java │ │ ├── PersistentMapSerializer.java │ │ ├── Sealed2Serializer.java │ │ ├── Sealed3Serializer.java │ │ ├── Sealed4Serializer.java │ │ ├── Sealed5Serializer.java │ │ ├── TrampolineSerializer.java │ │ ├── Tuple1Serializer.java │ │ ├── Tuple2Serializer.java │ │ ├── Tuple3Serializer.java │ │ ├── Tuple4Serializer.java │ │ ├── Tuple5Serializer.java │ │ ├── Tuple6Serializer.java │ │ ├── Tuple7Serializer.java │ │ ├── Tuple8Serializer.java │ │ └── ValueSerializer.java │ └── test │ └── java │ └── com │ └── oath │ └── cyclops │ └── jackson │ ├── EitherTest.java │ ├── EvalTest.java │ ├── FutureTest.java │ ├── IorTest.java │ ├── IterableXTest.java │ ├── JacksonUtil.java │ ├── LazyEither3Test.java │ ├── LazyEither4Test.java │ ├── LazyEitherTest.java │ ├── MaybeTest.java │ ├── OptionTest.java │ ├── PersistentMapTest.java │ ├── TrampolineTest.java │ ├── TupleTest.java │ └── fix │ ├── Query.java │ └── SerTest.java ├── cyclops-pure ├── README.MD ├── build.gradle ├── gradle.properties └── src │ ├── main │ └── java │ │ └── cyclops │ │ ├── arrow │ │ ├── Cokleisli.java │ │ ├── FunctionK.java │ │ ├── FunctionsHK.java │ │ ├── GroupK.java │ │ ├── Kleisli.java │ │ ├── MonoidK.java │ │ ├── MonoidKs.java │ │ ├── SemigroupK.java │ │ └── SemigroupKs.java │ │ ├── control │ │ ├── Constant.java │ │ ├── Coreader.java │ │ ├── Identity.java │ │ ├── Reader.java │ │ ├── ReaderWriterState.java │ │ ├── State.java │ │ └── Writer.java │ │ ├── data │ │ └── MultiMapHK.java │ │ ├── free │ │ ├── Cofree.java │ │ ├── Coyoneda.java │ │ ├── Free.java │ │ ├── FreeAp.java │ │ └── Yoneda.java │ │ ├── hkt │ │ ├── Active.java │ │ ├── Coproduct.java │ │ ├── Nested.java │ │ └── Product.java │ │ ├── instances │ │ ├── arrow │ │ │ └── KleisliInstances.java │ │ ├── control │ │ │ ├── ConstantInstances.java │ │ │ ├── EitherInstances.java │ │ │ ├── EvalInstances.java │ │ │ ├── FutureInstances.java │ │ │ ├── IdentityInstances.java │ │ │ ├── IorInstances.java │ │ │ ├── LazyEither3Instances.java │ │ │ ├── LazyEither4Instances.java │ │ │ ├── LazyEitherInstances.java │ │ │ ├── MaybeInstances.java │ │ │ ├── OptionInstances.java │ │ │ ├── RWSInstances.java │ │ │ ├── ReaderInstances.java │ │ │ ├── StateInstances.java │ │ │ ├── TryInstances.java │ │ │ ├── WriterInstances.java │ │ │ └── transformers │ │ │ │ ├── EitherTransformer.java │ │ │ │ ├── IdentityTransformer.java │ │ │ │ ├── MaybeTransformer.java │ │ │ │ └── TryTransformer.java │ │ ├── data │ │ │ ├── LazySeqInstances.java │ │ │ ├── SeqInstances.java │ │ │ ├── VectorInstances.java │ │ │ └── tuple │ │ │ │ ├── Tuple1Instances.java │ │ │ │ └── Tuple2Instances.java │ │ ├── free │ │ │ ├── FreeApInstances.java │ │ │ └── FreeInstances.java │ │ ├── jdk │ │ │ ├── CompletableFutureInstances.java │ │ │ ├── OptionalInstances.java │ │ │ ├── PredicateInstances.java │ │ │ ├── StreamInstances.java │ │ │ ├── SupplierInstances.java │ │ │ └── transformers │ │ │ │ └── OptionalTransformer.java │ │ └── reactive │ │ │ ├── IOInstances.java │ │ │ ├── IterableInstances.java │ │ │ ├── PublisherInstances.java │ │ │ └── collections │ │ │ ├── immutable │ │ │ ├── LinkedListXInstances.java │ │ │ ├── PersistentQueueXInstances.java │ │ │ ├── PersistentSetXInstances.java │ │ │ └── VectorXInstances.java │ │ │ └── mutable │ │ │ ├── DequeXInstances.java │ │ │ ├── ListXInstances.java │ │ │ ├── QueueXInstances.java │ │ │ └── SetXInstances.java │ │ ├── kinds │ │ ├── CompletableFutureKind.java │ │ ├── OptionalKind.java │ │ ├── PredicateKind.java │ │ ├── StreamKind.java │ │ └── SupplierKind.java │ │ ├── reactive │ │ └── IOMonad.java │ │ ├── transformers │ │ ├── Transformer.java │ │ └── TransformerFactory.java │ │ └── typeclasses │ │ ├── Combine.java │ │ ├── Comprehensions.java │ │ ├── Do.java │ │ ├── Filterable.java │ │ ├── InstanceDefinitions.java │ │ ├── Pure.java │ │ ├── Show.java │ │ ├── comonad │ │ ├── Comonad.java │ │ └── ComonadByPure.java │ │ ├── foldable │ │ ├── Foldable.java │ │ └── Unfoldable.java │ │ ├── functor │ │ ├── BiFunctor.java │ │ ├── Compose.java │ │ ├── ContravariantFunctor.java │ │ ├── FilterableFunctor.java │ │ ├── Functor.java │ │ └── ProFunctor.java │ │ ├── instances │ │ └── General.java │ │ └── monad │ │ ├── Applicative.java │ │ ├── ApplicativeError.java │ │ ├── ComposedTraverse.java │ │ ├── Monad.java │ │ ├── MonadPlus.java │ │ ├── MonadRec.java │ │ ├── MonadZero.java │ │ ├── Traverse.java │ │ ├── TraverseBySequence.java │ │ └── TraverseByTraverse.java │ └── test │ └── java │ └── cyclops │ ├── control │ ├── ReaderWriterStateTest.java │ ├── StateTest.java │ └── reader │ │ ├── Application.java │ │ ├── DITest.java │ │ ├── User.java │ │ ├── UserInfo.java │ │ ├── UserRepository.java │ │ └── Users.java │ ├── data │ └── tuple │ │ └── Tuple1Test.java │ ├── free │ ├── CharToy.java │ ├── CofreeTest.java │ └── FreeTest.java │ ├── reactive │ └── IOMonadTest.java │ └── typeclasses │ ├── ActiveTest.java │ ├── BaseDoGuardTest.java │ ├── BaseDoTest.java │ ├── CoproductTest.java │ ├── Do1Test.java │ ├── Do2Test.java │ ├── Do3Test.java │ ├── Do4Test.java │ ├── Do5Test.java │ ├── Do6Test.java │ ├── Do7Test.java │ ├── DoTest.java │ ├── KleisliTest.java │ ├── NestedTest.java │ ├── cyclops │ ├── DequesTest.java │ ├── EvalsTest.java │ ├── FuturesTest.java │ ├── ListsTest.java │ ├── MaybesTest.java │ ├── OptionsTest.java │ ├── PQueuesTest.java │ ├── PStacksTest.java │ ├── PVectorsTest.java │ └── QueuesTest.java │ ├── jdk │ ├── CompletableFuturesTest.java │ ├── OptionalsTest.java │ └── StreamsTest.java │ ├── monads │ └── MonadRecTest.java │ └── taglessfinal │ ├── AccountAlgebra.java │ ├── AccountAlgebra2.java │ ├── AccountIO.java │ ├── AccountIO2.java │ ├── Cases.java │ ├── LogAlgebra.java │ ├── LogID.java │ ├── LogIO.java │ ├── Program.java │ ├── Program2.java │ ├── Program3.java │ ├── ProgramStore.java │ ├── StoreAlgebra.java │ ├── StoreIO.java │ ├── TaglessFinal2Test.java │ ├── TaglessFinal3Test.java │ ├── TaglessFinal4Test.java │ └── TaglessFinalTest.java ├── cyclops-reactive-collections ├── README.MD ├── build.gradle ├── gradle.properties └── src │ ├── main │ └── java │ │ ├── com │ │ └── oath │ │ │ └── cyclops │ │ │ ├── ReactiveConvertableSequence.java │ │ │ └── data │ │ │ ├── ReactiveWitness.java │ │ │ └── collections │ │ │ └── extensions │ │ │ ├── CollectionX.java │ │ │ ├── CollectionXImpl.java │ │ │ ├── FluentCollectionX.java │ │ │ ├── FluentMapX.java │ │ │ ├── IndexedSequenceX.java │ │ │ ├── LazyFluentCollection.java │ │ │ ├── LazyFluentCollectionX.java │ │ │ ├── lazy │ │ │ ├── AbstractLazyCollection.java │ │ │ ├── LazyDequeX.java │ │ │ ├── LazyListX.java │ │ │ ├── LazyQueueX.java │ │ │ ├── LazySetX.java │ │ │ ├── LazySortedSetX.java │ │ │ └── immutable │ │ │ │ ├── AbstractLazyPersistentCollection.java │ │ │ │ ├── FoldToList.java │ │ │ │ ├── LazyLinkedListX.java │ │ │ │ ├── LazyPBagX.java │ │ │ │ ├── LazyPOrderedSetX.java │ │ │ │ ├── LazyPQueueX.java │ │ │ │ ├── LazyPSetX.java │ │ │ │ └── LazyPVectorX.java │ │ │ └── standard │ │ │ ├── LazyCollectionX.java │ │ │ ├── MapXImpl.java │ │ │ └── MutableSequenceX.java │ │ └── cyclops │ │ ├── ReactiveMonoids.java │ │ ├── ReactiveReducers.java │ │ ├── ReactiveSemigroups.java │ │ └── reactive │ │ ├── ReactiveCollections.java │ │ ├── collections │ │ ├── immutable │ │ │ ├── BagX.java │ │ │ ├── LinkedListX.java │ │ │ ├── OrderedSetX.java │ │ │ ├── PersistentQueueX.java │ │ │ ├── PersistentSetX.java │ │ │ └── VectorX.java │ │ └── mutable │ │ │ ├── DequeX.java │ │ │ ├── ListX.java │ │ │ ├── MapX.java │ │ │ ├── QueueX.java │ │ │ ├── SetX.java │ │ │ └── SortedSetX.java │ │ └── companion │ │ ├── Converters.java │ │ ├── CyclopsCollectors.java │ │ └── MapXs.java │ └── test │ └── java │ └── cyclops │ ├── AbstractConvertableSequenceTest.java │ └── reactive │ ├── ClojureOrJava8.java │ ├── SemigroupsTest.java │ ├── SpoutsAsyncCollectionsTest.java │ ├── SpoutsCollectionsTest.java │ ├── collections │ ├── AbstractCollectionXTest.java │ ├── AbstractOrderDependentCollectionXTest.java │ ├── AbstractSetTest.java │ ├── CollectionXTestsWithNulls.java │ ├── ConvertersTest.java │ ├── ExampleTest.java │ ├── NQueens.java │ ├── NQueensPStackTest.java │ ├── NQueensVectorTest.java │ ├── PersistentExample.java │ ├── ReactiveStreamsTest.java │ ├── SchedulingTest.java │ ├── ZipAsyncTest.java │ ├── guava │ │ ├── DequeXGenerator.java │ │ ├── DequeXTestSuite.java │ │ ├── ListXGenerator.java │ │ ├── ListXTestSuite.java │ │ ├── QueueXGenerator.java │ │ ├── QueueXTestSuite.java │ │ ├── SetXGenerator.java │ │ ├── SetXTestSuite.java │ │ ├── SortedSetTestSuite.java │ │ └── SortedSetXGenerator.java │ ├── persistent │ │ ├── LinkedListErrorTest.java │ │ ├── PBagXTest.java │ │ ├── POrderedSetXTest.java │ │ ├── PQueueXTest.java │ │ ├── PSetXTest.java │ │ ├── PStackXTest.java │ │ └── PVectorXTest.java │ └── standard │ │ ├── DequeXTest.java │ │ ├── ListXCollectableTest.java │ │ ├── ListXExamples.java │ │ ├── ListXTest.java │ │ ├── MapXsTest.java │ │ ├── QueueXTest.java │ │ ├── SetXTest.java │ │ └── SortedSetXTest.java │ └── data │ └── collections │ ├── PBagsTest.java │ ├── POrderedSetsTest.java │ ├── PQueuesTest.java │ ├── PSetsTest.java │ ├── PStacksTest.java │ ├── PVectorsTest.java │ ├── SimplePerfCheck.java │ └── extensions │ ├── lazy │ └── LazyListXTest.java │ └── standard │ └── MapXImplTest.java ├── cyclops-reactor-integration ├── README.md ├── build.gradle ├── gradle.properties └── src │ ├── main │ └── java │ │ ├── com │ │ └── oath │ │ │ └── cyclops │ │ │ └── reactor │ │ │ └── adapter │ │ │ ├── FluxAdapter.java │ │ │ ├── FluxReactiveSeqImpl.java │ │ │ └── MonoAdapter.java │ │ └── cyclops │ │ ├── companion │ │ └── reactor │ │ │ ├── Fluxs.java │ │ │ └── Monos.java │ │ ├── monads │ │ ├── FluxAnyM.java │ │ ├── MonoAnyM.java │ │ ├── ReactorWitness.java │ │ └── transformers │ │ │ └── reactor │ │ │ └── MonoT.java │ │ ├── reactive │ │ ├── FluxCollections.java │ │ ├── FluxIO.java │ │ ├── FluxManaged.java │ │ └── FluxReactiveSeq.java │ │ └── streams │ │ └── ReactorOperators.java │ └── test │ └── java │ ├── com │ └── oath │ │ └── cyclops │ │ └── reactor │ │ ├── FluxesTest.java │ │ ├── Functor2.java │ │ └── ReactorTest.java │ └── cyclops │ ├── companion │ ├── FluxsTest.java │ └── MonosTest.java │ ├── monads │ └── transformers │ │ ├── MonoTTest.java │ │ ├── StreamTSeqConvertableSequenceTest.java │ │ ├── StreamTSeqNestedFoldableTest.java │ │ ├── StreamTSeqTraversableTest.java │ │ └── StreamTTest.java │ ├── reactive │ ├── FluxCollectionsTest.java │ ├── FluxIOTest.java │ ├── FluxManagedTest.java │ └── HibernateManagedTest.java │ └── streams │ ├── CollectableTest.java │ ├── FluxReactiveSeqTest.java │ ├── asyncreactivestreams │ ├── AsyncRSBatchingTest.java │ ├── AsyncRSCollectableTest.java │ ├── AsyncRSExtensionOperatorsTest.java │ ├── AsyncRSJDKStreamTest.java │ ├── AsyncRSPartitionAndSplittingTest.java │ ├── AsyncRSReactiveStreamXTest.java │ ├── AsyncRSRetryTest.java │ ├── AsyncRSScanningTest.java │ ├── AsyncRSSchedulingTest.java │ ├── AsyncRSSequentialTest.java │ └── AsyncRSZippingTest.java │ ├── reactivestreamspath │ ├── BatchingRSTest.java │ ├── ExtensionOperatorsRSTest.java │ ├── PartitionAndSplittingRSTest.java │ ├── ReactiveJDKStreamRSTest.java │ ├── ReactiveScanningRSTest.java │ └── ReactiveZippingRSTest.java │ └── syncflux │ ├── SyncBatchingTest.java │ ├── SyncJDKStreamTest.java │ ├── SyncPartitionAndSplittingTest.java │ ├── SyncRSCollectableTest.java │ ├── SyncRSExtensionOperatorsTest.java │ ├── SyncReactiveStreamXTest.java │ ├── SyncRetryTest.java │ ├── SyncScanningTest.java │ ├── SyncSchedulingTest.java │ ├── SyncSequentialTest.java │ └── SyncZippingTest.java ├── cyclops-rxjava2-integration ├── README.md ├── build.gradle ├── gradle.properties └── src │ ├── main │ └── java │ │ ├── com │ │ └── oath │ │ │ └── cyclops │ │ │ └── rx2 │ │ │ └── adapter │ │ │ ├── FlowableAdapter.java │ │ │ ├── FlowableReactiveSeqImpl.java │ │ │ ├── MaybeAdapter.java │ │ │ ├── ObservableAdapter.java │ │ │ ├── ObservableReactiveSeqImpl.java │ │ │ └── SingleAdapter.java │ │ └── cyclops │ │ ├── companion │ │ └── rx2 │ │ │ ├── Flowables.java │ │ │ ├── Functions.java │ │ │ ├── Maybes.java │ │ │ ├── Observables.java │ │ │ └── Singles.java │ │ ├── monads │ │ ├── FlowableAnyM.java │ │ ├── MaybeAnyM.java │ │ ├── ObservableAnyM.java │ │ ├── Rx2Witness.java │ │ ├── SingleAnyM.java │ │ └── transformers │ │ │ └── rx2 │ │ │ ├── MaybeT.java │ │ │ └── SingleT.java │ │ ├── reactive │ │ ├── FlowableCollections.java │ │ ├── FlowableIO.java │ │ ├── FlowableManaged.java │ │ ├── FlowableReactiveSeq.java │ │ ├── ObservableCollections.java │ │ └── ObservableReactiveSeq.java │ │ └── streams │ │ └── Rx2Operators.java │ └── test │ └── java │ ├── com │ └── oath │ │ └── cyclops │ │ └── rx │ │ └── RxTest.java │ └── cyclops │ ├── companion │ ├── FlowablesTest.java │ └── SinglesTest.java │ ├── monads │ └── transformers │ │ ├── MaybeTTest.java │ │ ├── SingleTTest.java │ │ ├── flowables │ │ ├── StreamTSeqConvertableSequenceTest.java │ │ ├── StreamTSeqNestedFoldableTest.java │ │ └── StreamTSeqTraversableTest.java │ │ └── observables │ │ ├── StreamTSeqConvertableSequenceTest.java │ │ ├── StreamTSeqNestedFoldableTest.java │ │ └── StreamTSeqTraversableTest.java │ ├── reactive │ ├── FlowableCollectionsTest.java │ ├── FlowableIOTest.java │ ├── FlowableManagedTest.java │ ├── HibernateManagedTest.java │ └── ObservableCollectionsTest.java │ └── streams │ ├── flowables │ ├── CollectableTest.java │ ├── FlowableReactiveSeqTest.java │ ├── asyncreactivestreams │ │ ├── AsyncRSBatchingTest.java │ │ ├── AsyncRSCollectableTest.java │ │ ├── AsyncRSExtensionOperatorsTest.java │ │ ├── AsyncRSJDKStreamTest.java │ │ ├── AsyncRSPartitionAndSplittingTest.java │ │ ├── AsyncRSReactiveStreamXTest.java │ │ ├── AsyncRSRetryTest.java │ │ ├── AsyncRSScanningTest.java │ │ ├── AsyncRSSchedulingTest.java │ │ ├── AsyncRSSequentialTest.java │ │ └── AsyncRSZippingTest.java │ ├── reactivestreamspath │ │ ├── BatchingRSTest.java │ │ ├── ExtensionOperatorsRSTest.java │ │ ├── PartitionAndSplittingRSTest.java │ │ ├── ReactiveJDKStreamRSTest.java │ │ ├── ReactiveScanningRSTest.java │ │ └── ReactiveZippingRSTest.java │ └── syncflux │ │ ├── SyncBatchingTest.java │ │ ├── SyncJDKStreamTest.java │ │ ├── SyncPartitionAndSplittingTest.java │ │ ├── SyncRSCollectableTest.java │ │ ├── SyncRSExtensionOperatorsTest.java │ │ ├── SyncReactiveStreamXTest.java │ │ ├── SyncRetryTest.java │ │ ├── SyncScanningTest.java │ │ ├── SyncSchedulingTest.java │ │ ├── SyncSequentialTest.java │ │ └── SyncZippingTest.java │ └── observables │ ├── AsyncCollectableTest.java │ ├── AsyncConnectableTest.java │ ├── AsyncCycle.java │ ├── AsyncExtensionOperatorsTest.java │ ├── AsyncForEachSequenceMTest.java │ ├── AsyncForEachTest.java │ ├── AsyncJDKStreamTest.java │ ├── AsyncPartitionAndSplittingTest.java │ ├── AsyncPrimedConnectableTest.java │ ├── AsyncReactiveStreamXTest.java │ ├── AsyncRetryTest.java │ ├── AsyncScanningTest.java │ ├── AsyncSchedulingTest.java │ ├── AsyncSequentialTest.java │ ├── AsyncZippingTest.java │ ├── BatchingTest.java │ └── CollectableTest.java ├── cyclops ├── README.MD ├── build.gradle ├── gradle.properties └── src │ ├── jmh │ ├── java │ │ ├── cyclops │ │ │ ├── DataAppend.java │ │ │ ├── DataGet.java │ │ │ ├── DataSet.java │ │ │ ├── VectorOps.java │ │ │ ├── VectorTest.java │ │ │ ├── data │ │ │ │ ├── chain │ │ │ │ │ └── ChainAppend.java │ │ │ │ ├── seq │ │ │ │ │ ├── SeqMap.java │ │ │ │ │ └── SeqPrepend.java │ │ │ │ └── vector │ │ │ │ │ ├── VectorFilter.java │ │ │ │ │ ├── VectorFlatMap.java │ │ │ │ │ ├── VectorFoldLeft.java │ │ │ │ │ ├── VectorMap.java │ │ │ │ │ └── VectorZip.java │ │ │ └── reactiveSeq │ │ │ │ ├── Combinations.java │ │ │ │ ├── FindFirst.java │ │ │ │ ├── FlatMapCollect.java │ │ │ │ ├── FlatMapForEach.java │ │ │ │ ├── FlatMapLarge.java │ │ │ │ ├── Map.java │ │ │ │ ├── Map5.java │ │ │ │ └── MapLarge.java │ │ └── scrabble │ │ │ ├── IdenticalToStream.java │ │ │ ├── IterableSpliterator.java │ │ │ ├── IxScanLeftTakeRight.java │ │ │ ├── NonParallelStreams.java │ │ │ ├── ScanLeftTakeRight.java │ │ │ ├── ShakespearePlaysScrabble.java │ │ │ ├── ShakespearePlaysScrabbleWithStreams.java │ │ │ └── Util.java │ └── resources │ │ └── files │ │ ├── ospd.txt │ │ └── words.shakespeare.txt │ ├── main │ └── java │ │ ├── com │ │ └── oath │ │ │ └── cyclops │ │ │ ├── async │ │ │ ├── QueueFactories.java │ │ │ ├── adapters │ │ │ │ ├── Adapter.java │ │ │ │ ├── AdaptersModule.java │ │ │ │ ├── ContinuationStrategy.java │ │ │ │ ├── Queue.java │ │ │ │ ├── QueueFactory.java │ │ │ │ ├── Signal.java │ │ │ │ └── Topic.java │ │ │ └── wait │ │ │ │ ├── DirectWaitStrategy.java │ │ │ │ ├── ExponentialBackofWaitStrategy.java │ │ │ │ ├── NoWaitRetry.java │ │ │ │ ├── SpinWait.java │ │ │ │ ├── WaitStrategy.java │ │ │ │ └── YieldWait.java │ │ │ ├── hkt │ │ │ ├── Convert.java │ │ │ ├── DataWitness.java │ │ │ ├── Higher.java │ │ │ ├── Higher2.java │ │ │ ├── Higher3.java │ │ │ └── Higher4.java │ │ │ ├── internal │ │ │ ├── react │ │ │ │ └── exceptions │ │ │ │ │ └── SimpleReactProcessingException.java │ │ │ └── stream │ │ │ │ ├── BaseConnectableImpl.java │ │ │ │ ├── BaseExtendedStream.java │ │ │ │ ├── FullQueueException.java │ │ │ │ ├── FutureStreamUtils.java │ │ │ │ ├── IteratorHotStream.java │ │ │ │ ├── OneShotStreamX.java │ │ │ │ ├── PausableConnectableImpl.java │ │ │ │ ├── ReactiveStreamX.java │ │ │ │ ├── ReversedIterator.java │ │ │ │ ├── SeqUtils.java │ │ │ │ ├── SpliteratorBasedStream.java │ │ │ │ ├── StreamX.java │ │ │ │ ├── StreamableImpl.java │ │ │ │ ├── operators │ │ │ │ ├── DebounceOperator.java │ │ │ │ ├── MultiReduceOperator.java │ │ │ │ ├── OnePerOperator.java │ │ │ │ └── RecoverOperator.java │ │ │ │ ├── publisher │ │ │ │ └── PublisherIterable.java │ │ │ │ └── spliterators │ │ │ │ ├── ArrayConcatonatingSpliterator.java │ │ │ │ ├── BaseComposableSpliterator.java │ │ │ │ ├── ClosingSpliterator.java │ │ │ │ ├── CompleteSpliterator.java │ │ │ │ ├── Composable.java │ │ │ │ ├── ComposableFunction.java │ │ │ │ ├── ConcatonatingSpliterator.java │ │ │ │ ├── CopyableSpliterator.java │ │ │ │ ├── DistinctKeySpliterator.java │ │ │ │ ├── DistinctSpliterator.java │ │ │ │ ├── FillSpliterator.java │ │ │ │ ├── FilteringSpliterator.java │ │ │ │ ├── ForEachWithError.java │ │ │ │ ├── FunctionSpliterator.java │ │ │ │ ├── GroupedByTimeAndSizeSpliterator.java │ │ │ │ ├── GroupedByTimeSpliterator.java │ │ │ │ ├── GroupedStatefullySpliterator.java │ │ │ │ ├── GroupedWhileSpliterator.java │ │ │ │ ├── GroupingSpliterator.java │ │ │ │ ├── IterableFlatMappingSpliterator.java │ │ │ │ ├── IteratableSpliterator.java │ │ │ │ ├── IteratePredicateSpliterator.java │ │ │ │ ├── IterateSpliterator.java │ │ │ │ ├── LazyFilteringSpliterator.java │ │ │ │ ├── LazyMappingSpliterator.java │ │ │ │ ├── LazySingleSpliterator.java │ │ │ │ ├── LimitLastOneSpliterator.java │ │ │ │ ├── LimitLastSpliterator.java │ │ │ │ ├── LimitSpliterator.java │ │ │ │ ├── LimitWhileClosedSpliterator.java │ │ │ │ ├── LimitWhileSpliterator.java │ │ │ │ ├── LimitWhileTimeSpliterator.java │ │ │ │ ├── MappingSpliterator.java │ │ │ │ ├── OnEmptyGetSpliterator.java │ │ │ │ ├── OnEmptySpliterator.java │ │ │ │ ├── OnEmptyThrowSpliterator.java │ │ │ │ ├── OnErrorBreakSpliterator.java │ │ │ │ ├── OnErrorBreakWithPublisherSpliterator.java │ │ │ │ ├── PublisherFlatMappingSpliterator.java │ │ │ │ ├── RecoverSpliterator.java │ │ │ │ ├── ReversableSpliterator.java │ │ │ │ ├── ReversingArraySpliterator.java │ │ │ │ ├── ReversingListSpliterator.java │ │ │ │ ├── ScanLeftSpliterator.java │ │ │ │ ├── SingleSpliterator.java │ │ │ │ ├── SkipLastSpliterator.java │ │ │ │ ├── SkipSpliterator.java │ │ │ │ ├── SkipWhileClosedSpliterator.java │ │ │ │ ├── SkipWhileSpliterator.java │ │ │ │ ├── SkipWhileTimeSpliterator.java │ │ │ │ ├── SlidingSpliterator.java │ │ │ │ ├── StreamFlatMappingSpliterator.java │ │ │ │ ├── UnfoldSpliterator.java │ │ │ │ ├── Zipping3Spliterator.java │ │ │ │ ├── Zipping4Spliterator.java │ │ │ │ ├── ZippingSpliterator.java │ │ │ │ ├── doubles │ │ │ │ └── ReversingDoubleArraySpliterator.java │ │ │ │ ├── ints │ │ │ │ ├── ReversingIntArraySpliterator.java │ │ │ │ └── ReversingRangeIntSpliterator.java │ │ │ │ ├── longs │ │ │ │ ├── ReversingLongArraySpliterator.java │ │ │ │ └── ReversingRangeLongSpliterator.java │ │ │ │ └── push │ │ │ │ ├── AmbOperator.java │ │ │ │ ├── ArrayConcatonatingOperator.java │ │ │ │ ├── ArrayOfValuesOperator.java │ │ │ │ ├── BaseOperator.java │ │ │ │ ├── BufferingSinkOperator.java │ │ │ │ ├── CapturingOperator.java │ │ │ │ ├── CollectAllOperator.java │ │ │ │ ├── CollectingSinkSpliterator.java │ │ │ │ ├── CombineOperator.java │ │ │ │ ├── CompleteOperator.java │ │ │ │ ├── Concat.java │ │ │ │ ├── ConcurrentFlatMapper.java │ │ │ │ ├── FilterOperator.java │ │ │ │ ├── FlatMapOperator.java │ │ │ │ ├── FlatMapPublisher.java │ │ │ │ ├── GenerateOperator.java │ │ │ │ ├── GroupedByTimeAndSizeOperator.java │ │ │ │ ├── GroupedByTimeOperator.java │ │ │ │ ├── GroupedStatefullyOperator.java │ │ │ │ ├── GroupedWhileOperator.java │ │ │ │ ├── GroupingOperator.java │ │ │ │ ├── IterableSourceOperator.java │ │ │ │ ├── IterateOperator.java │ │ │ │ ├── IteratePredicateOperator.java │ │ │ │ ├── LazyArrayConcatonatingOperator.java │ │ │ │ ├── LazyConcat.java │ │ │ │ ├── LazyFilterOperator.java │ │ │ │ ├── LazyMapOperator.java │ │ │ │ ├── LazySingleValueOperator.java │ │ │ │ ├── LimitLastOneOperator.java │ │ │ │ ├── LimitLastOperator.java │ │ │ │ ├── LimitOperator.java │ │ │ │ ├── LimitWhileClosedOperator.java │ │ │ │ ├── LimitWhileOperator.java │ │ │ │ ├── LimitWhileTimeOperator.java │ │ │ │ ├── MapOperator.java │ │ │ │ ├── MergeLatestOperator.java │ │ │ │ ├── MultiCastOperator.java │ │ │ │ ├── OnEmptyErrorOperator.java │ │ │ │ ├── OnEmptyOperator.java │ │ │ │ ├── OnErrorBreakOperator.java │ │ │ │ ├── OnErrorBreakWithPublisherOperator.java │ │ │ │ ├── Operator.java │ │ │ │ ├── OperatorToIterable.java │ │ │ │ ├── PublisherToOperator.java │ │ │ │ ├── RangeIntOperator.java │ │ │ │ ├── RangeLongOperator.java │ │ │ │ ├── RecoverOperator.java │ │ │ │ ├── ReduceAllOperator.java │ │ │ │ ├── SingleValueOperator.java │ │ │ │ ├── SkipLastOneOperator.java │ │ │ │ ├── SkipLastOperator.java │ │ │ │ ├── SkipOperator.java │ │ │ │ ├── SkipWhileClosedOperator.java │ │ │ │ ├── SkipWhileOperator.java │ │ │ │ ├── SkipWhileTimeOperator.java │ │ │ │ ├── SlidingOperator.java │ │ │ │ ├── SpliteratorToOperator.java │ │ │ │ ├── StreamSubscription.java │ │ │ │ ├── TestOperatorToIterable.java │ │ │ │ ├── ValueEmittingSpliterator.java │ │ │ │ ├── ZippingLatestOperator.java │ │ │ │ └── ZippingOperator.java │ │ │ ├── matching │ │ │ ├── Case.java │ │ │ ├── Deconstruct.java │ │ │ ├── Matching.java │ │ │ ├── Pattern.java │ │ │ ├── Sealed2.java │ │ │ ├── Sealed3.java │ │ │ ├── Sealed4.java │ │ │ ├── Sealed5.java │ │ │ └── SealedOr.java │ │ │ ├── react │ │ │ ├── ThreadPools.java │ │ │ └── async │ │ │ │ └── subscription │ │ │ │ ├── AlwaysContinue.java │ │ │ │ ├── Continueable.java │ │ │ │ └── Subscription.java │ │ │ ├── types │ │ │ ├── Filters.java │ │ │ ├── MonadicValue.java │ │ │ ├── OrElseValue.java │ │ │ ├── Present.java │ │ │ ├── Unwrappable.java │ │ │ ├── Value.java │ │ │ ├── Zippable.java │ │ │ ├── factory │ │ │ │ ├── EmptyUnit.java │ │ │ │ └── Unit.java │ │ │ ├── foldable │ │ │ │ ├── Contains.java │ │ │ │ ├── ConvertableSequence.java │ │ │ │ ├── EqualTo.java │ │ │ │ ├── Evaluation.java │ │ │ │ ├── Folds.java │ │ │ │ ├── OrderedBy.java │ │ │ │ └── To.java │ │ │ ├── functor │ │ │ │ ├── BiTransformable.java │ │ │ │ ├── FilterableTransformable.java │ │ │ │ ├── ReactiveTransformable.java │ │ │ │ └── Transformable.java │ │ │ ├── futurestream │ │ │ │ └── Continuation.java │ │ │ ├── mixins │ │ │ │ └── Printable.java │ │ │ ├── persistent │ │ │ │ ├── PersistentBag.java │ │ │ │ ├── PersistentCollection.java │ │ │ │ ├── PersistentIndexed.java │ │ │ │ ├── PersistentList.java │ │ │ │ ├── PersistentMap.java │ │ │ │ ├── PersistentQueue.java │ │ │ │ ├── PersistentSet.java │ │ │ │ ├── PersistentSortedSet.java │ │ │ │ └── views │ │ │ │ │ ├── ListView.java │ │ │ │ │ ├── MapView.java │ │ │ │ │ ├── QueueView.java │ │ │ │ │ ├── SetView.java │ │ │ │ │ └── SortedSetView.java │ │ │ ├── reactive │ │ │ │ ├── AsyncSubscriber.java │ │ │ │ ├── BufferOverflowPolicy.java │ │ │ │ ├── Completable.java │ │ │ │ ├── PushSubscriber.java │ │ │ │ ├── QueueBasedSubscriber.java │ │ │ │ ├── ReactiveStreamsTerminalFutureOperations.java │ │ │ │ ├── ReactiveStreamsTerminalOperations.java │ │ │ │ ├── ReactiveSubscriber.java │ │ │ │ ├── ReactiveTask.java │ │ │ │ └── ValueSubscriber.java │ │ │ ├── recoverable │ │ │ │ ├── OnEmpty.java │ │ │ │ ├── OnEmptyError.java │ │ │ │ ├── OnEmptySwitch.java │ │ │ │ ├── Recoverable.java │ │ │ │ └── RecoverableFrom.java │ │ │ ├── stream │ │ │ │ ├── Connectable.java │ │ │ │ ├── FromStream.java │ │ │ │ ├── HasExec.java │ │ │ │ ├── HasStream.java │ │ │ │ ├── NonPausableConnectable.java │ │ │ │ ├── PausableConnectable.java │ │ │ │ └── ToStream.java │ │ │ └── traversable │ │ │ │ ├── IterableFilterable.java │ │ │ │ ├── IterableX.java │ │ │ │ ├── RecoverableTraversable.java │ │ │ │ └── Traversable.java │ │ │ └── util │ │ │ ├── ExceptionSoftener.java │ │ │ ├── SimpleTimer.java │ │ │ ├── ThrowsSoftened.java │ │ │ ├── box │ │ │ ├── LazyImmutable.java │ │ │ ├── Mutable.java │ │ │ ├── MutableBoolean.java │ │ │ ├── MutableByte.java │ │ │ ├── MutableChar.java │ │ │ ├── MutableDouble.java │ │ │ ├── MutableFloat.java │ │ │ ├── MutableInt.java │ │ │ ├── MutableLong.java │ │ │ └── MutableShort.java │ │ │ └── stream │ │ │ └── scheduling │ │ │ └── cron │ │ │ └── CronExpression.java │ │ └── cyclops │ │ ├── companion │ │ ├── BiFunctions.java │ │ ├── Comparators.java │ │ ├── CompletableFutures.java │ │ ├── Eithers.java │ │ ├── Functions.java │ │ ├── Groups.java │ │ ├── Iterables.java │ │ ├── Monoids.java │ │ ├── Optionals.java │ │ ├── Reducers.java │ │ ├── Semigroups.java │ │ ├── Streamable.java │ │ └── Streams.java │ │ ├── control │ │ ├── Either.java │ │ ├── Eval.java │ │ ├── Future.java │ │ ├── Ior.java │ │ ├── LazyEither.java │ │ ├── LazyEither3.java │ │ ├── LazyEither4.java │ │ ├── LazyEither5.java │ │ ├── Maybe.java │ │ ├── Option.java │ │ ├── Trampoline.java │ │ ├── Try.java │ │ ├── Unrestricted.java │ │ └── Validated.java │ │ ├── data │ │ ├── Bag.java │ │ ├── BankersQueue.java │ │ ├── Chain.java │ │ ├── DIET.java │ │ ├── DMap.java │ │ ├── DifferenceList.java │ │ ├── Enumeration.java │ │ ├── HList.java │ │ ├── HashMap.java │ │ ├── HashSet.java │ │ ├── ImmutableList.java │ │ ├── ImmutableMap.java │ │ ├── ImmutableQueue.java │ │ ├── ImmutableSet.java │ │ ├── ImmutableSortedSet.java │ │ ├── IntMap.java │ │ ├── LazySeq.java │ │ ├── LazyString.java │ │ ├── LinkedMap.java │ │ ├── NonEmptyChain.java │ │ ├── NonEmptyList.java │ │ ├── Range.java │ │ ├── Seq.java │ │ ├── Tree.java │ │ ├── TreeMap.java │ │ ├── TreeSet.java │ │ ├── TrieMap.java │ │ ├── TrieSet.java │ │ ├── Vector.java │ │ ├── Zipper.java │ │ ├── base │ │ │ ├── BAMT.java │ │ │ ├── HAMT.java │ │ │ ├── HashedPatriciaTrie.java │ │ │ ├── IntPatriciaTrie.java │ │ │ └── RedBlackTree.java │ │ └── tuple │ │ │ ├── Tuple.java │ │ │ ├── Tuple0.java │ │ │ ├── Tuple1.java │ │ │ ├── Tuple2.java │ │ │ ├── Tuple3.java │ │ │ ├── Tuple4.java │ │ │ ├── Tuple5.java │ │ │ ├── Tuple6.java │ │ │ ├── Tuple7.java │ │ │ └── Tuple8.java │ │ ├── function │ │ ├── BinaryFunction.java │ │ ├── BooleanFunction0.java │ │ ├── Cacheable.java │ │ ├── Consumer3.java │ │ ├── Consumer4.java │ │ ├── Consumer5.java │ │ ├── Curry.java │ │ ├── CurryConsumer.java │ │ ├── CurryVariance.java │ │ ├── Effect.java │ │ ├── Eq.java │ │ ├── FluentFunctions.java │ │ ├── Function0.java │ │ ├── Function1.java │ │ ├── Function2.java │ │ ├── Function3.java │ │ ├── Function4.java │ │ ├── Function5.java │ │ ├── Function6.java │ │ ├── Function7.java │ │ ├── Function8.java │ │ ├── Group.java │ │ ├── Lambda.java │ │ ├── Memoize.java │ │ ├── Monoid.java │ │ ├── NaturalTransformation.java │ │ ├── Ord.java │ │ ├── Ordering.java │ │ ├── PartialApplicator.java │ │ ├── PartialFunction.java │ │ ├── Predicate3.java │ │ ├── Predicate4.java │ │ ├── Predicate5.java │ │ ├── Predicate6.java │ │ ├── Predicate7.java │ │ ├── Predicate8.java │ │ ├── Predicates.java │ │ ├── Reducer.java │ │ ├── Semigroup.java │ │ ├── SoftenedCacheable.java │ │ ├── UnaryFunction.java │ │ ├── Uncurry.java │ │ ├── UncurryConsumer.java │ │ └── checked │ │ │ ├── CheckedBiConsumer.java │ │ │ ├── CheckedBiFunction.java │ │ │ ├── CheckedBiPredicate.java │ │ │ ├── CheckedBooleanSupplier.java │ │ │ ├── CheckedConsumer.java │ │ │ ├── CheckedDoubleConsumer.java │ │ │ ├── CheckedDoubleFunction.java │ │ │ ├── CheckedDoublePredicate.java │ │ │ ├── CheckedDoubleSupplier.java │ │ │ ├── CheckedFunction.java │ │ │ ├── CheckedIntConsumer.java │ │ │ ├── CheckedIntFunction.java │ │ │ ├── CheckedIntPredicate.java │ │ │ ├── CheckedIntSupplier.java │ │ │ ├── CheckedLongConsumer.java │ │ │ ├── CheckedLongFunction.java │ │ │ ├── CheckedLongPredicate.java │ │ │ ├── CheckedLongSupplier.java │ │ │ ├── CheckedPredicate.java │ │ │ ├── CheckedSupplier.java │ │ │ └── CheckedTriFunction.java │ │ ├── matching │ │ └── Api.java │ │ └── reactive │ │ ├── Generator.java │ │ ├── IO.java │ │ ├── Managed.java │ │ ├── ReactiveSeq.java │ │ └── Spouts.java │ └── test │ ├── java │ ├── com │ │ └── oath │ │ │ └── cyclops │ │ │ ├── XorsTest.java │ │ │ ├── closures │ │ │ ├── immutable │ │ │ │ └── ImmutableClosedValueTest.java │ │ │ └── mutable │ │ │ │ ├── MutableBooleanTest.java │ │ │ │ ├── MutableByteTest.java │ │ │ │ ├── MutableCharTest.java │ │ │ │ ├── MutableDoubleTest.java │ │ │ │ ├── MutableFloatTest.java │ │ │ │ ├── MutableIntTest.java │ │ │ │ ├── MutableLongTest.java │ │ │ │ ├── MutableShortTest.java │ │ │ │ └── MutableTest.java │ │ │ ├── comprehensions │ │ │ ├── CompletableFutureTest.java │ │ │ ├── ForPublishersTest.java │ │ │ ├── MixedDoTest.java │ │ │ ├── OptionalRunTest.java │ │ │ ├── OptionalTest.java │ │ │ ├── StreamTest.java │ │ │ └── donotation │ │ │ │ └── typed │ │ │ │ └── DoTest.java │ │ │ ├── control │ │ │ └── OptionalsTest.java │ │ │ ├── functions │ │ │ └── fluent │ │ │ │ ├── ExpressionTest.java │ │ │ │ ├── FluentBiFunctionTest.java │ │ │ │ ├── FluentFunctionTest.java │ │ │ │ ├── FluentSupplierTest.java │ │ │ │ └── FluentTriFunctionTest.java │ │ │ ├── internal │ │ │ └── stream │ │ │ │ └── spliterators │ │ │ │ ├── StreamFlatMappingSpliteratorTest.java │ │ │ │ ├── push │ │ │ │ ├── AbstractOperatorTest.java │ │ │ │ ├── AmbTest.java │ │ │ │ ├── Fixtures.java │ │ │ │ ├── LimitWhileClosedOperatorTest.java │ │ │ │ ├── LimitWhileOperatorTest.java │ │ │ │ ├── SkipWhileClosedOperatorTest.java │ │ │ │ ├── SkipWhileOperatorTest.java │ │ │ │ ├── SubscriberSource.java │ │ │ │ ├── arrayconcat │ │ │ │ │ ├── ArrayConcatTest.java │ │ │ │ │ └── ArrayConcatonatingOperatorTest.java │ │ │ │ ├── combine │ │ │ │ │ └── CombineTckPublisherTest.java │ │ │ │ ├── filter │ │ │ │ │ ├── FilterGenerateTckPublisherTest.java │ │ │ │ │ ├── FilterIterableTckPublisherTest.java │ │ │ │ │ ├── FilterOperatorTest.java │ │ │ │ │ ├── FilterOpteratorToIterableTckPublisherTest.java │ │ │ │ │ ├── FilterRangeIntTckPublisherTest.java │ │ │ │ │ ├── FilterRangeLongTckPublisherTest.java │ │ │ │ │ ├── FilterSpliteratorTckPublisherTest.java │ │ │ │ │ ├── FilterTckArrayConcatPublisherTest.java │ │ │ │ │ ├── FilterTckBlackBoxSubscriberTest.java │ │ │ │ │ └── FilterTckPublisherTest.java │ │ │ │ ├── flatMap │ │ │ │ │ ├── iterable │ │ │ │ │ │ ├── FlatMapOperatorTest.java │ │ │ │ │ │ ├── FlatMapTckPublisherTest.java │ │ │ │ │ │ ├── IterableFlatMap2TckPublisherTest.java │ │ │ │ │ │ └── IterableFlatMapTest.java │ │ │ │ │ ├── publisher │ │ │ │ │ │ ├── FlatMapPublisherTest.java │ │ │ │ │ │ ├── PublisherFlatMap2TckPublisherTest.java │ │ │ │ │ │ └── PublisherFlatMapTckPublisherTest.java │ │ │ │ │ └── stream │ │ │ │ │ │ ├── FlatMap2TckPublisherTest.java │ │ │ │ │ │ ├── FlatMapOperatorAsyncRSTest.java │ │ │ │ │ │ ├── FlatMapOperatorTest.java │ │ │ │ │ │ ├── FlatMapTckPublisherTest.java │ │ │ │ │ │ └── FlatMapTest.java │ │ │ │ ├── grouping │ │ │ │ │ ├── GroupedOperatorTest.java │ │ │ │ │ ├── GroupedTckPublisherTest.java │ │ │ │ │ ├── GroupedTest.java │ │ │ │ │ ├── groupedTimeAndSize │ │ │ │ │ │ ├── GroupedBySizeAndTimeTckPublisherTest.java │ │ │ │ │ │ └── GroupedByTimeAndSizeOperatorTest.java │ │ │ │ │ ├── groupedWhile │ │ │ │ │ │ ├── GroupedWhileTckPublisherTest.java │ │ │ │ │ │ └── GroupedWhileTest.java │ │ │ │ │ └── sliding │ │ │ │ │ │ ├── SlidingOperatorTest.java │ │ │ │ │ │ ├── SlidingTckPublisherTest.java │ │ │ │ │ │ └── SlidingTest.java │ │ │ │ ├── lazySingleValue │ │ │ │ │ └── LazySingleValueOperatorTest.java │ │ │ │ ├── map │ │ │ │ │ ├── MapOperatorTest.java │ │ │ │ │ ├── MapTckBlackBoxSubscriberTest.java │ │ │ │ │ └── MapTckPublisherTest.java │ │ │ │ ├── mergelatest │ │ │ │ │ ├── MergeLatestTckPublisherTest.java │ │ │ │ │ └── MergeLatestTest.java │ │ │ │ ├── rangeLong │ │ │ │ │ └── RangeLongTest.java │ │ │ │ ├── scan │ │ │ │ │ ├── ScanLimitTckPublisherTest.java │ │ │ │ │ ├── ScanOperatorTest.java │ │ │ │ │ ├── ScanTckPublisherTest.java │ │ │ │ │ └── ScanTest.java │ │ │ │ ├── skip │ │ │ │ │ └── SkipOperatorTest.java │ │ │ │ ├── spliterator │ │ │ │ │ └── SpliteratorToOperatorTest.java │ │ │ │ └── zip │ │ │ │ │ ├── ZipAsyncTest.java │ │ │ │ │ ├── ZipOperatorTest.java │ │ │ │ │ └── ZipTckPublisherTest.java │ │ │ │ └── standard │ │ │ │ └── flatMap │ │ │ │ ├── iterable │ │ │ │ └── IterableFlatMapTest.java │ │ │ │ ├── publisher │ │ │ │ ├── FlatMapPublisherListTest.java │ │ │ │ └── FlatMapPublisherTest.java │ │ │ │ └── stream │ │ │ │ └── FlatMapTest.java │ │ │ ├── invokedynamic │ │ │ ├── ExceptionSoftener2Test.java │ │ │ └── ExceptionSoftenerTest.java │ │ │ ├── lambda │ │ │ └── functions │ │ │ │ ├── CurryConsumerTest.java │ │ │ │ ├── CurryTest.java │ │ │ │ ├── CurryVarianceTest.java │ │ │ │ ├── MemoiseTest.java │ │ │ │ ├── PartialApplicatorTest.java │ │ │ │ ├── UncurryConsumerTest.java │ │ │ │ └── UncurryTest.java │ │ │ ├── matching │ │ │ ├── ApiTest.java │ │ │ ├── Case0Test.java │ │ │ ├── Case1Test.java │ │ │ ├── Case2Test.java │ │ │ ├── Case3Test.java │ │ │ ├── Case4Test.java │ │ │ ├── Case5Test.java │ │ │ ├── CaseOptionalTest.java │ │ │ ├── OptionalMatchingTest.java │ │ │ ├── PatternMatchingTest.java │ │ │ └── sample │ │ │ │ └── Pet.java │ │ │ ├── streams │ │ │ ├── AsStreamableTest.java │ │ │ ├── BaseSequentialTest.java │ │ │ ├── BatchingTest.java │ │ │ ├── CoreReactiveSeqTest.java │ │ │ ├── FlatMapStreamUtilsTest.java │ │ │ ├── ForComprehensionsTest.java │ │ │ ├── LiftAndBindStreamUtilsTest.java │ │ │ ├── PartitionAndSplittingTest.java │ │ │ ├── RangeTest.java │ │ │ ├── ReactiveSeqCollectableTest.java │ │ │ ├── ReductionTest.java │ │ │ ├── RetryTest.java │ │ │ ├── ScanningTest.java │ │ │ ├── SeqTest.java │ │ │ ├── SequenceMTest.java │ │ │ ├── StreamUtilsStreamTest.java │ │ │ ├── StreamUtilsTest.java │ │ │ ├── WindowingPushTest.java │ │ │ ├── WindowingTest.java │ │ │ ├── ZippingTest.java │ │ │ ├── future │ │ │ │ ├── ForEachSequenceMFutureTest.java │ │ │ │ └── FutureTest.java │ │ │ ├── hotstream │ │ │ │ ├── ConnectableTest.java │ │ │ │ ├── ConnectionTesst.java │ │ │ │ ├── PrimedConnectableTest.java │ │ │ │ └── SchedulingTest.java │ │ │ ├── reactivestreams │ │ │ │ ├── ForEachSequenceMTest.java │ │ │ │ ├── ForEachTest.java │ │ │ │ └── ValueSubscriberTest.java │ │ │ └── streamable │ │ │ │ ├── BatchingTest.java │ │ │ │ ├── CoreStreamableTest.java │ │ │ │ ├── PartitionAndSplittingTest.java │ │ │ │ ├── ReductionTest.java │ │ │ │ ├── RetryTest.java │ │ │ │ ├── ReverseTest.java │ │ │ │ ├── SQLTest.java │ │ │ │ ├── ScanningTest.java │ │ │ │ ├── SequenceMTest.java │ │ │ │ ├── StreamableSeqOpertationsTest.java │ │ │ │ ├── StreamableStreamOperatorsTest.java │ │ │ │ ├── WindowingTest.java │ │ │ │ └── ZippingTest.java │ │ │ ├── trycatch │ │ │ ├── FailureTest.java │ │ │ ├── GenericsTest.java │ │ │ ├── StreamTest.java │ │ │ ├── SuccessTest.java │ │ │ └── TryTest.java │ │ │ ├── types │ │ │ ├── AbstractFoldableTest.java │ │ │ ├── AbstractTraversableTest.java │ │ │ ├── AbstractValueTest.java │ │ │ ├── UnwrappableTest.java │ │ │ └── foldable │ │ │ │ ├── AbstractConvertableSequenceTest.java │ │ │ │ └── StatCollectorsTest.java │ │ │ ├── util │ │ │ ├── CompletableFuturesTest.java │ │ │ ├── function │ │ │ │ └── PredicatesTest.java │ │ │ └── stream │ │ │ │ └── reactivestreams │ │ │ │ ├── TckBlackBoxSubscriberTest.java │ │ │ │ └── TckWhiteBoxSubscriberTest.java │ │ │ └── value │ │ │ ├── AsStreamableValueTest.java │ │ │ └── AsValueTest.java │ └── cyclops │ │ ├── Sets.java │ │ ├── companion │ │ ├── BiFunctionsTest.java │ │ ├── MonoidsTest.java │ │ ├── ReducersTest.java │ │ ├── SemigroupsTest.java │ │ └── StreamsTest.java │ │ ├── control │ │ ├── AbstractOptionTest.java │ │ ├── AbstractOrElseValueTest.java │ │ ├── AbstractValueTest.java │ │ ├── Book.java │ │ ├── GeneratorTest.java │ │ ├── computations │ │ │ ├── ToyLanguage.java │ │ │ └── UnrestrictedTest.java │ │ ├── either │ │ │ ├── Either2Test.java │ │ │ ├── EitherLeftTest.java │ │ │ ├── EitherRightTest.java │ │ │ └── EitherTest.java │ │ ├── eval │ │ │ ├── CompletableEvalTest.java │ │ │ ├── Eval2Test.java │ │ │ └── EvalTest.java │ │ ├── future │ │ │ ├── FutureOrElseValueTest.java │ │ │ ├── FutureTest.java │ │ │ └── futureOverwriteIssue │ │ │ │ ├── AuthorizationService3.java │ │ │ │ ├── DataFileMetadata.java │ │ │ │ ├── Processor.java │ │ │ │ ├── SleepingURLDataFileMetadata.java │ │ │ │ ├── SuccessURLDataFileMetadata.java │ │ │ │ ├── URLDataFileMetadata.java │ │ │ │ └── User.java │ │ ├── ior │ │ │ ├── Ior2Test.java │ │ │ ├── IorBothTest.java │ │ │ ├── IorOrElseValueTest.java │ │ │ ├── IorPrimaryTest.java │ │ │ └── IorSecondaryTest.java │ │ ├── lazy │ │ │ ├── CompletableEither3Test.java │ │ │ ├── CompletableEither4Test.java │ │ │ ├── CompletableEither5Test.java │ │ │ ├── CompletableEitherTest.java │ │ │ ├── Either3Test.java │ │ │ ├── Either4Test.java │ │ │ ├── Either5Test.java │ │ │ ├── EitherTest.java │ │ │ ├── LazyEither3OrElseValueTest.java │ │ │ ├── LazyEither4OrElseValueTest.java │ │ │ ├── LazyEither5OrElseValueTest.java │ │ │ ├── LazyEitherOrElseValueTest.java │ │ │ └── MaybeTest.java │ │ ├── maybe │ │ │ ├── CompletableMaybeTest.java │ │ │ ├── MaybeOrElseValueTest.java │ │ │ ├── MaybeTest.java │ │ │ └── MaybeValueTest.java │ │ ├── option │ │ │ ├── OptionOrElseValueTest.java │ │ │ └── OptionTest.java │ │ ├── trampoline │ │ │ ├── EvalTrampolineTest.java │ │ │ ├── MaybeTrampolineTest.java │ │ │ └── TrampolineTest.java │ │ ├── trytests │ │ │ ├── TryOrElseValueTest.java │ │ │ └── TryTest.java │ │ └── validated │ │ │ ├── ValidatedOrElseValueTest.java │ │ │ └── ValidatedTest.java │ │ ├── data │ │ ├── BQTest.java │ │ ├── BagTest.java │ │ ├── BankersQueueTest.java │ │ ├── ChainTest.java │ │ ├── DIETTest.java │ │ ├── DMapTest.java │ │ ├── DifferenceListTest.java │ │ ├── EnumerationTest.java │ │ ├── HListTest.java │ │ ├── HashMapTest.java │ │ ├── HashSet2Test.java │ │ ├── HashSetTest.java │ │ ├── ImmutableHashMapTest.java │ │ ├── ImmutableLinkedMapTest.java │ │ ├── ImmutableTreeMapTest.java │ │ ├── ImmutableTrieMapTest.java │ │ ├── IntMapTest.java │ │ ├── LazySeqTest.java │ │ ├── LazyStringTest.java │ │ ├── ListTest.java │ │ ├── NaturalTransformationTest.java │ │ ├── NonEmptyListTest.java │ │ ├── RBTTest.java │ │ ├── RangeTest.java │ │ ├── SeqTest.java │ │ ├── TreeMapTest.java │ │ ├── TreeSetTest.java │ │ ├── TrieSetTest.java │ │ ├── VectorTest.java │ │ ├── ZipperTest.java │ │ ├── base │ │ │ ├── FiveTest.java │ │ │ ├── FourTest.java │ │ │ ├── HAMTTest.java │ │ │ ├── SixTest.java │ │ │ ├── ThreeTest.java │ │ │ └── TwoTest.java │ │ ├── basetests │ │ │ ├── AbstractIterableXTest.java │ │ │ ├── BaseImmutableListTest.java │ │ │ ├── BaseImmutableMapTest.java │ │ │ ├── BaseImmutableQueueTest.java │ │ │ ├── BaseImmutableSetTest.java │ │ │ ├── BaseImmutableSortedSetTest.java │ │ │ └── HeadAndTail.java │ │ ├── chain │ │ │ ├── AppendTest.java │ │ │ ├── IteratorTest.java │ │ │ ├── SingletonTest.java │ │ │ └── WrapTest.java │ │ ├── talk │ │ │ ├── EitherExample.java │ │ │ ├── EvalExample.java │ │ │ ├── Example.java │ │ │ ├── ImmutabeListThreadsTest.java │ │ │ ├── ImmutableTest.java │ │ │ ├── LazySeqExample.java │ │ │ ├── ListThreadsTest.java │ │ │ ├── NotLazySeqStub.java │ │ │ ├── OptionExample.java │ │ │ ├── UnmodifiableTest.java │ │ │ ├── VectorExample.java │ │ │ ├── arraylist │ │ │ │ ├── immutable │ │ │ │ │ ├── replace │ │ │ │ │ │ └── ImmutableArrayList.java │ │ │ │ │ ├── set │ │ │ │ │ │ └── ImmutableList.java │ │ │ │ │ └── stub │ │ │ │ │ │ └── ImmutableList.java │ │ │ │ ├── mutable │ │ │ │ │ ├── get │ │ │ │ │ │ └── MutableArrayList.java │ │ │ │ │ ├── set │ │ │ │ │ │ └── MutableArrayList.java │ │ │ │ │ └── stub │ │ │ │ │ │ └── MutableArrayList.java │ │ │ │ ├── notneeded │ │ │ │ │ ├── PersistentListTwoAppend.java │ │ │ │ │ ├── PersistentTail.java │ │ │ │ │ └── PersistentTailAppend.java │ │ │ │ └── persistent │ │ │ │ │ ├── one │ │ │ │ │ ├── get │ │ │ │ │ │ └── One.java │ │ │ │ │ ├── set │ │ │ │ │ │ └── One.java │ │ │ │ │ └── stub │ │ │ │ │ │ └── One.java │ │ │ │ │ └── two │ │ │ │ │ ├── get │ │ │ │ │ └── Two.java │ │ │ │ │ ├── set │ │ │ │ │ └── Two.java │ │ │ │ │ └── stub │ │ │ │ │ └── Two.java │ │ │ └── linkedlist │ │ │ │ ├── LazySeq.java │ │ │ │ └── Seq.java │ │ └── tuple │ │ │ ├── Tuple1Test.java │ │ │ ├── Tuple2Test.java │ │ │ ├── Tuple3Test.java │ │ │ ├── Tuple4Test.java │ │ │ ├── Tuple5Test.java │ │ │ ├── Tuple6Test.java │ │ │ ├── Tuple7Test.java │ │ │ └── Tuple8Test.java │ │ ├── function │ │ ├── Function0Test.java │ │ ├── Function1Test.java │ │ ├── Function2Test.java │ │ ├── Function3Test.java │ │ ├── MemoizeTest.java │ │ ├── MonoidTest.java │ │ └── PartialFunctionTest.java │ │ ├── reactive │ │ ├── AbstractIOTestBase.java │ │ ├── CheckedManagedTest.java │ │ ├── HibernateManagedTest.java │ │ ├── IOCheckedTest.java │ │ ├── IOTest.java │ │ ├── ManagedTest.java │ │ ├── SpoutsConcatTest.java │ │ ├── SpoutsTest.java │ │ ├── SpoutsZipTest.java │ │ ├── SyncIOTest.java │ │ └── SyncManagedTest.java │ │ └── streams │ │ ├── AbstractReactiveSeqTest.java │ │ ├── BaseSequenceTest.java │ │ ├── CollectableTest.java │ │ ├── PullReactiveSeqTest.java │ │ ├── ReactiveSeqIterableXTest.java │ │ ├── ReactiveSeqTest.java │ │ └── push │ │ ├── BatchingTest.java │ │ ├── BlockingTest.java │ │ ├── CoreReactiveStreamXTest.java │ │ ├── ExtensionOperatorsTest.java │ │ ├── ForEachSequenceMTest.java │ │ ├── ForEachTest.java │ │ ├── PartitionAndSplittingTest.java │ │ ├── PushSequentialTest.java │ │ ├── ReactiveJDKStreamTest.java │ │ ├── ReactiveRangeTest.java │ │ ├── ReactiveScanningTest.java │ │ ├── ReactiveStreamXCollectableTest.java │ │ ├── ReactiveStreamsTest.java │ │ ├── ReactiveZippingTest.java │ │ ├── RetryTest.java │ │ ├── SpoutsIterableXTest.java │ │ ├── ValueSubscriberTest.java │ │ ├── async │ │ ├── AsyncCollectableTest.java │ │ ├── AsyncConnectableTest.java │ │ ├── AsyncCycle.java │ │ ├── AsyncExtensionOperatorsTest.java │ │ ├── AsyncForEachSequenceMTest.java │ │ ├── AsyncForEachTest.java │ │ ├── AsyncJDKStreamTest.java │ │ ├── AsyncPartitionAndSplittingTest.java │ │ ├── AsyncPrimedConnectableTest.java │ │ ├── AsyncReactiveSeqTest.java │ │ ├── AsyncReactiveStreamXTest.java │ │ ├── AsyncRetryTest.java │ │ ├── AsyncScanningTest.java │ │ ├── AsyncSchedulingTest.java │ │ ├── AsyncSequentialTest.java │ │ ├── AsyncZippingTest.java │ │ └── BatchingTest.java │ │ ├── asyncreactivestreams │ │ ├── AsyncRSBatchingTest.java │ │ ├── AsyncRSCollectableTest.java │ │ ├── AsyncRSExtensionOperatorsTest.java │ │ ├── AsyncRSFlatMapPTest.java │ │ ├── AsyncRSJDKStreamTest.java │ │ ├── AsyncRSPartitionAndSplittingTest.java │ │ ├── AsyncRSReactiveSeqTest.java │ │ ├── AsyncRSReactiveStreamXTest.java │ │ ├── AsyncRSRetryTest.java │ │ ├── AsyncRSScanningTest.java │ │ ├── AsyncRSSchedulingTest.java │ │ ├── AsyncRSSequentialTest.java │ │ └── AsyncRSZippingTest.java │ │ ├── hotstream │ │ ├── ConnectableTest.java │ │ ├── ConnectionTesst.java │ │ ├── PrimedConnectableTest.java │ │ └── SchedulingTest.java │ │ ├── reactivestreamspath │ │ ├── BatchingRSTest.java │ │ ├── ExtensionOperatorsRSTest.java │ │ ├── PartitionAndSplittingRSTest.java │ │ ├── ReactiveJDKStreamRSTest.java │ │ ├── ReactiveScanningRSTest.java │ │ └── ReactiveZippingRSTest.java │ │ └── syncflux │ │ ├── SyncBatchingTest.java │ │ ├── SyncJDKStreamTest.java │ │ ├── SyncPartitionAndSplittingTest.java │ │ ├── SyncRSCollectableTest.java │ │ ├── SyncRSExtensionOperatorsTest.java │ │ ├── SyncRSReactiveSeqTest.java │ │ ├── SyncReactiveStreamXTest.java │ │ ├── SyncRetryTest.java │ │ ├── SyncScanningTest.java │ │ ├── SyncSchedulingTest.java │ │ ├── SyncSequentialTest.java │ │ └── SyncZippingTest.java │ └── resources │ ├── input.file │ └── input2.file ├── gradle.properties ├── gradle ├── jacoco-aggregator.gradle ├── jacoco-config.gradle ├── jacoco-excludes.gradle ├── jacoco-version.gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── license-for-derived-quartz-cronrexpression.md └── settings.gradle /.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig is awesome: http://EditorConfig.org 2 | 3 | root = true 4 | 5 | [*] 6 | charset = utf-8 7 | end_of_line = lf 8 | trim_trailing_whitespace = true 9 | insert_final_newline = true 10 | indent_style = space 11 | indent_size = 4 12 | 13 | [*.md] 14 | trim_trailing_whitespace = false 15 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior: 15 | 16 | 17 | **Expected behavior** 18 | A clear and concise description of what you expected to happen. 19 | 20 | **Screenshots / test / examples** 21 | If applicable, add screenshots to help explain your problem. 22 | 23 | 24 | **Additional context** 25 | Add any other context about the problem here. 26 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /.java-version: -------------------------------------------------------------------------------- 1 | 1.8.0.181 2 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: true 2 | language: java 3 | jdk: 4 | - openjdk8 5 | install: ./gradlew clean 6 | after_success: 7 | - bash <(curl -s https://codecov.io/bash) 8 | script: 9 | - ./gradlew assemble 10 | - ./gradlew build jacoco --parallel --max-workers 4 11 | 12 | before_cache: 13 | - rm -f $HOME/.gradle/caches/modules-2/modules-2.lock 14 | - rm -fr $HOME/.gradle/caches/*/plugin-resolution/ 15 | 16 | cache: 17 | directories: 18 | - $HOME/.gradle/caches/ 19 | - $HOME/.gradle/wrapper/ -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing guidelines 2 | 3 | Thanks for helping out! We recommend following a number of steps to make the contribution process as smooth as possible 4 | 5 | 6 | * Log (or select) an Issue you would like to work on. This is a good opportunity to get early input and allow the community to know about what you plan to work on. 7 | 8 | * [Issues](https://github.com/aol/cyclops/issues) 9 | * [New Issues](https://github.com/aol/cyclops/issues/new) 10 | * Fork the cyclops repo 11 | * Implement your feature - with unit tests! 12 | * Create a PR for your feature that references the issue number 13 | * Try to avoid making formating or other unrelated changes in a feature PR 14 | * On merge consider adding a wiki entry about your feature if appropriate 15 | * Thank you so much! 16 | 17 | ## Building cyclops 18 | 19 | ```groovy 20 | ./gradlew clean build 21 | ``` 22 | 23 | -------------------------------------------------------------------------------- /cyclops-anym/gradle.properties: -------------------------------------------------------------------------------- 1 | POM_NAME=cyclops-anym 2 | -------------------------------------------------------------------------------- /cyclops-anym/src/main/java/com/oath/cyclops/anym/extensability/AbstractMonadAdapter.java: -------------------------------------------------------------------------------- 1 | package com.oath.cyclops.anym.extensability; 2 | 3 | import java.util.function.Function; 4 | 5 | import cyclops.monads.AnyM; 6 | 7 | import cyclops.monads.WitnessType; 8 | 9 | 10 | public abstract class AbstractMonadAdapter> implements MonadAdapter { 11 | 12 | @Override 13 | public abstract AnyM ap(AnyM> fn, AnyM apply); 14 | 15 | @Override 16 | public AnyM map(AnyM t, Function fn) { 17 | return flatMap(t,fn.andThen(a->this.unit(a))); 18 | } 19 | 20 | @Override 21 | public abstract AnyM flatMap(AnyM t, Function> fn); 22 | 23 | @Override 24 | public abstract AnyM unitIterable(Iterable it); 25 | 26 | 27 | 28 | 29 | } 30 | -------------------------------------------------------------------------------- /cyclops-anym/src/main/java/com/oath/cyclops/anym/extensability/ValueAdapter.java: -------------------------------------------------------------------------------- 1 | package com.oath.cyclops.anym.extensability; 2 | 3 | 4 | import com.oath.cyclops.anym.AnyMValue; 5 | import cyclops.control.Option; 6 | 7 | import cyclops.monads.WitnessType; 8 | 9 | import java.util.function.Function; 10 | 11 | public interface ValueAdapter> extends MonadAdapter { 12 | 13 | default R fold(Function,? extends R> fn1, Function, ? extends R> fn2){ 14 | return fn2.apply(this); 15 | } 16 | Option get(AnyMValue t); 17 | } 18 | -------------------------------------------------------------------------------- /cyclops-anym/src/main/java/com/oath/cyclops/anym/internal/monads/BaseAnyMImpl.java: -------------------------------------------------------------------------------- 1 | package com.oath.cyclops.anym.internal.monads; 2 | 3 | import com.oath.cyclops.anym.extensability.MonadAdapter; 4 | import cyclops.monads.AnyMs; 5 | import cyclops.monads.WitnessType; 6 | 7 | import lombok.AccessLevel; 8 | import lombok.AllArgsConstructor; 9 | 10 | /** 11 | * 12 | * Wrapper for Any Monad type 13 | * @see AnyMs companion class for static helper methods 14 | * 15 | * @author johnmcclean 16 | * 17 | */ 18 | @AllArgsConstructor(access = AccessLevel.PROTECTED) 19 | public abstract class BaseAnyMImpl,T> { 20 | 21 | protected final Object monad; 22 | protected final MonadAdapter adapter; 23 | 24 | public MonadAdapter adapter(){ 25 | return adapter; 26 | } 27 | 28 | 29 | public R unwrap(){ 30 | return (R)monad; 31 | } 32 | 33 | 34 | @Override 35 | public String toString() { 36 | return String.format("AnyM(%s)", monad); 37 | } 38 | 39 | 40 | 41 | } 42 | -------------------------------------------------------------------------------- /cyclops-anym/src/main/java/cyclops/monads/WitnessType.java: -------------------------------------------------------------------------------- 1 | package cyclops.monads; 2 | 3 | import com.oath.cyclops.anym.extensability.MonadAdapter; 4 | 5 | public interface WitnessType> { 6 | 7 | MonadAdapter adapter(); 8 | } 9 | -------------------------------------------------------------------------------- /cyclops-anym/src/main/java/cyclops/monads/function/AnyMFunction3.java: -------------------------------------------------------------------------------- 1 | package cyclops.monads.function; 2 | 3 | import cyclops.function.Function3; 4 | import cyclops.monads.AnyM; 5 | import cyclops.monads.WitnessType; 6 | 7 | import java.util.function.BiFunction; 8 | 9 | /** 10 | * Created by johnmcclean on 18/12/2016. 11 | */ 12 | @FunctionalInterface 13 | public interface AnyMFunction3,T1,T2,T3,R> extends Function3,AnyM,AnyM,AnyM> { 14 | static ,T1,T2,T3,R> AnyMFunction3 liftF(Function3 fn){ 15 | return (u1, u2, u3) -> u1.flatMapA(input1 -> u2.flatMapA(input2 -> u3.map(input3 -> fn.apply(input1, input2, input3)))); 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /cyclops-anym/src/main/java/cyclops/monads/function/AnyMFunction4.java: -------------------------------------------------------------------------------- 1 | package cyclops.monads.function; 2 | 3 | import cyclops.function.Function4; 4 | import cyclops.monads.AnyM; 5 | import cyclops.monads.WitnessType; 6 | 7 | /** 8 | * Created by johnmcclean on 18/12/2016. 9 | */ 10 | @FunctionalInterface 11 | public interface AnyMFunction4,T1,T2,T3,T4,R> extends Function4,AnyM,AnyM,AnyM,AnyM> { 12 | 13 | } 14 | -------------------------------------------------------------------------------- /cyclops-anym/src/main/java/cyclops/monads/function/AnyMFunction5.java: -------------------------------------------------------------------------------- 1 | package cyclops.monads.function; 2 | 3 | import cyclops.function.Function5; 4 | import cyclops.monads.AnyM; 5 | import cyclops.monads.WitnessType; 6 | 7 | /** 8 | * Created by johnmcclean on 18/12/2016. 9 | */ 10 | @FunctionalInterface 11 | public interface AnyMFunction5,T1,T2,T3,T4,T5,R> extends Function5,AnyM,AnyM,AnyM,AnyM,AnyM> { 12 | 13 | } 14 | -------------------------------------------------------------------------------- /cyclops-anym/src/main/java/cyclops/monads/function/AnyMFunction6.java: -------------------------------------------------------------------------------- 1 | package cyclops.monads.function; 2 | 3 | import cyclops.function.Function6; 4 | import cyclops.monads.AnyM; 5 | import cyclops.monads.WitnessType; 6 | 7 | /** 8 | * Created by johnmcclean on 18/12/2016. 9 | */ 10 | @FunctionalInterface 11 | public interface AnyMFunction6,T1,T2,T3,T4,T5,T6,R> extends Function6,AnyM,AnyM,AnyM,AnyM,AnyM,AnyM> { 12 | 13 | } 14 | -------------------------------------------------------------------------------- /cyclops-anym/src/main/java/cyclops/monads/function/AnyMFunction7.java: -------------------------------------------------------------------------------- 1 | package cyclops.monads.function; 2 | 3 | import cyclops.function.Function7; 4 | import cyclops.monads.WitnessType; 5 | import cyclops.monads.AnyM; 6 | 7 | /** 8 | * Created by johnmcclean on 18/12/2016. 9 | */ 10 | @FunctionalInterface 11 | public interface AnyMFunction7,T1,T2,T3,T4,T5,T6,T7,R> extends Function7,AnyM,AnyM,AnyM,AnyM,AnyM,AnyM,AnyM> { 12 | 13 | } 14 | -------------------------------------------------------------------------------- /cyclops-anym/src/main/java/cyclops/monads/function/AnyMFunction8.java: -------------------------------------------------------------------------------- 1 | package cyclops.monads.function; 2 | 3 | import cyclops.function.Function8; 4 | import cyclops.monads.AnyM; 5 | import cyclops.monads.WitnessType; 6 | 7 | /** 8 | * Created by johnmcclean on 18/12/2016. 9 | */ 10 | @FunctionalInterface 11 | public interface AnyMFunction8,T1,T2,T3,T4,T5,T6,T7,T8,R> extends Function8,AnyM,AnyM,AnyM,AnyM,AnyM,AnyM,AnyM,AnyM> { 12 | 13 | } 14 | -------------------------------------------------------------------------------- /cyclops-anym/src/main/java/cyclops/monads/function/BinaryAnyMFunction.java: -------------------------------------------------------------------------------- 1 | package cyclops.monads.function; 2 | 3 | import cyclops.monads.AnyM; 4 | import cyclops.monads.WitnessType; 5 | 6 | import java.util.function.BinaryOperator; 7 | 8 | 9 | public interface BinaryAnyMFunction,T> extends BinaryOperator>, AnyMFunction2 { 10 | } 11 | -------------------------------------------------------------------------------- /cyclops-anym/src/main/java/cyclops/monads/function/UnaryAnyMFunction.java: -------------------------------------------------------------------------------- 1 | package cyclops.monads.function; 2 | 3 | import cyclops.monads.AnyM; 4 | 5 | import cyclops.monads.WitnessType; 6 | import cyclops.monads.function.AnyMFunction1; 7 | 8 | import java.util.function.UnaryOperator; 9 | 10 | 11 | public interface UnaryAnyMFunction,T> extends UnaryOperator>, AnyMFunction1 { 12 | } 13 | -------------------------------------------------------------------------------- /cyclops-anym/src/test/java/cyclops/monads/XorMTest.java: -------------------------------------------------------------------------------- 1 | package cyclops.monads; 2 | 3 | import cyclops.monads.Witness.maybe; 4 | import cyclops.monads.Witness.stream; 5 | import org.junit.Test; 6 | 7 | import static org.hamcrest.Matchers.equalTo; 8 | import static org.junit.Assert.*; 9 | 10 | 11 | public class XorMTest { 12 | 13 | XorM just = XorM.just(10); 14 | 15 | @Test 16 | public void map(){ 17 | assertThat(just.map(i->i*2),equalTo(XorM.just(20))); 18 | } 19 | @Test 20 | public void filter(){ 21 | assertThat(just.filter(i->i<10),equalTo(XorM.none())); 22 | } 23 | @Test 24 | public void filterTrue(){ 25 | assertThat(just.filter(i->i<11),equalTo(just)); 26 | } 27 | 28 | @Test 29 | public void visit(){ 30 | assertThat(just.fold(s->Witness.stream(s).count(), m->Witness.maybe(m).toOptional().get()),equalTo(10)); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /cyclops-anym/src/test/java/cyclops/monads/anym/value/IorAnyMValueTest.java: -------------------------------------------------------------------------------- 1 | package cyclops.monads.anym.value; 2 | 3 | import static org.hamcrest.Matchers.equalTo; 4 | import static org.junit.Assert.assertThat; 5 | 6 | import com.oath.cyclops.util.box.Mutable; 7 | import cyclops.monads.Witness; 8 | import cyclops.monads.Witness.ior; 9 | import org.junit.Before; 10 | import org.junit.Test; 11 | 12 | import cyclops.monads.AnyM; 13 | import cyclops.control.Ior; 14 | 15 | public class IorAnyMValueTest extends BaseAnyMValueTest { 16 | @Before 17 | public void setUp() throws Exception { 18 | just = AnyM.fromIor(Ior.right(10)); 19 | none = AnyM.fromIor(Ior.left(null)); 20 | } 21 | @Test 22 | public void testPeek() { 23 | Mutable capture = Mutable.of(null); 24 | 25 | just = just.peek(c->capture.set(c)); 26 | 27 | 28 | just.get(); 29 | assertThat(capture.get(),equalTo(10)); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /cyclops-anym/src/test/java/cyclops/monads/anym/value/MaybeAnyMValueTest.java: -------------------------------------------------------------------------------- 1 | package cyclops.monads.anym.value; 2 | 3 | import com.oath.cyclops.util.box.Mutable; 4 | import cyclops.monads.AnyM; 5 | import cyclops.control.Maybe; 6 | import cyclops.monads.Witness; 7 | import cyclops.monads.Witness.maybe; 8 | import org.junit.Before; 9 | import org.junit.Test; 10 | 11 | import static org.hamcrest.Matchers.equalTo; 12 | import static org.junit.Assert.assertNull; 13 | import static org.junit.Assert.assertThat; 14 | 15 | public class MaybeAnyMValueTest extends BaseAnyMValueTest { 16 | @Before 17 | public void setUp() throws Exception { 18 | just = AnyM.fromMaybe(Maybe.of(10)); 19 | none = AnyM.fromMaybe(Maybe.nothing()); 20 | } 21 | @Test 22 | public void testPeek() { 23 | Mutable capture = Mutable.of(null); 24 | just = just.peek(c->capture.set(c)); 25 | assertNull(capture.get()); 26 | 27 | just.get(); 28 | assertThat(capture.get(),equalTo(10)); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /cyclops-anym/src/test/java/cyclops/monads/anym/value/OptionalAnyMValueTest.java: -------------------------------------------------------------------------------- 1 | package cyclops.monads.anym.value; 2 | 3 | import java.util.Optional; 4 | 5 | import cyclops.monads.Witness; 6 | import cyclops.monads.Witness.optional; 7 | import org.junit.Before; 8 | 9 | import cyclops.monads.AnyM; 10 | 11 | public class OptionalAnyMValueTest extends BaseAnyMValueTest { 12 | @Before 13 | public void setUp() throws Exception { 14 | just = AnyM.fromOptional(Optional.of(10)); 15 | none = AnyM.fromOptional(Optional.empty()); 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /cyclops-anym/src/test/java/cyclops/monads/anym/value/TryAnyMValueTest.java: -------------------------------------------------------------------------------- 1 | package cyclops.monads.anym.value; 2 | 3 | import static org.hamcrest.Matchers.equalTo; 4 | import static org.junit.Assert.assertThat; 5 | 6 | import com.oath.cyclops.util.box.Mutable; 7 | import cyclops.monads.Witness; 8 | import cyclops.monads.Witness.tryType; 9 | import org.junit.Before; 10 | import org.junit.Test; 11 | 12 | import cyclops.monads.AnyM; 13 | import cyclops.control.Try; 14 | 15 | import java.util.NoSuchElementException; 16 | 17 | public class TryAnyMValueTest extends BaseAnyMValueTest { 18 | @Before 19 | public void setUp() throws Exception { 20 | just = AnyM.fromTry(Try.success(10)); 21 | none = AnyM.fromTry(Try.failure(new NoSuchElementException())); 22 | } 23 | @Test 24 | public void testPeek() { 25 | Mutable capture = Mutable.of(null); 26 | just = just.peek(c->capture.set(c)); 27 | 28 | 29 | just.get(); 30 | assertThat(capture.get(),equalTo(10)); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /cyclops-anym/src/test/java/cyclops/monads/anym/value/XorAnyMValueTest.java: -------------------------------------------------------------------------------- 1 | package cyclops.monads.anym.value; 2 | 3 | import static org.hamcrest.Matchers.equalTo; 4 | import static org.junit.Assert.assertThat; 5 | 6 | import cyclops.monads.Witness.either; 7 | import org.junit.Before; 8 | import org.junit.Test; 9 | 10 | import cyclops.monads.AnyM; 11 | import cyclops.control.Either; 12 | import com.oath.cyclops.util.box.Mutable; 13 | 14 | public class XorAnyMValueTest extends BaseAnyMValueTest { 15 | @Before 16 | public void setUp() throws Exception { 17 | just = AnyM.fromEither(Either.right(10)); 18 | none = AnyM.fromEither(Either.left(null)); 19 | } 20 | @Test 21 | public void testPeek() { 22 | Mutable capture = Mutable.of(null); 23 | just = just.peek(c->capture.set(c)); 24 | 25 | 26 | just.get(); 27 | assertThat(capture.get(),equalTo(10)); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /cyclops-anym/src/test/java/cyclops/monads/collections/mutable/DequeXTest.java: -------------------------------------------------------------------------------- 1 | package cyclops.monads.collections.mutable; 2 | 3 | import com.oath.cyclops.anym.AnyMSeq; 4 | import cyclops.monads.Witness; 5 | import cyclops.monads.Witness.*; 6 | import cyclops.reactive.collections.mutable.DequeX; 7 | import cyclops.monads.AnyM; 8 | import cyclops.monads.collections.AbstractAnyMSeqOrderedDependentTest; 9 | import org.junit.Test; 10 | 11 | import static org.hamcrest.Matchers.equalTo; 12 | import static org.junit.Assert.assertThat; 13 | 14 | public class DequeXTest extends AbstractAnyMSeqOrderedDependentTest { 15 | 16 | @Override 17 | public AnyMSeq of(T... values) { 18 | return AnyM.fromDeque(DequeX.of(values)); 19 | } 20 | /* (non-Javadoc) 21 | * @see com.oath.cyclops.function.collections.extensions.AbstractCollectionXTest#zero() 22 | */ 23 | @Override 24 | public AnyMSeq empty() { 25 | return AnyM.fromDeque(DequeX.empty()); 26 | } 27 | 28 | } 29 | 30 | -------------------------------------------------------------------------------- /cyclops-anym/src/test/java/cyclops/monads/collections/mutable/ListXTest.java: -------------------------------------------------------------------------------- 1 | package cyclops.monads.collections.mutable; 2 | 3 | import static org.hamcrest.Matchers.equalTo; 4 | import static org.junit.Assert.assertThat; 5 | 6 | import com.oath.cyclops.anym.AnyMSeq; 7 | import cyclops.monads.Witness.list; 8 | import cyclops.monads.collections.AbstractAnyMSeqOrderedDependentTest; 9 | import org.junit.Test; 10 | 11 | import cyclops.monads.AnyM; 12 | import cyclops.reactive.collections.mutable.ListX; 13 | 14 | public class ListXTest extends AbstractAnyMSeqOrderedDependentTest { 15 | 16 | @Override 17 | public AnyMSeq of(T... values) { 18 | return AnyM.fromList(ListX.of(values)); 19 | } 20 | 21 | @Override 22 | public AnyMSeq empty() { 23 | return AnyM.fromList(ListX.empty()); 24 | } 25 | 26 | 27 | } 28 | 29 | -------------------------------------------------------------------------------- /cyclops-anym/src/test/java/cyclops/monads/collections/mutable/QueueXTest.java: -------------------------------------------------------------------------------- 1 | package cyclops.monads.collections.mutable; 2 | 3 | 4 | import com.oath.cyclops.anym.AnyMSeq; 5 | import cyclops.reactive.collections.mutable.QueueX; 6 | import cyclops.monads.AnyM; 7 | import cyclops.monads.Witness.queue; 8 | import cyclops.monads.collections.AbstractAnyMSeqOrderedDependentTest; 9 | import org.junit.Test; 10 | 11 | import static org.hamcrest.Matchers.equalTo; 12 | import static org.junit.Assert.assertThat; 13 | 14 | public class QueueXTest extends AbstractAnyMSeqOrderedDependentTest { 15 | 16 | @Override 17 | public AnyMSeq of(T... values) { 18 | return AnyM.fromQueue(QueueX.of(values)); 19 | } 20 | 21 | @Override 22 | public AnyMSeq empty() { 23 | return AnyM.fromQueue(QueueX.empty()); 24 | } 25 | 26 | } 27 | 28 | -------------------------------------------------------------------------------- /cyclops-anym/src/test/java/cyclops/monads/collections/persistent/LinkedListXTest.java: -------------------------------------------------------------------------------- 1 | package cyclops.monads.collections.persistent; 2 | 3 | import com.oath.cyclops.anym.AnyMSeq; 4 | import cyclops.reactive.collections.immutable.LinkedListX; 5 | import cyclops.reactive.collections.mutable.ListX; 6 | import cyclops.monads.AnyM; 7 | import cyclops.monads.Witness.linkedListX; 8 | import cyclops.monads.collections.AbstractAnyMSeqOrderedDependentTest; 9 | import org.junit.Test; 10 | 11 | import static org.hamcrest.Matchers.equalTo; 12 | import static org.junit.Assert.assertThat; 13 | 14 | public class LinkedListXTest extends AbstractAnyMSeqOrderedDependentTest { 15 | 16 | @Override 17 | public AnyMSeq of(T... values) { 18 | return AnyM.fromLinkedListX(LinkedListX.of(values)); 19 | } 20 | 21 | @Override 22 | public AnyMSeq empty() { 23 | return AnyM.fromLinkedListX(LinkedListX.empty()); 24 | } 25 | 26 | 27 | 28 | } 29 | 30 | -------------------------------------------------------------------------------- /cyclops-anym/src/test/java/cyclops/monads/collections/persistent/PersistentQueueXTest.java: -------------------------------------------------------------------------------- 1 | package cyclops.monads.collections.persistent; 2 | 3 | 4 | import com.oath.cyclops.anym.AnyMSeq; 5 | import cyclops.reactive.collections.immutable.PersistentQueueX; 6 | import cyclops.reactive.collections.mutable.ListX; 7 | import cyclops.monads.AnyM; 8 | import cyclops.monads.Witness.persistentQueueX; 9 | import cyclops.monads.collections.AbstractAnyMSeqOrderedDependentTest; 10 | import org.junit.Test; 11 | 12 | import static org.hamcrest.Matchers.equalTo; 13 | import static org.junit.Assert.assertThat; 14 | 15 | public class PersistentQueueXTest extends AbstractAnyMSeqOrderedDependentTest { 16 | 17 | @Override 18 | public AnyMSeq of(T... values) { 19 | return AnyM.fromPersistentQueueX(PersistentQueueX.of(values)); 20 | } 21 | 22 | @Override 23 | public AnyMSeq empty() { 24 | return AnyM.fromPersistentQueueX(PersistentQueueX.empty()); 25 | } 26 | 27 | 28 | 29 | } 30 | 31 | -------------------------------------------------------------------------------- /cyclops-anym/src/test/java/cyclops/monads/collections/persistent/VectorXTest.java: -------------------------------------------------------------------------------- 1 | package cyclops.monads.collections.persistent; 2 | 3 | 4 | import com.oath.cyclops.anym.AnyMSeq; 5 | import cyclops.reactive.collections.immutable.VectorX; 6 | import cyclops.reactive.collections.mutable.ListX; 7 | import cyclops.monads.AnyM; 8 | import cyclops.monads.Witness.vectorX; 9 | import cyclops.monads.collections.AbstractAnyMSeqOrderedDependentTest; 10 | import org.junit.Test; 11 | 12 | import static org.hamcrest.Matchers.equalTo; 13 | import static org.junit.Assert.assertThat; 14 | 15 | public class VectorXTest extends AbstractAnyMSeqOrderedDependentTest { 16 | 17 | @Override 18 | public AnyMSeq of(T... values) { 19 | return AnyM.fromVectorX(VectorX.of(values)); 20 | } 21 | 22 | @Override 23 | public AnyMSeq empty() { 24 | return AnyM.fromVectorX(VectorX.empty()); 25 | } 26 | 27 | 28 | } 29 | 30 | -------------------------------------------------------------------------------- /cyclops-anym/src/test/java/cyclops/monads/control/TryMonadTest.java: -------------------------------------------------------------------------------- 1 | package cyclops.monads.control; 2 | 3 | import static org.hamcrest.Matchers.equalTo; 4 | import static org.junit.Assert.assertThat; 5 | 6 | import java.util.Arrays; 7 | 8 | import org.junit.Test; 9 | 10 | import cyclops.monads.AnyM; 11 | import cyclops.control.Try; 12 | 13 | 14 | 15 | public class TryMonadTest { 16 | 17 | @Test 18 | public void tryTest(){ 19 | assertThat(AnyM.fromTry(Try.withCatch(()->"hello world")) 20 | .map(o-> "2" + o) 21 | .stream() 22 | .toList(),equalTo(Arrays.asList("2hello world"))); 23 | } 24 | 25 | 26 | } 27 | -------------------------------------------------------------------------------- /cyclops-anym/src/test/java/cyclops/monads/data/SeqAnyMTest.java: -------------------------------------------------------------------------------- 1 | package cyclops.monads.data; 2 | 3 | import com.oath.cyclops.anym.AnyMSeq; 4 | import cyclops.data.Seq; 5 | import cyclops.monads.AnyM; 6 | import cyclops.monads.Witness.seq; 7 | import cyclops.monads.collections.AbstractAnyMSeqOrderedDependentTest; 8 | import org.junit.Ignore; 9 | import org.junit.Test; 10 | 11 | import static org.hamcrest.Matchers.equalTo; 12 | import static org.junit.Assert.assertThat; 13 | 14 | public class SeqAnyMTest extends AbstractAnyMSeqOrderedDependentTest { 15 | 16 | @Override 17 | public AnyMSeq of(T... values) { 18 | return AnyM.fromSeq(Seq.of(values)); 19 | } 20 | 21 | @Override 22 | public AnyMSeq empty() { 23 | return AnyM.fromSeq(Seq.empty()); 24 | } 25 | 26 | @Test @Override @Ignore //only works for lazy data types 27 | public void testRecover1(){ 28 | 29 | } 30 | @Test @Ignore //only works for lazy data types 31 | public void testRecover2(){ 32 | } 33 | 34 | } 35 | 36 | -------------------------------------------------------------------------------- /cyclops-anym/src/test/java/cyclops/monads/jdk/FlatMapTest.java: -------------------------------------------------------------------------------- 1 | package cyclops.monads.jdk; 2 | 3 | import static org.hamcrest.Matchers.equalTo; 4 | import static org.junit.Assert.assertThat; 5 | 6 | import java.util.Arrays; 7 | import java.util.stream.Stream; 8 | 9 | import org.junit.Test; 10 | 11 | import cyclops.monads.AnyM; 12 | public class FlatMapTest { 13 | 14 | 15 | @Test 16 | public void flatMap(){ 17 | assertThat(AnyM.fromStream(Stream.of(1,2,3)).flatMap(i->AnyM.fromStream(Stream.of(i))).stream().toList(),equalTo(Arrays.asList(1,2,3))); 18 | } 19 | 20 | @Test 21 | public void flatMapToSeq(){ 22 | 23 | assertThat(AnyM.fromStream(Stream.of(1,2,3)).flatMap(i-> AnyM.fromStream(Stream.of(i+2))).stream().toList(),equalTo(Arrays.asList(3,4,5))); 24 | } 25 | @Test 26 | public void flatMapSeqToStream(){ 27 | 28 | assertThat(AnyM.fromStream(Stream.of(1,2,3)).flatMap(i-> AnyM.fromStream(Stream.of(i+2))).stream().toList(),equalTo(Arrays.asList(3,4,5))); 29 | } 30 | 31 | 32 | 33 | } 34 | -------------------------------------------------------------------------------- /cyclops-anym/src/test/java/cyclops/monads/jdk/UnitTest.java: -------------------------------------------------------------------------------- 1 | package cyclops.monads.jdk; 2 | 3 | import static org.junit.Assert.assertEquals; 4 | 5 | import java.util.List; 6 | import java.util.Optional; 7 | 8 | import cyclops.reactive.collections.mutable.ListX; 9 | import cyclops.monads.Witness; 10 | import cyclops.monads.Witness.optional; 11 | import org.junit.Test; 12 | 13 | import cyclops.monads.AnyM; 14 | 15 | public class UnitTest { 16 | @Test 17 | public void unitOptional() { 18 | AnyM empty = AnyM.fromOptional(Optional.empty()); 19 | AnyM unit = empty.unit(1); 20 | Optional unwrapped = unit.unwrap(); 21 | assertEquals(Integer.valueOf(1), unwrapped.get()); 22 | } 23 | 24 | @Test 25 | public void unitList() { 26 | AnyM empty = AnyM.fromList(ListX.empty()); 27 | AnyM unit = empty.unit(1); 28 | List unwrapped = unit.stream().toList(); 29 | assertEquals(Integer.valueOf(1), unwrapped.get(0)); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /cyclops-anym/src/test/java/cyclops/monads/transformers/seq/ListTSeqTraversableTest.java: -------------------------------------------------------------------------------- 1 | package cyclops.monads.transformers.seq; 2 | 3 | import com.oath.cyclops.types.AbstractTraversableTest; 4 | import cyclops.reactive.collections.mutable.ListX; 5 | import com.oath.cyclops.types.traversable.Traversable; 6 | import cyclops.monads.AnyMs; 7 | import cyclops.monads.Witness.list; 8 | 9 | 10 | public class ListTSeqTraversableTest extends AbstractTraversableTest { 11 | 12 | @Override 13 | public Traversable of(T... elements) { 14 | return ListX.of(elements) 15 | .to(AnyMs::liftM) 16 | .apply(list.INSTANCE); 17 | } 18 | 19 | @Override 20 | public Traversable empty() { 21 | return ListX.empty() 22 | .to(AnyMs::liftM) 23 | .apply(list.INSTANCE); 24 | 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /cyclops-anym/src/test/java/cyclops/monads/transformers/seq/StreamTSeqTraversableTest.java: -------------------------------------------------------------------------------- 1 | package cyclops.monads.transformers.seq; 2 | 3 | 4 | import com.oath.cyclops.types.AbstractTraversableTest; 5 | import com.oath.cyclops.types.traversable.Traversable; 6 | import cyclops.monads.AnyMs; 7 | import cyclops.monads.Witness.reactiveSeq; 8 | import cyclops.reactive.ReactiveSeq; 9 | 10 | 11 | public class StreamTSeqTraversableTest extends AbstractTraversableTest { 12 | 13 | @Override 14 | public Traversable of(T... elements) { 15 | return AnyMs.liftM(ReactiveSeq.of(elements), reactiveSeq.ITERATIVE); 16 | } 17 | 18 | @Override 19 | public Traversable empty() { 20 | return ReactiveSeq.empty() 21 | .to(AnyMs::liftM) 22 | .apply(reactiveSeq.ITERATIVE); 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /cyclops-anym/src/test/java/cyclops/monads/transformers/seq/convertable/ListTSeqConvertableSequenceTest.java: -------------------------------------------------------------------------------- 1 | package cyclops.monads.transformers.seq.convertable; 2 | 3 | import com.oath.cyclops.types.foldable.AbstractConvertableSequenceTest; 4 | import com.oath.cyclops.types.foldable.ConvertableSequence; 5 | import cyclops.reactive.collections.mutable.ListX; 6 | import cyclops.monads.AnyMs; 7 | import cyclops.monads.Witness; 8 | 9 | 10 | public class ListTSeqConvertableSequenceTest extends AbstractConvertableSequenceTest { 11 | 12 | @Override 13 | public ConvertableSequence of(T... elements) { 14 | return ListX.of(elements) 15 | .to(AnyMs::liftM) 16 | .apply(Witness.list.INSTANCE).to(); 17 | } 18 | 19 | @Override 20 | public ConvertableSequence empty() { 21 | 22 | return ListX.empty() 23 | .to(AnyMs::liftM) 24 | .apply(Witness.list.INSTANCE) 25 | .to(); 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /cyclops-anym/src/test/java/cyclops/monads/transformers/seq/convertable/StreamTSeqConvertableSequenceTest.java: -------------------------------------------------------------------------------- 1 | package cyclops.monads.transformers.seq.convertable; 2 | 3 | import com.oath.cyclops.types.foldable.AbstractConvertableSequenceTest; 4 | import com.oath.cyclops.types.foldable.ConvertableSequence; 5 | import cyclops.monads.AnyMs; 6 | import cyclops.monads.Witness; 7 | import cyclops.reactive.ReactiveSeq; 8 | 9 | 10 | public class StreamTSeqConvertableSequenceTest extends AbstractConvertableSequenceTest { 11 | 12 | @Override 13 | public ConvertableSequence of(T... elements) { 14 | return ReactiveSeq.of(elements) .to(AnyMs::liftM) 15 | .apply(Witness.reactiveSeq.ITERATIVE).to(); 16 | } 17 | 18 | @Override 19 | public ConvertableSequence empty() { 20 | 21 | return ReactiveSeq.empty().to(AnyMs::liftM) 22 | .apply(Witness.reactiveSeq.ITERATIVE).to(); 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /cyclops-anym/src/test/java/cyclops/monads/transformers/seq/nestedfoldable/ListTSeqNestedFoldableTest.java: -------------------------------------------------------------------------------- 1 | package cyclops.monads.transformers.seq.nestedfoldable; 2 | 3 | import cyclops.reactive.collections.mutable.ListX; 4 | 5 | import com.oath.cyclops.anym.transformers.FoldableTransformerSeq; 6 | import cyclops.monads.AnyMs; 7 | import cyclops.monads.Witness; 8 | import cyclops.monads.transformers.AbstractNestedFoldableTest; 9 | 10 | 11 | public class ListTSeqNestedFoldableTest extends AbstractNestedFoldableTest { 12 | 13 | @Override 14 | public FoldableTransformerSeq of(T... elements) { 15 | return ListX.of(elements) 16 | .to(AnyMs::liftM) 17 | .apply(Witness.list.INSTANCE); 18 | } 19 | 20 | @Override 21 | public FoldableTransformerSeq empty() { 22 | return ListX.empty() 23 | .to(AnyMs::liftM) 24 | .apply(Witness.list.INSTANCE); 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /cyclops-futurestream/gradle.properties: -------------------------------------------------------------------------------- 1 | POM_NAME=cyclops-futurestream 2 | -------------------------------------------------------------------------------- /cyclops-futurestream/src/main/java/com/oath/cyclops/internal/react/async/future/CompletedException.java: -------------------------------------------------------------------------------- 1 | package com.oath.cyclops.internal.react.async.future; 2 | 3 | public class CompletedException extends RuntimeException { 4 | /** 5 | * 6 | */ 7 | private static final long serialVersionUID = 1L; 8 | private final Object resut; 9 | 10 | public CompletedException(final Object resut) { 11 | 12 | this.resut = resut; 13 | } 14 | 15 | @Override 16 | public synchronized Throwable fillInStackTrace() { 17 | return this; 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /cyclops-futurestream/src/main/java/com/oath/cyclops/internal/react/async/future/FinalPipeline.java: -------------------------------------------------------------------------------- 1 | package com.oath.cyclops.internal.react.async.future; 2 | 3 | import java.util.concurrent.Executor; 4 | import java.util.function.Consumer; 5 | import java.util.function.Function; 6 | 7 | import lombok.AllArgsConstructor; 8 | import lombok.ToString; 9 | 10 | @AllArgsConstructor 11 | @ToString 12 | public class FinalPipeline { 13 | public final Function[] functions; 14 | public final Executor[] executors; 15 | public final Function[] firstRecover; 16 | public final Consumer onFail; 17 | 18 | public static FinalPipeline empty() { 19 | return new FinalPipeline( 20 | new Function[0], new Executor[0], null, null); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /cyclops-futurestream/src/main/java/com/oath/cyclops/internal/react/exceptions/FilteredExecutionPathException.java: -------------------------------------------------------------------------------- 1 | package com.oath.cyclops.internal.react.exceptions; 2 | 3 | public class FilteredExecutionPathException extends SimpleReactProcessingException { 4 | 5 | @Override 6 | public Throwable fillInStackTrace() { 7 | return this; 8 | } 9 | 10 | private static final long serialVersionUID = 1L; 11 | 12 | } 13 | -------------------------------------------------------------------------------- /cyclops-futurestream/src/main/java/com/oath/cyclops/internal/react/exceptions/SimpleReactCompletionException.java: -------------------------------------------------------------------------------- 1 | package com.oath.cyclops.internal.react.exceptions; 2 | 3 | import java.util.concurrent.CompletionException; 4 | 5 | public class SimpleReactCompletionException extends CompletionException { 6 | 7 | /** 8 | * 9 | */ 10 | private static final long serialVersionUID = 1L; 11 | 12 | public SimpleReactCompletionException(final Throwable cause) { 13 | super(cause); 14 | 15 | } 16 | 17 | @Override 18 | public synchronized Throwable fillInStackTrace() { 19 | return this; 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /cyclops-futurestream/src/main/java/com/oath/cyclops/internal/react/stream/CloseableIterator.java: -------------------------------------------------------------------------------- 1 | package com.oath.cyclops.internal.react.stream; 2 | 3 | import java.util.Iterator; 4 | 5 | import com.oath.cyclops.react.async.subscription.Continueable; 6 | import com.oath.cyclops.async.adapters.Queue; 7 | 8 | import lombok.AllArgsConstructor; 9 | 10 | @AllArgsConstructor 11 | public class CloseableIterator implements Iterator { 12 | 13 | private final Iterator iterator; 14 | private final Continueable subscription; 15 | private final Queue queue; 16 | 17 | @Override 18 | public boolean hasNext() { 19 | if (!iterator.hasNext()) 20 | close(); 21 | return iterator.hasNext(); 22 | } 23 | 24 | public void close() { 25 | subscription.closeAll(queue); 26 | } 27 | 28 | @Override 29 | public T next() { 30 | final T next = iterator.next(); 31 | return next; 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /cyclops-futurestream/src/main/java/com/oath/cyclops/internal/react/stream/InfiniteProcessingException.java: -------------------------------------------------------------------------------- 1 | package com.oath.cyclops.internal.react.stream; 2 | 3 | import com.oath.cyclops.internal.react.exceptions.SimpleReactProcessingException; 4 | 5 | public class InfiniteProcessingException extends SimpleReactProcessingException { 6 | 7 | /** 8 | * 9 | */ 10 | private static final long serialVersionUID = 1L; 11 | 12 | public InfiniteProcessingException(final String message) { 13 | super(message); 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /cyclops-futurestream/src/main/java/com/oath/cyclops/internal/react/stream/MissingValue.java: -------------------------------------------------------------------------------- 1 | package com.oath.cyclops.internal.react.stream; 2 | 3 | public class MissingValue { 4 | public final static MissingValue MISSING_VALUE = new MissingValue(); 5 | 6 | } 7 | -------------------------------------------------------------------------------- /cyclops-futurestream/src/main/java/com/oath/cyclops/internal/react/stream/ReactBuilder.java: -------------------------------------------------------------------------------- 1 | package com.oath.cyclops.internal.react.stream; 2 | 3 | public interface ReactBuilder { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /cyclops-futurestream/src/main/java/com/oath/cyclops/internal/react/stream/StreamWrapper.java: -------------------------------------------------------------------------------- 1 | package com.oath.cyclops.internal.react.stream; 2 | 3 | import java.util.stream.Stream; 4 | 5 | public interface StreamWrapper { 6 | public Stream stream(); 7 | 8 | } 9 | -------------------------------------------------------------------------------- /cyclops-futurestream/src/main/java/com/oath/cyclops/react/SimpleReactFailedStageException.java: -------------------------------------------------------------------------------- 1 | package com.oath.cyclops.react; 2 | 3 | 4 | import cyclops.control.Either; 5 | 6 | import lombok.AllArgsConstructor; 7 | import lombok.Getter; 8 | 9 | @AllArgsConstructor 10 | public class SimpleReactFailedStageException extends RuntimeException { 11 | 12 | private static final long serialVersionUID = 1L; 13 | private final Object value; 14 | @Getter 15 | private final Throwable cause; 16 | 17 | public T getValue() { 18 | return (T) value; 19 | } 20 | 21 | public static Either matchable(final Throwable t) { 22 | final Either error = t instanceof SimpleReactFailedStageException 23 | ? Either.right((SimpleReactFailedStageException) t) : Either.left(t); 24 | return error; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /cyclops-futurestream/src/main/java/com/oath/cyclops/react/threads/SequentialElasticPools.java: -------------------------------------------------------------------------------- 1 | package com.oath.cyclops.react.threads; 2 | 3 | import java.util.concurrent.Executors; 4 | 5 | import cyclops.futurestream.LazyReact; 6 | import cyclops.futurestream.SimpleReact; 7 | 8 | /** 9 | * 10 | * A ReactPool of each type for sequential Streams 11 | * 12 | * @author johnmcclean 13 | * 14 | */ 15 | public class SequentialElasticPools { 16 | public final static ReactPool simpleReact = ReactPool.elasticPool(() -> new SimpleReact( 17 | Executors.newFixedThreadPool(1))); 18 | public final static ReactPool lazyReact = ReactPool.elasticPool(() -> new LazyReact( 19 | Executors.newFixedThreadPool(1))); 20 | } 21 | -------------------------------------------------------------------------------- /cyclops-futurestream/src/main/java/com/oath/cyclops/types/futurestream/HasExec.java: -------------------------------------------------------------------------------- 1 | package com.oath.cyclops.types.futurestream; 2 | 3 | import java.util.concurrent.Executor; 4 | 5 | public interface HasExec { 6 | Executor getExec(); 7 | } 8 | -------------------------------------------------------------------------------- /cyclops-futurestream/src/main/java/com/oath/cyclops/types/futurestream/HasFutureStream.java: -------------------------------------------------------------------------------- 1 | package com.oath.cyclops.types.futurestream; 2 | 3 | import cyclops.futurestream.FutureStream; 4 | 5 | public interface HasFutureStream { 6 | FutureStream getStream(); 7 | } 8 | -------------------------------------------------------------------------------- /cyclops-futurestream/src/main/java/com/oath/cyclops/types/futurestream/Locks.java: -------------------------------------------------------------------------------- 1 | package com.oath.cyclops.types.futurestream; 2 | 3 | class Locks { 4 | 5 | static Object lock = new Object(); 6 | } 7 | -------------------------------------------------------------------------------- /cyclops-futurestream/src/main/java/com/oath/cyclops/types/futurestream/NullValue.java: -------------------------------------------------------------------------------- 1 | package com.oath.cyclops.types.futurestream; 2 | 3 | public class NullValue { 4 | public final static Object NULL = new Object(); 5 | } 6 | -------------------------------------------------------------------------------- /cyclops-futurestream/src/main/java/com/oath/cyclops/types/futurestream/RepeatableStream.java: -------------------------------------------------------------------------------- 1 | package com.oath.cyclops.types.futurestream; 2 | 3 | import java.util.Collection; 4 | import java.util.Spliterator; 5 | import java.util.Spliterators; 6 | import java.util.stream.Stream; 7 | import java.util.stream.StreamSupport; 8 | 9 | import lombok.AllArgsConstructor; 10 | 11 | @AllArgsConstructor 12 | public class RepeatableStream { 13 | private final Collection col; 14 | 15 | public Stream stream() { 16 | return StreamSupport.stream(Spliterators.spliteratorUnknownSize(col.iterator(), Spliterator.ORDERED), false); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /cyclops-futurestream/src/main/java/com/oath/cyclops/types/futurestream/Val.java: -------------------------------------------------------------------------------- 1 | package com.oath.cyclops.types.futurestream; 2 | 3 | import lombok.AllArgsConstructor; 4 | 5 | @AllArgsConstructor 6 | public class Val { 7 | enum Pos { 8 | left, 9 | right 10 | }; 11 | 12 | Pos pos; 13 | T val; 14 | } 15 | -------------------------------------------------------------------------------- /cyclops-futurestream/src/main/java/cyclops/stream/pushable/PushableFutureStream.java: -------------------------------------------------------------------------------- 1 | package cyclops.stream.pushable; 2 | 3 | import com.oath.cyclops.async.adapters.Queue; 4 | import cyclops.futurestream.FutureStream; 5 | 6 | /** 7 | * A more concrete Tuple2 impl 8 | * _1 is Queue<T> 9 | * _2 is LazyFutureStream<T> 10 | * 11 | * @author johnmcclean 12 | * 13 | * @param data type 14 | */ 15 | public class PushableFutureStream extends AbstractPushableStream, FutureStream> { 16 | 17 | public PushableFutureStream(final Queue v1, final FutureStream v2) { 18 | super(v1, v2); 19 | 20 | } 21 | 22 | private static final long serialVersionUID = 1L; 23 | 24 | } 25 | -------------------------------------------------------------------------------- /cyclops-futurestream/src/main/java/cyclops/stream/pushable/PushableReactiveSeq.java: -------------------------------------------------------------------------------- 1 | package cyclops.stream.pushable; 2 | 3 | import cyclops.reactive.ReactiveSeq; 4 | import com.oath.cyclops.async.adapters.Queue; 5 | 6 | /** 7 | * A more concrete Tuple2 impl 8 | * _1 is Queue<T> 9 | * _2 is Seq<T> 10 | * 11 | * @author johnmcclean 12 | * 13 | * @param data type 14 | */ 15 | public class PushableReactiveSeq extends AbstractPushableStream, ReactiveSeq> { 16 | 17 | public PushableReactiveSeq(final Queue v1, final ReactiveSeq v2) { 18 | super(v1, v2); 19 | 20 | } 21 | 22 | private static final long serialVersionUID = 1L; 23 | 24 | } 25 | -------------------------------------------------------------------------------- /cyclops-futurestream/src/main/java/cyclops/stream/pushable/PushableStream.java: -------------------------------------------------------------------------------- 1 | package cyclops.stream.pushable; 2 | 3 | import java.util.stream.Stream; 4 | 5 | import com.oath.cyclops.async.adapters.Queue; 6 | 7 | /** 8 | * A more concrete Tuple2 impl 9 | * _1 is Queue<T> 10 | * _2 is Stream<T> 11 | * 12 | * @author johnmcclean 13 | * 14 | * @param data type 15 | */ 16 | public class PushableStream extends AbstractPushableStream, Stream> { 17 | 18 | public PushableStream(final Queue v1, final Stream v2) { 19 | super(v1, v2); 20 | } 21 | 22 | private static final long serialVersionUID = 1L; 23 | 24 | } 25 | -------------------------------------------------------------------------------- /cyclops-futurestream/src/test/java/cyclops/futurestream/react/async/vertx/Starter.java: -------------------------------------------------------------------------------- 1 | package cyclops.futurestream.react.async.vertx; 2 | 3 | import cyclops.futurestream.LazyReact; 4 | 5 | import io.vertx.core.AbstractVerticle; 6 | import io.vertx.core.Vertx; 7 | 8 | public class Starter extends AbstractVerticle { 9 | 10 | @Override 11 | public void start() throws Exception { 12 | super.start(); 13 | //this can't work as the tasks from cyclops2-react are being passed back into the 14 | //event loop that is executing this task, LazyReact needs to pass tasks to a different 15 | //event loop 16 | LazyReact react = new LazyReact(new VertxExecutor(getVertx())); 17 | 18 | int number = react.of(1, 2, 3).map(i -> i + 1).reduce((a,b) -> a + b).orElse(Integer.MIN_VALUE); 19 | System.out.println("sum = " + number); // 2 + 3 + 4 = 9 20 | 21 | } 22 | 23 | public static void main(String[] args) { 24 | Vertx.vertx().deployVerticle(Starter.class.getCanonicalName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /cyclops-futurestream/src/test/java/cyclops/futurestream/react/async/vertx/VertxExecutor.java: -------------------------------------------------------------------------------- 1 | package cyclops.futurestream.react.async.vertx; 2 | 3 | import java.util.concurrent.Executor; 4 | 5 | import io.vertx.core.Vertx; 6 | 7 | /* vert.x 3 dependency: 8 | 9 | io.vertx 10 | vertx-core 11 | 3.0.0 12 | 13 | */ 14 | 15 | public class VertxExecutor implements Executor { 16 | protected final Vertx vertx; 17 | 18 | public VertxExecutor(Vertx vertx) { 19 | super(); 20 | this.vertx = vertx; 21 | } 22 | 23 | @Override 24 | public void execute(Runnable command) { 25 | vertx.runOnContext(v -> command.run()); // event loop, non-blocking 26 | // vertx.executeBlocking(v -> command.run(), null); // thread pool, blocking 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /cyclops-futurestream/src/test/java/cyclops/futurestream/react/examples/FilesExamplesTest.java: -------------------------------------------------------------------------------- 1 | package cyclops.futurestream.react.examples; 2 | 3 | import java.io.IOException; 4 | import java.nio.file.Files; 5 | import java.nio.file.Paths; 6 | 7 | import org.junit.Test; 8 | 9 | import cyclops.futurestream.LazyReact; 10 | 11 | public class FilesExamplesTest { 12 | 13 | @Test 14 | public void test() throws IOException { 15 | 16 | LazyReact react = new LazyReact(100,110); 17 | react.fromStream(Files.walk(Paths.get("."))) 18 | // .map(Unchecked.function(Files::readAllBytes)) 19 | .map(d->{ throw new RuntimeException("hello");}) 20 | .map(Object::toString) 21 | .recover(e->"hello world") 22 | // .flatMap(s->Stream.of(s.split("\n"))) 23 | .forEach(System.out::println); 24 | 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /cyclops-futurestream/src/test/java/cyclops/futurestream/react/lazy/ForEachParallelTest.java: -------------------------------------------------------------------------------- 1 | package cyclops.futurestream.react.lazy; 2 | 3 | import cyclops.futurestream.LazyReact; 4 | import org.junit.Test; 5 | 6 | public class ForEachParallelTest { 7 | 8 | @Test 9 | public void testOnEmptyThrows(){ 10 | new LazyReact().of(1,2,3,4) 11 | .peek(i-> System.out.println("A"+Thread.currentThread().getId())) 12 | .peekSync(i->sleep(i*100)).forEach(i-> System.out.println(Thread.currentThread().getId())); 13 | 14 | 15 | } 16 | 17 | private Object sleep(int i) { 18 | try { 19 | Thread.sleep(i); 20 | } catch (InterruptedException e) { 21 | // TODO Auto-generated catch block 22 | e.printStackTrace(); 23 | } 24 | return i; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /cyclops-futurestream/src/test/java/cyclops/futurestream/react/lazy/LazyFutureNumberOperationsTest.java: -------------------------------------------------------------------------------- 1 | package cyclops.futurestream.react.lazy; 2 | 3 | import java.util.function.Supplier; 4 | 5 | import com.oath.cyclops.react.ThreadPools; 6 | import cyclops.futurestream.react.base.BaseNumberOperationsTest; 7 | import cyclops.futurestream.LazyReact; 8 | import cyclops.futurestream.FutureStream; 9 | 10 | public class LazyFutureNumberOperationsTest extends BaseNumberOperationsTest { 11 | @Override 12 | protected FutureStream of(U... array) { 13 | return new LazyReact().of(array); 14 | } 15 | @Override 16 | protected FutureStream ofThread(U... array) { 17 | return new LazyReact(ThreadPools.getCommonFreeThread()).of(array); 18 | } 19 | 20 | @Override 21 | protected FutureStream react(Supplier... array) { 22 | return LazyReact.parallelBuilder().ofAsync(array); 23 | 24 | } 25 | 26 | 27 | } 28 | -------------------------------------------------------------------------------- /cyclops-futurestream/src/test/java/cyclops/futurestream/react/lazy/LazyNumberOperationsTest.java: -------------------------------------------------------------------------------- 1 | package cyclops.futurestream.react.lazy; 2 | 3 | import java.util.function.Supplier; 4 | 5 | import cyclops.futurestream.react.base.BaseLazyNumberOperationsTest; 6 | import cyclops.futurestream.LazyReact; 7 | import cyclops.futurestream.FutureStream; 8 | 9 | public class LazyNumberOperationsTest extends BaseLazyNumberOperationsTest { 10 | @Override 11 | protected FutureStream of(U... array) { 12 | return LazyReact.parallelBuilder().of(array); 13 | } 14 | @Override 15 | protected FutureStream ofThread(U... array) { 16 | return LazyReact.sequentialCommonBuilder().of(array); 17 | } 18 | 19 | @Override 20 | protected FutureStream react(Supplier... array) { 21 | return LazyReact.parallelBuilder().ofAsync(array); 22 | 23 | } 24 | 25 | 26 | } 27 | -------------------------------------------------------------------------------- /cyclops-futurestream/src/test/java/cyclops/futurestream/react/lazy/sequence/FutureStreamCollectableTest.java: -------------------------------------------------------------------------------- 1 | package cyclops.futurestream.react.lazy.sequence; 2 | 3 | import com.oath.cyclops.types.foldable.Folds; 4 | import cyclops.futurestream.LazyReact; 5 | import cyclops.streams.CollectableTest; 6 | 7 | 8 | public class FutureStreamCollectableTest extends CollectableTest { 9 | @Override 10 | public Folds of(T... values) { 11 | return LazyReact.sequentialBuilder().of(values); 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /cyclops-futurestream/src/test/java/cyclops/futurestream/react/reactivestreams/jdk/TckSynchronousPublisherTest.java: -------------------------------------------------------------------------------- 1 | package cyclops.futurestream.react.reactivestreams.jdk; 2 | 3 | 4 | import org.reactivestreams.Publisher; 5 | import org.reactivestreams.tck.PublisherVerification; 6 | import org.reactivestreams.tck.TestEnvironment; 7 | import org.testng.annotations.Test; 8 | 9 | import cyclops.reactive.ReactiveSeq; 10 | @Test 11 | public class TckSynchronousPublisherTest extends PublisherVerification{ 12 | 13 | public TckSynchronousPublisherTest(){ 14 | super(new TestEnvironment(300L)); 15 | } 16 | 17 | 18 | @Override 19 | public Publisher createPublisher(long elements) { 20 | return ReactiveSeq.iterate(0l, i->i+1l).limit(elements); 21 | 22 | } 23 | 24 | @Override 25 | public Publisher createFailedPublisher() { 26 | return null; //not possible to forEachAsync to failed Stream 27 | 28 | } 29 | 30 | 31 | } 32 | -------------------------------------------------------------------------------- /cyclops-futurestream/src/test/java/cyclops/futurestream/react/reactivestreams/jdk/ValueSubscriberTckBlackBoxSubscriberTest2.java: -------------------------------------------------------------------------------- 1 | package cyclops.futurestream.react.reactivestreams.jdk; 2 | 3 | import org.reactivestreams.Subscriber; 4 | import org.reactivestreams.tck.SubscriberBlackboxVerification; 5 | import org.reactivestreams.tck.TestEnvironment; 6 | import org.testng.annotations.Test; 7 | 8 | import com.oath.cyclops.types.reactive.ValueSubscriber; 9 | 10 | @Test 11 | public class ValueSubscriberTckBlackBoxSubscriberTest2 extends SubscriberBlackboxVerification{ 12 | public ValueSubscriberTckBlackBoxSubscriberTest2() { 13 | super(new TestEnvironment(300L)); 14 | } 15 | 16 | @Override 17 | public Subscriber createSubscriber() { 18 | return ValueSubscriber.subscriber(); 19 | 20 | } 21 | 22 | @Override 23 | public Long createElement(int element) { 24 | return new Long(element); 25 | } 26 | 27 | 28 | } 29 | -------------------------------------------------------------------------------- /cyclops-futurestream/src/test/java/cyclops/futurestream/react/stream/StatusTest.java: -------------------------------------------------------------------------------- 1 | package cyclops.futurestream.react.stream; 2 | 3 | import static org.hamcrest.core.Is.is; 4 | import static org.junit.Assert.assertThat; 5 | 6 | import com.oath.cyclops.react.Status; 7 | import org.junit.Test; 8 | 9 | public class StatusTest { 10 | 11 | @Test 12 | public void testGetMillis() { 13 | Status status = new Status(0, 0, 0, 1000000L, null); 14 | assertThat(status.getElapsedMillis(), is(1L)); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /cyclops-futurestream/src/test/java/cyclops/futurestream/reactivestreams/TckAsynchronousPublisherTest.java: -------------------------------------------------------------------------------- 1 | package cyclops.futurestream.reactivestreams; 2 | 3 | 4 | import org.reactivestreams.Publisher; 5 | import org.reactivestreams.tck.PublisherVerification; 6 | import org.reactivestreams.tck.TestEnvironment; 7 | import org.testng.annotations.Test; 8 | 9 | import cyclops.futurestream.LazyReact; 10 | @Test 11 | public class TckAsynchronousPublisherTest extends PublisherVerification{ 12 | 13 | public TckAsynchronousPublisherTest(){ 14 | super(new TestEnvironment(300L)); 15 | } 16 | 17 | 18 | @Override 19 | public Publisher createPublisher(long elements) { 20 | return new LazyReact() 21 | .generateAsync(()->100l).limit(elements); 22 | 23 | } 24 | 25 | @Override 26 | public Publisher createFailedPublisher() { 27 | return null; //not possible to forEachAsync to failed Stream 28 | 29 | } 30 | 31 | 32 | } 33 | -------------------------------------------------------------------------------- /cyclops-futurestream/src/test/java/cyclops/futurestream/reactivestreams/TckSynchronousPublisherTest.java: -------------------------------------------------------------------------------- 1 | package cyclops.futurestream.reactivestreams; 2 | 3 | 4 | import com.oath.cyclops.react.ThreadPools; 5 | import cyclops.futurestream.LazyReact; 6 | import org.reactivestreams.Publisher; 7 | import org.reactivestreams.tck.PublisherVerification; 8 | import org.reactivestreams.tck.TestEnvironment; 9 | import org.testng.annotations.Test; 10 | 11 | @Test 12 | public class TckSynchronousPublisherTest extends PublisherVerification{ 13 | 14 | public TckSynchronousPublisherTest(){ 15 | super(new TestEnvironment(300L)); 16 | } 17 | 18 | 19 | @Override 20 | public Publisher createPublisher(long elements) { 21 | return new LazyReact(ThreadPools.getCommonFreeThread()).iterate(0l, i->i+1l).sync().limit(elements); 22 | 23 | } 24 | 25 | @Override 26 | public Publisher createFailedPublisher() { 27 | return null; //not possible to forEachAsync to failed Stream 28 | 29 | } 30 | 31 | 32 | } 33 | -------------------------------------------------------------------------------- /cyclops-jackson-integration/README.md: -------------------------------------------------------------------------------- 1 | # Jackson Data Bindings for Cyclops 2 | 3 | ## Get cyclops-jackson 4 | 5 | 6 | * [![Maven Central : cyclops-jackson](https://maven-badges.herokuapp.com/maven-central/com.oath.cyclops/cyclops-jackson-integration/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.oath.cyclops/cyclops-jackson-integration) 7 | * [Javadoc for cyclops-jackson](http://www.javadoc.io/doc/com.oath.cyclops/cyclops-cyclops-jackson-integration) 8 | 9 | 10 | JSON Serialiazation and Deserialization of Cyclops Control and Data Types 11 | 12 | ```java 13 | import com.oath.cyclops.jackson.CyclopsModule; 14 | import com.fasterxml.jackson.databind.ObjectMapper; 15 | 16 | ObjectMapper mapper = new ObjectMapper(); 17 | 18 | mapper = mapper.registerModule(new CyclopsModule()); 19 | ``` 20 | -------------------------------------------------------------------------------- /cyclops-jackson-integration/gradle.properties: -------------------------------------------------------------------------------- 1 | POM_NAME=cyclops-jackson-integration 2 | -------------------------------------------------------------------------------- /cyclops-jackson-integration/src/main/java/com/oath/cyclops/jackson/CyclopsModule.java: -------------------------------------------------------------------------------- 1 | package com.oath.cyclops.jackson; 2 | 3 | import com.fasterxml.jackson.databind.module.SimpleModule; 4 | import com.oath.cyclops.jackson.deserializers.CyclopsDeserializers; 5 | import com.oath.cyclops.jackson.serializers.CyclopsSerializers; 6 | 7 | public class CyclopsModule extends SimpleModule { 8 | 9 | 10 | 11 | 12 | @Override 13 | public void setupModule(SetupContext context) { 14 | context.addDeserializers(new CyclopsDeserializers()); 15 | context.addSerializers(new CyclopsSerializers()); 16 | context.addTypeModifier(new CyclopsTypeModifier()); 17 | 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /cyclops-jackson-integration/src/main/java/com/oath/cyclops/jackson/serializers/IterableXSerializer.java: -------------------------------------------------------------------------------- 1 | package com.oath.cyclops.jackson.serializers; 2 | 3 | import com.fasterxml.jackson.core.JsonGenerator; 4 | import com.fasterxml.jackson.databind.JsonSerializer; 5 | import com.fasterxml.jackson.databind.SerializerProvider; 6 | 7 | import java.io.IOException; 8 | 9 | public class IterableXSerializer extends JsonSerializer>{ 10 | 11 | @Override 12 | public void serialize(Iterable value, JsonGenerator gen, SerializerProvider serializers) throws IOException { 13 | if(value==null) { 14 | gen.writeNull(); 15 | return; 16 | } 17 | gen.writeStartArray(); 18 | for(Object o : value) { 19 | JsonSerializer ser = serializers.findTypedValueSerializer(o.getClass(),true,null); 20 | ser.serialize(o, gen, serializers); 21 | } 22 | gen.writeEndArray(); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /cyclops-jackson-integration/src/test/java/com/oath/cyclops/jackson/EvalTest.java: -------------------------------------------------------------------------------- 1 | package com.oath.cyclops.jackson; 2 | 3 | import cyclops.control.Eval; 4 | import org.junit.Test; 5 | import static org.hamcrest.MatcherAssert.assertThat; 6 | import static org.hamcrest.Matchers.equalTo; 7 | 8 | public class EvalTest { 9 | Eval some = Eval.now(10); 10 | 11 | @Test 12 | public void roundTrip(){ 13 | 14 | String json =JacksonUtil.serializeToJson(Eval.now(10)); 15 | System.out.println("Json " + json); 16 | Eval des = JacksonUtil.convertFromJson(json,Eval.class); 17 | 18 | assertThat(des,equalTo(some)); 19 | } 20 | 21 | @Test 22 | public void some(){ 23 | assertThat(JacksonUtil.serializeToJson(Eval.now(5)),equalTo("5")); 24 | } 25 | 26 | 27 | 28 | } 29 | -------------------------------------------------------------------------------- /cyclops-jackson-integration/src/test/java/com/oath/cyclops/jackson/FutureTest.java: -------------------------------------------------------------------------------- 1 | package com.oath.cyclops.jackson; 2 | 3 | import cyclops.control.Eval; 4 | import cyclops.control.Future; 5 | import org.junit.Ignore; 6 | import org.junit.Test; 7 | 8 | import static org.hamcrest.MatcherAssert.assertThat; 9 | import static org.hamcrest.Matchers.equalTo; 10 | 11 | public class FutureTest { 12 | Future some = Future.ofResult(10); 13 | 14 | @Test @Ignore 15 | public void roundTrip(){ 16 | 17 | String json =JacksonUtil.serializeToJson(Eval.now(10)); 18 | System.out.println("Json " + json); 19 | Future des = JacksonUtil.convertFromJson(json,Future.class); 20 | 21 | assertThat(des,equalTo(some)); 22 | } 23 | 24 | @Test 25 | public void some(){ 26 | assertThat(JacksonUtil.serializeToJson(Future.ofResult(5)),equalTo("5")); 27 | } 28 | 29 | 30 | 31 | } 32 | -------------------------------------------------------------------------------- /cyclops-jackson-integration/src/test/java/com/oath/cyclops/jackson/PersistentMapTest.java: -------------------------------------------------------------------------------- 1 | package com.oath.cyclops.jackson; 2 | 3 | import cyclops.data.HashMap; 4 | import org.junit.Test; 5 | 6 | import static org.hamcrest.MatcherAssert.assertThat; 7 | import static org.hamcrest.Matchers.equalTo; 8 | 9 | public class PersistentMapTest { 10 | 11 | @Test 12 | public void hashMap(){ 13 | System.out.println(JacksonUtil.serializeToJson(HashMap.of("a",10))); 14 | System.out.println(JacksonUtil.serializeToJson(HashMap.empty())); 15 | 16 | assertThat(JacksonUtil.convertFromJson(JacksonUtil.serializeToJson(HashMap.of("a",10)),HashMap.class),equalTo(HashMap.of("a",10))); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /cyclops-jackson-integration/src/test/java/com/oath/cyclops/jackson/TrampolineTest.java: -------------------------------------------------------------------------------- 1 | package com.oath.cyclops.jackson; 2 | 3 | import cyclops.control.Trampoline; 4 | import org.junit.Test; 5 | 6 | import static org.hamcrest.MatcherAssert.assertThat; 7 | import static org.hamcrest.Matchers.equalTo; 8 | 9 | public class TrampolineTest { 10 | Trampoline some = Trampoline.done(10); 11 | 12 | @Test 13 | public void roundTrip(){ 14 | 15 | String json =JacksonUtil.serializeToJson(Trampoline.done(10)); 16 | System.out.println("Json " + json); 17 | Trampoline des = JacksonUtil.convertFromJson(json,Trampoline.class); 18 | 19 | assertThat(des.get(),equalTo(some.get())); 20 | } 21 | 22 | @Test 23 | public void some(){ 24 | assertThat(JacksonUtil.serializeToJson(Trampoline.done(5)),equalTo("5")); 25 | } 26 | 27 | 28 | 29 | } 30 | -------------------------------------------------------------------------------- /cyclops-jackson-integration/src/test/java/com/oath/cyclops/jackson/fix/Query.java: -------------------------------------------------------------------------------- 1 | package com.oath.cyclops.jackson.fix; 2 | 3 | import cyclops.data.Seq; 4 | import lombok.AllArgsConstructor; 5 | import lombok.EqualsAndHashCode; 6 | import lombok.ToString; 7 | 8 | import javax.xml.bind.annotation.XmlElement; 9 | 10 | @AllArgsConstructor 11 | @ToString 12 | @EqualsAndHashCode 13 | public class Query { 14 | 15 | 16 | @XmlElement(name = "name") 17 | public final String name; 18 | 19 | 20 | @XmlElement(name = "queries") 21 | public final Seq queries; 22 | 23 | public Query(){ 24 | this.queries = null; 25 | this.name = null; 26 | } 27 | 28 | 29 | 30 | } 31 | -------------------------------------------------------------------------------- /cyclops-pure/gradle.properties: -------------------------------------------------------------------------------- 1 | POM_NAME=cyclops-pure 2 | -------------------------------------------------------------------------------- /cyclops-pure/src/main/java/cyclops/arrow/FunctionsHK.java: -------------------------------------------------------------------------------- 1 | package cyclops.arrow; 2 | 3 | import com.oath.cyclops.hkt.Higher; 4 | import cyclops.function.Function1; 5 | import cyclops.typeclasses.functor.Functor; 6 | import cyclops.typeclasses.monad.Monad; 7 | 8 | import java.util.function.Function; 9 | 10 | public interface FunctionsHK { 11 | public static Function1,Higher> liftNT(Function fn, 12 | Function,? extends Higher> hktTransform, 13 | Functor functor){ 14 | return (T1)-> functor.map(fn,hktTransform.apply(T1)); 15 | } 16 | 17 | public static Function1> arrow(Monad monad){ 18 | return t-> monad.unit(t); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /cyclops-pure/src/main/java/cyclops/arrow/GroupK.java: -------------------------------------------------------------------------------- 1 | package cyclops.arrow; 2 | 3 | 4 | import com.oath.cyclops.hkt.Higher; 5 | import cyclops.function.Group; 6 | 7 | public interface GroupK extends MonoidK { 8 | 9 | 10 | Higher invert(Higher wtHigher); 11 | 12 | default Group> asGroup(){ 13 | return Group.of(a->invert(a),asMonoid()); 14 | } 15 | 16 | 17 | } 18 | -------------------------------------------------------------------------------- /cyclops-pure/src/main/java/cyclops/arrow/MonoidK.java: -------------------------------------------------------------------------------- 1 | package cyclops.arrow; 2 | 3 | 4 | import com.oath.cyclops.hkt.Higher; 5 | import cyclops.function.Monoid; 6 | 7 | public interface MonoidK extends SemigroupK { 8 | 9 | Higher zero(); 10 | 11 | default Monoid> asMonoid(){ 12 | return Monoid.of(zero(),(a,b)->this.apply(a,b)); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /cyclops-pure/src/main/java/cyclops/arrow/SemigroupK.java: -------------------------------------------------------------------------------- 1 | package cyclops.arrow; 2 | 3 | 4 | import com.oath.cyclops.hkt.Higher; 5 | import cyclops.function.Semigroup; 6 | 7 | @FunctionalInterface 8 | public interface SemigroupK { 9 | 10 | Higher apply(Higher t1, Higher t2); 11 | 12 | default Semigroup> asSemigroup(){ 13 | return (a,b)->this.apply(a,b); 14 | } 15 | 16 | } 17 | 18 | -------------------------------------------------------------------------------- /cyclops-pure/src/main/java/cyclops/instances/jdk/PredicateInstances.java: -------------------------------------------------------------------------------- 1 | package cyclops.instances.jdk; 2 | 3 | import com.oath.cyclops.hkt.DataWitness; 4 | import com.oath.cyclops.hkt.DataWitness.predicate; 5 | import com.oath.cyclops.hkt.Higher; 6 | import cyclops.function.Predicates; 7 | import cyclops.kinds.PredicateKind; 8 | import cyclops.typeclasses.functor.ContravariantFunctor; 9 | 10 | import java.util.function.Function; 11 | 12 | public interface PredicateInstances { 13 | static ContravariantFunctor contravariantFunctor(){ 14 | return new ContravariantFunctor() { 15 | @Override 16 | public Higher contramap(Function fn, Higher ds) { 17 | PredicateKind r = in-> PredicateKind.narrow(ds).test(fn.apply(in)); 18 | return r; 19 | } 20 | }; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /cyclops-pure/src/main/java/cyclops/instances/jdk/SupplierInstances.java: -------------------------------------------------------------------------------- 1 | package cyclops.instances.jdk; 2 | 3 | import com.oath.cyclops.hkt.DataWitness; 4 | import com.oath.cyclops.hkt.DataWitness.supplier; 5 | import com.oath.cyclops.hkt.Higher; 6 | import cyclops.free.Free; 7 | import cyclops.function.Function0; 8 | import cyclops.kinds.SupplierKind; 9 | import cyclops.typeclasses.functor.Functor; 10 | 11 | import java.util.function.Function; 12 | import java.util.function.Supplier; 13 | 14 | public class SupplierInstances { 15 | 16 | 17 | public static final Functor functor = 18 | new Functor() { 19 | @Override 20 | public SupplierKind map(Function f, Higher fa) { 21 | return ((SupplierKind) fa).mapFn(f); 22 | } 23 | }; 24 | } 25 | -------------------------------------------------------------------------------- /cyclops-pure/src/main/java/cyclops/kinds/PredicateKind.java: -------------------------------------------------------------------------------- 1 | package cyclops.kinds; 2 | 3 | import com.oath.cyclops.hkt.DataWitness; 4 | import com.oath.cyclops.hkt.DataWitness.predicate; 5 | import com.oath.cyclops.hkt.Higher; 6 | 7 | import java.util.function.Predicate; 8 | 9 | public interface PredicateKind extends Higher,Predicate { 10 | 11 | public static PredicateKind narrow(Higher ds){ 12 | return (PredicateKind)ds; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /cyclops-pure/src/main/java/cyclops/transformers/Transformer.java: -------------------------------------------------------------------------------- 1 | package cyclops.transformers; 2 | 3 | 4 | import com.oath.cyclops.hkt.Higher; 5 | import cyclops.hkt.Nested; 6 | 7 | import java.util.function.Function; 8 | 9 | public interface Transformer { 10 | Nested flatMap(Function> fn); 11 | Nested flatMapK(Function>> fn); 12 | } 13 | -------------------------------------------------------------------------------- /cyclops-pure/src/main/java/cyclops/transformers/TransformerFactory.java: -------------------------------------------------------------------------------- 1 | package cyclops.transformers; 2 | 3 | 4 | import cyclops.hkt.Nested; 5 | 6 | public interface TransformerFactory{ 7 | Transformer build(Nested nested); 8 | } 9 | -------------------------------------------------------------------------------- /cyclops-pure/src/main/java/cyclops/typeclasses/Combine.java: -------------------------------------------------------------------------------- 1 | package cyclops.typeclasses; 2 | 3 | import java.util.function.BinaryOperator; 4 | import java.util.stream.Stream; 5 | 6 | 7 | import com.oath.cyclops.hkt.Higher; 8 | 9 | public interface Combine { 10 | 11 | 12 | default Higher plus(Higher identity, BinaryOperator> accumulator, Higher... tocombine){ 13 | return Stream.of(tocombine) 14 | .reduce(identity, accumulator); 15 | } 16 | default Higher plus(Higher identity, BinaryOperator> accumulator, Stream> tocombine){ 17 | return tocombine.reduce(identity, accumulator); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /cyclops-pure/src/main/java/cyclops/typeclasses/Filterable.java: -------------------------------------------------------------------------------- 1 | package cyclops.typeclasses; 2 | 3 | import java.util.function.Predicate; 4 | import com.oath.cyclops.hkt.Higher; 5 | 6 | public interface Filterable { 7 | 8 | public Higher filter(Predicate predicate, Higher ds); 9 | } 10 | -------------------------------------------------------------------------------- /cyclops-pure/src/main/java/cyclops/typeclasses/Pure.java: -------------------------------------------------------------------------------- 1 | package cyclops.typeclasses; 2 | 3 | 4 | import com.oath.cyclops.hkt.Higher; 5 | 6 | /** 7 | * Type class for creating instances of types 8 | * 9 | * @author johnmcclean 10 | * 11 | * @param The core type of the unit (e.g. the HKT witness type, not the generic type : ListType.µ) 12 | */ 13 | @FunctionalInterface 14 | public interface Pure { 15 | /** 16 | * Create a new instance of the core type (e.g. a List or CompletableFuture) that is HKT encoded 17 | * 18 | * @param value To populate new instance of 19 | * @return HKT encoded new instance with supplied value 20 | */ 21 | public Higher unit(T value); 22 | } 23 | -------------------------------------------------------------------------------- /cyclops-pure/src/main/java/cyclops/typeclasses/Show.java: -------------------------------------------------------------------------------- 1 | package cyclops.typeclasses; 2 | 3 | 4 | import com.oath.cyclops.hkt.Higher; 5 | 6 | public interface Show { 7 | 8 | default String show(Higher ds){ 9 | return ds.toString(); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /cyclops-pure/src/main/java/cyclops/typeclasses/functor/BiFunctor.java: -------------------------------------------------------------------------------- 1 | package cyclops.typeclasses.functor; 2 | 3 | import com.oath.cyclops.hkt.Higher2; 4 | 5 | import java.util.function.Function; 6 | 7 | 8 | public interface BiFunctor { 9 | 10 | Higher2 bimap(Function fn, Function fn2, Higher2 ds); 11 | } 12 | -------------------------------------------------------------------------------- /cyclops-pure/src/main/java/cyclops/typeclasses/functor/ContravariantFunctor.java: -------------------------------------------------------------------------------- 1 | package cyclops.typeclasses.functor; 2 | 3 | import com.oath.cyclops.hkt.Higher; 4 | 5 | import java.util.function.Function; 6 | 7 | 8 | public interface ContravariantFunctor{ 9 | 10 | Higher contramap(Function fn, Higher ds); 11 | } 12 | 13 | -------------------------------------------------------------------------------- /cyclops-pure/src/main/java/cyclops/typeclasses/functor/FilterableFunctor.java: -------------------------------------------------------------------------------- 1 | package cyclops.typeclasses.functor; 2 | 3 | import cyclops.typeclasses.Filterable; 4 | 5 | public interface FilterableFunctor extends Functor, Filterable { 6 | 7 | } 8 | -------------------------------------------------------------------------------- /cyclops-pure/src/main/java/cyclops/typeclasses/functor/ProFunctor.java: -------------------------------------------------------------------------------- 1 | package cyclops.typeclasses.functor; 2 | 3 | import com.oath.cyclops.hkt.Higher; 4 | 5 | import java.util.function.Function; 6 | 7 | public interface ProFunctor{ 8 | 9 | Higher,D> dimap(Function f, Function g, Higher,B> ds); 10 | 11 | default Higher,C> lmap(Function fn, Higher,C> ds) { 12 | return dimap(fn, Function.identity(), ds); 13 | } 14 | 15 | default Higher,C> rmap(Function g, Higher,B> ds) { 16 | return dimap(Function.identity(), g, ds); 17 | } 18 | 19 | 20 | } 21 | -------------------------------------------------------------------------------- /cyclops-pure/src/main/java/cyclops/typeclasses/monad/MonadPlus.java: -------------------------------------------------------------------------------- 1 | package cyclops.typeclasses.monad; 2 | 3 | 4 | import com.oath.cyclops.hkt.Higher; 5 | import cyclops.data.ImmutableList; 6 | import cyclops.arrow.MonoidK; 7 | 8 | public interface MonadPlus extends MonadZero{ 9 | 10 | MonoidK monoid(); 11 | 12 | 13 | @Override 14 | default Higher zero(){ 15 | return this.monoid().zero(); 16 | } 17 | 18 | 19 | default Higher plus(Higher a, Higher b){ 20 | return this.monoid().apply(a,b); 21 | } 22 | 23 | 24 | default Higher sum(ImmutableList> list) { 25 | return list.foldLeft(this.zero(),this::plus); 26 | } 27 | 28 | 29 | } 30 | -------------------------------------------------------------------------------- /cyclops-pure/src/main/java/cyclops/typeclasses/monad/MonadRec.java: -------------------------------------------------------------------------------- 1 | package cyclops.typeclasses.monad; 2 | 3 | 4 | import com.oath.cyclops.hkt.Higher; 5 | import cyclops.control.Either; 6 | 7 | import java.util.function.Function; 8 | 9 | // ref http://functorial.com/stack-safety-for-free/index.pdf Stack Safety for Free 10 | 11 | public interface MonadRec { 12 | 13 | Higher tailRec(T initial,Function>> fn); 14 | } 15 | -------------------------------------------------------------------------------- /cyclops-pure/src/main/java/cyclops/typeclasses/monad/MonadZero.java: -------------------------------------------------------------------------------- 1 | package cyclops.typeclasses.monad; 2 | 3 | import com.oath.cyclops.hkt.Higher; 4 | import cyclops.typeclasses.Filterable; 5 | 6 | 7 | import java.util.function.Predicate; 8 | 9 | 10 | 11 | /** 12 | * A filterable monad 13 | * 14 | * The zero() operator is used to one supplied HKT with it's zero / zero equivalent when filtered out 15 | * 16 | * @author johnmcclean 17 | * 18 | * @param CORE Type 19 | */ 20 | public interface MonadZero extends Monad, Filterable { 21 | 22 | 23 | Higher zero(); 24 | 25 | 26 | @Override 27 | default Higher filter(Predicate predicate, Higher ds){ 28 | 29 | return flatMap((T in)->predicate.test(in) ? ds : zero(),ds); 30 | } 31 | default Higher filter_(Higher ds,Predicate predicate){ 32 | 33 | return filter(predicate,ds); 34 | } 35 | 36 | 37 | 38 | } 39 | -------------------------------------------------------------------------------- /cyclops-pure/src/main/java/cyclops/typeclasses/monad/TraverseBySequence.java: -------------------------------------------------------------------------------- 1 | package cyclops.typeclasses.monad; 2 | 3 | import com.oath.cyclops.hkt.Higher; 4 | 5 | import java.util.function.Function; 6 | 7 | 8 | 9 | public interface TraverseBySequence extends Traverse { 10 | default Higher> traverseA(Applicative applicative, Function> fn, 11 | Higher ds){ 12 | return sequenceA(applicative, map(fn, ds)); 13 | } 14 | 15 | Higher> sequenceA(Applicative applicative, Higher> ds); 16 | } 17 | -------------------------------------------------------------------------------- /cyclops-pure/src/main/java/cyclops/typeclasses/monad/TraverseByTraverse.java: -------------------------------------------------------------------------------- 1 | package cyclops.typeclasses.monad; 2 | 3 | import com.oath.cyclops.hkt.Higher; 4 | 5 | import java.util.function.Function; 6 | 7 | 8 | 9 | public interface TraverseByTraverse extends Traverse { 10 | Higher> traverseA(Applicative applicative, Function> fn, 11 | Higher ds); 12 | 13 | default Higher> sequenceA(Applicative applicative, Higher> ds){ 14 | return traverseA(applicative,Function.identity(),ds); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /cyclops-pure/src/test/java/cyclops/control/ReaderWriterStateTest.java: -------------------------------------------------------------------------------- 1 | package cyclops.control; 2 | 3 | import cyclops.companion.Monoids; 4 | import cyclops.data.tuple.Tuple; 5 | import org.junit.Test; 6 | 7 | import static org.hamcrest.CoreMatchers.equalTo; 8 | import static org.junit.Assert.*; 9 | 10 | 11 | public class ReaderWriterStateTest { 12 | 13 | @Test 14 | public void map(){ 15 | ReaderWriterState rws = ReaderWriterState.rws((r, s)->Tuple.tuple(10,s,1), Monoids.intMax); 16 | ReaderWriterState mapped = rws.map(i -> i * 2); 17 | 18 | assertThat(mapped.run("hello","world"),equalTo(Tuple.tuple(10, "world", 2))); 19 | } 20 | 21 | } -------------------------------------------------------------------------------- /cyclops-pure/src/test/java/cyclops/control/reader/Application.java: -------------------------------------------------------------------------------- 1 | package cyclops.control.reader; 2 | 3 | import java.util.Map; 4 | 5 | import cyclops.control.Reader; 6 | 7 | 8 | public class Application { 9 | 10 | UserRepositoryImpl repo = new UserRepositoryImpl(); 11 | 12 | 13 | 14 | public Map userInfo(String username) { 15 | return run(new UserInfo().userInfo(username)); 16 | } 17 | private Map run( Reader > reader){ 18 | return reader.apply(repo); 19 | } 20 | static class UserRepositoryImpl implements UserRepository{ 21 | int count = 0; 22 | User boss = new User(10,"boss","boss@user.com",null); 23 | @Override 24 | public User get(int id) { 25 | if(id==boss.getId()) 26 | return boss; 27 | return new User(id,"user"+id,"user"+id+"@user.com",boss); 28 | } 29 | 30 | @Override 31 | public User find(String username) { 32 | return new User(count++,username,username+"@user.com",boss); 33 | } 34 | 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /cyclops-pure/src/test/java/cyclops/control/reader/User.java: -------------------------------------------------------------------------------- 1 | package cyclops.control.reader; 2 | 3 | import lombok.Value; 4 | 5 | @Value 6 | public class User { 7 | int id; 8 | String name; 9 | String email; 10 | User supervisor; 11 | 12 | } 13 | -------------------------------------------------------------------------------- /cyclops-pure/src/test/java/cyclops/control/reader/UserInfo.java: -------------------------------------------------------------------------------- 1 | package cyclops.control.reader; 2 | 3 | 4 | import java.util.HashMap; 5 | import java.util.Map; 6 | 7 | import cyclops.control.Reader; 8 | 9 | 10 | 11 | public class UserInfo implements Users { 12 | 13 | public Reader> userInfo(String username) { 14 | 15 | findUser(username).forEach2(user ->getUser(user.getSupervisor().getId()), 16 | (user,boss) -> "user:"+username+" boss is "+boss.getName()); 17 | 18 | 19 | return findUser(username).forEach2(user -> getUser(user.getSupervisor().getId()), 20 | (user,boss) -> buildMap(user,boss)); 21 | 22 | 23 | } 24 | 25 | private Map buildMap(User user, User boss) { 26 | return new HashMap (){{ 27 | put("fullname",user.getName()); 28 | put("email",user.getEmail()); 29 | put("boss",boss.getName()); 30 | 31 | }}; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /cyclops-pure/src/test/java/cyclops/control/reader/UserRepository.java: -------------------------------------------------------------------------------- 1 | package cyclops.control.reader; 2 | 3 | public interface UserRepository { 4 | 5 | public User get(int id); 6 | public User find(String username); 7 | } 8 | -------------------------------------------------------------------------------- /cyclops-pure/src/test/java/cyclops/control/reader/Users.java: -------------------------------------------------------------------------------- 1 | package cyclops.control.reader; 2 | 3 | import cyclops.function.FluentFunctions; 4 | import cyclops.control.Reader; 5 | 6 | public interface Users { 7 | 8 | 9 | default Reader getUser(Integer id){ 10 | return Reader.of( userRepository -> userRepository.get(id)); 11 | } 12 | 13 | default Reader findUser(String username) { 14 | return Reader.of(userRepository -> userRepository.find(username)); 15 | } 16 | 17 | 18 | 19 | } 20 | -------------------------------------------------------------------------------- /cyclops-pure/src/test/java/cyclops/data/tuple/Tuple1Test.java: -------------------------------------------------------------------------------- 1 | package cyclops.data.tuple; 2 | 3 | import cyclops.control.Identity; 4 | import org.junit.Before; 5 | import org.junit.Test; 6 | 7 | import static org.hamcrest.Matchers.equalTo; 8 | import static org.junit.Assert.assertThat; 9 | 10 | public class Tuple1Test { 11 | Tuple1 t1; 12 | @Before 13 | public void setUp() throws Exception { 14 | t1 = Tuple.tuple(10); 15 | } 16 | @Test 17 | public void toIdentity() throws Exception { 18 | assertThat(Identity.fromTuple(t1).get(),equalTo(10)); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /cyclops-pure/src/test/java/cyclops/typeclasses/taglessfinal/AccountAlgebra.java: -------------------------------------------------------------------------------- 1 | package cyclops.typeclasses.taglessfinal; 2 | 3 | import com.oath.cyclops.hkt.Higher; 4 | import cyclops.control.Either; 5 | import cyclops.control.Option; 6 | import cyclops.typeclasses.taglessfinal.Cases.Account; 7 | 8 | public interface AccountAlgebra { 9 | 10 | Higher debit(Account account, double amount); 11 | Higher credit(Account account, double amount); 12 | 13 | } 14 | -------------------------------------------------------------------------------- /cyclops-pure/src/test/java/cyclops/typeclasses/taglessfinal/AccountIO.java: -------------------------------------------------------------------------------- 1 | package cyclops.typeclasses.taglessfinal; 2 | 3 | import com.oath.cyclops.hkt.DataWitness.io; 4 | import com.oath.cyclops.hkt.Higher; 5 | import cyclops.control.Either; 6 | import cyclops.control.Option; 7 | import cyclops.reactive.IO; 8 | 9 | import cyclops.typeclasses.taglessfinal.Cases.Account; 10 | 11 | import java.util.concurrent.Executor; 12 | import java.util.concurrent.Executors; 13 | 14 | public class AccountIO implements AccountAlgebra { 15 | private final Executor exec = Executors.newFixedThreadPool(1); 16 | 17 | @Override 18 | public Higher debit(Account account, double amount) { 19 | return IO.of(()->account,exec) 20 | .map(a->a.debit(amount)); 21 | } 22 | 23 | @Override 24 | public Higher credit(Account account, double amount) { 25 | return IO.of(()->account,exec) 26 | .map(a->a.credit(amount)); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /cyclops-pure/src/test/java/cyclops/typeclasses/taglessfinal/AccountIO2.java: -------------------------------------------------------------------------------- 1 | package cyclops.typeclasses.taglessfinal; 2 | 3 | import com.oath.cyclops.hkt.DataWitness; 4 | import com.oath.cyclops.hkt.DataWitness.io; 5 | import cyclops.instances.reactive.IOInstances; 6 | import cyclops.typeclasses.Do; 7 | import cyclops.typeclasses.taglessfinal.Cases.Account; 8 | import lombok.AllArgsConstructor; 9 | 10 | @AllArgsConstructor 11 | public class AccountIO2 implements AccountAlgebra2 { 12 | StoreIO storeIO; 13 | @Override 14 | public StoreAlgebra store() { 15 | return storeIO; 16 | } 17 | 18 | @Override 19 | public Do forEach() { 20 | return Do.forEach(IOInstances::monad); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /cyclops-pure/src/test/java/cyclops/typeclasses/taglessfinal/Cases.java: -------------------------------------------------------------------------------- 1 | package cyclops.typeclasses.taglessfinal; 2 | 3 | import lombok.ToString; 4 | import lombok.Value; 5 | import lombok.experimental.Wither; 6 | 7 | public class Cases { 8 | @Value @Wither @ToString 9 | public static class Account { 10 | double balance; 11 | long id; 12 | 13 | public Account debit(double amount){ 14 | return withBalance(balance-amount); 15 | } 16 | public Account credit(double amount){ 17 | return withBalance(balance+amount); 18 | } 19 | } 20 | 21 | 22 | 23 | 24 | 25 | } 26 | -------------------------------------------------------------------------------- /cyclops-pure/src/test/java/cyclops/typeclasses/taglessfinal/LogAlgebra.java: -------------------------------------------------------------------------------- 1 | package cyclops.typeclasses.taglessfinal; 2 | 3 | import com.oath.cyclops.hkt.Higher; 4 | import cyclops.typeclasses.taglessfinal.Cases.Account; 5 | 6 | public interface LogAlgebra { 7 | 8 | Higher info(String message); 9 | Higher error(String message); 10 | 11 | } 12 | -------------------------------------------------------------------------------- /cyclops-pure/src/test/java/cyclops/typeclasses/taglessfinal/LogID.java: -------------------------------------------------------------------------------- 1 | package cyclops.typeclasses.taglessfinal; 2 | 3 | 4 | import com.oath.cyclops.hkt.DataWitness; 5 | import com.oath.cyclops.hkt.DataWitness.identity; 6 | import com.oath.cyclops.hkt.Higher; 7 | import cyclops.control.Identity; 8 | import cyclops.reactive.IO; 9 | 10 | public class LogID implements LogAlgebra { 11 | 12 | 13 | @Override 14 | public Higher info(String message) { 15 | return Identity.of(null); 16 | } 17 | 18 | @Override 19 | public Higher error(String message) { 20 | return Identity.of(null); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /cyclops-pure/src/test/java/cyclops/typeclasses/taglessfinal/LogIO.java: -------------------------------------------------------------------------------- 1 | package cyclops.typeclasses.taglessfinal; 2 | 3 | import com.oath.cyclops.hkt.DataWitness; 4 | import com.oath.cyclops.hkt.DataWitness.io; 5 | import com.oath.cyclops.hkt.Higher; 6 | import cyclops.reactive.IO; 7 | 8 | public class LogIO implements LogAlgebra { 9 | 10 | 11 | @Override 12 | public Higher info(String message) { 13 | return IO.of(null); 14 | } 15 | 16 | @Override 17 | public Higher error(String message) { 18 | return IO.of(null); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /cyclops-pure/src/test/java/cyclops/typeclasses/taglessfinal/StoreAlgebra.java: -------------------------------------------------------------------------------- 1 | package cyclops.typeclasses.taglessfinal; 2 | 3 | import com.oath.cyclops.hkt.Higher; 4 | import cyclops.control.Option; 5 | 6 | public interface StoreAlgebra { 7 | Higher> get(K key); 8 | Higher put(K key, V value); 9 | 10 | } 11 | -------------------------------------------------------------------------------- /cyclops-pure/src/test/java/cyclops/typeclasses/taglessfinal/StoreIO.java: -------------------------------------------------------------------------------- 1 | package cyclops.typeclasses.taglessfinal; 2 | 3 | import com.oath.cyclops.hkt.DataWitness; 4 | import com.oath.cyclops.hkt.DataWitness.io; 5 | import com.oath.cyclops.hkt.Higher; 6 | import cyclops.control.Option; 7 | import cyclops.data.HashMap; 8 | import cyclops.reactive.IO; 9 | 10 | import java.util.Map; 11 | 12 | public class StoreIO implements StoreAlgebra { 13 | private HashMap map = HashMap.empty(); 14 | @Override 15 | public Higher> get(K key) { 16 | return IO.of(map.get(key)); 17 | } 18 | 19 | @Override 20 | public Higher put(K key, V value) { 21 | map = map.put(key,value); 22 | 23 | return IO.of((Void)null); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /cyclops-pure/src/test/java/cyclops/typeclasses/taglessfinal/TaglessFinal2Test.java: -------------------------------------------------------------------------------- 1 | package cyclops.typeclasses.taglessfinal; 2 | 3 | import com.oath.cyclops.hkt.DataWitness.io; 4 | import cyclops.data.tuple.Tuple2; 5 | import cyclops.instances.reactive.IOInstances; 6 | import cyclops.reactive.IO; 7 | import org.junit.Before; 8 | import org.junit.Test; 9 | 10 | import static cyclops.typeclasses.taglessfinal.Cases.Account; 11 | 12 | public class TaglessFinal2Test { 13 | 14 | private Account acc1; 15 | private Account acc2; 16 | Program2 prog; 17 | @Before 18 | public void setup(){ 19 | acc1 = new Account(10000d,10); 20 | acc2 = new Account(0d,11); 21 | prog = new Program2(IOInstances.monad(),new AccountIO(),new LogIO(),acc1,acc2); 22 | } 23 | 24 | 25 | @Test 26 | public void programB(){ 27 | 28 | IO> res = prog.transfer(100,IO::narrowK); 29 | res.run().peek(System.out::println); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /cyclops-reactive-collections/gradle.properties: -------------------------------------------------------------------------------- 1 | POM_NAME=cyclops-reactive-collections 2 | -------------------------------------------------------------------------------- /cyclops-reactive-collections/src/main/java/com/oath/cyclops/data/ReactiveWitness.java: -------------------------------------------------------------------------------- 1 | package com.oath.cyclops.data; 2 | 3 | public interface ReactiveWitness { 4 | 5 | public static enum sortedSet {} 6 | public static enum set {} 7 | public static enum list {} 8 | public static enum linkedListX {} 9 | public static enum vectorX {} 10 | public static enum persistentQueueX{} 11 | public static enum persistentSetX {} 12 | public static enum orderedSetX {} 13 | public static enum bagX {} 14 | public static enum deque{} 15 | public static enum queue {} 16 | } 17 | -------------------------------------------------------------------------------- /cyclops-reactive-collections/src/main/java/com/oath/cyclops/data/collections/extensions/LazyFluentCollection.java: -------------------------------------------------------------------------------- 1 | package com.oath.cyclops.data.collections.extensions; 2 | 3 | import com.oath.cyclops.types.persistent.PersistentCollection; 4 | import cyclops.reactive.ReactiveSeq; 5 | 6 | public interface LazyFluentCollection> { 7 | 8 | C get(); 9 | 10 | ReactiveSeq stream(); 11 | 12 | 13 | 14 | 15 | 16 | 17 | } 18 | -------------------------------------------------------------------------------- /cyclops-reactive-collections/src/main/java/com/oath/cyclops/data/collections/extensions/lazy/immutable/FoldToList.java: -------------------------------------------------------------------------------- 1 | package com.oath.cyclops.data.collections.extensions.lazy.immutable; 2 | 3 | import com.oath.cyclops.types.persistent.PersistentList; 4 | 5 | import java.util.Iterator; 6 | 7 | 8 | public interface FoldToList { 9 | public PersistentList from(final Iterator i, int depth); 10 | } 11 | -------------------------------------------------------------------------------- /cyclops-reactive-collections/src/test/java/cyclops/reactive/collections/guava/DequeXGenerator.java: -------------------------------------------------------------------------------- 1 | package cyclops.reactive.collections.guava; 2 | 3 | import java.util.LinkedList; 4 | import java.util.Queue; 5 | import java.util.stream.Collectors; 6 | 7 | import cyclops.reactive.collections.mutable.DequeX; 8 | import com.google.common.collect.testing.TestStringQueueGenerator; 9 | 10 | public class DequeXGenerator extends TestStringQueueGenerator { 11 | 12 | 13 | @Override 14 | public Queue create(String... elements) { 15 | return DequeX.of(elements).type(Collectors.toCollection(()->new LinkedList<>())); 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /cyclops-reactive-collections/src/test/java/cyclops/reactive/collections/guava/ListXGenerator.java: -------------------------------------------------------------------------------- 1 | package cyclops.reactive.collections.guava; 2 | 3 | import java.util.List; 4 | 5 | import cyclops.reactive.collections.mutable.ListX; 6 | import com.google.common.collect.testing.TestStringListGenerator; 7 | 8 | public class ListXGenerator extends TestStringListGenerator { 9 | 10 | 11 | @Override 12 | public List create(String... elements) { 13 | return ListX.of(elements); 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /cyclops-reactive-collections/src/test/java/cyclops/reactive/collections/guava/QueueXGenerator.java: -------------------------------------------------------------------------------- 1 | package cyclops.reactive.collections.guava; 2 | 3 | import java.util.LinkedList; 4 | import java.util.Queue; 5 | import java.util.stream.Collectors; 6 | 7 | import com.google.common.collect.testing.TestStringQueueGenerator; 8 | import cyclops.reactive.collections.mutable.QueueX; 9 | 10 | public class QueueXGenerator extends TestStringQueueGenerator { 11 | 12 | 13 | @Override 14 | public Queue create(String... elements) { 15 | return QueueX.of(elements).type(Collectors.toCollection(()->new LinkedList<>())); 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /cyclops-reactive-collections/src/test/java/cyclops/reactive/collections/guava/SetXGenerator.java: -------------------------------------------------------------------------------- 1 | package cyclops.reactive.collections.guava; 2 | 3 | import java.util.Set; 4 | 5 | import cyclops.reactive.collections.mutable.SetX; 6 | import com.google.common.collect.testing.TestStringSetGenerator; 7 | 8 | public class SetXGenerator extends TestStringSetGenerator { 9 | 10 | 11 | @Override 12 | public Set create(String... elements) { 13 | return SetX.of(elements); 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /cyclops-reactive-collections/src/test/java/cyclops/reactive/collections/guava/SortedSetXGenerator.java: -------------------------------------------------------------------------------- 1 | package cyclops.reactive.collections.guava; 2 | 3 | import java.util.Set; 4 | 5 | import cyclops.reactive.collections.mutable.SortedSetX; 6 | import com.google.common.collect.testing.TestStringSetGenerator; 7 | 8 | public class SortedSetXGenerator extends TestStringSetGenerator { 9 | 10 | 11 | @Override 12 | public Set create(String... elements) { 13 | return SortedSetX.of(elements); 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /cyclops-reactive-collections/src/test/java/cyclops/reactive/collections/standard/ListXCollectableTest.java: -------------------------------------------------------------------------------- 1 | package cyclops.reactive.collections.standard; 2 | 3 | import com.oath.cyclops.types.foldable.Folds; 4 | 5 | 6 | import cyclops.reactive.collections.mutable.ListX; 7 | import cyclops.streams.CollectableTest; 8 | 9 | 10 | public class ListXCollectableTest extends CollectableTest { 11 | 12 | @Override 13 | public Folds of(T... values) { 14 | return ListX.of(values); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /cyclops-reactor-integration/gradle.properties: -------------------------------------------------------------------------------- 1 | POM_NAME=cyclops-reactor-integration 2 | -------------------------------------------------------------------------------- /cyclops-reactor-integration/src/test/java/com/oath/cyclops/reactor/Functor2.java: -------------------------------------------------------------------------------- 1 | package com.oath.cyclops.reactor; 2 | 3 | import java.util.function.Function; 4 | 5 | public interface Functor2 { 6 | 7 | Functor2 map(Function fn); 8 | } 9 | -------------------------------------------------------------------------------- /cyclops-reactor-integration/src/test/java/cyclops/monads/transformers/StreamTSeqConvertableSequenceTest.java: -------------------------------------------------------------------------------- 1 | package cyclops.monads.transformers; 2 | 3 | 4 | import com.oath.cyclops.types.foldable.AbstractConvertableSequenceTest; 5 | import com.oath.cyclops.types.foldable.ConvertableSequence; 6 | import cyclops.companion.reactor.Fluxs; 7 | import cyclops.monads.AnyMs; 8 | import cyclops.monads.Witness.list; 9 | import cyclops.reactive.FluxReactiveSeq; 10 | 11 | 12 | public class StreamTSeqConvertableSequenceTest extends AbstractConvertableSequenceTest { 13 | 14 | @Override 15 | public ConvertableSequence of(T... elements) { 16 | 17 | return AnyMs.liftM(FluxReactiveSeq.of(elements), list.INSTANCE).to(); 18 | } 19 | 20 | @Override 21 | public ConvertableSequence empty() { 22 | 23 | return AnyMs.liftM(FluxReactiveSeq.empty(),list.INSTANCE).to(); 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /cyclops-reactor-integration/src/test/java/cyclops/monads/transformers/StreamTSeqNestedFoldableTest.java: -------------------------------------------------------------------------------- 1 | package cyclops.monads.transformers; 2 | 3 | 4 | import com.oath.cyclops.anym.transformers.FoldableTransformerSeq; 5 | import cyclops.companion.reactor.Fluxs; 6 | import cyclops.monads.AnyMs; 7 | import cyclops.monads.Witness.list; 8 | import cyclops.reactive.FluxReactiveSeq; 9 | 10 | 11 | public class StreamTSeqNestedFoldableTest extends AbstractNestedFoldableTest { 12 | 13 | @Override 14 | public FoldableTransformerSeq of(T... elements) { 15 | return AnyMs.liftM(FluxReactiveSeq.of(elements), list.INSTANCE); 16 | } 17 | 18 | @Override 19 | public FoldableTransformerSeq empty() { 20 | return AnyMs.liftM(FluxReactiveSeq.empty(), list.INSTANCE); 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /cyclops-reactor-integration/src/test/java/cyclops/monads/transformers/StreamTSeqTraversableTest.java: -------------------------------------------------------------------------------- 1 | package cyclops.monads.transformers; 2 | 3 | import com.oath.cyclops.types.AbstractTraversableTest; 4 | import com.oath.cyclops.types.traversable.Traversable; 5 | import cyclops.companion.reactor.Fluxs; 6 | import cyclops.monads.AnyMs; 7 | import cyclops.monads.Witness; 8 | import cyclops.reactive.FluxReactiveSeq; 9 | 10 | 11 | public class StreamTSeqTraversableTest extends AbstractTraversableTest { 12 | 13 | @Override 14 | public Traversable of(T... elements) { 15 | return AnyMs.liftM(FluxReactiveSeq.of(elements), Witness.reactiveSeq.ITERATIVE); 16 | } 17 | 18 | @Override 19 | public Traversable empty() { 20 | return AnyMs.liftM(FluxReactiveSeq.empty(), Witness.reactiveSeq.ITERATIVE); 21 | 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /cyclops-reactor-integration/src/test/java/cyclops/streams/asyncreactivestreams/AsyncRSCollectableTest.java: -------------------------------------------------------------------------------- 1 | package cyclops.streams.asyncreactivestreams; 2 | 3 | import cyclops.companion.reactor.Fluxs; 4 | import cyclops.reactive.FluxReactiveSeq; 5 | import cyclops.reactive.ReactiveSeq; 6 | import cyclops.streams.CollectableTest; 7 | import reactor.core.publisher.Flux; 8 | import reactor.core.scheduler.Schedulers; 9 | 10 | import java.util.concurrent.ForkJoinPool; 11 | 12 | public class AsyncRSCollectableTest extends CollectableTest { 13 | 14 | 15 | public ReactiveSeq of(T... values){ 16 | 17 | return FluxReactiveSeq.reactiveSeq(Flux.just(values) 18 | .subscribeOn(Schedulers.fromExecutor(ForkJoinPool.commonPool()))); 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /cyclops-reactor-integration/src/test/java/cyclops/streams/syncflux/SyncRSCollectableTest.java: -------------------------------------------------------------------------------- 1 | package cyclops.streams.syncflux; 2 | 3 | 4 | import cyclops.companion.reactor.Fluxs; 5 | import cyclops.reactive.FluxReactiveSeq; 6 | import cyclops.reactive.ReactiveSeq; 7 | import cyclops.streams.CollectableTest; 8 | 9 | import reactor.core.publisher.Flux; 10 | 11 | public class SyncRSCollectableTest extends CollectableTest { 12 | 13 | 14 | public ReactiveSeq of(T... values){ 15 | return FluxReactiveSeq.reactiveSeq(Flux.just(values)); 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /cyclops-rxjava2-integration/gradle.properties: -------------------------------------------------------------------------------- 1 | POM_NAME=cyclops-rxjava2-integration 2 | -------------------------------------------------------------------------------- /cyclops-rxjava2-integration/src/test/java/cyclops/monads/transformers/flowables/StreamTSeqConvertableSequenceTest.java: -------------------------------------------------------------------------------- 1 | package cyclops.monads.transformers.flowables; 2 | 3 | 4 | import com.oath.cyclops.types.foldable.AbstractConvertableSequenceTest; 5 | import com.oath.cyclops.types.foldable.ConvertableSequence; 6 | import cyclops.companion.rx2.Flowables; 7 | import cyclops.monads.AnyMs; 8 | import cyclops.monads.Witness.list; 9 | import cyclops.reactive.FlowableReactiveSeq; 10 | 11 | 12 | public class StreamTSeqConvertableSequenceTest extends AbstractConvertableSequenceTest { 13 | 14 | @Override 15 | public ConvertableSequence of(T... elements) { 16 | 17 | return AnyMs.liftM(FlowableReactiveSeq.of(elements), list.INSTANCE).to(); 18 | } 19 | 20 | @Override 21 | public ConvertableSequence empty() { 22 | 23 | return AnyMs.liftM(FlowableReactiveSeq.empty(),list.INSTANCE).to(); 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /cyclops-rxjava2-integration/src/test/java/cyclops/monads/transformers/flowables/StreamTSeqNestedFoldableTest.java: -------------------------------------------------------------------------------- 1 | package cyclops.monads.transformers.flowables; 2 | 3 | 4 | import com.oath.cyclops.anym.transformers.FoldableTransformerSeq; 5 | import cyclops.companion.rx2.Flowables; 6 | import cyclops.monads.AnyMs; 7 | import cyclops.monads.Witness; 8 | import cyclops.monads.transformers.AbstractNestedFoldableTest; 9 | import cyclops.reactive.FlowableReactiveSeq; 10 | 11 | 12 | public class StreamTSeqNestedFoldableTest extends AbstractNestedFoldableTest { 13 | 14 | @Override 15 | public FoldableTransformerSeq of(T... elements) { 16 | return AnyMs.liftM(FlowableReactiveSeq.just(elements),Witness.list.INSTANCE); 17 | } 18 | 19 | @Override 20 | public FoldableTransformerSeq empty() { 21 | return AnyMs.liftM(FlowableReactiveSeq.empty(),Witness.list.INSTANCE); 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /cyclops-rxjava2-integration/src/test/java/cyclops/monads/transformers/observables/StreamTSeqConvertableSequenceTest.java: -------------------------------------------------------------------------------- 1 | package cyclops.monads.transformers.observables; 2 | 3 | 4 | import com.oath.cyclops.types.foldable.AbstractConvertableSequenceTest; 5 | import com.oath.cyclops.types.foldable.ConvertableSequence; 6 | import cyclops.companion.rx2.Observables; 7 | import cyclops.monads.AnyMs; 8 | import cyclops.monads.Witness; 9 | import cyclops.reactive.ObservableReactiveSeq; 10 | 11 | 12 | public class StreamTSeqConvertableSequenceTest extends AbstractConvertableSequenceTest { 13 | 14 | @Override 15 | public ConvertableSequence of(T... elements) { 16 | 17 | return AnyMs.liftM(ObservableReactiveSeq.of(elements),Witness.list.INSTANCE).to(); 18 | } 19 | 20 | @Override 21 | public ConvertableSequence empty() { 22 | 23 | return AnyMs.liftM(ObservableReactiveSeq.empty(),Witness.list.INSTANCE).to(); 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /cyclops-rxjava2-integration/src/test/java/cyclops/monads/transformers/observables/StreamTSeqNestedFoldableTest.java: -------------------------------------------------------------------------------- 1 | package cyclops.monads.transformers.observables; 2 | 3 | 4 | import com.oath.cyclops.anym.transformers.FoldableTransformerSeq; 5 | import cyclops.companion.rx2.Observables; 6 | import cyclops.monads.AnyMs; 7 | import cyclops.monads.Witness; 8 | import cyclops.monads.transformers.AbstractNestedFoldableTest; 9 | import cyclops.reactive.ObservableReactiveSeq; 10 | 11 | 12 | public class StreamTSeqNestedFoldableTest extends AbstractNestedFoldableTest { 13 | 14 | @Override 15 | public FoldableTransformerSeq of(T... elements) { 16 | return AnyMs.liftM(ObservableReactiveSeq.just(elements),Witness.list.INSTANCE); 17 | } 18 | 19 | @Override 20 | public FoldableTransformerSeq empty() { 21 | return AnyMs.liftM(ObservableReactiveSeq.empty(),Witness.list.INSTANCE); 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /cyclops-rxjava2-integration/src/test/java/cyclops/streams/flowables/asyncreactivestreams/AsyncRSCollectableTest.java: -------------------------------------------------------------------------------- 1 | package cyclops.streams.flowables.asyncreactivestreams; 2 | 3 | 4 | import cyclops.companion.rx2.Flowables; 5 | 6 | import cyclops.reactive.FlowableReactiveSeq; 7 | import cyclops.reactive.ReactiveSeq; 8 | import cyclops.streams.flowables.CollectableTest; 9 | 10 | import reactor.core.publisher.Flux; 11 | import reactor.core.scheduler.Schedulers; 12 | 13 | import java.util.concurrent.ForkJoinPool; 14 | 15 | public class AsyncRSCollectableTest extends CollectableTest { 16 | 17 | 18 | public ReactiveSeq of(T... values){ 19 | 20 | return FlowableReactiveSeq.reactiveSeq(Flux.just(values) 21 | .subscribeOn(Schedulers.fromExecutor(ForkJoinPool.commonPool()))); 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /cyclops-rxjava2-integration/src/test/java/cyclops/streams/flowables/syncflux/SyncRSCollectableTest.java: -------------------------------------------------------------------------------- 1 | package cyclops.streams.flowables.syncflux; 2 | 3 | 4 | 5 | import cyclops.companion.rx2.Flowables; 6 | 7 | import cyclops.reactive.FlowableReactiveSeq; 8 | import cyclops.reactive.ReactiveSeq; 9 | import cyclops.streams.flowables.CollectableTest; 10 | import reactor.core.publisher.Flux; 11 | 12 | public class SyncRSCollectableTest extends CollectableTest { 13 | 14 | 15 | public ReactiveSeq of(T... values){ 16 | return FlowableReactiveSeq.reactiveSeq(Flux.just(values)); 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /cyclops-rxjava2-integration/src/test/java/cyclops/streams/observables/AsyncCollectableTest.java: -------------------------------------------------------------------------------- 1 | package cyclops.streams.observables; 2 | 3 | 4 | import cyclops.companion.rx2.Observables; 5 | import cyclops.reactive.ObservableReactiveSeq; 6 | import cyclops.reactive.ReactiveSeq; 7 | import cyclops.reactive.Spouts; 8 | 9 | 10 | public class AsyncCollectableTest extends CollectableTest { 11 | 12 | 13 | public ReactiveSeq of(T... values){ 14 | 15 | ReactiveSeq seq = Spouts.async(s->{ 16 | Thread t = new Thread(()-> { 17 | for (T next : values) { 18 | s.onNext(next); 19 | } 20 | s.onComplete(); 21 | }); 22 | t.start(); 23 | }); 24 | 25 | return ObservableReactiveSeq.reactiveSeq(Observables.observableFrom(seq)); 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /cyclops/gradle.properties: -------------------------------------------------------------------------------- 1 | POM_NAME=cyclops 2 | POM_PACKAGING=jar 3 | POM_DESCRIPTION=Platform for Functional Reactive Programming with Java 8 4 | POM_URL=https://github.com/aol/cyclops 5 | -------------------------------------------------------------------------------- /cyclops/src/main/java/com/oath/cyclops/async/adapters/ContinuationStrategy.java: -------------------------------------------------------------------------------- 1 | package com.oath.cyclops.async.adapters; 2 | 3 | import com.oath.cyclops.types.futurestream.Continuation; 4 | 5 | public interface ContinuationStrategy { 6 | 7 | public void addContinuation(Continuation c); 8 | 9 | public void handleContinuation(); 10 | 11 | default boolean isBlocking(){ 12 | return false; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /cyclops/src/main/java/com/oath/cyclops/hkt/Convert.java: -------------------------------------------------------------------------------- 1 | package com.oath.cyclops.hkt; 2 | 3 | import java.util.function.Function; 4 | 5 | public interface Convert> { 6 | 7 | /** 8 | * Fluent interface for converting this type to another 9 | * 10 | * @param reduce Funtion to convert this type 11 | * @return Converted type 12 | */ 13 | default R convert(Function reduce){ 14 | return reduce.apply((T)this); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /cyclops/src/main/java/com/oath/cyclops/hkt/Higher2.java: -------------------------------------------------------------------------------- 1 | package com.oath.cyclops.hkt; 2 | 3 | //import org.derive4j.hkt.__; 4 | 5 | 6 | /** 7 | * Higher Kinded Type - a core type (e.g. a List) and a data type of the elements within the List (e.g. Integers). 8 | * 9 | * 10 | * @author johnmcclean 11 | * 12 | * @param Core type 13 | * @param Data type of elements in Core Type 14 | */ 15 | public interface Higher2 extends Higher,T3>{// , __{ 16 | 17 | 18 | } 19 | -------------------------------------------------------------------------------- /cyclops/src/main/java/com/oath/cyclops/hkt/Higher3.java: -------------------------------------------------------------------------------- 1 | package com.oath.cyclops.hkt; 2 | 3 | //import org.derive4j.hkt.__; 4 | 5 | 6 | /** 7 | * Higher Kinded Type - a core type (e.g. a List) and a data type of the elements within the List (e.g. Integers). 8 | * 9 | * 10 | * @author johnmcclean 11 | * 12 | * @param Core type 13 | * @param Data type of elements in Core Type 14 | */ 15 | public interface Higher3 extends Higher2,T3,T4>{// , __{ 16 | 17 | 18 | } 19 | -------------------------------------------------------------------------------- /cyclops/src/main/java/com/oath/cyclops/hkt/Higher4.java: -------------------------------------------------------------------------------- 1 | package com.oath.cyclops.hkt; 2 | 3 | //import org.derive4j.hkt.__; 4 | 5 | 6 | /** 7 | * Higher Kinded Type - a core type (e.g. a List) and a data type of the elements within the List (e.g. Integers). 8 | * 9 | * 10 | * @author johnmcclean 11 | * 12 | * @param Core type 13 | * @param Data type of elements in Core Type 14 | */ 15 | public interface Higher4 extends Higher3,T3,T4,T5>{ 16 | 17 | 18 | } 19 | -------------------------------------------------------------------------------- /cyclops/src/main/java/com/oath/cyclops/internal/stream/FullQueueException.java: -------------------------------------------------------------------------------- 1 | package com.oath.cyclops.internal.stream; 2 | 3 | /** 4 | * Created by johnmcclean on 16/05/2017. 5 | */ 6 | public class FullQueueException extends Throwable { 7 | } 8 | -------------------------------------------------------------------------------- /cyclops/src/main/java/com/oath/cyclops/internal/stream/StreamableImpl.java: -------------------------------------------------------------------------------- 1 | package com.oath.cyclops.internal.stream; 2 | 3 | import cyclops.companion.Streamable; 4 | 5 | import lombok.AllArgsConstructor; 6 | import lombok.Getter; 7 | 8 | @AllArgsConstructor 9 | public class StreamableImpl implements Streamable { 10 | @Getter 11 | private final Iterable streamable; 12 | 13 | @Override 14 | public String toString() { 15 | return String.format("Streamable[%s]", streamable); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /cyclops/src/main/java/com/oath/cyclops/internal/stream/spliterators/Composable.java: -------------------------------------------------------------------------------- 1 | package com.oath.cyclops.internal.stream.spliterators; 2 | 3 | import java.util.Spliterator; 4 | 5 | /** 6 | * Created by johnmcclean on 23/12/2016. 7 | */ 8 | public interface Composable { 9 | 10 | public Spliterator compose(); 11 | } 12 | -------------------------------------------------------------------------------- /cyclops/src/main/java/com/oath/cyclops/internal/stream/spliterators/ComposableFunction.java: -------------------------------------------------------------------------------- 1 | package com.oath.cyclops.internal.stream.spliterators; 2 | 3 | import java.util.Spliterator; 4 | import java.util.function.Function; 5 | 6 | /** 7 | * Created by johnmcclean on 30/12/2016. 8 | */ 9 | public interface ComposableFunction> { 10 | X compose(Function fn); 11 | } 12 | -------------------------------------------------------------------------------- /cyclops/src/main/java/com/oath/cyclops/internal/stream/spliterators/CopyableSpliterator.java: -------------------------------------------------------------------------------- 1 | package com.oath.cyclops.internal.stream.spliterators; 2 | 3 | import java.util.Spliterator; 4 | 5 | /** 6 | * Created by johnmcclean on 22/12/2016. 7 | */ 8 | public interface CopyableSpliterator extends Spliterator { 9 | 10 | Spliterator copy(); 11 | 12 | public static Spliterator copy(Spliterator split){ 13 | if(split instanceof CopyableSpliterator){ 14 | return ((CopyableSpliterator)split).copy(); 15 | } 16 | return split; 17 | } 18 | public static Spliterator[] copy(Spliterator[] spliterators){ 19 | Spliterator[] copies = new Spliterator[spliterators.length]; 20 | int i = 0; 21 | for(Spliterator next : spliterators){ 22 | copies[i++] = copy(next); 23 | } 24 | 25 | return copies; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /cyclops/src/main/java/com/oath/cyclops/internal/stream/spliterators/FunctionSpliterator.java: -------------------------------------------------------------------------------- 1 | package com.oath.cyclops.internal.stream.spliterators; 2 | 3 | import java.util.Spliterator; 4 | import java.util.function.Function; 5 | 6 | /** 7 | * Created by johnmcclean on 30/12/2016. 8 | */ 9 | public interface FunctionSpliterator extends Spliterator{ 10 | Spliterator source(); 11 | 12 | Function function(); 13 | } 14 | -------------------------------------------------------------------------------- /cyclops/src/main/java/com/oath/cyclops/internal/stream/spliterators/ReversableSpliterator.java: -------------------------------------------------------------------------------- 1 | package com.oath.cyclops.internal.stream.spliterators; 2 | 3 | public interface ReversableSpliterator extends CopyableSpliterator{ 4 | 5 | boolean isReverse(); 6 | 7 | void setReverse(boolean reverse); 8 | 9 | default ReversableSpliterator invert() { 10 | setReverse(!isReverse()); 11 | return this; 12 | } 13 | 14 | ReversableSpliterator copy(); 15 | 16 | 17 | } 18 | -------------------------------------------------------------------------------- /cyclops/src/main/java/com/oath/cyclops/internal/stream/spliterators/push/BaseOperator.java: -------------------------------------------------------------------------------- 1 | package com.oath.cyclops.internal.stream.spliterators.push; 2 | 3 | import lombok.AllArgsConstructor; 4 | 5 | import java.util.concurrent.locks.LockSupport; 6 | 7 | /** 8 | * Created by johnmcclean on 12/01/2017. 9 | */ 10 | @AllArgsConstructor 11 | public abstract class BaseOperator implements Operator { 12 | final Operator source; 13 | 14 | 15 | protected void request(StreamSubscription[] upstream ,long req){ 16 | while(upstream[0]==null){ 17 | LockSupport.parkNanos(10l); 18 | } 19 | upstream[0].request(req); 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /cyclops/src/main/java/com/oath/cyclops/internal/stream/spliterators/push/Operator.java: -------------------------------------------------------------------------------- 1 | package com.oath.cyclops.internal.stream.spliterators.push; 2 | 3 | import java.util.function.Consumer; 4 | 5 | /** 6 | * Created by johnmcclean on 12/01/2017. 7 | */ 8 | public interface Operator { 9 | 10 | 11 | public StreamSubscription subscribe(Consumer onNext, Consumer onError, Runnable onComplete); 12 | public void subscribeAll(Consumer onNext, Consumer onError, Runnable onComplete); 13 | 14 | } 15 | -------------------------------------------------------------------------------- /cyclops/src/main/java/com/oath/cyclops/matching/Sealed2.java: -------------------------------------------------------------------------------- 1 | package com.oath.cyclops.matching; 2 | 3 | import java.util.function.Function; 4 | 5 | public interface Sealed2 { 6 | 7 | public R fold(Function fn1, Function fn2); 8 | 9 | } 10 | -------------------------------------------------------------------------------- /cyclops/src/main/java/com/oath/cyclops/matching/Sealed3.java: -------------------------------------------------------------------------------- 1 | package com.oath.cyclops.matching; 2 | 3 | 4 | import java.util.function.Function; 5 | 6 | public interface Sealed3 { 7 | 8 | public R fold(Function fn1, Function fn2, Function fn3); 9 | 10 | } 11 | -------------------------------------------------------------------------------- /cyclops/src/main/java/com/oath/cyclops/matching/Sealed4.java: -------------------------------------------------------------------------------- 1 | package com.oath.cyclops.matching; 2 | 3 | import java.util.function.Function; 4 | 5 | public interface Sealed4 { 6 | 7 | public R fold(Function fn1, Function fn2, 8 | Function fn3, Function fn4); 9 | 10 | 11 | 12 | } 13 | -------------------------------------------------------------------------------- /cyclops/src/main/java/com/oath/cyclops/matching/Sealed5.java: -------------------------------------------------------------------------------- 1 | package com.oath.cyclops.matching; 2 | 3 | 4 | import java.util.function.Function; 5 | 6 | public interface Sealed5 { 7 | 8 | public R fold(Function fn1, Function fn2, 9 | Function fn3, Function fn4, 10 | Function fn5); 11 | 12 | 13 | 14 | 15 | } 16 | -------------------------------------------------------------------------------- /cyclops/src/main/java/com/oath/cyclops/matching/SealedOr.java: -------------------------------------------------------------------------------- 1 | package com.oath.cyclops.matching; 2 | 3 | 4 | import java.util.function.Function; 5 | import java.util.function.Supplier; 6 | 7 | public interface SealedOr { 8 | 9 | public R fold(Function fn1, Supplier s); 10 | 11 | } 12 | -------------------------------------------------------------------------------- /cyclops/src/main/java/com/oath/cyclops/react/async/subscription/Continueable.java: -------------------------------------------------------------------------------- 1 | package com.oath.cyclops.react.async.subscription; 2 | 3 | import com.oath.cyclops.async.adapters.Queue; 4 | 5 | public interface Continueable { 6 | 7 | public void closeQueueIfFinished(Queue queue); 8 | 9 | public void addQueue(Queue queue); 10 | 11 | public void registerSkip(long skip); 12 | 13 | public void registerLimit(long limit); 14 | 15 | public void closeAll(Queue q); 16 | 17 | public boolean closed(); 18 | 19 | public void closeQueueIfFinishedStateless(Queue queue); 20 | 21 | public void closeAll(); 22 | 23 | public long timeLimit(); 24 | 25 | public void registerTimeLimit(long nanos); 26 | } 27 | -------------------------------------------------------------------------------- /cyclops/src/main/java/com/oath/cyclops/types/OrElseValue.java: -------------------------------------------------------------------------------- 1 | package com.oath.cyclops.types; 2 | 3 | import com.oath.cyclops.types.recoverable.OnEmptySwitch; 4 | 5 | import java.util.function.Supplier; 6 | 7 | @Deprecated 8 | public interface OrElseValue> extends Value{ 9 | @Deprecated 10 | default X orElseUse(X opt){ 11 | if(isPresent()) 12 | return (X)this; 13 | return opt; 14 | } 15 | @Deprecated 16 | default X orElseUse(Supplier opt){ 17 | if(isPresent()) 18 | return (X)this; 19 | return opt.get(); 20 | 21 | } 22 | 23 | 24 | default X recoverWith(Supplier supplier){ 25 | if(isPresent()) 26 | return (X)this; 27 | return supplier.get(); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /cyclops/src/main/java/com/oath/cyclops/types/Present.java: -------------------------------------------------------------------------------- 1 | package com.oath.cyclops.types; 2 | 3 | 4 | public interface Present { 5 | 6 | public T orElse(T alt); 7 | } 8 | -------------------------------------------------------------------------------- /cyclops/src/main/java/com/oath/cyclops/types/factory/EmptyUnit.java: -------------------------------------------------------------------------------- 1 | package com.oath.cyclops.types.factory; 2 | 3 | /** 4 | * Represents a type that can be instantiated in zero form. 5 | * 6 | * @author johnmcclean 7 | * 8 | * @param Data type of element(s) storeable within this EmptyUnit 9 | */ 10 | public interface EmptyUnit extends Unit { 11 | /** 12 | * @return A new, zero instance of this EmptyUnit type 13 | */ 14 | public Unit emptyUnit(); 15 | } 16 | -------------------------------------------------------------------------------- /cyclops/src/main/java/com/oath/cyclops/types/factory/Unit.java: -------------------------------------------------------------------------------- 1 | package com.oath.cyclops.types.factory; 2 | 3 | /** 4 | * A Data type that supports instantiation of instances of the same type 5 | * 6 | * @author johnmcclean 7 | * 8 | * @param Data type of element(s) stored inside this Pure instance 9 | */ 10 | @FunctionalInterface 11 | public interface Unit { 12 | 13 | public Unit unit(T unit); 14 | 15 | } 16 | -------------------------------------------------------------------------------- /cyclops/src/main/java/com/oath/cyclops/types/foldable/Contains.java: -------------------------------------------------------------------------------- 1 | package com.oath.cyclops.types.foldable; 2 | 3 | import java.util.Objects; 4 | 5 | public interface Contains extends Folds { 6 | default boolean contains(T value){ 7 | return anyMatch(p-> Objects.equals(p,value)); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /cyclops/src/main/java/com/oath/cyclops/types/foldable/EqualTo.java: -------------------------------------------------------------------------------- 1 | package com.oath.cyclops.types.foldable; 2 | 3 | 4 | import com.oath.cyclops.hkt.Higher; 5 | import cyclops.function.Eq; 6 | 7 | public interface EqualTo> extends Higher{ 8 | 9 | default boolean equalTo(T other){ 10 | return this.equalTo(new Eq() {},other); 11 | } 12 | default boolean equalTo(Eq eq, T other){ 13 | return eq.equals(this,other); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /cyclops/src/main/java/com/oath/cyclops/types/foldable/Evaluation.java: -------------------------------------------------------------------------------- 1 | package com.oath.cyclops.types.foldable; 2 | 3 | 4 | import java.util.function.Consumer; 5 | 6 | public enum Evaluation { 7 | EAGER, LAZY; 8 | 9 | public void fold(Runnable eager, Runnable lazy){ 10 | if(this==EAGER){ 11 | eager.run(); 12 | } 13 | lazy.run(); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /cyclops/src/main/java/com/oath/cyclops/types/foldable/OrderedBy.java: -------------------------------------------------------------------------------- 1 | package com.oath.cyclops.types.foldable; 2 | 3 | import com.oath.cyclops.hkt.Higher; 4 | import cyclops.function.Ord; 5 | 6 | 7 | public interface OrderedBy> extends Higher { 8 | default Ord.Ordering order(Ord ord, T2 other){ 9 | return ord.compare(this,other); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /cyclops/src/main/java/com/oath/cyclops/types/foldable/To.java: -------------------------------------------------------------------------------- 1 | package com.oath.cyclops.types.foldable; 2 | 3 | import java.util.function.Function; 4 | 5 | /** 6 | * Fluent interface for converting this type to another 7 | 8 |
 9 | {@code
10 |    api.doThis(a->a*2)
11 |       .doThat(a->a+2)
12 |       .to(Stream::toStream)
13 |       .peek(System.out::println);
14 | 
15 |  }
16 |  
17 | 18 | * 19 | * @author johnmcclean 20 | * 21 | * @param Self type used for conversion 22 | */ 23 | public interface To> { 24 | 25 | /** 26 | * Fluent api for type conversion 27 | * 28 | * @param reduce Funtion to convert this type 29 | * @return Converted type 30 | */ 31 | default R to(Function reduce){ 32 | return reduce.apply((T)this); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /cyclops/src/main/java/com/oath/cyclops/types/functor/FilterableTransformable.java: -------------------------------------------------------------------------------- 1 | package com.oath.cyclops.types.functor; 2 | 3 | import com.oath.cyclops.types.Filters; 4 | 5 | import java.util.function.Function; 6 | import java.util.function.Predicate; 7 | 8 | /** 9 | * Represents a Transformable that is also Filters (e.g. a Stream or Optional type) 10 | * 11 | * @author johnmcclean 12 | * 13 | * @param Data type of the element(s) in this FilterableTransformable 14 | */ 15 | public interface FilterableTransformable extends Filters, Transformable { 16 | 17 | /* (non-Javadoc) 18 | * @see com.oath.cyclops.types.Filters#filter(java.util.function.Predicate) 19 | */ 20 | @Override 21 | FilterableTransformable filter(Predicate fn); 22 | 23 | /* (non-Javadoc) 24 | * @see com.oath.cyclops.types.functor.Transformable#transform(java.util.function.Function) 25 | */ 26 | @Override 27 | FilterableTransformable map(Function fn); 28 | 29 | } 30 | -------------------------------------------------------------------------------- /cyclops/src/main/java/com/oath/cyclops/types/persistent/PersistentBag.java: -------------------------------------------------------------------------------- 1 | package com.oath.cyclops.types.persistent; 2 | 3 | public interface PersistentBag extends PersistentCollection { 4 | PersistentBag plus(T e); 5 | PersistentBag plusAll(Iterable list); 6 | PersistentBag removeValue(T e); 7 | PersistentBag removeAll(Iterable list); 8 | 9 | 10 | } 11 | -------------------------------------------------------------------------------- /cyclops/src/main/java/com/oath/cyclops/types/persistent/PersistentCollection.java: -------------------------------------------------------------------------------- 1 | package com.oath.cyclops.types.persistent; 2 | 3 | import cyclops.reactive.ReactiveSeq; 4 | 5 | import java.util.Objects; 6 | 7 | public interface PersistentCollection extends Iterable{ 8 | 9 | PersistentCollection plus(T e); 10 | 11 | PersistentCollection plusAll(Iterable list); 12 | 13 | 14 | PersistentCollection removeValue(T e); 15 | 16 | int size(); 17 | 18 | PersistentCollection removeAll(Iterable list); 19 | 20 | default boolean isEmpty(){ 21 | return size()==0; 22 | } 23 | 24 | //@TODO align with Folds#contains 25 | default boolean containsValue(T item){ 26 | return stream().filter(t-> Objects.equals(t,item)).findFirst().isPresent(); 27 | } 28 | 29 | default ReactiveSeq stream(){ 30 | return ReactiveSeq.fromIterable(this); 31 | } 32 | 33 | 34 | } 35 | -------------------------------------------------------------------------------- /cyclops/src/main/java/com/oath/cyclops/types/persistent/PersistentIndexed.java: -------------------------------------------------------------------------------- 1 | package com.oath.cyclops.types.persistent; 2 | 3 | import com.oath.cyclops.types.persistent.views.ListView; 4 | import cyclops.control.Option; 5 | import lombok.AllArgsConstructor; 6 | import lombok.experimental.Delegate; 7 | 8 | import java.util.*; 9 | import java.util.function.Supplier; 10 | import java.util.function.UnaryOperator; 11 | 12 | public interface PersistentIndexed extends PersistentCollection { 13 | Option get(int index); 14 | T getOrElse(int index, T alt); 15 | T getOrElseGet(int index, Supplier alt); 16 | 17 | 18 | 19 | } 20 | -------------------------------------------------------------------------------- /cyclops/src/main/java/com/oath/cyclops/types/persistent/PersistentList.java: -------------------------------------------------------------------------------- 1 | package com.oath.cyclops.types.persistent; 2 | 3 | import com.oath.cyclops.types.persistent.views.ListView; 4 | 5 | public interface PersistentList extends PersistentIndexed { 6 | PersistentList plus(T e); 7 | 8 | 9 | PersistentList plusAll(Iterable list); 10 | 11 | 12 | PersistentList updateAt(int i, T e); 13 | 14 | 15 | PersistentList insertAt(int i, T e); 16 | 17 | 18 | PersistentList insertAt(int i, Iterable list); 19 | 20 | 21 | PersistentList removeValue(T e); 22 | 23 | 24 | PersistentList removeAll(Iterable list); 25 | 26 | 27 | PersistentList removeAt(long i); 28 | 29 | default ListView listView(){ 30 | return new ListView.Impl<>(this); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /cyclops/src/main/java/com/oath/cyclops/types/persistent/PersistentQueue.java: -------------------------------------------------------------------------------- 1 | package com.oath.cyclops.types.persistent; 2 | 3 | 4 | import com.oath.cyclops.types.persistent.views.QueueView; 5 | 6 | public interface PersistentQueue extends PersistentIndexed { 7 | 8 | 9 | PersistentQueue minus(); 10 | PersistentQueue plus(T e); 11 | PersistentQueue plusAll(Iterable list); 12 | 13 | 14 | public PersistentQueue removeValue(T e); 15 | public PersistentQueue removeAll(Iterable list); 16 | 17 | 18 | default QueueView queueView(){ 19 | return new QueueView.Impl<>(this); 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /cyclops/src/main/java/com/oath/cyclops/types/persistent/PersistentSet.java: -------------------------------------------------------------------------------- 1 | package com.oath.cyclops.types.persistent; 2 | 3 | import com.oath.cyclops.types.persistent.views.SetView; 4 | import cyclops.reactive.ReactiveSeq; 5 | 6 | public interface PersistentSet extends PersistentCollection{ 7 | 8 | PersistentSet plus(T e); 9 | PersistentSet plusAll(Iterable list); 10 | 11 | PersistentSet removeValue(T e); 12 | 13 | PersistentSet removeAll(Iterable list); 14 | 15 | default ReactiveSeq stream(){ 16 | return ReactiveSeq.fromIterable(this); 17 | } 18 | 19 | default SetView setView(){ 20 | return new SetView.Impl<>(this); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /cyclops/src/main/java/com/oath/cyclops/types/persistent/PersistentSortedSet.java: -------------------------------------------------------------------------------- 1 | package com.oath.cyclops.types.persistent; 2 | 3 | 4 | import com.oath.cyclops.types.persistent.views.SortedSetView; 5 | import cyclops.control.Option; 6 | 7 | import java.util.Comparator; 8 | 9 | public interface PersistentSortedSet extends PersistentSet { 10 | public PersistentSortedSet plus(T e); 11 | 12 | public PersistentSortedSet plusAll(Iterable list); 13 | 14 | public PersistentSortedSet removeValue(T e); 15 | 16 | public PersistentSortedSet removeAll(Iterable list); 17 | 18 | Option get(int index); 19 | 20 | Comparator comparator(); 21 | 22 | default SortedSetView sortedSetView(){ 23 | return new SortedSetView.Impl<>(this); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /cyclops/src/main/java/com/oath/cyclops/types/reactive/BufferOverflowPolicy.java: -------------------------------------------------------------------------------- 1 | package com.oath.cyclops.types.reactive; 2 | 3 | import cyclops.control.Either; 4 | import cyclops.control.Option; 5 | 6 | public enum BufferOverflowPolicy{ DROP, BLOCK; 7 | public Option match(T value){ 8 | return this==DROP? Option.none() : Option.some(value); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /cyclops/src/main/java/com/oath/cyclops/types/reactive/Completable.java: -------------------------------------------------------------------------------- 1 | package com.oath.cyclops.types.reactive; 2 | 3 | 4 | import org.reactivestreams.Publisher; 5 | 6 | public interface Completable{ 7 | 8 | boolean isFailed(); 9 | 10 | boolean isDone(); 11 | boolean complete(T complete); 12 | boolean completeExceptionally(Throwable error); 13 | 14 | 15 | } 16 | 17 | -------------------------------------------------------------------------------- /cyclops/src/main/java/com/oath/cyclops/types/recoverable/OnEmpty.java: -------------------------------------------------------------------------------- 1 | package com.oath.cyclops.types.recoverable; 2 | 3 | import java.util.function.Supplier; 4 | 5 | /** 6 | * Represents a container that may be zero 7 | * 8 | * @author johnmcclean 9 | * 10 | * @param container type 11 | */ 12 | public interface OnEmpty { 13 | 14 | /** 15 | * If this Container instance is zero, create a new instance containing the provided value 16 | * 17 | * @param value 18 | * @return New instance containing value if container is zero, otherwise returns this container 19 | */ 20 | OnEmpty onEmpty(T value); 21 | 22 | /** 23 | * If this Container instance is zero, create a new instance containing the value returned from the provided Supplier 24 | * 25 | * @param supplier to determine new value for container 26 | * @return New Container with value if this is zero, otherwise this container 27 | */ 28 | OnEmpty onEmptyGet(Supplier supplier); 29 | 30 | 31 | 32 | } 33 | -------------------------------------------------------------------------------- /cyclops/src/main/java/com/oath/cyclops/types/recoverable/OnEmptyError.java: -------------------------------------------------------------------------------- 1 | package com.oath.cyclops.types.recoverable; 2 | 3 | import cyclops.control.Try; 4 | 5 | import java.util.function.Supplier; 6 | 7 | public interface OnEmptyError> { 8 | /** 9 | * If this container instance is zero, throw the exception returned by the provided Supplier 10 | * 11 | * @param supplier to create exception from 12 | * @return Throw exception if zero, otherwise this container 13 | */ 14 | Try onEmptyTry(Supplier supplier); 15 | } 16 | -------------------------------------------------------------------------------- /cyclops/src/main/java/com/oath/cyclops/types/recoverable/OnEmptySwitch.java: -------------------------------------------------------------------------------- 1 | package com.oath.cyclops.types.recoverable; 2 | 3 | import java.util.function.Supplier; 4 | 5 | /** 6 | * Represents a container that may be zero for which we can switch a container with another value 7 | * 8 | * @author johnmcclean 9 | * 10 | * @param Data type of element(s) stored in this container 11 | * @param Data type of element(s) stored in the container to be used if this container is zero 12 | */ 13 | public interface OnEmptySwitch { 14 | /** 15 | * Switch to container created by provided Supplier, if current Container zero 16 | * 17 | *
18 |      * {@code
19 |      *     Seq.zero().onEmptySwitch(()->Seq.of(1));
20 |      * }
21 |      * 
22 | * 23 | * @param supplier to create replacement container 24 | * @return Either this container or if zero, an alternative returned by the provided supplier 25 | */ 26 | R onEmptySwitch(Supplier supplier); 27 | 28 | 29 | } 30 | -------------------------------------------------------------------------------- /cyclops/src/main/java/com/oath/cyclops/types/recoverable/Recoverable.java: -------------------------------------------------------------------------------- 1 | package com.oath.cyclops.types.recoverable; 2 | 3 | 4 | import java.util.function.Supplier; 5 | 6 | public interface Recoverable { 7 | 8 | Recoverable recover(Supplier value); 9 | 10 | 11 | } 12 | -------------------------------------------------------------------------------- /cyclops/src/main/java/com/oath/cyclops/types/recoverable/RecoverableFrom.java: -------------------------------------------------------------------------------- 1 | package com.oath.cyclops.types.recoverable; 2 | 3 | import java.util.function.Function; 4 | 5 | /** 6 | * Created by johnmcclean on 23/06/2017. 7 | */ 8 | public interface RecoverableFrom extends Recoverable { 9 | RecoverableFrom recover(Function fn); 10 | } 11 | -------------------------------------------------------------------------------- /cyclops/src/main/java/com/oath/cyclops/types/stream/FromStream.java: -------------------------------------------------------------------------------- 1 | package com.oath.cyclops.types.stream; 2 | 3 | import cyclops.reactive.ReactiveSeq; 4 | 5 | public interface FromStream { 6 | 7 | public R fromStream(ReactiveSeq t); 8 | } 9 | -------------------------------------------------------------------------------- /cyclops/src/main/java/com/oath/cyclops/types/stream/HasExec.java: -------------------------------------------------------------------------------- 1 | package com.oath.cyclops.types.stream; 2 | 3 | import java.util.concurrent.Executor; 4 | 5 | /** 6 | * Represents a type that has an executor for asynchronous execution 7 | * 8 | * @author johnmcclean 9 | * 10 | */ 11 | public interface HasExec { 12 | /** 13 | * @return Executor used for asynchronous execution. 14 | */ 15 | Executor getExec(); 16 | } 17 | -------------------------------------------------------------------------------- /cyclops/src/main/java/com/oath/cyclops/types/stream/HasStream.java: -------------------------------------------------------------------------------- 1 | package com.oath.cyclops.types.stream; 2 | 3 | import cyclops.reactive.ReactiveSeq; 4 | 5 | /** 6 | * A type that lazy has a stream of data or can be converted to a Stream of data 7 | * 8 | * @author johnmcclean 9 | * 10 | * @param Data type of elements in this HasStream 11 | */ 12 | public interface HasStream { 13 | /** 14 | * @return Stream of elements 15 | */ 16 | ReactiveSeq getStream(); 17 | } 18 | -------------------------------------------------------------------------------- /cyclops/src/main/java/com/oath/cyclops/types/stream/PausableConnectable.java: -------------------------------------------------------------------------------- 1 | package com.oath.cyclops.types.stream; 2 | 3 | /** 4 | * A Connectable (Stream already emitting data) that can be paused and unpaused 5 | * 6 | * @author johnmcclean 7 | * 8 | * @param Data type of elements in the Stream 9 | */ 10 | public interface PausableConnectable extends Connectable { 11 | /** 12 | * Unpause this Connectable (restart data production) 13 | */ 14 | void unpause(); 15 | 16 | /** 17 | * Pause this Connectable (stop it producing data until unpaused) 18 | */ 19 | void pause(); 20 | } 21 | -------------------------------------------------------------------------------- /cyclops/src/main/java/com/oath/cyclops/types/stream/ToStream.java: -------------------------------------------------------------------------------- 1 | package com.oath.cyclops.types.stream; 2 | 3 | import java.util.List; 4 | import java.util.stream.Stream; 5 | import java.util.stream.StreamSupport; 6 | 7 | import com.oath.cyclops.internal.stream.ReversedIterator; 8 | import cyclops.reactive.ReactiveSeq; 9 | import com.oath.cyclops.internal.stream.SeqUtils; 10 | 11 | /** 12 | * Interface that represents a data type that can be converted to a Stream 13 | * 14 | * @author johnmcclean 15 | * 16 | * @param Data type of elements in the this ToStream type 17 | */ 18 | public interface ToStream extends Iterable { 19 | 20 | 21 | 22 | default ReactiveSeq stream() { 23 | return ReactiveSeq.fromSpliterator(this.spliterator()); 24 | } 25 | 26 | 27 | 28 | 29 | /** 30 | * @return This type as a reversed Stream 31 | */ 32 | default ReactiveSeq reveresedStream() { 33 | return ReactiveSeq.fromStream(reveresedStream()); 34 | } 35 | 36 | 37 | 38 | } 39 | -------------------------------------------------------------------------------- /cyclops/src/main/java/com/oath/cyclops/util/SimpleTimer.java: -------------------------------------------------------------------------------- 1 | package com.oath.cyclops.util; 2 | 3 | /** 4 | * 5 | * Simple Timer class that returns elapsed milliseconds since construction 6 | * 7 | * @author johnmcclean 8 | * 9 | */ 10 | public final class SimpleTimer { 11 | 12 | private final long startNanoSeconds = System.nanoTime(); 13 | 14 | /** 15 | * @return Time elapsed in nanoseconds since object construction 16 | */ 17 | public final long getElapsedNanoseconds() { 18 | return System.nanoTime() - startNanoSeconds; 19 | } 20 | 21 | public final long getElapsedMillis(){ 22 | return (long)(getElapsedNanoseconds()/ 1e+6); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /cyclops/src/main/java/com/oath/cyclops/util/ThrowsSoftened.java: -------------------------------------------------------------------------------- 1 | package com.oath.cyclops.util; 2 | 3 | public @interface ThrowsSoftened { 4 | 5 | Class[]value(); 6 | } 7 | -------------------------------------------------------------------------------- /cyclops/src/main/java/cyclops/companion/Comparators.java: -------------------------------------------------------------------------------- 1 | package cyclops.companion; 2 | 3 | 4 | import java.util.Comparator; 5 | 6 | public class Comparators { 7 | 8 | private final static Comparator IDENTITY_COMPARATOR_INSTANCE = (a, b)-> Comparator.naturalOrder().compare(System.identityHashCode(a),System.identityHashCode(b)); 9 | public static > Comparator naturalComparator(){ 10 | return Comparator.naturalOrder(); 11 | } 12 | public static Comparator identityComparator(){ 13 | return IDENTITY_COMPARATOR_INSTANCE; 14 | } 15 | public static Comparator naturalOrderIdentityComparator(){ 16 | return (a,b)-> { 17 | if (a instanceof Comparable) { 18 | return Comparator.naturalOrder().compare((Comparable)a,(Comparable)b); 19 | } 20 | return identityComparator().compare(a,b); 21 | }; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /cyclops/src/main/java/cyclops/companion/Groups.java: -------------------------------------------------------------------------------- 1 | package cyclops.companion; 2 | 3 | import cyclops.function.Group; 4 | 5 | import java.math.BigInteger; 6 | 7 | 8 | public interface Groups { 9 | 10 | /** 11 | * Combine two Integers by summing them 12 | */ 13 | static Group intSum = Group.of(a->-a, Monoids.intSum); 14 | /** 15 | * Combine two Longs by summing them 16 | */ 17 | static Group longSum = Group.of(a->-a, Monoids.longSum); 18 | /** 19 | * Combine two Doubles by summing them 20 | */ 21 | static Group doubleSum = Group.of(a->-a, Monoids.doubleSum); 22 | /** 23 | * Combine two BigIngegers by summing them 24 | */ 25 | static Group bigIntSum = Group.of(a->BigInteger.ZERO.subtract(a), Monoids.bigIntSum); 26 | 27 | 28 | } 29 | -------------------------------------------------------------------------------- /cyclops/src/main/java/cyclops/data/tuple/Tuple0.java: -------------------------------------------------------------------------------- 1 | package cyclops.data.tuple; 2 | 3 | import lombok.AccessLevel; 4 | import lombok.AllArgsConstructor; 5 | 6 | /** 7 | * Empty tuple type 8 | */ 9 | @AllArgsConstructor(access = AccessLevel.PRIVATE) 10 | public final class Tuple0 { 11 | static Tuple0 INSTANCE = new Tuple0(); 12 | 13 | public static Tuple0 empty(){ 14 | return INSTANCE; 15 | } 16 | 17 | public Tuple1 add(T t){ 18 | return Tuple.tuple(t); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /cyclops/src/main/java/cyclops/function/BinaryFunction.java: -------------------------------------------------------------------------------- 1 | package cyclops.function; 2 | 3 | import java.util.function.BinaryOperator; 4 | 5 | 6 | public interface BinaryFunction extends BinaryOperator, Function2 { 7 | } 8 | -------------------------------------------------------------------------------- /cyclops/src/main/java/cyclops/function/BooleanFunction0.java: -------------------------------------------------------------------------------- 1 | package cyclops.function; 2 | 3 | import java.util.function.BooleanSupplier; 4 | 5 | @Deprecated 6 | public interface BooleanFunction0 extends BooleanSupplier { 7 | 8 | default BooleanFunction0 before(Runnable r){ 9 | return ()->{ 10 | r.run(); 11 | return getAsBoolean(); 12 | }; 13 | } 14 | default BooleanFunction0 after(Runnable r){ 15 | return ()->{ 16 | 17 | boolean res = getAsBoolean(); 18 | r.run(); 19 | return res; 20 | }; 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /cyclops/src/main/java/cyclops/function/Eq.java: -------------------------------------------------------------------------------- 1 | package cyclops.function; 2 | 3 | 4 | import com.oath.cyclops.hkt.Higher; 5 | 6 | public interface Eq{ 7 | 8 | default boolean equals(Higher c1, Higher c2){ 9 | return c1.equals(c2); 10 | } 11 | 12 | default boolean notEquals(Higher c1, Higher c2){ 13 | return !equals(c1,c2); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /cyclops/src/main/java/cyclops/function/Semigroup.java: -------------------------------------------------------------------------------- 1 | package cyclops.function; 2 | 3 | import java.util.function.BinaryOperator; 4 | 5 | /** 6 | * An (associative) binary operation for combining values. 7 | * Implementations should obey associativity laws. 8 | * 9 | * @author johnmcclean 10 | * 11 | * @param Data type of elements to be combined 12 | */ 13 | @FunctionalInterface 14 | public interface Semigroup extends BinaryFunction,BinaryOperator { 15 | 16 | /* (non-Javadoc) 17 | * @see java.util.function.BiFunction#applyHKT(java.lang.Object, java.lang.Object) 18 | */ 19 | @Override 20 | T apply(T t, T u); 21 | 22 | } 23 | -------------------------------------------------------------------------------- /cyclops/src/main/java/cyclops/function/UnaryFunction.java: -------------------------------------------------------------------------------- 1 | package cyclops.function; 2 | 3 | import java.util.function.UnaryOperator; 4 | 5 | 6 | public interface UnaryFunction extends UnaryOperator, Function1 { 7 | } 8 | -------------------------------------------------------------------------------- /cyclops/src/main/java/cyclops/function/checked/CheckedBiConsumer.java: -------------------------------------------------------------------------------- 1 | package cyclops.function.checked; 2 | 3 | public interface CheckedBiConsumer { 4 | public void accept(T1 a,T2 b) throws Throwable; 5 | } 6 | -------------------------------------------------------------------------------- /cyclops/src/main/java/cyclops/function/checked/CheckedBiFunction.java: -------------------------------------------------------------------------------- 1 | package cyclops.function.checked; 2 | 3 | public interface CheckedBiFunction { 4 | public R apply(T1 t1,T2 t2) throws Throwable; 5 | } 6 | -------------------------------------------------------------------------------- /cyclops/src/main/java/cyclops/function/checked/CheckedBiPredicate.java: -------------------------------------------------------------------------------- 1 | package cyclops.function.checked; 2 | 3 | public interface CheckedBiPredicate { 4 | public boolean test(T1 t1,T2 t2) throws Throwable; 5 | } 6 | -------------------------------------------------------------------------------- /cyclops/src/main/java/cyclops/function/checked/CheckedBooleanSupplier.java: -------------------------------------------------------------------------------- 1 | package cyclops.function.checked; 2 | 3 | public interface CheckedBooleanSupplier { 4 | public Boolean getAsBoolean() throws Throwable; 5 | } 6 | -------------------------------------------------------------------------------- /cyclops/src/main/java/cyclops/function/checked/CheckedConsumer.java: -------------------------------------------------------------------------------- 1 | package cyclops.function.checked; 2 | 3 | public interface CheckedConsumer { 4 | public void accept(T a) throws Throwable; 5 | } 6 | -------------------------------------------------------------------------------- /cyclops/src/main/java/cyclops/function/checked/CheckedDoubleConsumer.java: -------------------------------------------------------------------------------- 1 | package cyclops.function.checked; 2 | 3 | public interface CheckedDoubleConsumer { 4 | public void accept(double a) throws Throwable; 5 | } 6 | -------------------------------------------------------------------------------- /cyclops/src/main/java/cyclops/function/checked/CheckedDoubleFunction.java: -------------------------------------------------------------------------------- 1 | package cyclops.function.checked; 2 | 3 | public interface CheckedDoubleFunction { 4 | public R apply(double t) throws Throwable; 5 | } 6 | -------------------------------------------------------------------------------- /cyclops/src/main/java/cyclops/function/checked/CheckedDoublePredicate.java: -------------------------------------------------------------------------------- 1 | package cyclops.function.checked; 2 | 3 | public interface CheckedDoublePredicate { 4 | public boolean test(double test) throws Throwable; 5 | } 6 | -------------------------------------------------------------------------------- /cyclops/src/main/java/cyclops/function/checked/CheckedDoubleSupplier.java: -------------------------------------------------------------------------------- 1 | package cyclops.function.checked; 2 | 3 | public interface CheckedDoubleSupplier { 4 | public double getAsDouble() throws Throwable; 5 | } 6 | -------------------------------------------------------------------------------- /cyclops/src/main/java/cyclops/function/checked/CheckedFunction.java: -------------------------------------------------------------------------------- 1 | package cyclops.function.checked; 2 | 3 | public interface CheckedFunction { 4 | public R apply(T t) throws Throwable; 5 | } 6 | -------------------------------------------------------------------------------- /cyclops/src/main/java/cyclops/function/checked/CheckedIntConsumer.java: -------------------------------------------------------------------------------- 1 | package cyclops.function.checked; 2 | 3 | public interface CheckedIntConsumer { 4 | public void accept(int a) throws Throwable; 5 | } 6 | -------------------------------------------------------------------------------- /cyclops/src/main/java/cyclops/function/checked/CheckedIntFunction.java: -------------------------------------------------------------------------------- 1 | package cyclops.function.checked; 2 | 3 | public interface CheckedIntFunction { 4 | public R apply(int t) throws Throwable; 5 | } 6 | -------------------------------------------------------------------------------- /cyclops/src/main/java/cyclops/function/checked/CheckedIntPredicate.java: -------------------------------------------------------------------------------- 1 | package cyclops.function.checked; 2 | 3 | public interface CheckedIntPredicate { 4 | public boolean test(int test) throws Throwable; 5 | } 6 | -------------------------------------------------------------------------------- /cyclops/src/main/java/cyclops/function/checked/CheckedIntSupplier.java: -------------------------------------------------------------------------------- 1 | package cyclops.function.checked; 2 | 3 | public interface CheckedIntSupplier { 4 | public int getAsInt() throws Throwable; 5 | } 6 | -------------------------------------------------------------------------------- /cyclops/src/main/java/cyclops/function/checked/CheckedLongConsumer.java: -------------------------------------------------------------------------------- 1 | package cyclops.function.checked; 2 | 3 | public interface CheckedLongConsumer { 4 | public void accept(long a) throws Throwable; 5 | } 6 | -------------------------------------------------------------------------------- /cyclops/src/main/java/cyclops/function/checked/CheckedLongFunction.java: -------------------------------------------------------------------------------- 1 | package cyclops.function.checked; 2 | 3 | public interface CheckedLongFunction { 4 | public R apply(long t) throws Throwable; 5 | } 6 | -------------------------------------------------------------------------------- /cyclops/src/main/java/cyclops/function/checked/CheckedLongPredicate.java: -------------------------------------------------------------------------------- 1 | package cyclops.function.checked; 2 | 3 | public interface CheckedLongPredicate { 4 | public boolean test(long test) throws Throwable; 5 | } 6 | -------------------------------------------------------------------------------- /cyclops/src/main/java/cyclops/function/checked/CheckedLongSupplier.java: -------------------------------------------------------------------------------- 1 | package cyclops.function.checked; 2 | 3 | public interface CheckedLongSupplier { 4 | public long getAsLong() throws Throwable; 5 | } 6 | -------------------------------------------------------------------------------- /cyclops/src/main/java/cyclops/function/checked/CheckedPredicate.java: -------------------------------------------------------------------------------- 1 | package cyclops.function.checked; 2 | 3 | public interface CheckedPredicate { 4 | public boolean test(T test) throws Throwable; 5 | } 6 | -------------------------------------------------------------------------------- /cyclops/src/main/java/cyclops/function/checked/CheckedSupplier.java: -------------------------------------------------------------------------------- 1 | package cyclops.function.checked; 2 | 3 | public interface CheckedSupplier { 4 | public T get() throws Throwable; 5 | } 6 | -------------------------------------------------------------------------------- /cyclops/src/main/java/cyclops/function/checked/CheckedTriFunction.java: -------------------------------------------------------------------------------- 1 | package cyclops.function.checked; 2 | 3 | public interface CheckedTriFunction { 4 | 5 | public R apply(T1 t1, T2 t2, T3 t3) throws Throwable; 6 | 7 | } 8 | -------------------------------------------------------------------------------- /cyclops/src/test/java/com/oath/cyclops/comprehensions/ForPublishersTest.java: -------------------------------------------------------------------------------- 1 | package com.oath.cyclops.comprehensions; 2 | 3 | import cyclops.data.tuple.Tuple; 4 | import cyclops.data.tuple.Tuple2; 5 | import org.junit.Test; 6 | 7 | import cyclops.reactive.ReactiveSeq; 8 | 9 | public class ForPublishersTest { 10 | 11 | 12 | 13 | @Test 14 | public void publishers(){ 15 | 16 | // import static com.oath.cyclops.control.For.*; 17 | 18 | ReactiveSeq> stream = ReactiveSeq.of(1,2,3).forEach2(i-> ReactiveSeq.range(i,5), 19 | Tuple::tuple) 20 | .stream(); 21 | 22 | stream.printOut(); 23 | /* 24 | (1, 1) 25 | (1, 2) 26 | (1, 3) 27 | (1, 4) 28 | (2, 2) 29 | (2, 3) 30 | (2, 4) 31 | (3, 3) 32 | (3, 4) 33 | 34 | */ 35 | 36 | } 37 | 38 | 39 | } 40 | -------------------------------------------------------------------------------- /cyclops/src/test/java/com/oath/cyclops/comprehensions/donotation/typed/DoTest.java: -------------------------------------------------------------------------------- 1 | package com.oath.cyclops.comprehensions.donotation.typed; 2 | 3 | import cyclops.reactive.ReactiveSeq; 4 | import org.junit.Test; 5 | 6 | import static cyclops.reactive.ReactiveSeq.range; 7 | import static cyclops.data.tuple.Tuple.tuple; 8 | public class DoTest { 9 | 10 | @Test 11 | public void doGen2(){ 12 | 13 | ReactiveSeq.range(1,10) 14 | .forEach2(i->range(0, i), (i,j)->tuple(i,j)); 15 | 16 | // .forEach(System.out::println); 17 | 18 | 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /cyclops/src/test/java/com/oath/cyclops/internal/stream/spliterators/push/combine/CombineTckPublisherTest.java: -------------------------------------------------------------------------------- 1 | package com.oath.cyclops.internal.stream.spliterators.push.combine; 2 | 3 | 4 | import cyclops.reactive.Spouts; 5 | import org.reactivestreams.Publisher; 6 | import org.reactivestreams.tck.PublisherVerification; 7 | import org.reactivestreams.tck.TestEnvironment; 8 | import org.testng.annotations.Test; 9 | 10 | @Test 11 | public class CombineTckPublisherTest extends PublisherVerification{ 12 | 13 | public CombineTckPublisherTest(){ 14 | super(new TestEnvironment(300L)); 15 | } 16 | 17 | 18 | @Override 19 | public Publisher createPublisher(long elements) { 20 | return Spouts.iterate(0l, i->i+1l).combine((a,b)->false,(a,b)->a+b).limit(elements); 21 | 22 | } 23 | 24 | @Override 25 | public Publisher createFailedPublisher() { 26 | return null; //not possible to forEachAsync to failed Stream 27 | 28 | } 29 | 30 | 31 | } 32 | -------------------------------------------------------------------------------- /cyclops/src/test/java/com/oath/cyclops/internal/stream/spliterators/push/filter/FilterGenerateTckPublisherTest.java: -------------------------------------------------------------------------------- 1 | package com.oath.cyclops.internal.stream.spliterators.push.filter; 2 | 3 | 4 | import cyclops.reactive.Spouts; 5 | import org.reactivestreams.Publisher; 6 | import org.reactivestreams.tck.PublisherVerification; 7 | import org.reactivestreams.tck.TestEnvironment; 8 | import org.testng.annotations.Test; 9 | 10 | @Test 11 | public class FilterGenerateTckPublisherTest extends PublisherVerification{ 12 | 13 | public FilterGenerateTckPublisherTest(){ 14 | super(new TestEnvironment(300L)); 15 | } 16 | 17 | 18 | @Override 19 | public Publisher createPublisher(long elements) { 20 | return Spouts.generate(()->2l).filter(i->i%2==0).limit(elements); 21 | 22 | } 23 | 24 | @Override 25 | public Publisher createFailedPublisher() { 26 | return null; //not possible to forEachAsync to failed Stream 27 | 28 | } 29 | 30 | 31 | } 32 | -------------------------------------------------------------------------------- /cyclops/src/test/java/com/oath/cyclops/internal/stream/spliterators/push/filter/FilterIterableTckPublisherTest.java: -------------------------------------------------------------------------------- 1 | package com.oath.cyclops.internal.stream.spliterators.push.filter; 2 | 3 | import cyclops.data.LazySeq; 4 | import cyclops.reactive.Spouts; 5 | import org.reactivestreams.Publisher; 6 | import org.reactivestreams.tck.PublisherVerification; 7 | import org.reactivestreams.tck.TestEnvironment; 8 | import org.testng.annotations.Test; 9 | 10 | @Test 11 | public class FilterIterableTckPublisherTest extends PublisherVerification{ 12 | 13 | public FilterIterableTckPublisherTest(){ 14 | super(new TestEnvironment(300L)); 15 | } 16 | 17 | 18 | @Override 19 | public Publisher createPublisher(long elements) { 20 | return Spouts.fromIterable(LazySeq.fill(Math.min(elements,10_000),10l)).filter(i->true); 21 | 22 | } 23 | 24 | @Override 25 | public Publisher createFailedPublisher() { 26 | return null; //not possible to forEachAsync to failed Stream 27 | 28 | } 29 | 30 | 31 | } 32 | -------------------------------------------------------------------------------- /cyclops/src/test/java/com/oath/cyclops/internal/stream/spliterators/push/filter/FilterTckArrayConcatPublisherTest.java: -------------------------------------------------------------------------------- 1 | package com.oath.cyclops.internal.stream.spliterators.push.filter; 2 | 3 | 4 | import cyclops.reactive.Spouts; 5 | import org.reactivestreams.Publisher; 6 | import org.reactivestreams.tck.PublisherVerification; 7 | import org.reactivestreams.tck.TestEnvironment; 8 | import org.testng.annotations.Test; 9 | 10 | @Test 11 | public class FilterTckArrayConcatPublisherTest extends PublisherVerification{ 12 | 13 | public FilterTckArrayConcatPublisherTest(){ 14 | super(new TestEnvironment(300L)); 15 | } 16 | 17 | 18 | @Override 19 | public Publisher createPublisher(long elements) { 20 | return Spouts.concat(Spouts.of(),Spouts.iterate(0l, i->i+1l)).filter(i->true).limit(elements); 21 | 22 | } 23 | 24 | @Override 25 | public Publisher createFailedPublisher() { 26 | return null; //not possible to forEachAsync to failed Stream 27 | 28 | } 29 | 30 | 31 | } 32 | -------------------------------------------------------------------------------- /cyclops/src/test/java/com/oath/cyclops/internal/stream/spliterators/push/filter/FilterTckPublisherTest.java: -------------------------------------------------------------------------------- 1 | package com.oath.cyclops.internal.stream.spliterators.push.filter; 2 | 3 | 4 | import cyclops.reactive.Spouts; 5 | import org.reactivestreams.Publisher; 6 | import org.reactivestreams.tck.PublisherVerification; 7 | import org.reactivestreams.tck.TestEnvironment; 8 | import org.testng.annotations.Test; 9 | 10 | @Test 11 | public class FilterTckPublisherTest extends PublisherVerification{ 12 | 13 | public FilterTckPublisherTest(){ 14 | super(new TestEnvironment(300L)); 15 | } 16 | 17 | 18 | @Override 19 | public Publisher createPublisher(long elements) { 20 | return Spouts.iterate(0l, i->i+1l).filter(i->i%2==0).limit(elements); 21 | 22 | } 23 | 24 | @Override 25 | public Publisher createFailedPublisher() { 26 | return null; //not possible to forEachAsync to failed Stream 27 | 28 | } 29 | 30 | 31 | } 32 | -------------------------------------------------------------------------------- /cyclops/src/test/java/com/oath/cyclops/internal/stream/spliterators/push/flatMap/iterable/FlatMapTckPublisherTest.java: -------------------------------------------------------------------------------- 1 | package com.oath.cyclops.internal.stream.spliterators.push.flatMap.iterable; 2 | 3 | 4 | import cyclops.reactive.Spouts; 5 | import org.reactivestreams.Publisher; 6 | import org.reactivestreams.tck.PublisherVerification; 7 | import org.reactivestreams.tck.TestEnvironment; 8 | import org.testng.annotations.Test; 9 | 10 | @Test 11 | public class FlatMapTckPublisherTest extends PublisherVerification{ 12 | 13 | public FlatMapTckPublisherTest(){ 14 | super(new TestEnvironment(300L)); 15 | } 16 | 17 | 18 | @Override 19 | public Publisher createPublisher(long elements) { 20 | return Spouts.iterate(0l, i->i+1l).concatMap(i->Spouts.of(i)).limit(elements); 21 | 22 | } 23 | 24 | @Override 25 | public Publisher createFailedPublisher() { 26 | return null; //not possible to forEachAsync to failed Stream 27 | 28 | } 29 | 30 | 31 | } 32 | -------------------------------------------------------------------------------- /cyclops/src/test/java/com/oath/cyclops/internal/stream/spliterators/push/flatMap/iterable/IterableFlatMap2TckPublisherTest.java: -------------------------------------------------------------------------------- 1 | package com.oath.cyclops.internal.stream.spliterators.push.flatMap.iterable; 2 | 3 | 4 | import cyclops.reactive.Spouts; 5 | import org.reactivestreams.Publisher; 6 | import org.reactivestreams.tck.PublisherVerification; 7 | import org.reactivestreams.tck.TestEnvironment; 8 | import org.testng.annotations.Test; 9 | 10 | @Test 11 | public class IterableFlatMap2TckPublisherTest extends PublisherVerification{ 12 | 13 | public IterableFlatMap2TckPublisherTest(){ 14 | super(new TestEnvironment(300L)); 15 | } 16 | 17 | 18 | @Override 19 | public Publisher createPublisher(long elements) { 20 | return Spouts.iterate(0l, i->i+1l).concatMap(i->Spouts.of(0l,i)).limit(elements); 21 | 22 | } 23 | 24 | @Override 25 | public Publisher createFailedPublisher() { 26 | return null; //not possible to forEachAsync to failed Stream 27 | 28 | } 29 | 30 | 31 | } 32 | -------------------------------------------------------------------------------- /cyclops/src/test/java/com/oath/cyclops/internal/stream/spliterators/push/flatMap/publisher/PublisherFlatMap2TckPublisherTest.java: -------------------------------------------------------------------------------- 1 | package com.oath.cyclops.internal.stream.spliterators.push.flatMap.publisher; 2 | 3 | 4 | import cyclops.reactive.Spouts; 5 | import org.reactivestreams.Publisher; 6 | import org.testng.annotations.Test; 7 | 8 | @Test(enabled =false) 9 | public class PublisherFlatMap2TckPublisherTest{//} extends PublisherVerification{ 10 | 11 | public PublisherFlatMap2TckPublisherTest(){ 12 | // super(new TestEnvironment(300L)); 13 | } 14 | 15 | 16 | //@Override 17 | public Publisher createPublisher(long elements) { 18 | return Spouts.iterate(0l, i->i+1l).mergeMap(i->Spouts.of(0l,i)).limit(elements); 19 | 20 | } 21 | 22 | // @Override 23 | public Publisher createFailedPublisher() { 24 | return null; //not possible to forEachAsync to failed Stream 25 | 26 | } 27 | // @Override @Test 28 | public void optional_spec111_maySupportMultiSubscribe() throws Throwable { 29 | 30 | } 31 | 32 | 33 | 34 | } 35 | -------------------------------------------------------------------------------- /cyclops/src/test/java/com/oath/cyclops/internal/stream/spliterators/push/flatMap/stream/FlatMap2TckPublisherTest.java: -------------------------------------------------------------------------------- 1 | package com.oath.cyclops.internal.stream.spliterators.push.flatMap.stream; 2 | 3 | 4 | import cyclops.reactive.Spouts; 5 | import org.reactivestreams.Publisher; 6 | import org.reactivestreams.tck.PublisherVerification; 7 | import org.reactivestreams.tck.TestEnvironment; 8 | import org.testng.annotations.Test; 9 | 10 | @Test 11 | public class FlatMap2TckPublisherTest extends PublisherVerification{ 12 | 13 | public FlatMap2TckPublisherTest(){ 14 | super(new TestEnvironment(300L)); 15 | } 16 | 17 | 18 | @Override 19 | public Publisher createPublisher(long elements) { 20 | return Spouts.iterate(0l, i->i+1l).flatMap(i->Spouts.of(0l,i)).limit(elements); 21 | 22 | } 23 | 24 | @Override 25 | public Publisher createFailedPublisher() { 26 | return null; //not possible to forEachAsync to failed Stream 27 | 28 | } 29 | 30 | 31 | } 32 | -------------------------------------------------------------------------------- /cyclops/src/test/java/com/oath/cyclops/internal/stream/spliterators/push/flatMap/stream/FlatMapTckPublisherTest.java: -------------------------------------------------------------------------------- 1 | package com.oath.cyclops.internal.stream.spliterators.push.flatMap.stream; 2 | 3 | 4 | import cyclops.reactive.Spouts; 5 | import org.reactivestreams.Publisher; 6 | import org.reactivestreams.tck.PublisherVerification; 7 | import org.reactivestreams.tck.TestEnvironment; 8 | import org.testng.annotations.Test; 9 | 10 | @Test 11 | public class FlatMapTckPublisherTest extends PublisherVerification{ 12 | 13 | public FlatMapTckPublisherTest(){ 14 | super(new TestEnvironment(300L)); 15 | } 16 | 17 | 18 | @Override 19 | public Publisher createPublisher(long elements) { 20 | return Spouts.iterate(0l, i->i+1l).flatMap(i->Spouts.of(i)).limit(elements); 21 | 22 | } 23 | 24 | @Override 25 | public Publisher createFailedPublisher() { 26 | return null; //not possible to forEachAsync to failed Stream 27 | 28 | } 29 | 30 | 31 | } 32 | -------------------------------------------------------------------------------- /cyclops/src/test/java/com/oath/cyclops/internal/stream/spliterators/push/grouping/GroupedTckPublisherTest.java: -------------------------------------------------------------------------------- 1 | package com.oath.cyclops.internal.stream.spliterators.push.grouping; 2 | 3 | 4 | import cyclops.reactive.Spouts; 5 | import org.reactivestreams.Publisher; 6 | import org.reactivestreams.tck.PublisherVerification; 7 | import org.reactivestreams.tck.TestEnvironment; 8 | import org.testng.annotations.Test; 9 | 10 | @Test 11 | public class GroupedTckPublisherTest extends PublisherVerification{ 12 | 13 | public GroupedTckPublisherTest(){ 14 | super(new TestEnvironment(300L)); 15 | } 16 | 17 | 18 | @Override 19 | public Publisher createPublisher(long elements) { 20 | return Spouts.iterate(0l, i->i+1l).grouped(1).map(l->l.getOrElse(0,-1l)).limit(elements); 21 | 22 | } 23 | 24 | @Override 25 | public Publisher createFailedPublisher() { 26 | return null; //not possible to forEachAsync to failed Stream 27 | 28 | } 29 | 30 | 31 | } 32 | -------------------------------------------------------------------------------- /cyclops/src/test/java/com/oath/cyclops/internal/stream/spliterators/push/grouping/groupedWhile/GroupedWhileTckPublisherTest.java: -------------------------------------------------------------------------------- 1 | package com.oath.cyclops.internal.stream.spliterators.push.grouping.groupedWhile; 2 | 3 | 4 | import cyclops.reactive.Spouts; 5 | import org.reactivestreams.Publisher; 6 | import org.reactivestreams.tck.PublisherVerification; 7 | import org.reactivestreams.tck.TestEnvironment; 8 | import org.testng.annotations.Test; 9 | 10 | @Test 11 | public class GroupedWhileTckPublisherTest extends PublisherVerification{ 12 | 13 | public GroupedWhileTckPublisherTest(){ 14 | super(new TestEnvironment(300L)); 15 | } 16 | 17 | 18 | @Override 19 | public Publisher createPublisher(long elements) { 20 | return Spouts.iterate(0l, i->i+1l).groupedWhile(i->false).map(l->l.getOrElse(0,-1l)).limit(elements); 21 | 22 | } 23 | 24 | @Override 25 | public Publisher createFailedPublisher() { 26 | return null; //not possible to forEachAsync to failed Stream 27 | 28 | } 29 | 30 | 31 | } 32 | -------------------------------------------------------------------------------- /cyclops/src/test/java/com/oath/cyclops/internal/stream/spliterators/push/grouping/sliding/SlidingTckPublisherTest.java: -------------------------------------------------------------------------------- 1 | package com.oath.cyclops.internal.stream.spliterators.push.grouping.sliding; 2 | 3 | 4 | import cyclops.reactive.Spouts; 5 | import org.reactivestreams.Publisher; 6 | import org.reactivestreams.tck.PublisherVerification; 7 | import org.reactivestreams.tck.TestEnvironment; 8 | import org.testng.annotations.Test; 9 | 10 | @Test 11 | public class SlidingTckPublisherTest extends PublisherVerification{ 12 | 13 | public SlidingTckPublisherTest(){ 14 | super(new TestEnvironment(300L)); 15 | } 16 | 17 | 18 | @Override 19 | public Publisher createPublisher(long elements) { 20 | return Spouts.concat(Spouts.of(1l,2l,3l,4l,5l),Spouts.iterate(0l, i->i+1l).sliding(2,1).skip(4).map(l->l.getOrElse(0,-1l))).limit(elements); 21 | 22 | } 23 | 24 | @Override 25 | public Publisher createFailedPublisher() { 26 | return null; //not possible to forEachAsync to failed Stream 27 | 28 | } 29 | 30 | 31 | } 32 | -------------------------------------------------------------------------------- /cyclops/src/test/java/com/oath/cyclops/internal/stream/spliterators/push/map/MapTckPublisherTest.java: -------------------------------------------------------------------------------- 1 | package com.oath.cyclops.internal.stream.spliterators.push.map; 2 | 3 | 4 | 5 | import cyclops.data.LazySeq; 6 | import cyclops.reactive.Spouts; 7 | import org.reactivestreams.Publisher; 8 | import org.reactivestreams.tck.PublisherVerification; 9 | import org.reactivestreams.tck.TestEnvironment; 10 | import org.testng.annotations.Test; 11 | 12 | @Test 13 | public class MapTckPublisherTest extends PublisherVerification{ 14 | 15 | public MapTckPublisherTest(){ 16 | super(new TestEnvironment(300L)); 17 | } 18 | 19 | 20 | @Override 21 | public Publisher createPublisher(long elements) { 22 | 23 | return Spouts.fromIterable(LazySeq.fill(Math.min(elements,10_000),10l)).map(i->i*2); 24 | 25 | } 26 | 27 | @Override 28 | public Publisher createFailedPublisher() { 29 | return null; //not possible to forEachAsync to failed Stream 30 | 31 | } 32 | 33 | 34 | } 35 | -------------------------------------------------------------------------------- /cyclops/src/test/java/com/oath/cyclops/internal/stream/spliterators/push/scan/ScanLimitTckPublisherTest.java: -------------------------------------------------------------------------------- 1 | package com.oath.cyclops.internal.stream.spliterators.push.scan; 2 | 3 | 4 | import cyclops.reactive.Spouts; 5 | import org.reactivestreams.Publisher; 6 | import org.reactivestreams.tck.PublisherVerification; 7 | import org.reactivestreams.tck.TestEnvironment; 8 | import org.testng.annotations.Test; 9 | 10 | @Test 11 | public class ScanLimitTckPublisherTest extends PublisherVerification{ 12 | 13 | public ScanLimitTckPublisherTest(){ 14 | super(new TestEnvironment(300L)); 15 | } 16 | 17 | 18 | @Override 19 | public Publisher createPublisher(long elements) { 20 | return Spouts.iterate(0l, i->i+1l).limit(elements-1).scanLeft(1l,(a,b)->a+b); 21 | 22 | } 23 | 24 | @Override 25 | public Publisher createFailedPublisher() { 26 | return null; //not possible to forEachAsync to failed Stream 27 | 28 | } 29 | 30 | 31 | } 32 | -------------------------------------------------------------------------------- /cyclops/src/test/java/com/oath/cyclops/internal/stream/spliterators/push/scan/ScanTckPublisherTest.java: -------------------------------------------------------------------------------- 1 | package com.oath.cyclops.internal.stream.spliterators.push.scan; 2 | 3 | 4 | import cyclops.reactive.Spouts; 5 | import org.reactivestreams.Publisher; 6 | import org.reactivestreams.tck.PublisherVerification; 7 | import org.reactivestreams.tck.TestEnvironment; 8 | import org.testng.annotations.Test; 9 | 10 | @Test 11 | public class ScanTckPublisherTest extends PublisherVerification{ 12 | 13 | public ScanTckPublisherTest(){ 14 | super(new TestEnvironment(300L)); 15 | } 16 | 17 | 18 | @Override 19 | public Publisher createPublisher(long elements) { 20 | return Spouts.iterate(0l, i->i+1l).scanLeft(1l,(a,b)->a+b).limit(elements); 21 | 22 | } 23 | 24 | @Override 25 | public Publisher createFailedPublisher() { 26 | return null; //not possible to forEachAsync to failed Stream 27 | 28 | } 29 | 30 | 31 | } 32 | -------------------------------------------------------------------------------- /cyclops/src/test/java/com/oath/cyclops/internal/stream/spliterators/push/zip/ZipTckPublisherTest.java: -------------------------------------------------------------------------------- 1 | package com.oath.cyclops.internal.stream.spliterators.push.zip; 2 | 3 | 4 | import cyclops.reactive.Spouts; 5 | import org.reactivestreams.Publisher; 6 | import org.reactivestreams.tck.PublisherVerification; 7 | import org.reactivestreams.tck.TestEnvironment; 8 | import org.testng.annotations.Test; 9 | 10 | @Test 11 | public class ZipTckPublisherTest extends PublisherVerification{ 12 | 13 | public ZipTckPublisherTest(){ 14 | super(new TestEnvironment(300L)); 15 | } 16 | 17 | 18 | @Override 19 | public Publisher createPublisher(long elements) { 20 | return Spouts.iterate(0l, i->i+1l).zip(Spouts.iterate(0l,i->i+1l)) 21 | .limit(elements).map(t->t._1()); 22 | 23 | } 24 | 25 | @Override 26 | public Publisher createFailedPublisher() { 27 | return null; //not possible to forEachAsync to failed Stream 28 | 29 | } 30 | 31 | 32 | } 33 | -------------------------------------------------------------------------------- /cyclops/src/test/java/com/oath/cyclops/matching/Case0Test.java: -------------------------------------------------------------------------------- 1 | package com.oath.cyclops.matching; 2 | 3 | import static org.junit.Assert.assertEquals; 4 | import static org.junit.Assert.assertFalse; 5 | 6 | import org.junit.Test; 7 | 8 | public class Case0Test { 9 | 10 | @Test 11 | public void shouldMatchForAllPredicates() { 12 | String value = "value"; 13 | assertEquals("case0", new Case.Case0<>((String t1) -> t1.equals("value"), (v) -> "case0").test(value).orElse(null)); 14 | } 15 | 16 | @Test 17 | public void shouldMatchForPartial() { 18 | String value = "value"; 19 | assertFalse(new Case.Case0<>((String t1) -> false, (v) -> "case0").test(value).isPresent()); 20 | } 21 | 22 | 23 | } 24 | -------------------------------------------------------------------------------- /cyclops/src/test/java/com/oath/cyclops/matching/Case1Test.java: -------------------------------------------------------------------------------- 1 | package com.oath.cyclops.matching; 2 | 3 | import static org.junit.Assert.assertEquals; 4 | import static org.junit.Assert.assertFalse; 5 | 6 | import cyclops.data.tuple.Tuple1; 7 | import org.junit.Test; 8 | 9 | public class Case1Test { 10 | 11 | @Test 12 | public void shouldMatchForAllPredicates() { 13 | Tuple1 tuple1 = new Tuple1<>("tuple"); 14 | assertEquals("tuple1", new Case.Case1<>((String t1) -> t1.equals("tuple"), (value) -> "tuple1").test(tuple1).orElse(null)); 15 | } 16 | 17 | @Test 18 | public void shouldMatchForPartial() { 19 | Tuple1 tuple1 = new Tuple1<>("tuple"); 20 | assertFalse(new Case.Case1<>((String t1) -> false, (value) -> "tuple").test(tuple1).isPresent()); 21 | } 22 | 23 | 24 | } 25 | -------------------------------------------------------------------------------- /cyclops/src/test/java/com/oath/cyclops/matching/CaseOptionalTest.java: -------------------------------------------------------------------------------- 1 | package com.oath.cyclops.matching; 2 | 3 | import static java.util.Optional.empty; 4 | import static java.util.Optional.of; 5 | 6 | import org.junit.Assert; 7 | import org.junit.Test; 8 | 9 | public class CaseOptionalTest { 10 | 11 | @Test 12 | public void shouldMatchOptionalPresent() { 13 | Case.CaseOptional caseOptional = new Case.CaseOptional<>(() -> 1L, () -> 2L); 14 | Assert.assertEquals((Long) 1L, caseOptional.test(of("")).orElse(null)); 15 | } 16 | 17 | @Test 18 | public void shouldMatchOptionalAbsent() { 19 | Case.CaseOptional caseOptional = new Case.CaseOptional<>(() -> 1L, () -> 2L); 20 | Assert.assertEquals((Long) 2L, caseOptional.test(empty()).orElse(null)); 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /cyclops/src/test/java/com/oath/cyclops/matching/sample/Pet.java: -------------------------------------------------------------------------------- 1 | package com.oath.cyclops.matching.sample; 2 | 3 | import com.oath.cyclops.matching.Deconstruct; 4 | import cyclops.data.tuple.Tuple3; 5 | import lombok.AllArgsConstructor; 6 | import lombok.Getter; 7 | 8 | public interface Pet extends Deconstruct.Deconstruct3 { 9 | 10 | String getName(); 11 | 12 | int getAge(); 13 | 14 | String getGender(); 15 | 16 | @Override 17 | default Tuple3 unapply() { 18 | return new Tuple3<>(getName(), getAge(), getGender()); 19 | } 20 | 21 | @AllArgsConstructor 22 | @Getter 23 | class Dog implements Pet { 24 | private final String name; 25 | private final int age; 26 | private final String gender; 27 | } 28 | 29 | @AllArgsConstructor 30 | @Getter 31 | class Cat implements Pet { 32 | private final String name; 33 | private final int age; 34 | private final String gender; 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /cyclops/src/test/java/com/oath/cyclops/streams/ReactiveSeqCollectableTest.java: -------------------------------------------------------------------------------- 1 | package com.oath.cyclops.streams; 2 | 3 | import com.oath.cyclops.types.foldable.Folds; 4 | 5 | 6 | import cyclops.reactive.ReactiveSeq; 7 | import cyclops.streams.CollectableTest; 8 | 9 | 10 | public class ReactiveSeqCollectableTest extends CollectableTest { 11 | 12 | @Override 13 | public Folds of(T... values) { 14 | return ReactiveSeq.of(values); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /cyclops/src/test/java/com/oath/cyclops/streams/SeqTest.java: -------------------------------------------------------------------------------- 1 | package com.oath.cyclops.streams; 2 | 3 | import static cyclops.data.tuple.Tuple.tuple; 4 | import static org.junit.Assert.assertTrue; 5 | 6 | import java.util.Arrays; 7 | import java.util.function.Supplier; 8 | 9 | import cyclops.reactive.ReactiveSeq; 10 | import cyclops.data.tuple.Tuple2; 11 | import org.junit.Test; 12 | 13 | public class SeqTest { 14 | 15 | @Test 16 | public void testUnzipWithLimits() { 17 | 18 | Supplier>> s = () -> ReactiveSeq.of( 19 | tuple(1, "a"),tuple(2, "b"),tuple(3, "c")); 20 | 21 | Tuple2, ReactiveSeq> u1 = ReactiveSeq.unzip(s 22 | .get()); 23 | 24 | assertTrue(u1._1().limit(2).toList().containsAll(Arrays.asList(1, 2))); 25 | 26 | assertTrue(u1._2().toList().containsAll(Arrays.asList("a", "b", "c"))); 27 | 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /cyclops/src/test/java/com/oath/cyclops/types/AbstractValueTest.java: -------------------------------------------------------------------------------- 1 | package com.oath.cyclops.types; 2 | 3 | import static org.junit.Assert.assertEquals; 4 | 5 | import java.util.List; 6 | import java.util.stream.Collectors; 7 | 8 | import org.junit.Test; 9 | 10 | public abstract class AbstractValueTest { 11 | public abstract Value of(T element); 12 | 13 | @Test 14 | public void collect(){ 15 | List lst = of(1).collect(Collectors.toList()); 16 | assertEquals(new Integer(1), lst.get(0)); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /cyclops/src/test/java/com/oath/cyclops/types/UnwrappableTest.java: -------------------------------------------------------------------------------- 1 | package com.oath.cyclops.types; 2 | 3 | import cyclops.control.Either; 4 | import cyclops.control.LazyEither; 5 | import org.junit.Test; 6 | 7 | import static org.hamcrest.Matchers.equalTo; 8 | import static org.junit.Assert.*; 9 | 10 | public class UnwrappableTest { 11 | @Test 12 | public void unwrapIfInstanceHit() throws Exception { 13 | Object o = new MyUnWrappable().unwrapIfInstance(Either.class,()->"hello"); 14 | assertThat(o,equalTo(LazyEither.left("hello"))); 15 | } 16 | 17 | @Test 18 | public void unwrapIfInstanceMiss() throws Exception { 19 | Object o = new MyUnWrappable().unwrapIfInstance(String.class,()->"hello"); 20 | assertThat(o,equalTo("hello")); 21 | } 22 | static class MyUnWrappable implements Unwrappable { 23 | @Override 24 | public R unwrap() { 25 | return (R) LazyEither.left("hello"); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /cyclops/src/test/java/com/oath/cyclops/util/stream/reactivestreams/TckBlackBoxSubscriberTest.java: -------------------------------------------------------------------------------- 1 | package com.oath.cyclops.util.stream.reactivestreams; 2 | 3 | import com.oath.cyclops.types.reactive.QueueBasedSubscriber; 4 | import org.reactivestreams.Subscriber; 5 | import org.reactivestreams.tck.SubscriberBlackboxVerification; 6 | import org.reactivestreams.tck.TestEnvironment; 7 | import org.testng.annotations.Test; 8 | 9 | @Test 10 | public class TckBlackBoxSubscriberTest extends SubscriberBlackboxVerification{ 11 | public TckBlackBoxSubscriberTest() { 12 | super(new TestEnvironment(300L)); 13 | } 14 | 15 | @Override 16 | public Subscriber createSubscriber() { 17 | return new QueueBasedSubscriber(new QueueBasedSubscriber.Counter(),500); 18 | 19 | } 20 | 21 | @Override 22 | public Long createElement(int element) { 23 | return new Long(element); 24 | } 25 | 26 | 27 | } 28 | -------------------------------------------------------------------------------- /cyclops/src/test/java/cyclops/Sets.java: -------------------------------------------------------------------------------- 1 | package cyclops; 2 | 3 | import java.util.Arrays; 4 | import java.util.HashSet; 5 | import java.util.Set; 6 | 7 | public interface Sets { 8 | 9 | public static Set empty(){ 10 | return new HashSet<>(Arrays.asList()); 11 | } 12 | public static Set set(T... values){ 13 | return new HashSet<>(Arrays.asList(values)); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /cyclops/src/test/java/cyclops/companion/ReducersTest.java: -------------------------------------------------------------------------------- 1 | package cyclops.companion; 2 | 3 | import cyclops.data.Bag; 4 | import org.junit.Test; 5 | 6 | import java.util.Arrays; 7 | import java.util.stream.Stream; 8 | 9 | import static org.hamcrest.Matchers.equalTo; 10 | import static org.junit.Assert.*; 11 | 12 | public class ReducersTest { 13 | @Test 14 | public void toBagX() throws Exception { 15 | assertThat(Reducers.toPersistentBag().foldMap(Stream.of(1,2,3)),equalTo(Bag.of(1,2,3))); 16 | assertThat(Bag.empty().plus(10),equalTo(Bag.of(10))); 17 | assertThat(Bag.empty().plusAll(Arrays.asList(10)),equalTo(Bag.of(10))); 18 | assertThat(Bag.empty().plus(5).plusAll(Arrays.asList(10,20)),equalTo(Bag.of(5,10,20))); 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /cyclops/src/test/java/cyclops/control/AbstractOptionTest.java: -------------------------------------------------------------------------------- 1 | package cyclops.control; 2 | 3 | import org.junit.Test; 4 | import org.reactivestreams.Publisher; 5 | 6 | import static junit.framework.TestCase.assertTrue; 7 | import static org.junit.Assert.assertFalse; 8 | 9 | public abstract class AbstractOptionTest extends AbstractValueTest { 10 | 11 | protected abstract Option of(T value); 12 | protected abstract Option empty(); 13 | protected abstract Option fromPublisher(Publisher p); 14 | 15 | boolean run; 16 | @Test 17 | public void whenEmpty_onEmpty_isRun(){ 18 | run = false; 19 | empty().onEmpty(()->run=true) 20 | .isPresent(); 21 | assertTrue(run); 22 | } 23 | 24 | @Test 25 | public void whenNotEmpty_onEmpty_isNotRun(){ 26 | run = false; 27 | of(10).onEmpty(()->run=true) 28 | .isPresent(); 29 | assertFalse(run); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /cyclops/src/test/java/cyclops/control/future/futureOverwriteIssue/AuthorizationService3.java: -------------------------------------------------------------------------------- 1 | package cyclops.control.future.futureOverwriteIssue; 2 | 3 | 4 | import cyclops.control.Either; 5 | import cyclops.data.NonEmptyList; 6 | import cyclops.data.Vector; 7 | 8 | public class AuthorizationService3 { 9 | public Either> isAuthorized(User user, NonEmptyList nel) { 10 | return Either.right(nel.vector()); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /cyclops/src/test/java/cyclops/control/future/futureOverwriteIssue/SleepingURLDataFileMetadata.java: -------------------------------------------------------------------------------- 1 | package cyclops.control.future.futureOverwriteIssue; 2 | 3 | import cyclops.control.Either; 4 | import lombok.Getter; 5 | 6 | import java.io.IOException; 7 | import java.net.URL; 8 | 9 | 10 | @Getter 11 | public class SleepingURLDataFileMetadata extends DataFileMetadata { 12 | 13 | private final URL url; 14 | 15 | public SleepingURLDataFileMetadata(long customerId, String type, URL url) { 16 | super(customerId, type); 17 | this.url = url; 18 | } 19 | 20 | @Override 21 | public Either loadContents() { 22 | // System.out.println("Current thread " + Thread.currentThread().getId()); 23 | try { 24 | Thread.sleep(501l); 25 | } catch (InterruptedException e) { 26 | e.printStackTrace(); 27 | } 28 | return Either.right("success"); 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /cyclops/src/test/java/cyclops/control/future/futureOverwriteIssue/SuccessURLDataFileMetadata.java: -------------------------------------------------------------------------------- 1 | package cyclops.control.future.futureOverwriteIssue; 2 | 3 | import cyclops.control.Either; 4 | import lombok.Getter; 5 | 6 | import java.io.IOException; 7 | import java.net.URL; 8 | 9 | 10 | @Getter 11 | public class SuccessURLDataFileMetadata extends DataFileMetadata { 12 | 13 | private final URL url; 14 | 15 | public SuccessURLDataFileMetadata(long customerId, String type, URL url) { 16 | super(customerId, type); 17 | this.url = url; 18 | } 19 | 20 | @Override 21 | public Either loadContents() { 22 | return Either.right("contents here"); 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /cyclops/src/test/java/cyclops/control/future/futureOverwriteIssue/User.java: -------------------------------------------------------------------------------- 1 | package cyclops.control.future.futureOverwriteIssue; 2 | 3 | import cyclops.data.Seq; 4 | import lombok.AllArgsConstructor; 5 | import lombok.Getter; 6 | 7 | @Getter 8 | @AllArgsConstructor 9 | public class User { 10 | 11 | private final Seq groups; 12 | } 13 | -------------------------------------------------------------------------------- /cyclops/src/test/java/cyclops/control/lazy/MaybeTest.java: -------------------------------------------------------------------------------- 1 | package cyclops.control.lazy; 2 | 3 | import cyclops.control.Maybe; 4 | import org.junit.Test; 5 | 6 | public class MaybeTest { 7 | 8 | @Test 9 | public void flatMap() { 10 | Maybe.of(10) 11 | .flatMap(i -> { System.out.println("Not maybe!"); return Maybe.of(15);}) 12 | .map(i -> { System.out.println("Not maybe!"); return Maybe.of(15);}) 13 | .map(i -> Maybe.of(20)); 14 | 15 | } 16 | @Test 17 | public void odd() { 18 | System.out.println(even(Maybe.just(200000)).toOptional().get()); 19 | } 20 | 21 | public Maybe odd(Maybe n) { 22 | 23 | return n.flatMap(x -> even(Maybe.just(x - 1))); 24 | } 25 | 26 | public Maybe even(Maybe n) { 27 | return n.flatMap(x -> { 28 | return x <= 0 ? Maybe.just("done") : odd(Maybe.just(x - 1)); 29 | }); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /cyclops/src/test/java/cyclops/control/maybe/MaybeValueTest.java: -------------------------------------------------------------------------------- 1 | package cyclops.control.maybe; 2 | 3 | import com.oath.cyclops.types.AbstractValueTest; 4 | import com.oath.cyclops.types.Value; 5 | import cyclops.control.Maybe; 6 | 7 | public class MaybeValueTest extends AbstractValueTest { 8 | 9 | @Override 10 | public Value of(T element) { 11 | return Maybe.of(element); 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /cyclops/src/test/java/cyclops/data/BQTest.java: -------------------------------------------------------------------------------- 1 | package cyclops.data; 2 | 3 | import org.junit.Test; 4 | 5 | import java.util.stream.Stream; 6 | 7 | import static org.hamcrest.Matchers.equalTo; 8 | import static org.junit.Assert.assertThat; 9 | 10 | public class BQTest { 11 | @Test 12 | public void fromStream(){ 13 | System.out.println(BankersQueue.of(1,2,3)); 14 | System.out.println(BankersQueue.fromStream(Stream.of(1,2,3))); 15 | BankersQueue.fromStream(Stream.of(1,2,3)).iterator(); 16 | assertThat(BankersQueue.fromStream(Stream.of(1,2,3)),equalTo(BankersQueue.of(1,2,3))); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /cyclops/src/test/java/cyclops/data/HListTest.java: -------------------------------------------------------------------------------- 1 | package cyclops.data; 2 | 3 | import org.junit.Test; 4 | 5 | /** 6 | * Created by johnmcclean on 06/09/2017. 7 | */ 8 | public class HListTest { 9 | @Test 10 | public void simple(){ 11 | HList.HCons> list = HList.cons(1, HList.of("hello")); 12 | } 13 | 14 | } -------------------------------------------------------------------------------- /cyclops/src/test/java/cyclops/data/ListTest.java: -------------------------------------------------------------------------------- 1 | package cyclops.data; 2 | 3 | import cyclops.companion.Monoids; 4 | import cyclops.reactive.ReactiveSeq; 5 | import org.junit.Test; 6 | 7 | import static org.hamcrest.Matchers.equalTo; 8 | import static org.junit.Assert.assertThat; 9 | 10 | 11 | public class ListTest{ 12 | 13 | @Test 14 | public void testMapA(){ 15 | assertThat(Seq.of(1,2,3).map(i->i*2),equalTo(Seq.of(2,4,6))); 16 | assertThat(Seq.empty().map(i->i*2),equalTo(Seq.empty())); 17 | } 18 | @Test 19 | public void testFlatMapA(){ 20 | assertThat(Seq.of(1,2,3).flatMap(i-> Seq.of(i*2)),equalTo(Seq.of(2,4,6))); 21 | assertThat(Seq.empty().flatMap(i-> Seq.of(i*2)),equalTo(Seq.empty())); 22 | } 23 | 24 | @Test 25 | public void testFoldRightA(){ 26 | assertThat(Seq.fromStream(ReactiveSeq.range(0,100_000)).foldRight(Monoids.intSum),equalTo(704982704)); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /cyclops/src/test/java/cyclops/data/TreeMapTest.java: -------------------------------------------------------------------------------- 1 | package cyclops.data; 2 | 3 | 4 | import org.junit.Test; 5 | 6 | import java.util.Comparator; 7 | 8 | /** 9 | * Created by johnmcclean on 02/09/2017. 10 | */ 11 | public class TreeMapTest { 12 | 13 | @Test 14 | public void put(){ 15 | 16 | TreeMap map = TreeMap.fromMap(Comparator.naturalOrder(), HashMap.of(1,"hello",2,"world")); 17 | 18 | map.stream().printOut(); 19 | 20 | map.put(10,"boo!") 21 | .put(20,"world").remove(10).stream().printOut(); 22 | 23 | System.out.println(map.put(10,"boo!").elementAt(10).orElse(null)); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /cyclops/src/test/java/cyclops/data/talk/EitherExample.java: -------------------------------------------------------------------------------- 1 | package cyclops.data.talk; 2 | 3 | import cyclops.control.Either; 4 | 5 | public class EitherExample { 6 | 7 | public static void main(String[] args){ 8 | 9 | Either right = Either.right("hello"); 10 | 11 | Either left = Either.left(10); 12 | 13 | System.out.println(right.map(str->str+" world")); 14 | 15 | System.out.println(left.mapLeft(i->i*2)); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /cyclops/src/test/java/cyclops/data/talk/EvalExample.java: -------------------------------------------------------------------------------- 1 | package cyclops.data.talk; 2 | 3 | import cyclops.control.Eval; 4 | 5 | public class EvalExample { 6 | 7 | static int count; 8 | 9 | public static void main(String[] args){ 10 | 11 | Eval lazy = Eval.later(()->count++) 12 | .map(i->i*2); 13 | 14 | 15 | System.out.println("doubled (1) " + lazy.get()); 16 | System.out.println("count (1) " + count); 17 | 18 | 19 | System.out.println("doubled (2) " + lazy.get()); 20 | System.out.println("count (2) " + count); 21 | 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /cyclops/src/test/java/cyclops/data/talk/Example.java: -------------------------------------------------------------------------------- 1 | package cyclops.data.talk; 2 | 3 | 4 | import cyclops.data.Seq; 5 | 6 | public class Example { 7 | 8 | public static void main(String[] args){ 9 | 10 | Seq seq = Seq.empty(); 11 | int first = seq.fold(c->c.head(), 12 | n->-1); 13 | 14 | 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /cyclops/src/test/java/cyclops/data/talk/LazySeqExample.java: -------------------------------------------------------------------------------- 1 | package cyclops.data.talk; 2 | 3 | import cyclops.data.LazySeq; 4 | import org.junit.Test; 5 | 6 | public class LazySeqExample { 7 | 8 | String b = "!"; 9 | @Test 10 | public void lazy(){ 11 | 12 | LazySeq.of("hello","world") 13 | .map(a->b=a); 14 | 15 | System.out.println(b); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /cyclops/src/test/java/cyclops/data/talk/NotLazySeqStub.java: -------------------------------------------------------------------------------- 1 | package cyclops.data.talk; 2 | 3 | import cyclops.control.Eval; 4 | import cyclops.data.LazySeq; 5 | import lombok.AccessLevel; 6 | import lombok.AllArgsConstructor; 7 | 8 | import java.util.function.Supplier; 9 | 10 | @AllArgsConstructor(access = AccessLevel.PRIVATE) 11 | public class NotLazySeqStub { 12 | 13 | public final T head; 14 | public final Supplier> tail; 15 | 16 | } 17 | -------------------------------------------------------------------------------- /cyclops/src/test/java/cyclops/data/talk/OptionExample.java: -------------------------------------------------------------------------------- 1 | package cyclops.data.talk; 2 | 3 | import cyclops.control.Option; 4 | 5 | public class OptionExample { 6 | 7 | public static void main(String[] args){ 8 | Option.none() 9 | .orElse(-1); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /cyclops/src/test/java/cyclops/data/talk/UnmodifiableTest.java: -------------------------------------------------------------------------------- 1 | package cyclops.data.talk; 2 | 3 | import org.junit.Test; 4 | 5 | import java.util.ArrayList; 6 | import java.util.Collections; 7 | import java.util.List; 8 | 9 | public class UnmodifiableTest { 10 | int CORE_USER = 0; 11 | 12 | public void unmod(){ 13 | List list = new ArrayList<>(); 14 | list.add(10); 15 | list.add(20); 16 | doSomething(Collections.unmodifiableList(list)); 17 | } 18 | 19 | 20 | public void doSomething(List list){ 21 | list.add(CORE_USER); 22 | updateActiveUsers(list); 23 | } 24 | 25 | private void updateActiveUsers(List list) { 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /cyclops/src/test/java/cyclops/data/talk/VectorExample.java: -------------------------------------------------------------------------------- 1 | package cyclops.data.talk; 2 | 3 | import cyclops.data.Vector; 4 | 5 | public class VectorExample { 6 | 7 | public static void main(String[] args){ 8 | 9 | Vector v = Vector.of(1,2,3); 10 | 11 | System.out.println("Out of range : " + v.get(-1)); 12 | 13 | Vector v2 = v.append(10); 14 | 15 | System.out.println("First " + v); 16 | System.out.println("Second " + v2); 17 | 18 | 19 | System.out.println(v2.set(5,100)); 20 | 21 | System.out.println(v.delete(-100)); 22 | 23 | 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /cyclops/src/test/java/cyclops/data/talk/arraylist/immutable/replace/ImmutableArrayList.java: -------------------------------------------------------------------------------- 1 | package cyclops.data.talk.arraylist.immutable.replace; 2 | 3 | import java.util.Arrays; 4 | 5 | public class ImmutableArrayList { 6 | 7 | private final E[] elementData; 8 | 9 | private ImmutableArrayList(E[] elementData){ 10 | this.elementData=elementData; 11 | } 12 | 13 | 14 | public ImmutableArrayList set(int index, E e){ 15 | E[] array = Arrays.copyOf(elementData,elementData.length); 16 | array[index]=e; 17 | return new ImmutableArrayList<>(array); 18 | } 19 | } 20 | 21 | -------------------------------------------------------------------------------- /cyclops/src/test/java/cyclops/data/talk/arraylist/immutable/set/ImmutableList.java: -------------------------------------------------------------------------------- 1 | package cyclops.data.talk.arraylist.immutable.set; 2 | 3 | public class ImmutableList { 4 | 5 | private final E[] elementData; 6 | 7 | private ImmutableList(E[] elementData){ 8 | this.elementData=elementData; 9 | } 10 | 11 | public E set(int index,E e) { 12 | throw new UnsupportedOperationException("Set is not supported"); 13 | } 14 | 15 | 16 | } 17 | 18 | 19 | -------------------------------------------------------------------------------- /cyclops/src/test/java/cyclops/data/talk/arraylist/immutable/stub/ImmutableList.java: -------------------------------------------------------------------------------- 1 | package cyclops.data.talk.arraylist.immutable.stub; 2 | 3 | 4 | 5 | public class ImmutableList { 6 | 7 | private final E[] elementData; 8 | 9 | private ImmutableList(E[] elementData){ 10 | this.elementData=elementData; 11 | } 12 | 13 | } 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /cyclops/src/test/java/cyclops/data/talk/arraylist/mutable/get/MutableArrayList.java: -------------------------------------------------------------------------------- 1 | package cyclops.data.talk.arraylist.mutable.get; 2 | 3 | public class MutableArrayList { 4 | 5 | private int size; 6 | private E[] elementData; 7 | 8 | 9 | public E get(int index) { 10 | rangeCheck(index); 11 | return (E) elementData[index]; 12 | } 13 | 14 | 15 | private void rangeCheck(int index) { 16 | if (index < 0 || index >= this.size) 17 | throw new IndexOutOfBoundsException("Index: "+index+", Size: "+this.size); 18 | } 19 | 20 | 21 | } 22 | 23 | 24 | -------------------------------------------------------------------------------- /cyclops/src/test/java/cyclops/data/talk/arraylist/mutable/set/MutableArrayList.java: -------------------------------------------------------------------------------- 1 | package cyclops.data.talk.arraylist.mutable.set; 2 | 3 | public class MutableArrayList { 4 | 5 | private int size; 6 | private E[] elementData; 7 | private int modCount; 8 | 9 | 10 | public E set(int index, E e) { 11 | rangeCheck(index); 12 | checkForComodification(); 13 | E oldValue = elementData[index]; 14 | elementData[index] = e; 15 | return oldValue; 16 | } 17 | 18 | 19 | private void checkForComodification() { 20 | //check for concurrent modification 21 | } 22 | 23 | 24 | private void rangeCheck(int index) { 25 | if (index < 0 || index >= this.size) 26 | throw new IndexOutOfBoundsException("Index: "+index+", Size: "+this.size); 27 | } 28 | 29 | } 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /cyclops/src/test/java/cyclops/data/talk/arraylist/mutable/stub/MutableArrayList.java: -------------------------------------------------------------------------------- 1 | package cyclops.data.talk.arraylist.mutable.stub; 2 | 3 | public class MutableArrayList { 4 | 5 | private int size; 6 | private E[] elementData; 7 | 8 | 9 | } 10 | 11 | 12 | -------------------------------------------------------------------------------- /cyclops/src/test/java/cyclops/data/talk/arraylist/notneeded/PersistentListTwoAppend.java: -------------------------------------------------------------------------------- 1 | package cyclops.data.talk.arraylist.notneeded; 2 | 3 | import java.util.Arrays; 4 | 5 | public class PersistentListTwoAppend { 6 | 7 | public static final int bitShiftDepth =5; 8 | static final int SIZE =32; 9 | private final Object[][] array; //An array of 32 arrays each potentially containing 32 elements 10 | 11 | public PersistentListTwoAppend(Object[][] array) { 12 | this.array = array; 13 | } 14 | 15 | 16 | public PersistentListTwoAppend append(PersistentTail tail) { 17 | if(array.length<32){ 18 | Object[][] updatedNodes = Arrays.copyOf(array, array.length+1,Object[][].class); 19 | updatedNodes[array.length]=tail.getArray(); 20 | return new PersistentListTwoAppend<>(updatedNodes); 21 | } 22 | return null;// create PersistentListThree!!; 23 | 24 | } 25 | 26 | 27 | } 28 | 29 | -------------------------------------------------------------------------------- /cyclops/src/test/java/cyclops/data/talk/arraylist/notneeded/PersistentTail.java: -------------------------------------------------------------------------------- 1 | package cyclops.data.talk.arraylist.notneeded; 2 | 3 | import lombok.Getter; 4 | 5 | import java.util.Arrays; 6 | 7 | public class PersistentTail { 8 | 9 | @Getter 10 | private final E[] array; 11 | 12 | public PersistentTail(E[] array) { 13 | this.array = array; 14 | } 15 | 16 | public E getOrElse(int pos, E alt) { 17 | int indx = pos & 0x01f; 18 | if(indx set(int pos, E value) { 24 | E[] updatedNodes = Arrays.copyOf(array, array.length); 25 | updatedNodes[pos] = value; 26 | return new PersistentTail<>(updatedNodes); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /cyclops/src/test/java/cyclops/data/talk/arraylist/notneeded/PersistentTailAppend.java: -------------------------------------------------------------------------------- 1 | package cyclops.data.talk.arraylist.notneeded; 2 | 3 | public class PersistentTailAppend { 4 | 5 | private final E[] array; 6 | 7 | public PersistentTailAppend(E[] array) { 8 | this.array = array; 9 | } 10 | 11 | public PersistentTailAppend append(E t) { 12 | if(array.length<32){ 13 | return new PersistentTailAppend<>(append(array,t)); 14 | } 15 | return this; 16 | } 17 | public static T[] append(T[] array, T value) { 18 | T[] newArray = (T[])new Object[array.length + 1]; 19 | System.arraycopy(array, 0, newArray, 0, array.length); 20 | newArray[array.length] = value; 21 | return newArray; 22 | } 23 | } 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /cyclops/src/test/java/cyclops/data/talk/arraylist/persistent/one/get/One.java: -------------------------------------------------------------------------------- 1 | package cyclops.data.talk.arraylist.persistent.one.get; 2 | 3 | import cyclops.control.Option; 4 | 5 | public class One { 6 | 7 | private final E[] array; 8 | 9 | public One(E[] array) { 10 | this.array = array; 11 | } 12 | 13 | public Option get(int index) { 14 | if(index>=0 && index=0 && index { 9 | 10 | private final E[] array; //an array of 32 values 11 | 12 | 13 | public One(E[] array) { 14 | this.array = array; 15 | } 16 | 17 | public Option> set(int pos, E t) { 18 | if(pos<0||pos>31) 19 | return Option.none(); 20 | E[] updatedNodes = Arrays.copyOf(array, array.length); 21 | updatedNodes[pos] = t; 22 | return Option.some(new One<>(updatedNodes)); 23 | } 24 | } 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /cyclops/src/test/java/cyclops/data/talk/arraylist/persistent/one/stub/One.java: -------------------------------------------------------------------------------- 1 | package cyclops.data.talk.arraylist.persistent.one.stub; 2 | 3 | public class One { 4 | 5 | private final E[] array; 6 | 7 | public One(E[] array) { 8 | this.array = array; 9 | } 10 | 11 | 12 | } 13 | 14 | -------------------------------------------------------------------------------- /cyclops/src/test/java/cyclops/data/talk/arraylist/persistent/two/stub/Two.java: -------------------------------------------------------------------------------- 1 | package cyclops.data.talk.arraylist.persistent.two.stub; 2 | 3 | public class Two { 4 | 5 | public static final int bitShiftDepth =5; 6 | static final int SIZE =32; 7 | private final Object[][] array; //An array of 32 arrays each potentially containing 32 elements 8 | 9 | public Two(Object[][] array) { 10 | this.array = array; 11 | } 12 | 13 | 14 | private E[] getNestedArrayAtIndex(int index) { 15 | int arrayIndex = (index >>> bitShiftDepth) & (SIZE-1); 16 | if(arrayIndex { 10 | 11 | @AllArgsConstructor 12 | static class Cons implements LazySeq { 13 | 14 | private final Supplier head; 15 | private final Supplier> tail; 16 | 17 | public E head(){ 18 | return head.get(); 19 | } 20 | 21 | } 22 | 23 | static class Nil implements Seq{ 24 | 25 | } 26 | 27 | } 28 | 29 | 30 | -------------------------------------------------------------------------------- /cyclops/src/test/java/cyclops/data/talk/linkedlist/Seq.java: -------------------------------------------------------------------------------- 1 | package cyclops.data.talk.linkedlist; 2 | 3 | import lombok.AllArgsConstructor; 4 | 5 | 6 | public interface Seq { 7 | 8 | @AllArgsConstructor 9 | static class Cons implements Seq { 10 | 11 | public final E head; 12 | private final Seq tail; 13 | 14 | } 15 | 16 | static class Nil implements Seq{ 17 | 18 | } 19 | 20 | } 21 | 22 | -------------------------------------------------------------------------------- /cyclops/src/test/java/cyclops/function/MemoizeTest.java: -------------------------------------------------------------------------------- 1 | package cyclops.function; 2 | 3 | import org.junit.Test; 4 | 5 | import java.util.concurrent.Executors; 6 | import java.util.concurrent.ScheduledExecutorService; 7 | 8 | import static org.hamcrest.MatcherAssert.assertThat; 9 | import static org.hamcrest.Matchers.equalTo; 10 | 11 | 12 | public class MemoizeTest { 13 | int x =0; 14 | @Test 15 | public void asyncUpdate() throws InterruptedException { 16 | Function1 fn = Memoize.memoizeFunctionAsync(Lambda.λ(i -> i + x), Executors.newScheduledThreadPool(1), 1); 17 | assertThat(fn.apply(1),equalTo(1)); 18 | assertThat(fn.apply(1),equalTo(1)); 19 | x=x+1; 20 | Thread.sleep(2); 21 | 22 | assertThat(fn.apply(1),equalTo(2)); 23 | } 24 | 25 | } -------------------------------------------------------------------------------- /cyclops/src/test/java/cyclops/function/MonoidTest.java: -------------------------------------------------------------------------------- 1 | package cyclops.function; 2 | 3 | import cyclops.companion.Monoids; 4 | import org.junit.Test; 5 | 6 | import static org.hamcrest.CoreMatchers.equalTo; 7 | import static org.junit.Assert.*; 8 | 9 | 10 | public class MonoidTest { 11 | @Test 12 | public void visit() throws Exception { 13 | 14 | int res = Monoids.intSum.fold((fn, z)-> { 15 | if(z==0){ 16 | return fn.apply(1,2); 17 | } 18 | else 19 | return fn.apply(10,20); 20 | }); 21 | 22 | assertThat(res,equalTo(3)); 23 | 24 | 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /cyclops/src/test/java/cyclops/streams/PullReactiveSeqTest.java: -------------------------------------------------------------------------------- 1 | package cyclops.streams; 2 | 3 | import cyclops.reactive.ReactiveSeq; 4 | 5 | public class PullReactiveSeqTest extends AbstractReactiveSeqTest { 6 | 7 | @Override 8 | public ReactiveSeq of(Integer... values) { 9 | return ReactiveSeq.of(values); 10 | } 11 | 12 | @Override 13 | public ReactiveSeq empty() { 14 | return ReactiveSeq.empty(); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /cyclops/src/test/java/cyclops/streams/push/ReactiveStreamXCollectableTest.java: -------------------------------------------------------------------------------- 1 | package cyclops.streams.push; 2 | 3 | import com.oath.cyclops.types.foldable.Folds; 4 | import cyclops.reactive.Spouts; 5 | import cyclops.streams.CollectableTest; 6 | 7 | 8 | public class ReactiveStreamXCollectableTest extends CollectableTest { 9 | 10 | @Override 11 | public Folds of(T... values) { 12 | return Spouts.of(values); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /cyclops/src/test/java/cyclops/streams/push/async/AsyncCollectableTest.java: -------------------------------------------------------------------------------- 1 | package cyclops.streams.push.async; 2 | 3 | import com.oath.cyclops.types.foldable.Folds; 4 | import cyclops.reactive.Spouts; 5 | import cyclops.streams.CollectableTest; 6 | 7 | 8 | public class AsyncCollectableTest extends CollectableTest { 9 | 10 | 11 | public Folds of(T... values){ 12 | 13 | return Spouts.async(s->{ 14 | Thread t = new Thread(()-> { 15 | for (T next : values) { 16 | s.onNext(next); 17 | } 18 | s.onComplete(); 19 | }); 20 | t.start(); 21 | }); 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /cyclops/src/test/java/cyclops/streams/push/asyncreactivestreams/AsyncRSCollectableTest.java: -------------------------------------------------------------------------------- 1 | package cyclops.streams.push.asyncreactivestreams; 2 | 3 | 4 | import com.oath.cyclops.types.foldable.Folds; 5 | import cyclops.reactive.Spouts; 6 | import cyclops.streams.CollectableTest; 7 | import reactor.core.publisher.Flux; 8 | import reactor.core.scheduler.Schedulers; 9 | 10 | import java.util.concurrent.ForkJoinPool; 11 | 12 | public class AsyncRSCollectableTest extends CollectableTest { 13 | 14 | 15 | public Folds of(T... values){ 16 | 17 | return Spouts.from(Flux.just(values) 18 | .subscribeOn(Schedulers.fromExecutor(ForkJoinPool.commonPool()))); 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /cyclops/src/test/java/cyclops/streams/push/syncflux/SyncRSCollectableTest.java: -------------------------------------------------------------------------------- 1 | package cyclops.streams.push.syncflux; 2 | 3 | import com.oath.cyclops.types.foldable.Folds; 4 | import cyclops.reactive.Spouts; 5 | import cyclops.streams.CollectableTest; 6 | import reactor.core.publisher.Flux; 7 | 8 | public class SyncRSCollectableTest extends CollectableTest { 9 | 10 | 11 | public Folds of(T... values){ 12 | return Spouts.from(Flux.just(values)); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /cyclops/src/test/java/cyclops/streams/push/syncflux/SyncRSReactiveSeqTest.java: -------------------------------------------------------------------------------- 1 | package cyclops.streams.push.syncflux; 2 | 3 | import cyclops.reactive.ReactiveSeq; 4 | import cyclops.reactive.Spouts; 5 | import cyclops.streams.AbstractReactiveSeqTest; 6 | import reactor.core.publisher.Flux; 7 | import reactor.core.scheduler.Schedulers; 8 | 9 | import java.util.concurrent.ForkJoinPool; 10 | 11 | public class SyncRSReactiveSeqTest extends AbstractReactiveSeqTest { 12 | 13 | @Override 14 | public ReactiveSeq of(Integer... values) { 15 | return Spouts.of(values); 16 | } 17 | 18 | @Override 19 | public ReactiveSeq empty() { 20 | return Spouts.empty(); 21 | } 22 | 23 | 24 | 25 | 26 | 27 | } 28 | -------------------------------------------------------------------------------- /cyclops/src/test/resources/input.file: -------------------------------------------------------------------------------- 1 | hello 2 | world -------------------------------------------------------------------------------- /cyclops/src/test/resources/input2.file: -------------------------------------------------------------------------------- 1 | line 1 2 | line 2 3 | line 3 -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | version = 10.4.1 2 | agronaVersion=1.1.11 3 | reactiveStreamsVersion=1.0.3 4 | reactorVersion=3.3.1.RELEASE 5 | rxJava2Version=2.2.16 6 | kindedJVersion=1.1.0 7 | hamcrestVersion=1.3 8 | lombokVersion=1.18.4 9 | jacksonVersion=2.13.2 10 | 11 | 12 | POM_NAME=cyclops 13 | POM_PACKAGING=jar 14 | POM_DESCRIPTION=Platform for Functional Reactive Programming with Java 8 15 | POM_URL=https://github.com/aol/cyclops 16 | -------------------------------------------------------------------------------- /gradle/jacoco-aggregator.gradle: -------------------------------------------------------------------------------- 1 | task jacocoRootReport(type: JacocoReport, description: 'Aggregated jacoco report') { 2 | dependsOn = subprojects.test 3 | sourceDirectories = files(subprojects.sourceSets.main.allSource.srcDirs) 4 | classDirectories = files(subprojects.sourceSets.main.output) 5 | executionData = files(subprojects.jacocoTestReport.executionData) 6 | reports { 7 | html.enabled = true 8 | xml.enabled = true 9 | csv.enabled = false 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /gradle/jacoco-config.gradle: -------------------------------------------------------------------------------- 1 | jacocoTestReport { 2 | reports { 3 | html.enabled = true 4 | xml.enabled = true 5 | csv.enabled = false 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /gradle/jacoco-excludes.gradle: -------------------------------------------------------------------------------- 1 | test { 2 | jacoco { 3 | excludes = ["test.*", "*.*Test", "*.acceptance.*", "*.integration.*", "*.*Main"] 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /gradle/jacoco-version.gradle: -------------------------------------------------------------------------------- 1 | jacoco { 2 | toolVersion = '0.7.1.201405082137' 3 | } 4 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aol/cyclops/11cedae18b8623de6d710289e5c088d7b7b16361/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Wed May 11 16:46:50 IST 2022 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip 7 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'com.oath.cyclops' 2 | include ':cyclops' 3 | include ':cyclops-anym' 4 | include 'cyclops-futurestream' 5 | include 'cyclops-pure' 6 | include 'cyclops-reactive-collections' 7 | include 'cyclops-reactor-integration' 8 | include 'cyclops-rxjava2-integration' 9 | include 'cyclops-jackson-integration' 10 | 11 | --------------------------------------------------------------------------------