Skip to content

Release 0.15.0: refactored generators - #19

Merged
zaiev merged 2 commits into
mainfrom
sound-generated-bindings
Nov 23, 2026
Merged

zaiev merged 2 commits into
mainfrom
sound-generated-bindings

Conversation

@zaiev

@zaiev zaiev commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Why

A review of how a TypeScript library becomes a binding found places where a wrong program still compiled or a wrong build still ran.

A function's type does not say whether it takes its arguments at once: fun a b -> e and a function that takes a, then gives a function of b, are one type and two JavaScript functions. One of the second kind given to For, Index, a component's function prop or Kobalte's on_open_change compiled and was called wrong, or never. Carrying the arity in the type was weighed and refused: a caller would write every such function in place, and read an error that names Melange's calling convention. So whoever receives the function applies it as OCaml applies one it did not make: the ppx's read of a prop, For and Index as components over Solid's, a generated part through Solidtype.Arity, a generated constructor and function inside the binding. And a function JavaScript hands to OCaml is wrapped at the binding to its arity, since Melange calls one it did not make by its length.

A type argument typed any was written _, so reading it gave whatever type the caller chose; it is Types.Unknown.t where it is read. A bigint was bound as an object named for where it was first met. Kobalte's and Html's generators dropped what no rule mapped without a word, where rhp's failed: every generator now fails unless the declaration is named as left out, with why, and a name left out that no longer applies fails it too.

A module of Types was named for where its type was first met, and numbered when two met at one name, so Bins was a function's options and Bins2 what it gave, by the order they were read in. A type with no name is now named by the path to it, a parameter's name after its function's, and two types of one name fail the run until the generator names each.

The plugin moved a bound function to its use without asking whether the names it reads mean the same there, and removed the markers' import while a marker held as a value still named it.

The core was one file of a thousand lines over module-level state, so it bound one library a process and nothing could test a rule alone. It is a Binding made per library, with the mapping, the emitters and the Types file each a file, the way a value crosses passed rather than ambient, a test per rule, and one driver that reads a package and writes its files, so a library of functions is a few calls.

A generator wrote each file as lines it indented, and its interface as other lines beside them, so a comment was a line some declaration followed: 167 of Kobalte's fields carried the next one's description, and ocamlformat refused the files. A generator now says what a file declares, each declaration with its comment; one printer writes the file and its interface, and ocamlformat lays them out, as it does any file here. Every file parses to the declarations it had.

AGENTS.md had grown to 754 lines, most of them a tree that repeated each module's own .mli and rules that restated the pipeline: its layout now says where things are and what no file says of itself, and its rules are grouped by what they hold. impeccable's configuration, which nothing here reads, is removed.

Changes

  • Breaking: a module of Types is named by one rule and never numbered; CHANGES.md lists each rename in Kobalte, rhp and @internationalized/date.
  • Breaking: what Kobalte types any is Types.Unknown.t where it is read; a bigint is Js.Bigint.t; For.component and Index.component are components over Solid's; Types.Toast_Toaster.make is gone.
  • A function of two or more arguments given in JSX, to a generated constructor or to a generated function runs however it takes its arguments; nothing changes in what is written.
  • A function a Kobalte object may not have is called with the arguments it is given.
  • A field's description in the generated reference is on its field.
  • The plugin fails the build on a marker it cannot read or one left outside an element, and keeps a bound function where moving it would change a name it reads.
  • Every generator fails on a declaration no rule maps unless it is named as left out, with why.
  • AGENTS.md is a third shorter, and impeccable's configuration is removed.

Verified

  • make lint, make test and make docs pass on this commit.
  • Each regenerated file parses to the declarations it had before the generator was rewritten, compared with comments and whitespace removed.
  • A function that takes its arguments one at a time, given to For, Index, a component and Kobalte's Combobox, failed before and passes now; a list and an adapted component keep the server's nodes when hydrated.

A review of how a TypeScript library becomes a binding found places
where a wrong program still compiled or a wrong build still ran.

A function's type does not say whether it takes its arguments at once:
fun a b -> e and a function that takes a, then gives a function of b,
are one type and two JavaScript functions. One of the second kind given
to For, Index, a component's function prop or Kobalte's on_open_change
compiled and was called wrong, or never. Carrying the arity in the type
was weighed and refused: a caller would write every such function in
place, and read an error that names Melange's calling convention. So
whoever receives the function applies it as OCaml applies one it did
not make: the ppx's read of a prop, For and Index as components over
Solid's, a generated part through Solidtype.Arity, a generated
constructor and function inside the binding. And a function JavaScript
hands to OCaml is wrapped at the binding to its arity, since Melange
calls one it did not make by its length.

A type argument typed any was written _, so reading it gave whatever
type the caller chose; it is Types.Unknown.t where it is read. A bigint
was bound as an object named for where it was first met. Kobalte's and
Html's generators dropped what no rule mapped without a word, where
rhp's failed: every generator now fails unless the declaration is named
as left out, with why, and a name left out that no longer applies fails
it too.

A module of Types was named for where its type was first met, and
numbered when two met at one name, so Bins was a function's options and
Bins2 what it gave, by the order they were read in. A type with no name
is now named by the path to it, a parameter's name after its function's,
and two types of one name fail the run until the generator names each.

The plugin moved a bound function to its use without asking whether the
names it reads mean the same there, and removed the markers' import
while a marker held as a value still named it.

The core was one file of a thousand lines over module-level state, so
it bound one library a process and nothing could test a rule alone. It
is a Binding made per library, with the mapping, the emitters and the
Types file each a file, the way a value crosses passed rather than
ambient, a test per rule, and one driver that reads a package and
writes its files, so a library of functions is a few calls.

A generator wrote each file as lines it indented, and its interface as
other lines beside them, so a comment was a line some declaration
followed: 167 of Kobalte's fields carried the next one's description,
and ocamlformat refused the files. A generator now says what a file
declares, each declaration with its comment; one printer writes the
file and its interface, and ocamlformat lays them out, as it does any
file here. Every file parses to the declarations it had.

AGENTS.md had grown to 754 lines, most of them a tree that repeated
each module's own .mli and rules that restated the pipeline: its layout
now says where things are and what no file says of itself, and its
rules are grouped by what they hold. impeccable's configuration, which
nothing here reads, is removed.
CI's lower-bounds job runs the tests against the oldest Melange the
packages allow, whose Dom is laid out where the generators do not look,
so the rule tests failed there before one ran: they are lint's, beside
the generators' own check. And a marker's error is printed without
colour, which CI's terminal added and the test read as text.
@zaiev
zaiev merged commit b4e9c99 into main Nov 23, 2026
4 checks passed
@zaiev
zaiev deleted the sound-generated-bindings branch November 23, 2026 12:04
@zaiev zaiev changed the title Release 0.15.0: sound generated bindings, and callbacks that run Release 0.15.0: refactored generators Nov 23, 2026
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