2015-10-09 47 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) 

是类型检查。