Skip to content

[PoC] support inline/nested records inside of externals#7791

Closed
zth wants to merge 1 commit intomasterfrom
inline-records-in-externals
Closed

[PoC] support inline/nested records inside of externals#7791
zth wants to merge 1 commit intomasterfrom
inline-records-in-externals

Conversation

@zth
Copy link
Member

@zth zth commented Aug 22, 2025

Closes #7386

Mostly a PoC for now, to see if it was possible to just extend the current mechanisms to this. Feedback appreciated. There are still issues to solve, but this serves as a base for discussion/experimentation.

Support inline record definitions in externals:

@module("node:fs")
external readFileSync: (
  string,
  ~options: {
    encoding?: [#utf8 | #ascii | #base64],
    flag?: string,
    misc?: {
      mode?: int,
    },
  },
) => option<{filename: string, size: string}> = "fs.readFileSync"

@zth
Copy link
Member Author

zth commented Aug 22, 2025

cc @nojaf

@pkg-pr-new
Copy link

pkg-pr-new bot commented Aug 22, 2025

Open in StackBlitz

rescript

npm i https://pkg.pr.new/rescript-lang/rescript@7791

@rescript/darwin-arm64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/darwin-arm64@7791

@rescript/darwin-x64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/darwin-x64@7791

@rescript/linux-arm64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/linux-arm64@7791

@rescript/linux-x64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/linux-x64@7791

@rescript/win32-x64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/win32-x64@7791

commit: 9eaa9be

@tsnobip
Copy link
Member

tsnobip commented Aug 24, 2025

This would make writing bindings so much easier!!

@@ -0,0 +1,9 @@
@module("node:fs")
external readFileSync: (string, ~options: {
encoding?: [#utf8 | #ascii | #base64],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would regular variants also work here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not inline, no. But you could reference a defined one.

@nojaf
Copy link
Member

nojaf commented Aug 25, 2025

Beautiful! Ship it!

@zth
Copy link
Member Author

zth commented Mar 18, 2026

Superseded by #8304

@zth zth closed this Mar 18, 2026
@zth zth deleted the inline-records-in-externals branch March 18, 2026 19:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Consider allowing inline records in external definitions

4 participants