Skip to content

[fork-ffi] foldable-traversable: declare the fork-shaped traverseArrayImpl as Fn6 #271

Description

@Unisay

Problem

The fork's Data.Traversable.traverseArrayImpl diverges from upstream: it takes an extra array-concat argument, making it a 6-argument curried foreign (upstream's is 5). It is not exported, so its shape is free to change, and it is the only fork-diverged foreign signature in the whole package set (#186 audit, stream 1). As a curried foreign it costs a closure per argument on every traverse over an array.

Approach

Declare it Fn6 and wrap: traverseArrayImpl = runFn6 traverseArrayImplNative … (or reshape the definition site traverse = runFn6 impl apply map pure (<>) directly). The .lua entry becomes one 6-ary function. The win is real only where the call site ends up saturated after inlining: the instance defines traverse by partially applying 4 of 6 arguments, so the collapse depends on the dictionary method inlining at use sites. Worth doing when touching the fork anyway; measure before claiming a number.

Prerequisites / Relations

No hard prerequisites. Found by the #186 audit (closed). The measured win depends on the inliner collapsing dictionary-method call sites, so it pairs with the call-site inliner work in #245 without depending on it. Ships as a foldable-traversable fork release plus a set bump.

Verification / Measurement

The fork's regression tests stay green, a compiled traverse-over-array program still evaluates identically, and the generated Lua for a saturated call site shows the direct 6-ary call.

Metadata

Metadata

Assignees

No one assigned

    Labels

    OptimisationA Compiler Optimisationarea: package-setBug in a package-set fork (FFI/sources), not the compilerenhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions