# class point (int) = val mutable x : int method get_x : int method move : int -> unit end # val p : point = # - : int = 7 # - : unit = () # - : int = 10 # val q : point = # - : int * int = 10, 17 # class color_point (int) (string) = val c : string val mutable x : int method color : string method get_x : int method move : int -> unit end # val p' : color_point = # - : int * string = 5, "red" # val l : point list = [; ] # val get_x : < get_x : 'a; .. > -> 'a = # val set_x : < set_x : 'a; .. > -> 'a = # - : int list = [10; 5] # Characters 6-86: The type variable 'a is not bound in implicit type definition ref = < get : 'a; set : 'a -> unit > It should be captured by a class type parameter # class ref (int) = val mutable x : int method get : int method set : int -> unit end # class 'a ref ('a) = val mutable x : 'a method get : 'a method set : 'a -> unit end # - : int = 2 # class 'a circle ('a) = constraint 'a = < move : int -> unit; .. > val mutable center : 'a method center : 'a method move : int -> unit method set_center : 'a -> unit end # class 'a circle ('a) = constraint 'a = #point val mutable center : 'a method center : 'a method move : int -> unit method set_center : 'a -> unit end # val c : point circle = val c' : color_point circle = # class 'a color_circle ('a) = constraint 'a = #color_point val mutable center : 'a method center : 'a method color : string method move : int -> unit method set_center : 'a -> unit end # Characters 28-29: This expression has type point = < get_x : int; move : int -> unit > but is here used with type #color_point = < get_x : int; move : int -> unit; color : string; .. > # val c'' : color_point color_circle = # - : color_point circle = # Characters 1-4: This expression cannot be coerced to type point circle = < center : point; set_center : point -> unit; move : int -> unit >; it has type color_point color_circle = < center : color_point; set_center : color_point -> unit; move : int -> unit; color : string > but is here used with type < center : color_point; set_center : point -> unit; move : int -> unit; color : string > Type color_point = < get_x : int; move : int -> unit; color : string > is not compatible with type point = < get_x : int; move : int -> unit > # Characters 9-55: Type color_point color_circle = < center : color_point; set_center : color_point -> unit; move : int -> unit; color : string > is not a subtype of type point circle = < center : point; set_center : point -> unit; move : int -> unit > Type color_point -> unit is not a subtype of type point -> unit Type point = < get_x : int; move : int -> unit > is not a subtype of type color_point = < get_x : int; move : int -> unit; color : string > # class printable_point (int) = val mutable x : int method get_x : int method move : int -> unit method print : unit end # val p : printable_point = # 7- : unit = () # class printable_color_point (int) (string) = val c : string val mutable x : int method color : string method get_x : int method move : int -> unit method print : unit end # val p' : printable_color_point = # (7, red)- : unit = () # class functional_point (int) : 'a = val x : int method get_x : int method move : int -> 'a end # val p : functional_point = # - : int = 7 # - : int = 10 # - : int = 7 # - : (< get_x : int; move : int -> 'a; .. > as 'a) -> functional_point = # class virtual 'a lst (unit) = virtual hd : 'a method iter : ('a -> unit) -> unit method map : ('a -> 'a) -> 'a lst virtual null : bool method print : ('a -> unit) -> unit virtual tl : 'a lst end class 'a nil (unit) = method hd : 'a method iter : ('a -> unit) -> unit method map : ('a -> 'a) -> 'a lst method null : bool method print : ('a -> unit) -> unit method tl : 'a lst end class 'a cons ('a) ('a lst) = val h : 'a val t : 'a lst method hd : 'a method iter : ('a -> unit) -> unit method map : ('a -> 'a) -> 'a lst method null : bool method print : ('a -> unit) -> unit method tl : 'a lst end # val l1 : int cons = # (3::10::[])- : unit = () # val l2 : int lst = # (4::11::[])- : unit = () # val map_list : ('a -> 'b) -> 'a lst -> 'b lst = # val p1 : printable_color_point lst = # ((3, red)::(10, red)::[])- : unit = () # class virtual comparable (unit) : 'a = virtual leq : 'a -> bool end # class int_comparable (int) : 'a = val x : int method leq : 'a -> bool method x : int end # class int_comparable2 (int) : 'a = method leq : 'a -> bool method set_x : int -> unit method x : int end # class 'a sorted_list (unit) = constraint 'a = #comparable val mutable l : 'a list method add : 'a -> unit method hd : 'a end # val l : _#comparable sorted_list = # val c : int_comparable = # - : unit = () # val c2 : int_comparable2 = # Characters 7-9: This expression cannot be coerced to type int_comparable = < leq : int_comparable -> bool; x : int >; it has type int_comparable2 = < leq : int_comparable2 -> bool; x : int; set_x : int -> unit > but is here used with type < leq : int_comparable -> bool; x : int; set_x : int -> unit > Type int_comparable2 = < leq : int_comparable2 -> bool; x : int; set_x : int -> unit > is not compatible with type int_comparable = < leq : int_comparable -> bool; x : int > # - : unit = () # class int_comparable3 (int) = val mutable x : int method leq : int_comparable -> bool method setx : int -> unit method x : int end # val c3 : int_comparable3 = # - : unit = () # Characters 25-27: This expression has type int_comparable3 = < leq : int_comparable -> bool; x : int; setx : int -> unit > but is here used with type < leq : 'a -> bool; setx : int -> unit; x : int > as 'a Type int_comparable = < leq : int_comparable -> bool; x : int > is not compatible with type int_comparable3 = < leq : int_comparable -> bool; x : int; setx : int -> unit > # val sort : (#comparable as 'a) list -> 'a list = # val pr : < x : int; .. > list -> unit = # val l : int_comparable list = [; ; ] # 5 2 4 - : unit = () # 2 4 5 - : unit = () # val l : int_comparable2 list = [; ] # 2 0 - : unit = () # 0 2 - : unit = () # val min : (#comparable as 'a) -> 'a -> 'a = # - : int = 7 # - : int = 3 # class 'a link ('a) : 'b = val mutable next : 'b option val mutable x : 'a method append : 'b option -> unit method next : 'b option method set_next : 'b option -> unit method set_x : 'a -> unit method x : 'a end # class 'a double_link ('a) : 'b = val mutable next : 'b option val mutable prev : 'b option val mutable x : 'a method append : 'b option -> unit method next : 'b option method prev : 'b option method set_next : 'b option -> unit method set_prev : 'b option -> unit method set_x : 'a -> unit method x : 'a end # val fold_right : ('a -> 'b -> 'b) -> 'a #link option -> 'b -> 'b = # class calculator (unit) : 'a = val mutable acc : float val mutable arg : float val mutable equals : 'a -> float method acc : float method add : 'a method arg : float method enter : float -> 'a method equals : float method sub : 'a end # - : float = 5 # - : float = 1.5 # - : float = 15 # class calculator (unit) : 'a = val mutable acc : float val mutable arg : float val mutable equals : 'a -> float method acc : float method add : 'a method arg : float method enter : float -> 'a method equals : float method sub : 'a end # - : float = 5 # - : float = 1.5 # - : float = 15 # class calculator (float) (float) = val acc : float val arg : float method add : calculator_add method enter : float -> calculator method equals : float method sub : calculator_sub end class calculator_add (float) (float) = val acc : float val arg : float method add : calculator_add method enter : float -> calculator method equals : float method sub : calculator_sub end class calculator_sub (float) (float) = val acc : float val arg : float method add : calculator_add method enter : float -> calculator method equals : float method sub : calculator_sub end # val calculator : calculator = # - : float = 5 # - : float = 1.5 # - : float = 15 #