Created
August 26, 2016 15:19
-
-
Save oleg-py/4418c15c656dd901aca81d76d30d252a to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import cats.SemigroupK | |
import cats._ | |
import cats.syntax.all._ | |
import cats.instances.option._ | |
import org.scalacheck.Arbitrary._ | |
import cats.laws.discipline.SemigroupKTests | |
implicit val semigroupByLongest = new SemigroupK[List] { | |
override def combineK[A](x: List[A], y: List[A]): List[A] = | |
x.map(_.some).zipAll(y.map(_.some), none[A], none[A]) | |
.map { case (a, b) => a <+> b } | |
.map { _.get } | |
} | |
List(1, 2, 3) <+> List(4, 5, 6, 7) | |
implicit val eq = Eq.fromUniversalEquals[List[Int]] | |
val rs = SemigroupKTests[List].semigroupK[Int] | |
rs.all.check |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment