From 707e566bccf99d2a673031faa8dbf12ed9b79a68 Mon Sep 17 00:00:00 2001 From: Yura Lazarev Date: Sun, 12 Jul 2026 19:00:09 +0200 Subject: [PATCH 1/2] fix: pin Data.Unit.unit to the shared foreign singleton (never) The FFI value unit = ({}) is a table constructor, not a value, so the old `@inline unit always` pragma pasted a fresh {} allocation into every use site (7 inlined {} in the linked Data.Array output alone, including void = map(function() return {} end): one allocation per void step). Flip the pragma to `@inline unit never` so unit stays one shared table bound to the foreign module. This matches the foreign table-constructor sharing the compiler performs by default since purescript-lua/purescript-lua#175, and declares the sharing intent explicitly against future heuristic changes. Refs purescript-lua/purescript-lua#176 --- changelog.d/20260712_165906_unisay.md | 7 +++++++ src/Data/Unit.purs | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 changelog.d/20260712_165906_unisay.md diff --git a/changelog.d/20260712_165906_unisay.md b/changelog.d/20260712_165906_unisay.md new file mode 100644 index 00000000..bf433521 --- /dev/null +++ b/changelog.d/20260712_165906_unisay.md @@ -0,0 +1,7 @@ +### Changed + +- `Data.Unit.unit` is pinned to the shared foreign singleton (`@inline unit + never`). The value is a table constructor (`{}`), so the former `always` + pragma duplicated the allocation at every use site; `never` keeps one shared + table, matching the foreign-table sharing the compiler now performs by + default (purescript-lua/purescript-lua#176). diff --git a/src/Data/Unit.purs b/src/Data/Unit.purs index b45f6005..91b30de6 100644 --- a/src/Data/Unit.purs +++ b/src/Data/Unit.purs @@ -1,4 +1,4 @@ --- @inline unit always +-- @inline unit never module Data.Unit where -- | The `Unit` type has a single inhabitant, called `unit`. It represents From 55ac30bd90cd56d0f186ea17efe49908c3e4bfdb Mon Sep 17 00:00:00 2001 From: Yura Lazarev Date: Sun, 12 Jul 2026 21:08:09 +0200 Subject: [PATCH 2/2] address copilot review on PR #14 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - changelog.d/20260712_165906_unisay.md:7 — keep `@inline unit never` code span on one line (#14 discussion_r3566905136) --- changelog.d/20260712_165906_unisay.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/changelog.d/20260712_165906_unisay.md b/changelog.d/20260712_165906_unisay.md index bf433521..0aa7136f 100644 --- a/changelog.d/20260712_165906_unisay.md +++ b/changelog.d/20260712_165906_unisay.md @@ -1,7 +1,7 @@ ### Changed -- `Data.Unit.unit` is pinned to the shared foreign singleton (`@inline unit - never`). The value is a table constructor (`{}`), so the former `always` - pragma duplicated the allocation at every use site; `never` keeps one shared - table, matching the foreign-table sharing the compiler now performs by - default (purescript-lua/purescript-lua#176). +- `Data.Unit.unit` is pinned to the shared foreign singleton + (`@inline unit never`). The value is a table constructor (`{}`), so the + former `always` pragma duplicated the allocation at every use site; `never` + keeps one shared table, matching the foreign-table sharing the compiler now + performs by default (purescript-lua/purescript-lua#176).