Skip to content

wasm-runner: add run/4, map/4, flat_map/5, and reduce/6 collection helpers#16

Open
yevbar wants to merge 3 commits intomasterfrom
sleepy/wasm-runner-map-and-run
Open

wasm-runner: add run/4, map/4, flat_map/5, and reduce/6 collection helpers#16
yevbar wants to merge 3 commits intomasterfrom
sleepy/wasm-runner-map-and-run

Conversation

@yevbar
Copy link
Copy Markdown
Contributor

@yevbar yevbar commented Feb 28, 2026

Add ergonomic collection operations to WasmRunner that load a WASM module once and apply a function across multiple inputs:

  • run/4, run!/4: One-shot load+call+stop with WASI auto-detect and cache support, returning a single unwrapped value (vs Firebird.run/4 which returns a list)
  • map/4: Apply a WASM function over a list of argument lists using a single instance. Supports parallel execution via :concurrency option.
  • flat_map/5: Map + filter in a single pass over inputs
  • reduce/6: Fold WASM function results through an Elixir accumulator

All functions accept file paths, raw bytes, or precompiled modules. 24 new tests included.

By Sleepy

Sleepy added 3 commits February 28, 2026 22:02
…lpers

Add ergonomic collection operations to WasmRunner that load a WASM module
once and apply a function across multiple inputs:

- run/4, run!/4: One-shot load+call+stop with WASI auto-detect and cache
  support, returning a single unwrapped value (vs Firebird.run/4 which
  returns a list)
- map/4: Apply a WASM function over a list of argument lists using a
  single instance. Supports parallel execution via :concurrency option.
- flat_map/5: Map + filter in a single pass over inputs
- reduce/6: Fold WASM function results through an Elixir accumulator

All functions accept file paths, raw bytes, or precompiled modules.

By Sleepy
- Run mix format across all files (Elixir 1.16 formatting rules)
- Fix unused generate_expr/3 in wat_gen.ex
- Fix unused module_name variable in firebird.compile.ex
- Register @wasm attribute with accumulate: true in wasm_modules
- Suppress noisy FastNif load warning (expected in dev)
- Fix @wasm warning in physics.ex (missed in previous commit)
- Compile deps separately to avoid --warnings-as-errors on rustler
- Replace charlist literal with integer list for cross-version compat
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.

1 participant