Skip to content

docs: close out the GHC-style Note pass (#44)#130

Merged
Unisay merged 1 commit into
mainfrom
issue-44/notes-low-items
Jun 25, 2026
Merged

docs: close out the GHC-style Note pass (#44)#130
Unisay merged 1 commit into
mainfrom
issue-44/notes-low-items

Conversation

@Unisay

@Unisay Unisay commented Jun 25, 2026

Copy link
Copy Markdown
Collaborator

Summary

The final #44 batch. It adds the one remaining low-priority Note that earns its keep and makes a conscious call on the rest, so the issue's "decide consciously rather than by omission" goal is met for every listed item. Comments only, so generated code, goldens, and eval oracles are unchanged.

Closes #44.

  • Added Note [IR is assumed well-typed] in IR.Optimizer. The optimizer trusts the type checker rather than re-checking: constantFolding rewrites Eq True b to b because b must be a Bool, and betaReduce substitutes an argument for a parameter without checking the types match. Cited from both rewrites.

Conscious calls on the rest

Left as adequate inline documentation (a titled Note would add ceremony without a second citation site):

  • InternalIdentData (Names) already has a complete Haddock.
  • "Prim is always imported" (Backend.IR.mkImports) has a one-line comment explaining the always-add-then-DCE approach; it is a single site.
  • unsafePerformIO in PSString.decodeString already carries the standard safety argument.
  • The case-alternatives ASCII diagram lives in the IR spec; it is test-local and fine where it is.

Deliberately not retitled, to avoid divergence from upstream purs:

  • The remaining CoreFn.Laziness prose (the full delay/force rules, the USE-INIT/USE-USE/USE-IMMEDIATE derivation, and the MaxRoseTree termination argument) is thorough and only cited from within that file. Batch 3 already gave the cross-module contract (the runtime-lazy convention) and the transform a citable anchor; titling the rest would diverge from the adapted upstream source for marginal benefit.

Note discovered along the way

@inline never does not currently veto inlining (documented in Note [Inline annotations and inlining heuristics] from the previous batch): isInlinableExpr treats Just Never like Nothing, so a ref / small literal / single-use binding is still inlined. Flagging it here; whether never should actually veto is a behavior question for a separate change, not this docs pass.

Checklist

  • Added a changelog.d/ fragment for any user-facing change (scriv create
    in the dev shell), or this change ships nothing releasable (CI, docs, or an
    internal refactor).
  • In the dev shell (nix develop), fourmolu -i lib/ exe/ test/ and
    hlint lib/ exe/ test/ are clean.
  • In the dev shell, cabal test all passes; structural goldens were
    re-accepted on purpose if codegen moved (PSLUA_GOLDEN_ACCEPT=1), and
    eval/golden.txt still holds.

Add Note [IR is assumed well-typed] (IR.Optimizer), cited from constantFolding
and betaReduce, and make the conscious call on the remaining low-priority #44
candidates (left as adequate inline comments, or deliberately not retitled in
the upstream-adapted CoreFn.Laziness). Comments only; generated code unchanged.

Closes #44.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR completes the final documentation pass for issue #44 by adding a single remaining low-priority GHC-style Note that documents a load-bearing invariant in the IR optimizer, with citations from the rewrite sites that depend on it. The changes are comment/documentation-only and do not modify compiler behavior or generated output.

Changes:

  • Added Note [IR is assumed well-typed] to document the optimizer’s reliance on upstream type checking.
  • Updated the relevant rewrite sites (constantFolding and betaReduce) to cite the new Note.
  • Added a changelog.d/ fragment recording the closure of the #44 documentation pass.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
lib/Language/PureScript/Backend/IR/Optimizer.hs Adds and cites a new GHC-style Note documenting the “IR is well-typed” optimizer invariant.
changelog.d/20260625_203341_unisay_notes_low_items.md Records the documentation-only change and closure of #44.

@Unisay Unisay marked this pull request as ready for review June 25, 2026 18:57
@Unisay Unisay merged commit 9242f20 into main Jun 25, 2026
3 checks passed
@Unisay Unisay deleted the issue-44/notes-low-items branch June 25, 2026 18:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Document load-bearing invariants and subsystems with GHC-style Notes

2 participants