@send to create interop with builder patterns from libraries?

I’d like to understand how to create interop for something like the code at the bottom of this post using @send so it could be something like this: program → name(“foo”) → description(“bar”) etc

I think I understand the basics of @send, but I’m struggling to define functions that belong to the equivalent of name or description in my example. They belong to the program instance, but I have hard time defining that in my interop

I get stuck trying things like this that doesn’t work:
external name: () => myProgramType = “name??”

any advice, examples, or documentation I’m missing? :slight_smile:

const { Command } = require('commander');
const program = new Command();

  .description('CLI to some JavaScript string utilities')

  .description('Split a string into substrings and display as an array')
  .argument('<string>', 'string to split')
  .option('--first', 'display just the first substring')
  .option('-s, --separator <char>', 'separator character', ',')
  .action((str, options) => {
    const limit = options.first ? 1 : undefined;
    console.log(str.split(options.separator, limit));


@send tag expexcts the function to take instance as first argument, and “send” rest.

type program

@module("commander") @new
external make: unit => t = "Command"

external name: (t, string) => t = "name"

external description: (t, string) => "description"

let pogram =

Works great, thanks!