我做了一个类方法,我想要这种类型:
unit -> (dir -> 'b)
但我的实际方法:
method iter () = fun x -> match x with
| Up -> if (Stack.is_empty pz) then raise Stack.Empty else if (Stack.length pz = 1) then failwith "Cannot go up" else (ignore (Stack.pop pz) ; {< a = (Stack.top pz) >})
| Down(v) -> match (Stack.top pz) with
| Noeud(o, {contents = []}) -> raise Not_found
| Noeud(o, {contents = l}) -> if mem_assoc v l then ((Stack.push (assoc v l) pz) ; {< a = (Stack.top pz) >} ) else raise Not_found
有类型unit -> dir -> 'b
我怎样才能使它成为第一种类型?
以下是自定义类型:
type 'a arbre = Noeud of 'a option ref * (char * 'a arbre) list ref
type dir = Up | Down of char
编辑:我需要这个,所以它可以符合某个接口,并且由于类型不匹配,它不会编译。谢谢!