F# Interactive (fsi) では、AddPrinter
orを使用AddPrinterTransformer
して、インタラクティブ セッションで型のプリティ プリントを提供できます。ジェネリック型にそのようなプリンターを追加するにはどうすればよいですか? タイプにワイルドカード_
を使用しても機能しません:
> 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'.
これは私が望むものでもありません。