Uh oh!
There was an error while loading. Please reload this page.
fix: restore the missing Data.Array.ST.clone - #4
Merged
Conversation
Upstream purescript-arrays v7.3.0 exports clone, backed by the
cloneImpl :: STFn1 (STArray h a) h (STArray h a) foreign, but the fork
tracked the 7.3.0 sources with neither the export nor the foreign, so
code written against the registry package failed to compile against the
fork ("Unknown value clone"). Restore the declarations as upstream
states them and bind cloneImpl to the same independent copy the FFI
already uses for thawImpl/freezeImpl; the regression guard now covers
it.
Refs purescript-lua/purescript-lua#267.There was a problem hiding this comment.
Pull request overview
Restores the missing Data.Array.ST.clone API in this PureScript→Lua arrays fork to match upstream purescript-arrays v7.3.0, fixing downstream compilation failures for code expecting Data.Array.ST.clone.
Changes:
- Re-add
cloneand itscloneImplforeign toData.Array.ST, matching upstream signatures and export ordering. - Implement
cloneImplin Lua by reusing the existingcopyImpl(same independent-copy path used byfreezeImpl/thawImpl). - Add a Lua regression guard asserting
cloneImplproduces an independent copy.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/Data/Array/ST.purs | Reintroduces clone export and foreign cloneImpl with STFn1 wiring via runSTFn1. |
src/Data/Array/ST.lua | Exposes cloneImpl = (copyImpl) consistent with existing freezeImpl/thawImpl behavior and FFI export wrapping requirements. |
test/regression/array_st.lua | Adds regression coverage ensuring cloneImpl copies and is independent of the source table. |
changelog.d/20260713_180352_st_clone.md | Documents the restoration of Data.Array.ST.clone and its Lua backing implementation. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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 freeto 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.
Problem
Upstream
purescript-arraysv7.3.0 exportsData.Array.ST.clone, backed by thecloneImpl :: STFn1 (STArray h a) h (STArray h a)foreign. The fork tracks the 7.3.0 sources but carried neither the export nor the foreign, so code written against the registry package failed to compile against the fork ("Unknown value clone"). Found by the upstream diff of the purescript-lua/purescript-lua#186 audit, where this was the only missing value export in arrays.Change
src/Data/Array/ST.purs: restoreclone/cloneImplexactly as upstream declares them (export afterthaw, declarations afterthawImpl).src/Data/Array/ST.lua: bindcloneImplto the existingcopyImpl, the same independent copythawImpl/freezeImplalready use, per the STFn convention: a 1-ary entry that performs the copy directly.test/regression/array_st.lua: the guard coverscloneImpl(copies, independent of the source). It was red against the old FFI (attempt to call field 'cloneImpl' (a nil value)) and is green after the fix.Verification
scripts/testgreen (regression suites for ST and NonEmpty),luacheck --std lua51 --no-unused-args src/clean,nix develop -c ./scripts/buildlinks all seven modules. End-to-end check with a small program that thaws[1,2,3], clones it, and pokes the clone, built on setpsc-0.15.15-20260713witharraysoverridden to this checkout: before the fix purs rejected it with "Unknown value clone"; with the fix it compiles and prints[1,2,3]then[99,2,3], so poking the clone leaves the source array intact.Suggested release: patch (v7.4.3) plus a package-set bump.
Refs purescript-lua/purescript-lua#267.