F # Interactive (fsi)에서는 AddPrinter
또는 AddPrinterTransformer
을 사용하여 대화 형 세션의 유형에 대해 예쁜 인쇄를 제공 할 수 있습니다. 제네릭 형식의 프린터를 추가하려면 어떻게합니까? 유형에 와일드 카드 _
를 사용하면 작동하지 않습니다제네릭 형식의 예쁜 프린터를 fsi에 추가하려면 어떻게합니까?
> fsi.AddPrinter(fun (A : MyList<_>) -> A.ToString());;
프린터는 사용되지 않습니다. 하나, 내가 원하는 것이 아니다
> fsi.AddPrinter(fun (A : MyList<'T>) -> A.ToString());;
fsi.AddPrinter(fun (A : MyList<'T>) -> A.ToString());;
-------------------------------^^
d:\projects\stdin(70,51): warning FS0064: This construct causes code
to be less generic than indicated by the type annotations. The type
variable 'T been constrained to be type 'obj'.
: 형식 매개 변수에 넣는
는 경고를 표시합니다.
저는 이것이 가능하지 않을 것이라고 확신합니다. 형식 인수에는 구체적인 형식이 필요합니다. – Daniel
'MyList <'T>'에 대해'ToString'을 오버라이드 할 수 있습니까? – Daniel