Fix consLazy laziness: tail must not be forced when accessing head#255
Open
Copilot wants to merge 2 commits intorepo-assist/improve-lazylist-conslazy-23c4939b68642ec5from
Open
Fix consLazy laziness: tail must not be forced when accessing head#255Copilot wants to merge 2 commits intorepo-assist/improve-lazylist-conslazy-23c4939b68642ec5from
consLazy laziness: tail must not be forced when accessing head#255Copilot wants to merge 2 commits intorepo-assist/improve-lazylist-conslazy-23c4939b68642ec5from
Conversation
…n head access Co-authored-by: gdziadkiewicz <8547855+gdziadkiewicz@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] [WIP] Address feedback on LazyList.consLazy PR regarding mutable usage
Fix Mar 15, 2026
consLazy laziness: tail must not be forced when accessing head
github-actions bot
added a commit
that referenced
this pull request
Mar 16, 2026
Previously consLazy wrapped the entire cell construction in lzy, meaning forcing the head cell (e.g. via LazyList.head) also forced l.Value — defeating the laziness guarantee of consLazy. Fix: use notlazy for the outer CellCons so the head is immediately available, wrapping only the tail evaluation in lzy. Test: replace the failwith divergence test with an explicit mutable flag asserting that neither construction nor head access forces the tail. Incorporates fix from PR #255. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
29 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
consLazywas wrapping both the head cell construction and tail evaluation inside a singlelzy, meaning forcing the head cell (e.g. viaLazyList.head) also forced the lazy tail — defeating the purpose ofconsLazy.Changes
LazyList.fs— RewriteconsLazyto usenotlazyfor the outer cell so the head is immediately available, with only the tail wrapped in a deferredlzy:LazyListTests.fs— Replace thefailwith-based divergence test with amutable tailForcedflag to explicitly assert that neither construction norLazyList.headforces the tail:📱 Kick off Copilot coding agent tasks wherever you are with GitHub Mobile, available on iOS and Android.