How can I refer to a type in a signature used in a structure that derives the type from the result of a functor. Here is an example using the poly interpreter:
> 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
First, I don't understand why A.f shows up in the resulting signature when it is local to the structure. Second, how can I create a signature that matches this structure S?
Something like this does not work:
signature SSig = sig type t = F(struct type t = int end).t list end
Also, if the type f is an int instead of a datatype, somehow S ultimately becomes aware that f is an int instead of it being hidden by the signature. This doesn't seem like reasonable behavior even if using opaque signatures doesn't show the 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