-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace machinist macros by plain forwarders
Partial fix for #2553. Co-authored-by: drdozer <turingatemyhamster@gmail.com>
- Loading branch information
Showing
8 changed files
with
21 additions
and
61 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
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,16 +1,14 @@ | ||
package cats | ||
package syntax | ||
|
||
import cats.macros.Ops | ||
|
||
trait GroupSyntax extends SemigroupSyntax { | ||
// TODO: use simulacrum instances eventually | ||
implicit final def catsSyntaxGroup[A: Group](a: A): GroupOps[A] = | ||
new GroupOps[A](a) | ||
} | ||
|
||
final class GroupOps[A: Group](lhs: A) { | ||
def |-|(rhs: A): A = macro Ops.binop[A, A] | ||
def remove(rhs: A): A = macro Ops.binop[A, A] | ||
def inverse(): A = macro Ops.unop[A] | ||
def |-|(rhs: A): A = Group[A].remove(lhs, rhs) | ||
def remove(rhs: A): A = Group[A].remove(lhs, rhs) | ||
def inverse(): A = Group[A].inverse(lhs) | ||
} |
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
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,21 +1,19 @@ | ||
package cats | ||
package syntax | ||
|
||
import cats.macros.Ops | ||
|
||
trait PartialOrderSyntax extends EqSyntax { | ||
implicit final def catsSyntaxPartialOrder[A: PartialOrder](a: A): PartialOrderOps[A] = | ||
new PartialOrderOps[A](a) | ||
} | ||
|
||
final class PartialOrderOps[A](lhs: A)(implicit A: PartialOrder[A]) { | ||
def >(rhs: A): Boolean = macro Ops.binop[A, Boolean] | ||
def >=(rhs: A): Boolean = macro Ops.binop[A, Boolean] | ||
def <(rhs: A): Boolean = macro Ops.binop[A, Boolean] | ||
def <=(rhs: A): Boolean = macro Ops.binop[A, Boolean] | ||
def >(rhs: A): Boolean = A.gt(lhs, rhs) | ||
def >=(rhs: A): Boolean = A.gteqv(lhs, rhs) | ||
def <(rhs: A): Boolean = A.lt(lhs, rhs) | ||
def <=(rhs: A): Boolean = A.lteqv(lhs, rhs) | ||
|
||
def partialCompare(rhs: A): Double = macro Ops.binop[A, Double] | ||
def tryCompare(rhs: A): Option[Int] = macro Ops.binop[A, Option[Int]] | ||
def pmin(rhs: A): Option[A] = macro Ops.binop[A, Option[A]] | ||
def pmax(rhs: A): Option[A] = macro Ops.binop[A, Option[A]] | ||
def partialCompare(rhs: A): Double = A.partialCompare(lhs, rhs) | ||
def tryCompare(rhs: A): Option[Int] = A.tryCompare(lhs, rhs) | ||
def pmin(rhs: A): Option[A] = A.pmin(lhs, rhs) | ||
def pmax(rhs: A): Option[A] = A.pmax(lhs, rhs) | ||
} |
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,16 +1,14 @@ | ||
package cats | ||
package syntax | ||
|
||
import cats.macros.Ops | ||
|
||
trait SemigroupSyntax { | ||
// TODO: use simulacrum instances eventually | ||
implicit final def catsSyntaxSemigroup[A: Semigroup](a: A): SemigroupOps[A] = | ||
new SemigroupOps[A](a) | ||
} | ||
|
||
final class SemigroupOps[A: Semigroup](lhs: A) { | ||
def |+|(rhs: A): A = macro Ops.binop[A, A] | ||
def combine(rhs: A): A = macro Ops.binop[A, A] | ||
def combineN(rhs: Int): A = macro Ops.binop[A, A] | ||
def |+|(rhs: A): A = Semigroup[A].combine(lhs, rhs) | ||
def combine(rhs: A): A = Semigroup[A].combine(lhs, rhs) | ||
def combineN(rhs: Int): A = Semigroup[A].combineN(lhs, rhs) | ||
} |
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 was deleted.
Oops, something went wrong.