_Number

it.grypho.scala.leonardo.core._Number
See the_Number companion class
object _Number

Companion for the concrete real scalar value _Number.

Attributes

Companion
class
Graph
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
_Number.type

Members list

Type members

Inherited and Abstract types

type MirroredElemLabels <: Tuple

The names of the product elements

The names of the product elements

Attributes

Inherited from:
Mirror
type MirroredLabel <: String

The name of the type

The name of the type

Attributes

Inherited from:
Mirror

Value members

Concrete methods

def unapply(e: _Expression): Option[Double]

Matches any value that reads as a real number, including an exact _Rational — the widening reader for the numeric tier.

Matches any value that reads as a real number, including an exact _Rational — the widening reader for the numeric tier.

This replaces the synthesized case-class extractor deliberately, and it is the single decision that let the exact tier be added without editing the hundred-odd case _Number(x) sites across the library. The rule it establishes:

case _Number(x) means "reads as the real number x". Code that must preserve exactness matches case r: _Rational explicitly, and must place that case first.

The default is therefore float contagion and exactness is opt-in, which is the safe direction: the worst a missed opt-in can do is degrade a result to the Double behaviour it already had, never produce a wrong one. scalar._Operation is where the opt-in lives, and RationalTest pins the ordering it depends on.

Note this cannot change any existing behaviour: outside the parser's exact mode no _Rational is ever constructed, so the extra arm is unreachable and the Double path stays byte-identical.

Value parameters

e

the expression to read

Attributes

Returns

Some(d) for a _Number or a _Rational, None otherwise