-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Either/Validated Parallel instance
- Loading branch information
Luka Jacobowitz
committed
Aug 21, 2017
1 parent
714b84d
commit ef6c75c
Showing
2 changed files
with
20 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package cats.instances | ||
|
||
import cats.data.Validated | ||
import cats.kernel.Semigroup | ||
import cats.syntax.either._ | ||
import cats.{Applicative, Monad, Parallel, ~>} | ||
|
||
|
||
trait ParallelInstances { | ||
implicit def parEitherValidated[E: Semigroup] = new Parallel[Either[E, ?], Validated[E, ?]] { | ||
def applicative: Applicative[Validated[E, ?]] = Validated.catsDataApplicativeErrorForValidated | ||
|
||
def sequential(implicit M: Monad[Either[E, ?]]): Validated[E, ?] ~> Either[E, ?] = | ||
λ[Validated[E, ?] ~> Either[E, ?]](_.toEither) | ||
|
||
def parallel(implicit M: Monad[Either[E, ?]]): Either[E, ?] ~> Validated[E, ?] = | ||
λ[Either[E, ?] ~> Validated[E, ?]](_.toValidated) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters