CatsKernelInstances

com.phasmidsoftware.number.cats.CatsKernelInstances

Centralized Cats Kernel instances, kept out of core companion objects to avoid forcing a Cats dependency on core types at definition sites.

Import usage: import com.phasmidsoftware.number.instances.catsKernel._

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Known subtypes
object CatsKernel

Members list

Implicits

Implicits

implicit val complexEq: Eq[Complex]
implicit val complexShow: Show[Complex]
implicit val exactNumberEq: Eq[ExactNumber]
implicit val exactNumberOrder: Order[ExactNumber]
implicit val exactNumberShow: Show[ExactNumber]
implicit val fieldEq: Eq[Field]
implicit val fieldShow: Show[Field]
implicit val fuzzEq: Eq[Fuzziness[Double]]
implicit val fuzzPartialOrder: PartialOrder[Fuzziness[Double]]
implicit val numberEq: Eq[Number]

NOTE: This has changed from the original. It now uses isSame instead of isSameWithinTolerance.

NOTE: This has changed from the original. It now uses isSame instead of isSameWithinTolerance.

WARNING: Avoid providing inputs that "look like zero but are not exactly zero". Examples: 0.00(...), 0.00[...], 0* — these are fuzzy renderings whose nominal values may be non-zero. This Eq[Number] deems two numbers equal only if their numeric values are equal within a tolerance AND their factors match. Near-zero-but-non-zero inputs can therefore compare unequal to exact zero and may violate users’ expectations in equality/ordering checks.

Guidance for callers:

  • When zero is intended, pass an exact zero (e.g., ExactNumber(Rational(0,1)) or Number.zeroR), not a fuzzy/near-zero value.
  • Upstream, normalize or filter values with |x| <= 1e-10 to exact zero if semantic zero is desired.
  • Avoid comparing numbers across different factors unless you first normalize them into the same factor.

Attributes

implicit val numberPartialOrder: PartialOrder[Number]
implicit val numberShow: Show[Number]
implicit val rationalEq: Eq[Rational]
implicit val rationalOrder: Order[Rational]
implicit val rationalShow: Show[Rational]
implicit val realEq: Eq[Real]
implicit val realPartialOrder: PartialOrder[Real]
implicit val realShow: Show[Real]