Questions tagged [vavr]

Questions about the Vavr functional programming library (formerly known as Javaslang).

Vavr (formerly known as Javaslang) is an open-source, functional component library for Java 8+.

Vavr provides immutable collections and the necessary functions and control structures to operate on these values. Most Vavr data structures are purely functional, i.e. they are both immutable and persistent. Operations that appear to modify a purely functional data structure do not alter the underlying data, but instead create a new version (and, in Vavr, a new Java object); references to the old version remain valid.

(For efficiency, persistent data structures are generally implemented so as to share as much state between versions as possible.)

See Also:

154 questions
0
votes
1 answer

java vavr future multiple rest call

I want to run multiple rest calls with different output asynchronously. I am writing the code as Future> products = Future.of(() -> validateProducts([INPUT]) ); …
raaeusagvc
  • 71
  • 6
0
votes
2 answers

java vavr map return from function if statement

I have the code private static Validation> validatePersonDetail( List personRequest) { for (PersonRequest request:personRequest) { if…
raaeusagvc
  • 71
  • 6
0
votes
2 answers

Is there an util function to translate a Supplier which throws Exception into Optional in Java8?

I'm using vavr, and find there is no such util in Option, is there a similar handy util in any other package in java8? public final class Utils { public static Option optionOfThrowableSupplier(Supplier supplier){ try { …
luochen1990
  • 3,689
  • 1
  • 22
  • 37
0
votes
0 answers

Vavr try fold want an exception in the first argument

I use GraphQL with Vavr. In the first function argument, the Try.fold is waiting to raise an exception but in my case, I want to return a DataFetcherResult. When compiling, I get the following error Object / Required type:…
CedricM
  • 11
  • 3
0
votes
1 answer

How to widen a vavr sequence?

I notice the narrow method exists for sequences. How would one go about doing the opposite, going from sequence of a subclass to a sequence of a superclass in a type-safe manner?
Noel Yap
  • 18,822
  • 21
  • 92
  • 144
0
votes
3 answers

Java 8 Vavr onFailure concatenation

Im trying to parse a string that contain a date in an unknown format and the way I choose (not the best) is to try all the possible formats until parse correctlly. To do this Im using Vavr library and till now I've created something like this: // My…
Ares91
  • 506
  • 2
  • 8
  • 27
0
votes
1 answer

What vavr collection to use to wrap a java.util.ArrayList

I have a java.util.ArrayList returned by a library. As soon as I receive the object I would like to convert it to a vavr collection. What should I use to minimize the computations for this? I don't have a clear scenario of usage after that. The…
raisercostin
  • 8,777
  • 5
  • 67
  • 76
0
votes
1 answer

logic using functional-style exception handling with java and Vavr

I'm trying to get into basics of functional programming with Java 8 and I have a simple task which is to set a property on the object and then persist it. The database proper type is ltree so it might fail if it contains not allowed characters. I…
greengold
  • 1,184
  • 3
  • 18
  • 43
0
votes
2 answers

Why can't all Functors be Monads?

To my knowledge, Functors are those which have map() and Monads are those which also have flatMap(). All Monads are Functors but not vice-versa. What prevents Functors to implement a flatMap() and be a Monad? Are there any Functors which stayed that…
Gopal S Akshintala
  • 1,933
  • 1
  • 17
  • 24
0
votes
1 answer

ClassCastException while returning generic type

I'm writing Spring application and I want to divide it into several layers to separate domain from framework totally. So, my domain methods are returning vavr's Either and my controllers are using simple resolver for all of those methods.…
Weeedooo
  • 501
  • 8
  • 25
0
votes
0 answers

Hashmap not empty tuple vavr

I'm reading a file, and extract from if some fields that I suppose to store in a tuple. (vavr tuples) The hashmap does not store any elements. I think I have a problem with initialization that I don't seem to figure out Hashmap is of Java.util and…
Her sincerly
  • 373
  • 1
  • 13
0
votes
1 answer

vavr Validation stream of validators

I have a code like this: return validators .stream() .flatMap(v -> v.validate(scoreRequest).stream()) .collect(toList()); Each validator returns a List of errors, if the list is empty it means that the…
Fabry
  • 1,498
  • 4
  • 23
  • 47
0
votes
1 answer

Using Vavr List.distinctBy

I want to use List.distinctBy to filter lists provided by (Javaslang) I added this dependency in my pom.xml io.vavr vavr-kotlin 0.10.0 but when I use it in the…
Nuñito Calzada
  • 4,394
  • 47
  • 174
  • 301
0
votes
1 answer

Null check with vavr

For my API I'm parsing an object and creating my object with the lombok builder. One of the variables is an "arrivalTime" of type LocalDateTime that, of course, could be null. I used to have it like this: visits.add(visit.builder() …
coconut
  • 1,074
  • 4
  • 12
  • 30
0
votes
2 answers

Has vavr io.vavr.API been removed in 1.0.0-alpha-2?

I have been investigating the use of the excellent functional library vavr // https://mvnrepository.com/artifact/io.vavr/vavr compile group: 'io.vavr', name: 'vavr', version: '0.9.2' // https://mvnrepository.com/artifact/io.vavr/vavr-match compile…
Hector
  • 4,016
  • 21
  • 112
  • 211