AngouriMath

Navigation

← Back to list of members

RationalLiterals​(AngouriMath.​Entity)

 Method (no overloads)

Summary

Rewrites a quotient of two integer literals into the Rational it denotes,
so that a Rational's printed form parses back to a
Rational.

Remarks

The rewrite itself is RationalLiteral(AngouriMath.Entity), which the
domain(...) rule also calls — on its argument, before annotating it. That is what
lets this sweep hand back a bare Rational and read no codomain at all: a
quotient reaching here has never been annotated, because the only syntax that annotates
anything has already folded what it was given.
Reading one would be wrong as well as unnecessary. An unannotated quotient carries the
default, Complex, and a rational literal the tighter
Rational, so copying it across would make 7/2 and 3.5 structurally unequal — the round trip this exists to fix, broken from the other end.
Telling that default apart from a domain(x, CC) somebody wrote is what no reader
of a finished tree can do, and it cost domain(1/2, CC) its annotation until
the fold moved to where the annotation is applied.
https://github.com/asc-community/AngouriMath/issues/1048

























Angouri © 2019-2023 · Project's repo · Site's repo · Octicons · Transparency · 4378 pages online