Skip to content

Module Type Structure

The public package is flat under WebAPI. Concrete interface modules commonly keep the interface’s t type and its operations together in one source file. For example, the HTMLButtonElement binding lives in the HTML family directory:

  • Directorysrc
    • Directoryhtml
      • HTMLButtonElement.res

An interface value is passed as the first argument to its operation. Consumer code uses the public owner module:

let button: WebAPI.HTMLButtonElement.t = getButton()
let isValid = button->WebAPI.HTMLButtonElement.checkValidity

The corresponding binding follows the same shape:

type rec t = {
...DOMTree.htmlElement,
disabled: bool,
}
@send
external checkValidity: t => bool = "checkValidity"

Some DOM bindings reuse inherited operations through existing Impl helpers, but those are implementation details, not additional consumer namespaces. Do not add include directives just to expose internal modules. Prefer a concrete public owner module and selectively expose only the aliases consumers need.

Not every public module represents an interface value or exports t; some modules provide operations or auxiliary types only. Internal *Types modules are implementation details. See the API module structure and public API surface for the package’s current module layout.