{"id":26115596,"url":"https://github.com/aol/cyclops-integration","last_synced_at":"2025-04-07T11:01:18.450Z","repository":{"id":32920458,"uuid":"36515909","full_name":"aol/cyclops-integration","owner":"aol","description":"Home of the cyclops integration modules : support for Scala, Clojure, RxJava (1+2), Reactor, FunctionalJava, Guava, Dexx \u0026 Vavr","archived":false,"fork":false,"pushed_at":"2023-03-21T11:09:48.000Z","size":5968,"stargazers_count":441,"open_issues_count":28,"forks_count":51,"subscribers_count":55,"default_branch":"master","last_synced_at":"2025-03-31T10:01:32.673Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://cyclops-react.io","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aol.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-05-29T16:27:55.000Z","updated_at":"2025-02-28T06:55:22.000Z","dependencies_parsed_at":"2025-03-31T10:45:29.129Z","dependency_job_id":null,"html_url":"https://github.com/aol/cyclops-integration","commit_stats":null,"previous_names":[],"tags_count":34,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aol%2Fcyclops-integration","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aol%2Fcyclops-integration/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aol%2Fcyclops-integration/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aol%2Fcyclops-integration/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aol","download_url":"https://codeload.github.com/aol/cyclops-integration/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247640459,"owners_count":20971556,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-03-10T07:55:55.939Z","updated_at":"2025-04-07T11:01:18.348Z","avatar_url":"https://github.com/aol.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Integration modules home\n\n* [cyclops core](https://github.com/aol/cyclops)\n\n\u003cimg width=\"820\" alt=\"screen shot 2016-02-22 at 8 44 42 pm\" src=\"https://cloud.githubusercontent.com/assets/9964792/13232030/306b0d50-d9a5-11e5-9706-d44d7731790d.png\"\u003e\n\n# Documentation\n\n* [cyclops user guide](https://github.com/aol/cyclops-react/wiki)\n\n## Latest Articles\n\n* [DSLs with the Free Monad in Java 8 : Part I](https://medium.com/@johnmcclean/dsls-with-the-free-monad-in-java-8-part-i-701408e874f8)\n* [Cross Library Stream Benchmarking : Playing Scrabble with Shakespeare](https://medium.com/@johnmcclean/cross-library-stream-benchmarking-playing-scrabble-with-shakespeare-8dd1d1654717)\n\n# A common API across the functional landscape\n\ncyclops provides a common set of APIs across the major functional libraries for Java. It does this via :\n\n1. A common abstraction layer (AnyM short for AnyMonad)\n2. Companion classes (Optionals, Streams, CompletableFutures, Options, Eithers, Lists, Trys etc) that provide common functionality such as For Comprehensions and Higher Kinded Haskell like type classes\n3. Provided conversion classes between types via FromXXX and ToXXX classes\n4. Allows collection types from all major functional libraries to be substituted behind cyclops-react lazy \u0026 reactive collection APIs\n\n## AnyM : a type safe abstraction across Any Monadic type in Java.\n\nDefine ultra-generic code that can be used by types across Vavr, Reactor, cyclops-react, Guava, JDK, Functional Java, RxJava. \n\n```java\npublic \u003cW extends WitnessType\u003cW\u003e\u003e AnyMSeq\u003cW,Integer\u003e sumAdjacent(AnyMSeq\u003cW,Integer\u003e sequence){\n     return sequence.sliding(1)\n                    .map(t-\u003et.sum(i-\u003ei).get())\n}\n```\n\nUse them with Vavr \n\n```java\nimport static cyclops.monads.VavrWitness.list;\nimport cyclops.companion.vavr.Lists;\n\n\nAnyMSeq\u003clist,Integer\u003e vavrList = Lists.anyM(List.range(0, 10));\nAnyMSeq\u003clist,Integer\u003e summedVavr = sumAdjacent(vavrList);\nList\u003cInteger\u003e backToVavr = VavrWitness.list(summedVavr);\n\n\n```\n\nOr RxJava\n\n```java\nimport static cyclops.monads.Rx2Witness.observable;\nimport cyclops.companion.rx.Observables;\n\nAnyMSeq\u003cobservable,Integer\u003e rxObservable = Observables.anyM(Observable.range(0, 10));\nAnyMSeq\u003cobservable,Integer\u003e summedRx = sumAdjacent(rxObservable);\nObservable\u003cInteger\u003e backToRx = RxWitness.observable(summedRx);\n\n\n```\n\n## Common functionality in Companion classes\n\nFor comprehensions\n\n```java\nimport static cyclops.companion.vavr.Trys.*;\n\n        \nTry\u003cString\u003e result = Trys.forEach4(grind(\"arabica beans\"),\n                                   ground -\u003e heatWater(new Water(25)),\n                                   (ground, water) -\u003e brew(ground, water),\n                                   (ground, water ,espresso) -\u003e frothMilk(\"milk\"),\n                                   (ground , water ,espresso , foam) -\u003e combine(espresso, foam));\n\nSystem.out.println(result.get());\n\n\nTry\u003cString\u003e grind(String beans) {\n    return Try.of(() -\u003e \"ground coffee of \" + beans);\n}\n\nTry\u003cWater\u003e heatWater(Water water) {\n    return Try.of(() -\u003e water.withTemperature(85));\n}\n\nTry\u003cString\u003e frothMilk(String milk) {\n    return Try.of(() -\u003e \"frothed \" + milk);\n}\n\nTry\u003cString\u003e brew(String coffee, Water heatedWater) {\n    return Try.of(() -\u003e \"espresso\");\n}\n\nString combine(String espresso, String frothedMilk) {\n        return \"cappuccino\";\n}\n```\n\n```java\nimport static cyclops.companion.reactor.Fluxs.*;\n\nFlux\u003cInteger\u003e result = Fluxs.forEach(Flux.just(10, 20), a -\u003e Flux.\u003cInteger\u003e just(a + 10), (a, b) -\u003e a + b);\nresult.collectList()\n       .block(),\n//List[30, 50];\n```\n## Lazy and Reactive Collection APIs\n\ncyclops \u0026 cyclops-react allow collection types from all major functional libraries to be used behind fast lazy \u0026 reactive collection apis.\n\n### What do we mean by fast lazy \u0026 reactive APIs\n\nMost Collection APIs provided by the major functional libraries are eager. That means when a map transformation is invoked on a Functional Java or Vavr List it is executed immediately. Performing multiple chained operations often results in the the collection being processed (traversed) multiple different times. With cyclops map and other functional operations become lazy, and the your chain of commands are only executed when data within the collection is exected for the first time. This allows cyclops to process the entire chain of operations in a single traversal of the data. The resultant transformed collection is then stored in the underlying structure of your favourite functional collection API.\n\n#### The Performance benefit\n\nLeveraging cyclops can significantly improve the execution times of operations on collections.\n\nThe code for this performance testing speeding up the execution of functional operations on Javaslang Vectors is available [here](https://gist.githubusercontent.com/johnmcclean-aol/f6d9216ae179fa619d4a6ae67eea3802/raw/740fc413c13784529f30b375b219b0a6c9004865/cyclops-javaslang-benchmark.java)\n![cyclops-speed-up](https://cdn-images-1.medium.com/max/1600/1*ocbwTrrsjPmEp22SliKvFQ.png)\n\n##### Reactive APIs\n\ncyclops also allows data to be pushed asynchronously into collection types from the major functional libraries. For example to asynchronously populate a JavaSlang / Vavr Vector we can write\n\n```java\nVectorX\u003cInteger\u003e asyncPopulated = JavaSlangPersistentList.fromStream(Spouts.publishOn(ReactiveSeq.of(1,2,3),\n                Executors.newFixedThreadPool(1));\n```\n\n## Type safe, higher kinded typeclassess\n\nE.g. Using a functor and applicative type classes on FunctionalJava Lists (Higher Kinded encoding via ListKind type)\n\n```java\n\nimport static com.oath.cyclops.functionaljava.ListKind;\nimport static cyclops.companion.functionaljava.Lists.Instances.functor;\nimport static cyclops.companion.functionaljava.Lists.Instances.zippingApplicative;\n\nListKind\u003cFunction1\u003cInteger,Integer\u003e\u003e listFn = ListKind.widen(List.list((Lambda.λ((Integer i) -\u003ei*2))\n                                                .convert(ListKind::narrowK);\n        \nList\u003cInteger\u003e list =  zippingApplicative().ap(listFn,functor().map((String v)-\u003ev.length(),\n                                                     widen(List.list(\"hello\"))))\n                                          .convert(ListKind::narrow);\n        \n//List.list(\"hello\".length()*2))\n```\n\nThere are a number of integration modules for cyclops-react, they are\n\n* [cyclops-reactor](https://github.com/aol/cyclops/tree/master/cyclops-reactor)\n* [cyclops-rxjava2](https://github.com/aol/cyclops/tree/master/cyclops-rxjava2)\n* [cyclops-rx](https://github.com/aol/cyclops/tree/master/cyclops-rx)\n* [cyclops-guava](https://github.com/aol/cyclops/tree/master/cyclops-guava)\n* [cyclops-functionaljava](https://github.com/aol/cyclops/tree/master/cyclops-functionaljava)\n* [cyclops-vavr](https://github.com/aol/cyclops/tree/master/cyclops-vavr)\n\nThis screencast gives an overview of how cyclops can help integrate and provide abstractions across the datatypes in the above libraries. [Unifying the cambrian explosion with cyclops-react ] (https://www.youtube.com/watch?v=YgzvpMbxiRo)\n\n\n## Getting cyclops-react\n\n* [![Maven Central : cyclops-react](https://maven-badges.herokuapp.com/maven-central/com.aol.simplereact/cyclops-react/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.aol.simple-react/cyclops-react)\n\n## Gradle\n\nwhere x.y.z represents the latest version\n\ncompile 'com.oath.simplereact:cyclops-react:x.y.z'\n\n## Maven\n\n```xml\n\u003cdependency\u003e\n    \u003cgroupId\u003ecom.oath.simplereact\u003c/groupId\u003e\n    \u003cartifactId\u003ecyclops-react\u003c/artifactId\u003e\n    \u003cversion\u003ex.y.z\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faol%2Fcyclops-integration","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faol%2Fcyclops-integration","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faol%2Fcyclops-integration/lists"}