by riffraff · 5y ago · 0 comments
def process[L[_]](input: L[Int]): Unit = ???
Where `L[_]` could be any type that has a type parameter, e.g. `List[_]`, `Option[_]`, `Future[_]` or `Either[String, *]`. This opens the door to a new level of abstraction where other languages must resort to code generation or similar ad hoc-like solutions. <L> void process(final L<Integer> input) {
}
------------------------------------------
<L> void process(final L<Integer> input) {
^
required: class
found: type parameter L
where L is a type-variable:
L extends Object declared in method <L>process(<any>)public <T extends Collection<Integer>> T process(T collectionOfInteger) { return collectionOfInteger; }
I dream about "implicit" interfaces in Java like in Go. So everything that has "flatMap" would implicitly implement "FlatMappable" or something like that.