Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove EE >: E constraint from Validated.orElse #606

Merged
merged 1 commit into from
Nov 8, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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