-
Notifications
You must be signed in to change notification settings - Fork 69
Add Signed and TruncatedDivision typeclasses #247
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very cool. Thanks for sending.
|
||
def *(that: Sign): Sign = Sign(this.toInt * that.toInt) | ||
|
||
def **(that: Int): Sign = this match { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add a comment that this is exponentiation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure!
def signed(implicit A: Signed[A]) = new OrderProperties( | ||
name = "signed", | ||
parent = Some(order), | ||
"abs non-negative" -> forAll((x: A) => A.sign(A.abs(x)) != Signed.Negative), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we require that abs(x) >= x?
Seems natural to me, but I don't see that is implied.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure!
@@ -123,6 +123,8 @@ class LawTests extends munit.DisciplineSuite { | |||
checkAll("Long", RingLaws[Long].commutativeRing) | |||
checkAll("Long", LatticeLaws[Long].boundedDistributiveLattice) | |||
|
|||
// catsKernelStdOrderForBigInt | |||
checkAll("BigInt", OrderLaws[BigInt].truncatedDivision) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add implementations for the specialized things?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment as for the intermediate ring structures-- the instances are only approximations due to the type limited range.
Partially merges typelevel/algebra#247
Partially merges typelevel/algebra#247
This follows the Spire implementations as well (we just put
Sign
into theSigned
companion object).We added the missing companion object functions.