2015-10-09 63 views

回答

4

參見OCaml的參考手冊(http://caml.inria.fr/pub/docs/manual-ocaml/types.html)的#-types部分。

函數類型#node -> t需要類node或其子類的對象,並返回t

例如,

class c = object method x = 1 end 

let g : #c -> int = fun o -> o#x 

功能g可以採取c類或它的子類的一個對象。 #c因此的< x : int; ..>的縮寫,

let h = (g : < x : int; ...> -> int) 

是類型檢查。