scalaz/scalaz — pull request #796 by ceedubs (2014-08-22 12:56:34+00:00)
Title: Foldable short circuiting

`Foldable.any` and `Foldable.all` can stop iterating through elements if they find an element that matches the right condition.

I've made them short-circuit evaluation for List, Iterable, and IList. It's possible there are other instances that could also have similar logic.

Is there a more general way to do this? In Haskell I think defining `any` and `all` in terms of `foldr` would be enough. But in the Scala world, it doesn't seem like we can do the same with `foldRight` (except for perhaps on lazy structures like `Stream`).

Let me know if there is a preferred alternative to what I've done with the `FoldableTests` object. These seemed more like useful traits than laws, so it didn't seem like mixing them in with the law declarations was the right thing to do.