4 ms·
> using a List instead of a NonEmptyList when at least one element is expected. I'm not sure why this is a problem. An empty list is a perfectly valid list. It
by AzzieElbab 5y ago
> using a List instead of a NonEmptyList when at least one element is expected.
I'm not sure why this is a problem. An empty list is a perfectly valid list. It strikes me that what you really wanted to pass was an object, not a list.
-------
Not in every domain. For example - common pattern in FP is to return an Either[NonEmptyList[Error], SomeResult] when parsing. You can clearly see why the list of errors should never be empty
- blacktriangle 5y agoI don't know about Scala, but List vs NonEmptyList is a huge problem in Haskell since head [] -> throws an error. There was an article on HN a week or so ago about how to deal with this in a type system where it ultimately felt like they were reinventing nil punning.