vʌvr (formerly called Javaslang) is a non-commercial, non-profit object-functional library that runs with Java 8+. It aims to reduce the lines of code and increase code quality.
I want to use vavr in my project with original java collections, and I feels the Seq seems to be a proper replacement of java.util.List since there are the common interface of linear ADT.
But I got some error in compile time when use Seq.
For example:
class MyType { String id; int score; }
Seq<MyType> L = Vector.empty();
var m = L.groupBy(e -> e.id);
m.getOrElse("some_id", Vector.empty());
The last line would got a compile error that
Required type:
capture of ? extends Seq<MyType>
Provided:
Vector<java.lang.Object>
It looks like the type ? extends Seq<MyType> is NOT compatible for Vector<MyType> or Seq<MyType>.
Question1: Is there a good method to resolve the type issue? Or we need to accept the fact?
Question2: I also found that many of the Seq methods delcared with ? extends Seq<T>. If the ? extends Seq<T> is not good to use in Java, why not declare them just as Seq<T>?
I want to use vavr in my project with original java collections, and I feels the Seq seems to be a proper replacement of java.util.List since there are the common interface of linear ADT.
But I got some error in compile time when use Seq. For example:
The last line would got a compile error that
Event I try
The similar error still exists.
It looks like the type
? extends Seq<MyType>
is NOT compatible forVector<MyType>
orSeq<MyType>
.Question1: Is there a good method to resolve the type issue? Or we need to accept the fact? Question2: I also found that many of the Seq methods delcared with
? extends Seq<T>
. If the? extends Seq<T>
is not good to use in Java, why not declare them just asSeq<T>
?