From 71fcdc07f0867476c2e8738418ba0e7d0d229a86 Mon Sep 17 00:00:00 2001 From: Cody Allen Date: Sat, 7 Nov 2015 10:19:57 -0500 Subject: [PATCH] Remove Validated.filter I think this was leftover from copy/paste from `Xor`. It mentions that it's useful when using `Validated` in for-comprehensions, but you can't actually use `Validated` in for-comprehensions since it doesn't have a `flatMap` method :). Also, `Xor` no longer has a `filter` method. It was removed in #276 since using the monoid zero when the predicate doesn't match is rather arbitrary and can lead to surprises. I think we should follow that precedent for `Validated`. --- core/src/main/scala/cats/data/Validated.scala | 9 --------- 1 file changed, 9 deletions(-) diff --git a/core/src/main/scala/cats/data/Validated.scala b/core/src/main/scala/cats/data/Validated.scala index a7d998f35f..90b75b613c 100644 --- a/core/src/main/scala/cats/data/Validated.scala +++ b/core/src/main/scala/cats/data/Validated.scala @@ -38,15 +38,6 @@ sealed abstract class Validated[+E, +A] extends Product with Serializable { */ def forall(f: A => Boolean): Boolean = fold(_ => true, f) - /** - * If the value is Valid but the predicate fails, return an empty - * Invalid value, otherwise leaves the value unchanged. This method - * is mostly useful for allowing validated values to be used in a - * for comprehension with pattern matching. - */ - def filter[EE >: E](pred: A => Boolean)(implicit M: Monoid[EE]): Validated[EE,A] = - fold(Invalid.apply, a => if(pred(a)) this else Invalid(M.empty)) - /** * Return this if it is Valid, or else fall back to the given default. */