• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

moonbitlang / core / 4283
95%

Build:
DEFAULT BRANCH: main
Ran 10 May 2026 03:01AM UTC
Jobs 1
Files 365
Run time 1min
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

10 May 2026 03:00AM UTC coverage: 94.647% (+0.002%) from 94.645%
4283

push

github

web-flow
feat(lazy): add memoized-thunk primitive package (#3568)

* feat(lazy): add memoized-thunk primitive package

Extracts the package-private `Lazy[A]` helper that the upcoming
`lazy_list` package was using into a standalone primitive, so other
deferred-evaluation users (lazy trees, memoized graph nodes, etc.)
can share it without taking a list dependency.

Public API:

- `make` / `pure` constructors and `force` / `is_forced` queries.
- `try_make`, which lifts a raising thunk into a
  `Lazy[Result[A, Error]]`. This is the recommended way to defer a
  fallible computation: failure becomes part of the value and is
  handled at the call site that consumes the cell.

Design choices captured in doc comments on `Lazy[A]`:

- `force` is non-raising and non-async. With raises in MoonBit's
  signatures, a raising `force` would leak the effect into every
  downstream consumer; async additionally needs in-flight state to
  handle concurrent forcers, which would pull a concurrency primitive
  into a type whose only job is to delay a value. `try_make` is the
  one-line bridge that signature-tracked errors make cheap to express
  (and that OCaml/F# `Lazy.t` cannot express as cleanly because their
  arrows do not carry the effect).

- Failure memoization: `try_make` caches both `Ok` and `Err`, so the
  thunk runs at most once regardless of outcome.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* feat(lazy): detect reentrant force, abort instead of re-running thunk

If a thunk holds an indirect reference back to the same `Lazy` cell
(via a captured `Ref` / `Array`) and forces it during evaluation, the
inner force previously found `Unforced(...)` still in place and ran the
thunk again — silently violating the documented at-most-once guarantee
and risking unbounded recursion.

Add a third state, `Forcing`, that is installed before the thunk runs
and replaced with `Forced(v)` after it returns. A reentrant force hits
the new arm and calls `abort("La... (continued)

7 of 7 new or added lines in 1 file covered. (100.0%)

14888 of 15730 relevant lines covered (94.65%)

218158.78 hits per line

Jobs
ID Job ID Ran Files Coverage
1 4283.1 10 May 2026 03:01AM UTC 366
94.66
GitHub Action Run
Source Files on build 4283
  • Tree
  • List 365
  • Changed 1
  • Source Changed 1
  • Coverage Changed 1
Coverage ∆ File Lines Relevant Covered Missed Hits/Line
  • Back to Repo
  • bf3963b8 on github
  • Prev Build on main (#4277)
  • Next Build on main (#4292)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc