Skip to content

feat: bring arrays to the canon and make the FFI Lua 5.1-safe#1

Merged
Unisay merged 1 commit into
masterfrom
chore/agents-md-and-canon-ci
Jun 14, 2026
Merged

feat: bring arrays to the canon and make the FFI Lua 5.1-safe#1
Unisay merged 1 commit into
masterfrom
chore/agents-md-and-canon-ci

Conversation

@Unisay

@Unisay Unisay commented Jun 14, 2026

Copy link
Copy Markdown
Collaborator

Brings purescript-lua-arrays (the last fork still on JavaScript-era tooling) onto the package-set canon and fixes the Lua 5.1 FFI that the canon luacheck --std lua51 surfaced.

Scaffolding. Overlay flake pinning purs 0.15.16 / spago 0.21.0 / Lua 5.1 and pslua at the current main, hardened CI, scripts/build, AGENTS.md + CLAUDE.md, a clean .gitignore, and the purescript-lua org package-set URL. Drops .eslintrc, bower.json, package.json.

FFI fix (Lua 5.1). The foreign modules used builtins that do not exist in Lua 5.1:

  • src/Data/Array.luatable.pack(table.unpack(...)) in unconsImpl, _insertAt, _deleteAt, _updateAt and the merge sort, replaced with { unpack(...) } (the .n field was never read).
  • src/Data/Array/ST.luatable.move in freeze/thaw, pushAll, unshiftAll, splice and sortBy, replaced with a hand-written move whose semantics match Lua 5.3's table.move, including copying backwards when source and destination overlap to the right.

Tests. scripts/test runs test/regression/array_st.lua, a lean guard over exactly the rewritten paths: freeze independence, pushAll, splice in both overlap directions (the shift-right case is what a naive forward copy gets wrong), a stable sort, and the unpack-based uncons/insertAt/deleteAt/updateAt.

Verified locally: ./scripts/build, ./scripts/test (all FFI regression checks passed), and luacheck --std lua51 are all green. This is a src/ change, so the fork needs a release before the set is re-tagged.

@Unisay Unisay requested a review from Copilot June 14, 2026 19:31
@Unisay Unisay self-assigned this Jun 14, 2026

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 modernizes purescript-lua-arrays for the purescript-lua package set and updates the Lua FFI to be Lua 5.1-compatible (removing reliance on table.move, table.pack, and table.unpack). It also introduces Nix-based tooling/CI and adds a Lua regression test focused on the rewritten FFI paths.

Changes:

  • Replace Lua 5.3-only FFI usages: implement an overlap-safe move in Data/Array/ST.lua and switch Data/Array.lua copies to { unpack(...) }.
  • Add Lua regression tests and a scripts/test runner; harden build/test scripts and CI around nix develop.
  • Update package-set/flake inputs and remove legacy JS-era tooling files (npm/bower/eslint).

Reviewed changes

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

Show a summary per file
File Description
test/regression/array_st.lua Adds Lua regression coverage for move-based operations and unpack-based array ops.
src/Data/Array/ST.lua Replaces table.move with a local overlap-safe move and uses it in affected functions.
src/Data/Array.lua Replaces table.pack(table.unpack(...)) with { unpack(...) } in several copy paths.
scripts/test Adds a simple regression-test runner for the Lua checks.
scripts/build Hardens build script (adds set -euo pipefail) and runs spago build + pslua emits.
packages.dhall Switches package-set URL to the purescript-lua org.
package.json Removes legacy npm/pulp tooling configuration.
flake.nix Moves to purescript-overlay, pins toolchain, and adds Nix cache config.
flake.lock Updates lockfile to match new flake inputs/pins.
CLAUDE.md Adds a pointer to AGENTS.md.
bower.json Removes legacy bower-era dependency manifest.
AGENTS.md Documents Lua 5.1 constraints, commands, and release/tooling notes.
.gitignore Simplifies ignore rules for the new workflow/tooling.
.github/workflows/ci.yml Updates CI to use Nix, run build, regression tests (if present), and luacheck.
.eslintrc.json Removes legacy ESLint config.
Comments suppressed due to low confidence (1)

scripts/build:6

  • The build script relies on pslua creating dist/ implicitly. Creating the directory explicitly makes the build more robust across pslua versions and avoids the failure mode called out in AGENTS.md.
set -euo pipefail

echo "Building..."

spago build 

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread AGENTS.md
Comment thread test/regression/array_st.lua Outdated
Scaffolding. Move purescript-lua-arrays onto the package-set canon: an
overlay flake (purs 0.15.16, spago 0.21.0, Lua 5.1, pslua at the current
main), hardened CI, scripts/build, AGENTS.md + CLAUDE.md, a clean
.gitignore, and the purescript-lua org package-set URL. Drop the
.eslintrc, bower.json and package.json.

FFI fix. The foreign modules used Lua 5.2/5.3 builtins absent in 5.1:
src/Data/Array.lua called table.pack(table.unpack(...)) in unconsImpl,
_insertAt, _deleteAt, _updateAt and the sort, now { unpack(...) }; and
src/Data/Array/ST.lua used table.move in freeze/thaw, pushAll, unshiftAll,
splice and sortBy, now a hand-written overlap-safe move with the same
semantics as Lua 5.3 table.move (it copies backwards when the source and
destination overlap to the right).

Tests. scripts/test runs test/regression/array_st.lua, a lean guard over
exactly the rewritten paths: freeze independence, pushAll, splice in both
overlap directions, a stable sort, and the unpack-based uncons/insertAt/
deleteAt/updateAt. Verified locally with build, the regression run, and
luacheck --std lua51 all green.
@Unisay Unisay force-pushed the chore/agents-md-and-canon-ci branch from d94a9a5 to fb573d4 Compare June 14, 2026 19:40
@Unisay Unisay merged commit 272db5c into master Jun 14, 2026
1 check passed
@Unisay Unisay deleted the chore/agents-md-and-canon-ci branch June 14, 2026 19:43
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.

2 participants