Not sure I fully follow what you’re after, but here’s an example:
module Storage = {
// TODO: Fill in
type t = unit
}
module StorageManager = {
type t
type redisConfig = {prefix?: string, password?: string, ip?: string}
type config = {redis?: redisConfig}
@new @module("xyz")
external make: config => t = "default"
@send external storage: (t, {..}) => Storage.t = "Storage"
}
let storageManager = StorageManager.make({
redis: {prefix: "storage:file:", password: "password", ip: "ip"},
})
storageManager->StorageManager.storage({"path": "test"})
Compiles to:
// Generated by ReScript, PLEASE EDIT WITH CARE
import Xyz from "xyz";
var $$Storage = {};
var StorageManager = {};
var storageManager = new Xyz({
redis: {
prefix: "storage:file:",
password: "password",
ip: "ip"
}
});
storageManager.Storage({
path: "test"
});
export {
$$Storage ,
StorageManager ,
storageManager ,
}
/* storageManager Not a pure module */