List(1).withFilter(_ > 0)
val res63: scala.collection.WithFilter[Int,[_]List[_]] = scala.collection.IterableOps$WithFilter@cf76c0b
def something(list: List[_])
, then the [_]
is a wildcard, meaning you can pass a list value whose elements are any type.
[_]
there means "i don't care what the type is, so i'm going to forget its name", just like _
in places like pattern matching means "i don't care what this is, i'm not even going to name it")
if you use cats you can follow the examples at https://typelevel.org/cats/typeclasses/parallel.html#parallel
basically you write your validation functions to produce Either
. but you "glue together" those functions to act using Validated
, which then gets converted back to Either
at the end
mapN
from cats. it's like a mode: you switch from fail-fast (flatMap via Either) to collect-errors (mapN via Validated), and back.
val res63: scala.collection.WithFilter[Int, List] = ...
to be correct
mapN
also does it.
[A]Foo[Int, String, A]
- on this post about partial unification, so I guess it does have a specific meaning that I'm not familiar with