Skip to content

Commit

Permalink
Merge pull request #606 from ceedubs/validated-orElse
Browse files Browse the repository at this point in the history
Remove EE >: E constraint from Validated.orElse
  • Loading branch information
non committed Nov 8, 2015
2 parents d4125a5 + 73ed7f7 commit 65db253
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions core/src/main/scala/cats/data/Validated.scala
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,11 @@ sealed abstract class Validated[+E, +A] extends Product with Serializable {
/**
* Return this if it is Valid, or else fall back to the given default.
*/
def orElse[EE >: E, AA >: A](default: => Validated[EE,AA]): Validated[EE,AA] =
fold(_ => default, _ => this)
def orElse[EE, AA >: A](default: => Validated[EE,AA]): Validated[EE,AA] =
this match {
case v @ Valid(_) => v
case Invalid(_) => default
}

/**
* Converts the value to an Either[E,A]
Expand Down

0 comments on commit 65db253

Please sign in to comment.