@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:
@module(“commander”)
external name: () => myProgramType = “name??”

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

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

program
  .name('string-util')
  .description('CLI to some JavaScript string utilities')
  .version('0.8.0');

program.command('split')
  .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));
  });

program.parse();

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

type program

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

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

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

let pogram =
  make()
  ->name("string-util")
  ->description("...")

Works great, thanks!