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

CommutativeMonad for Eval #2103

Merged
merged 1 commit into from
Dec 14, 2017
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions core/src/main/scala/cats/Eval.scala
Original file line number Diff line number Diff line change
Expand Up @@ -375,8 +375,8 @@ object Eval extends EvalInstances {

private[cats] sealed abstract class EvalInstances extends EvalInstances0 {

implicit val catsBimonadForEval: Bimonad[Eval] =
new Bimonad[Eval] with StackSafeMonad[Eval] {
implicit val catsBimonadForEval: Bimonad[Eval] with CommutativeMonad[Eval] =
new Bimonad[Eval] with StackSafeMonad[Eval] with CommutativeMonad[Eval] {
override def map[A, B](fa: Eval[A])(f: A => B): Eval[B] = fa.map(f)
def pure[A](a: A): Eval[A] = Now(a)
def flatMap[A, B](fa: Eval[A])(f: A => Eval[B]): Eval[B] = fa.flatMap(f)
Expand Down
5 changes: 4 additions & 1 deletion tests/src/test/scala/cats/tests/EvalSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package cats
package tests

import cats.laws.ComonadLaws
import cats.laws.discipline.{BimonadTests, SemigroupalTests, ReducibleTests, SerializableTests}
import cats.laws.discipline.{BimonadTests, CommutativeMonadTests, SemigroupalTests, ReducibleTests, SerializableTests}
import cats.laws.discipline.arbitrary._
import cats.kernel.laws.discipline.{EqTests, GroupTests, MonoidTests, OrderTests, PartialOrderTests, SemigroupTests}
import org.scalacheck.{Arbitrary, Cogen, Gen}
Expand Down Expand Up @@ -93,6 +93,9 @@ class EvalSuite extends CatsSuite {
checkAll("Eval[Int]", BimonadTests[Eval].bimonad[Int, Int, Int])
}

checkAll("Eval[Int]", CommutativeMonadTests[Eval].commutativeMonad[Int, Int, Int])
checkAll("CommutativeMonad[Eval]", SerializableTests.serializable(CommutativeMonad[Eval]))

checkAll("Bimonad[Eval]", SerializableTests.serializable(Bimonad[Eval]))

checkAll("Eval[Int]", ReducibleTests[Eval].reducible[Option, Int, Int])
Expand Down