Skip to content

[Beam] Support ImportAll + Erase interface pattern for typed FFI#4384

Merged
dbrattli merged 1 commit intomainfrom
dbrattli/beam-imports
Mar 5, 2026
Merged

[Beam] Support ImportAll + Erase interface pattern for typed FFI#4384
dbrattli merged 1 commit intomainfrom
dbrattli/beam-imports

Conversation

@dbrattli
Copy link
Collaborator

@dbrattli dbrattli commented Mar 5, 2026

Summary

  • Support [<ImportAll>] + [<Erase>] interface pattern for BEAM target, enabling typed FFI bindings to Erlang modules
  • myModule.someMethod(args) emits module:some_method(Args) as a direct Erlang remote call
  • Handles both method calls (in transformCall) and property access (in transformGet)

Example

[<Erase>]
type INativeCode =
    abstract getName: unit -> string
    abstract addValues: x: int * y: int -> int

[<ImportAll("native_code")>]
let nativeCode: INativeCode = nativeOnly

nativeCode.addValues(3, 4) // → native_code:add_values(3, 4)
nativeCode.getName()       // → native_code:get_name()

Test plan

  • Three new interop tests: zero-arg, multi-arg, and string method calls
  • All 2244 Beam tests pass (./build.sh test beam)
  • Build succeeds with 0 warnings

🤖 Generated with Claude Code

…FFI bindings

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@dbrattli dbrattli merged commit 8e4f0de into main Mar 5, 2026
23 checks passed
@dbrattli dbrattli deleted the dbrattli/beam-imports branch March 5, 2026 16:15
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