私は理由で遊んでいます。私はdebug
のFFIを学びたいと思っていました。私はこのコードモジュール全体を関数としてバインドする方法は?
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
を取得しますか?
は 'Instance.t'は' Instance'モジュールで定義された抽象型であるあなたが使用しようとしている何
は実際にはレコードです。これはモジュールの一種ではありません。モジュールを値として本当に扱いたい場合は、ファーストクラスのモジュール(http://caml.inria.fr/pub/docs/manual-ocaml-400/manual021.html#toc81)を使用する必要があります。 – camlspotter