Created
June 20, 2018 19:25
-
-
Save scalolli/7728581fb1ecba56e44897e49320a766 to your computer and use it in GitHub Desktop.
ScalaCheckOr
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
sealed trait Or[A, B] | |
object Or { | |
case class FstA, B extends Or[A, B] | |
case class SndA, B extends Or[A, B] | |
} | |
implicit def eqOr[A: Eq, B: Eq]: Eq[Or[A, B]] = Eq.fromUniversalEquals | |
implicit def arbitraryOrA, B: Arbitrary[Gen[Or[A, B]]] = Arbitrary( | |
Gen.oneOf(Seq(Arbitrary.arbitrary[A].map(Fst()), Arbitrary.arbitrary[B].map(Snd()))) | |
) | |
checkAll("SemiGroup laws for Or", SemigroupTests[Or[Int, String]].semigroup) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment