我在玩理性,我想尝试做 FFIdebug
来学习。我有这个代码
module Instance = {
type t;
external t : t = "" [@@bs.module];
};
module Debug = {
type t;
external createDebug : string => Instance.t = "debug" [@@bs.module];
};
我正在尝试像这样使用它
open Debug;
let instance = Debug.createDebug "app";
instance "Hello World !!!";
但我收到以下错误
Error: This expression has type Debug.Instance.t
This is not a function; it cannot be applied.
不instance
应该绑定到函数吗?我也试过
module Instance = {
type t;
external write : string => unit = "" [@@bs.send];
};
和
open Debug;
let instance = Debug.createDebug "app";
instance.write "Hello World !!!";
但我明白了
Error: Unbound record field write
我错过了什么?