-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
There are Alternative and CommutativeApplicative instances for both ZipLazyList and ZipStream:
Details
| implicit val catsDataAlternativeForZipLazyList: Alternative[ZipLazyList] & CommutativeApplicative[ZipLazyList] = |
| implicit val catsDataAlternativeForZipStream: Alternative[ZipStream] with CommutativeApplicative[ZipStream] = |
| implicit val catsDataAlternativeForZipStream: Alternative[ZipStream] & CommutativeApplicative[ZipStream] = |
However, the corresponding laws have never been verified. The existing tests for both ZipLazyList and ZipStream check laws only up to CommutativeApply, with the following comment:
Can't test applicative laws as they don't terminate
Details
cats/tests/shared/src/test/scala-2.13+/cats/tests/LazyListSuite.scala
Lines 71 to 72 in a69b592
| // Can't test applicative laws as they don't terminate | |
| checkAll("ZipLazyList[Int]", CommutativeApplyTests[ZipLazyList].apply[Int, Int, Int]) |
cats/tests/shared/src/test/scala/cats/tests/StreamSuite.scala
Lines 57 to 58 in a69b592
| // Can't test applicative laws as they don't terminate | |
| checkAll("ZipStream[Int]", CommutativeApplyTests[ZipStream].apply[Int, Int, Int]) |
Moreover, ZipList, ZipVector, ZipSeq, as well as their *NonEmpty* counterparts, define instances only up to CommutativeApply.
Taken together, this strongly suggests that ZipLazyList and ZipStream cannot lawfully provide anything stronger than CommutativeApply.
Perhaps the Alternative and CommutativeApplicative instances for ZipLazyList and ZipStream should be moved to alleycats-core, while cats-core should retain only CommutativeApply.