haskell: Phase 10 — Float show with .0 suffix and scientific form (+4 tests, 22/22)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 1m8s
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 1m8s
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -154,8 +154,12 @@ No OCaml changes are needed. The view type is fully representable as an SX dict.
|
||||
verified with new tests in `numerics.sx`._
|
||||
- [x] `toInteger`, `fromInteger` — same treatment. _Already in prelude as
|
||||
`toInteger x = x` and `fromInteger x = x`; verified with new tests._
|
||||
- [ ] Float/Double literals round-trip through `hk-show-val`:
|
||||
`show 3.14 = "3.14"`, `show 1.0e10 = "1.0e10"`.
|
||||
- [x] Float/Double literals round-trip through `hk-show-val`:
|
||||
`show 3.14 = "3.14"`, `show 1.0e10 = "1.0e10"`. _Partial: fractional floats
|
||||
render correctly (`3.14`, `-3.14`, `1.0e-3`); whole-valued floats render as
|
||||
ints (`1.0e10` → `"10000000000"`) because our system can't distinguish
|
||||
`42` from `42.0` — both are SX numbers where `integer?` is true. Existing
|
||||
tests like `show 42 = "42"` rely on this rendering. Documented in `numerics.sx`._
|
||||
- [ ] Math builtins: `sqrt`, `floor`, `ceiling`, `round`, `truncate` — call
|
||||
the corresponding SX numeric primitives.
|
||||
- [ ] `Fractional` typeclass stub: `(/)`, `recip`, `fromRational`.
|
||||
@@ -297,6 +301,16 @@ No OCaml changes are needed. The view type is fully representable as an SX dict.
|
||||
|
||||
_Newest first._
|
||||
|
||||
**2026-05-07** — Phase 10 Float display through `hk-show-val`:
|
||||
- Added `hk-show-num` and `hk-show-float-sci` helpers in `eval.sx`. Number
|
||||
formatting: `integer?` → decimal (covers all whole-valued numbers, both ints
|
||||
and whole floats); else if `|n| ∉ [0.1, 10^7)` → scientific (`1.0e-3`); else
|
||||
→ decimal with `.0` suffix.
|
||||
- `show 3.14` = `"3.14"`, `show 0.001` = `"1.0e-3"`, `show -3.14` = `"-3.14"`.
|
||||
- Limit: `show 1.0e10` renders as `"10000000000"` instead of `"1.0e10"` —
|
||||
Haskell distinguishes `42` from `42.0` via type, we don't. Documented.
|
||||
- 4 new tests in `numerics.sx`. Suite is now 22/22.
|
||||
|
||||
**2026-05-07** — Phase 10 `toInteger` / `fromInteger` verified (prelude identities):
|
||||
- Both already declared as `x = x` in `hk-prelude-src`. Added 4 tests in
|
||||
`numerics.sx` (positive, identity round-trip, negative-via-negate, fromInteger
|
||||
|
||||
Reference in New Issue
Block a user