-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Derive Commutative{Semigroup, Monoid} (#341)
- Loading branch information
1 parent
cd6baa2
commit 803b582
Showing
7 changed files
with
60 additions
and
10 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 |
---|---|---|
@@ -1,13 +1,15 @@ | ||
package cats.derived | ||
|
||
object all extends | ||
CommutativeMonoidDerivation, | ||
CommutativeSemigroupDerivation, | ||
EmptyDerivation, | ||
SemigroupDerivation, | ||
MonoidDerivation, | ||
EqDerivation, | ||
PartialOrderDerivation, | ||
OrderDerivation, | ||
HashDerivation, | ||
FunctorDerivation, | ||
FoldableDerivation, | ||
FunctorDerivation, | ||
HashDerivation, | ||
MonoidDerivation, | ||
OrderDerivation, | ||
PartialOrderDerivation, | ||
SemigroupDerivation, | ||
TraverseDerivation |
14 changes: 14 additions & 0 deletions
14
core/src/main/scala-3.0.0-RC3/cats/derived/commutativeMonoid.scala
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,14 @@ | ||
package cats.derived | ||
|
||
import cats.kernel.CommutativeMonoid | ||
import shapeless3.deriving.K0 | ||
|
||
object commutativeMonoid extends CommutativeMonoidDerivation | ||
|
||
trait ProductCommutativeMonoid[T[x] <: CommutativeMonoid[x], A](using inst: K0.ProductInstances[T, A]) | ||
extends ProductCommutativeSemigroup[T, A], ProductMonoid[T, A], CommutativeMonoid[A] {} | ||
|
||
trait CommutativeMonoidDerivation: | ||
extension (F: CommutativeMonoid.type) | ||
inline def derived[A](using gen: K0.ProductGeneric[A]): CommutativeMonoid[A] = | ||
new ProductCommutativeMonoid[CommutativeMonoid, A]{} |
14 changes: 14 additions & 0 deletions
14
core/src/main/scala-3.0.0-RC3/cats/derived/commutativeSemigroup.scala
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,14 @@ | ||
package cats.derived | ||
|
||
import cats.kernel.CommutativeSemigroup | ||
import shapeless3.deriving.{K0, Continue} | ||
|
||
object commutativeSemigroup extends CommutativeSemigroupDerivation | ||
|
||
trait ProductCommutativeSemigroup[T[x] <: CommutativeSemigroup[x], A](using inst: K0.ProductInstances[T, A]) | ||
extends ProductSemigroup[T, A], CommutativeSemigroup[A] {} | ||
|
||
trait CommutativeSemigroupDerivation: | ||
extension (F: CommutativeSemigroup.type) | ||
inline def derived[A](using gen: K0.ProductGeneric[A]): CommutativeSemigroup[A] = | ||
new ProductCommutativeSemigroup[CommutativeSemigroup, A]{} |
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
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
10 changes: 10 additions & 0 deletions
10
core/src/test/scala-3.0.0-RC3/cats/derived/CommutativeMonoidTests.scala
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,10 @@ | ||
package cats.derived | ||
|
||
import alleycats._ | ||
import cats._ | ||
import cats.kernel.CommutativeMonoid | ||
import cats.derived.all._ | ||
|
||
class CommutativeMonoidTests { // | ||
case class Foo(i: Int, b: Option[Int]) derives CommutativeMonoid | ||
} |
10 changes: 10 additions & 0 deletions
10
core/src/test/scala-3.0.0-RC3/cats/derived/CommutativeSemigroupTests.scala
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,10 @@ | ||
package cats.derived | ||
|
||
import alleycats._ | ||
import cats._ | ||
import cats.kernel.CommutativeSemigroup | ||
import cats.derived.all._ | ||
|
||
class CommutativeSemigroupTests { // | ||
case class Foo(i: Int, b: Option[Int]) derives CommutativeSemigroup | ||
} |