https://github.com/timic/vavr-groovy
Groovy extensions for vavr - http://vavr.io
https://github.com/timic/vavr-groovy
groovy vavr
Last synced: 7 months ago
JSON representation
Groovy extensions for vavr - http://vavr.io
- Host: GitHub
- URL: https://github.com/timic/vavr-groovy
- Owner: timic
- License: apache-2.0
- Created: 2018-02-02T16:20:23.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2021-11-03T12:01:50.000Z (over 4 years ago)
- Last Synced: 2025-08-13T22:02:03.900Z (7 months ago)
- Topics: groovy, vavr
- Language: Java
- Homepage:
- Size: 191 KB
- Stars: 0
- Watchers: 0
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://search.maven.org/search?q=g:%22com.github.timic%22%20AND%20a:%22vavr-groovy%22)
[](https://travis-ci.org/timic/vavr-groovy)
[](https://codecov.io/gh/timic/vavr-groovy)
This library provides groovy extension modules which allows to use [vavr](http://vavr.io) functional data structures
with groovy closures without a pain.
For example,
```groovy
def option = Option.when(true) {
"True"
}
// when no extension provided closure argument will not coerce to supplier
// because of Option has method signature Option#when(T object)
assert option.get() instanceof Closure
// as a workaround you can cast closure to supplier directly
Option.when(true, { "True" } as Supplier)
// or when extension provided this example just works as how it should
assert option.get() == "True"
```
### More examples
```groovy
// tuple multiple assignment
def (a, b, c) = new Tuple3(1, "A", true)
// infinite streams
assert Stream.iterate(1) {
++ it
}.take(3) == Stream.of(1, 2, 3)
// pattern matching
import static com.github.timic.vavr.groovy.API.*
assert Match(3).of(
Case(1) {
"One"
},
Case(3) {
"Three"
}) == "Three"
```
You can find more example in tests files.
### Download
Download via gradle:
```groovy
repositories {
jcenter()
}
dependencies {
compile "com.github.timic:vavr-groovy:0.3.0"
}
```