ファンクタの結果から型を導出する構造で使用されるシグネチャで型を参照するにはどうすればよいですか。poly インタープリターを使用した例を次に示します。
> signature Res = sig type f end;
signature Res = sig type f end
> functor F (A: sig type t end) : Res = struct datatype f = None | Some end;
functor F (A: sig type t end): Res
> structure S = struct local structure A = F(struct type t = int end) in type t = A.f list end end;
structure S: sig type t = A.f list end
まず、Af が構造に対してローカルである場合に、結果の署名に Af が表示される理由がわかりません。次に、この構造 S に一致する署名を作成するにはどうすればよいですか?
このようなものは機能しません:
signature SSig = sig type t = F(struct type t = int end).t list end
また、型 f がデータ型ではなく int の場合、最終的に S は f が署名によって隠されているのではなく int であることを認識するようになります。不透明な署名を使用してもintが表示されない場合でも、これは合理的な動作とは思えません。
> functor F (A: sig type t end) : Res = struct type f = int end;
functor F (A: sig type t end): Res
> structure S = struct local structure A = F(struct type t = int end) in type t = A.f list end end;
structure S: sig type t = int list end
> functor F(A: sig type t end):> Res = struct type f = int end;
functor F (A: sig type t end): Res
> structure S = struct local structure A = F(struct type t = int end) in type t = A.f list end end;
structure S: sig type t = A.f list end