Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@adamgfraser
Copy link
Contributor

We know that if validateM failed there was at least one failure, so we can return a nonempty list to express this in the type signature.

@fanf
Copy link
Contributor

fanf commented Dec 18, 2019

That makes me happy :)

@saraiva132
Copy link
Contributor

saraiva132 commented Dec 18, 2019

I considered using NonEmptyList initially but along the way opted not to for an arbitrary reason. Someone mentioned :: might be a bit obscure for some people, would a type alias Nel help? Or do you think it is just fine as is?

Happy as well :)

@adamgfraser
Copy link
Contributor Author

@saraiva132 At least right now it is the standard representation in ZIO for a nonempty list. It has the advantage that it is actually a subtype of scala.collection.immutable.List, so anything you could do with a List you could do with it, plus being able to pattern match on it and know that it is nonempty which is quite natural with the :: operator that people are familiar with.

There has been some discussion of having more of a full fledged nonempty list representation but I think the concern has been that it moves us away from the standard library a bit in a way that is not really core to what we are trying to do, plus if you are going to do it right there are a lot of collection operations you would have to reimplement so I don't think it really makes sense.

@saraiva132
Copy link
Contributor

Good to get that clarified! Extremely good catch and agreed.

@adamgfraser adamgfraser merged commit 70e6ce1 into zio:master Dec 18, 2019
@adamgfraser adamgfraser deleted the validateM branch December 18, 2019 23:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants