펑터의 결과에서 형식을 파생하는 구조에서 사용되는 서명의 형식을 어떻게 참조 할 수 있습니까? 다음은 폴리 인터프리터를 사용하는 예입니다.서명에 펑터의 결과가 포함 된 형식을 참조합니다.
> 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
우선 구조체에 로컬 인 경우 A.f가 결과 서명에 나타나는 이유를 알 수 없습니다. 둘째, 어떻게이 구조 S와 일치하는 서명을 만들 수 있습니까?
이런 식으로 뭔가가 작동하지 않습니다
signature SSig = sig type t = F(struct type t = int end).t list end
을 또한, F 형 대신 데이터 형식의 INT 경우, 어떻게 든 궁극적으로 f는 대신이 서명에 의해 숨겨진되고 지능이 있음을 알게 될 S . 불투명 한 시그니처를 사용하더라도 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
나는 이것을해야 할지도 모른다고 걱정했다. 문제는 SSig에서 타입 t를 불투명하게하고 싶지는 않지만, 소비자가 그것에 접근하기를 원하지 않기 때문에 서명에 R을 포함하고 싶지 않다는 것입니다. 나는 불투명 한 타입의 f = R.f로 비슷한 일을 할 수 있었지만 서명에 그것을 포함 시켜야만했고 서명이 더러워졌습니다. 마지막으로, Res는 f의 타입 정의를 제공하지 않기 때문에 혼란 스러웠습니다. 하지만 F가 불투명 한 서명을 사용하지 않았기 때문에 SML이 S에서 사용할 수있는 것을 꺼낼 수 있다고 생각합니다. – eatonphil