Nullable types give us the ability to have zero or one appearance of a value,
collections allow us to have any number of them. However, in some scenarios, we need to work with collections that should contain at least one element. Arrow provides both
One concrete example is given by error accumulation.
A type like
Either<List<Problem>, Result> may take us to the weird case in
which we end with
Left, but we have no
Problems in the
List. To avoid
this issue, Arrow makes
Either<NonEmptyList<Problem>, Result> instead.
The API of non-empty collections follows the conventions from
On top of that, some types become stronger to ensure or keep track of the
non-empty nature of the collection.