1997-01-19 16:05:21 -08:00
|
|
|
# class point (int) =
|
|
|
|
val mutable x : int
|
|
|
|
method get_x : int
|
|
|
|
method move : int -> unit
|
|
|
|
end
|
|
|
|
# val p : point = <obj>
|
|
|
|
# - : int = 7
|
|
|
|
# - : unit = ()
|
|
|
|
# - : int = 10
|
|
|
|
# val q : point = <obj>
|
|
|
|
# - : int * int = 10, 17
|
|
|
|
# class color_point (int) (string) =
|
|
|
|
val c : string
|
|
|
|
val mutable x : int
|
1997-05-11 14:48:21 -07:00
|
|
|
method color : string
|
1997-01-19 16:05:21 -08:00
|
|
|
method get_x : int
|
|
|
|
method move : int -> unit
|
|
|
|
end
|
|
|
|
# val p' : color_point = <obj>
|
|
|
|
# - : int * string = 5, "red"
|
|
|
|
# val l : point list = [<obj>; <obj>]
|
|
|
|
# val get_x : < get_x : 'a; .. > -> 'a = <fun>
|
|
|
|
# val set_x : < set_x : 'a; .. > -> 'a = <fun>
|
|
|
|
# - : 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
|
1997-05-11 14:48:21 -07:00
|
|
|
method set_center : 'a -> unit
|
1997-01-19 16:05:21 -08:00
|
|
|
end
|
|
|
|
# class 'a circle ('a) =
|
|
|
|
constraint 'a = #point
|
|
|
|
val mutable center : 'a
|
|
|
|
method center : 'a
|
|
|
|
method move : int -> unit
|
1997-05-11 14:48:21 -07:00
|
|
|
method set_center : 'a -> unit
|
1997-01-19 16:05:21 -08:00
|
|
|
end
|
|
|
|
# val c : point circle = <obj>
|
|
|
|
val c' : color_point circle = <obj>
|
|
|
|
# class 'a color_circle ('a) =
|
|
|
|
constraint 'a = #color_point
|
|
|
|
val mutable center : 'a
|
|
|
|
method center : 'a
|
|
|
|
method color : string
|
1997-05-11 14:48:21 -07:00
|
|
|
method move : int -> unit
|
|
|
|
method set_center : 'a -> unit
|
1997-01-19 16:05:21 -08:00
|
|
|
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 = <obj>
|
|
|
|
# - : color_point circle = <obj>
|
|
|
|
# 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 = <obj>
|
|
|
|
# 7- : unit = ()
|
|
|
|
# class printable_color_point (int) (string) =
|
|
|
|
val c : string
|
|
|
|
val mutable x : int
|
1997-05-11 14:48:21 -07:00
|
|
|
method color : string
|
1997-01-19 16:05:21 -08:00
|
|
|
method get_x : int
|
|
|
|
method move : int -> unit
|
|
|
|
method print : unit
|
|
|
|
end
|
|
|
|
# val p' : printable_color_point = <obj>
|
|
|
|
# (7, red)- : unit = ()
|
|
|
|
# class functional_point (int) : 'a =
|
|
|
|
val x : int
|
|
|
|
method get_x : int
|
|
|
|
method move : int -> 'a
|
|
|
|
end
|
|
|
|
# val p : functional_point = <obj>
|
|
|
|
# - : int = 7
|
|
|
|
# - : int = 10
|
|
|
|
# - : int = 7
|
|
|
|
# - : (< get_x : int; move : int -> 'a; .. > as 'a) -> functional_point = <fun>
|
|
|
|
# class virtual 'a lst (unit) =
|
1997-05-11 14:48:21 -07:00
|
|
|
virtual hd : 'a
|
1997-01-19 16:05:21 -08:00
|
|
|
method iter : ('a -> unit) -> unit
|
1997-05-11 14:48:21 -07:00
|
|
|
method map : ('a -> 'a) -> 'a lst
|
1997-01-19 16:05:21 -08:00
|
|
|
virtual null : bool
|
1997-05-11 14:48:21 -07:00
|
|
|
method print : ('a -> unit) -> unit
|
1997-01-19 16:05:21 -08:00
|
|
|
virtual tl : 'a lst
|
|
|
|
end
|
|
|
|
class 'a nil (unit) =
|
|
|
|
method hd : 'a
|
|
|
|
method iter : ('a -> unit) -> unit
|
1997-05-11 14:48:21 -07:00
|
|
|
method map : ('a -> 'a) -> 'a lst
|
|
|
|
method null : bool
|
1997-01-19 16:05:21 -08:00
|
|
|
method print : ('a -> unit) -> unit
|
1997-05-11 14:48:21 -07:00
|
|
|
method tl : 'a lst
|
1997-01-19 16:05:21 -08:00
|
|
|
end
|
|
|
|
class 'a cons ('a) ('a lst) =
|
|
|
|
val h : 'a
|
|
|
|
val t : 'a lst
|
|
|
|
method hd : 'a
|
|
|
|
method iter : ('a -> unit) -> unit
|
1997-05-11 14:48:21 -07:00
|
|
|
method map : ('a -> 'a) -> 'a lst
|
|
|
|
method null : bool
|
1997-01-19 16:05:21 -08:00
|
|
|
method print : ('a -> unit) -> unit
|
1997-05-11 14:48:21 -07:00
|
|
|
method tl : 'a lst
|
1997-01-19 16:05:21 -08:00
|
|
|
end
|
|
|
|
# val l1 : int cons = <obj>
|
|
|
|
# (3::10::[])- : unit = ()
|
|
|
|
# val l2 : int lst = <obj>
|
|
|
|
# (4::11::[])- : unit = ()
|
|
|
|
# val map_list : ('a -> 'b) -> 'a lst -> 'b lst = <fun>
|
|
|
|
# val p1 : printable_color_point lst = <obj>
|
|
|
|
# ((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
|
1997-05-11 14:48:21 -07:00
|
|
|
method x : int
|
1997-01-19 16:05:21 -08:00
|
|
|
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 = <obj>
|
|
|
|
# val c : int_comparable = <obj>
|
|
|
|
# - : unit = ()
|
|
|
|
# val c2 : int_comparable2 = <obj>
|
|
|
|
# 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
|
1997-05-11 14:48:21 -07:00
|
|
|
method x : int
|
1997-01-19 16:05:21 -08:00
|
|
|
end
|
|
|
|
# val c3 : int_comparable3 = <obj>
|
|
|
|
# - : 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 = <fun>
|
|
|
|
# val pr : < x : int; .. > list -> unit = <fun>
|
|
|
|
# val l : int_comparable list = [<obj>; <obj>; <obj>]
|
|
|
|
# 5 2 4
|
|
|
|
- : unit = ()
|
|
|
|
# 2 4 5
|
|
|
|
- : unit = ()
|
|
|
|
# val l : int_comparable2 list = [<obj>; <obj>]
|
|
|
|
# 2 0
|
|
|
|
- : unit = ()
|
|
|
|
# 0 2
|
|
|
|
- : unit = ()
|
|
|
|
# val min : (#comparable as 'a) -> 'a -> 'a = <fun>
|
|
|
|
# - : int = 7
|
|
|
|
# - : int = 3
|
|
|
|
# class 'a link ('a) : 'b =
|
|
|
|
val mutable next : 'b option
|
|
|
|
val mutable x : 'a
|
1997-05-11 14:48:21 -07:00
|
|
|
method append : 'b option -> unit
|
1997-01-19 16:05:21 -08:00
|
|
|
method next : 'b option
|
|
|
|
method set_next : 'b option -> unit
|
1997-05-11 14:48:21 -07:00
|
|
|
method set_x : 'a -> unit
|
|
|
|
method x : 'a
|
1997-01-19 16:05:21 -08:00
|
|
|
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
|
1997-05-11 14:48:21 -07:00
|
|
|
method next : 'b option
|
1997-01-19 16:05:21 -08:00
|
|
|
method prev : 'b option
|
1997-05-11 14:48:21 -07:00
|
|
|
method set_next : 'b option -> unit
|
1997-01-19 16:05:21 -08:00
|
|
|
method set_prev : 'b option -> unit
|
1997-05-11 14:48:21 -07:00
|
|
|
method set_x : 'a -> unit
|
|
|
|
method x : 'a
|
1997-01-19 16:05:21 -08:00
|
|
|
end
|
|
|
|
# val fold_right : ('a -> 'b -> 'b) -> 'a #link option -> 'b -> 'b = <fun>
|
|
|
|
# class calculator (unit) : 'a =
|
|
|
|
val mutable acc : float
|
|
|
|
val mutable arg : float
|
|
|
|
val mutable equals : 'a -> float
|
|
|
|
method acc : float
|
|
|
|
method add : 'a
|
1997-05-11 14:48:21 -07:00
|
|
|
method arg : float
|
1997-01-19 16:05:21 -08:00
|
|
|
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
|
1997-05-11 14:48:21 -07:00
|
|
|
method arg : float
|
1997-01-19 16:05:21 -08:00
|
|
|
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
|
1997-05-11 14:48:21 -07:00
|
|
|
method enter : float -> calculator
|
1997-01-19 16:05:21 -08:00
|
|
|
method equals : float
|
1997-05-11 14:48:21 -07:00
|
|
|
method sub : calculator_sub
|
1997-01-19 16:05:21 -08:00
|
|
|
end
|
|
|
|
class calculator_add (float) (float) =
|
|
|
|
val acc : float
|
|
|
|
val arg : float
|
|
|
|
method add : calculator_add
|
1997-05-11 14:48:21 -07:00
|
|
|
method enter : float -> calculator
|
1997-01-19 16:05:21 -08:00
|
|
|
method equals : float
|
1997-05-11 14:48:21 -07:00
|
|
|
method sub : calculator_sub
|
1997-01-19 16:05:21 -08:00
|
|
|
end
|
|
|
|
class calculator_sub (float) (float) =
|
|
|
|
val acc : float
|
|
|
|
val arg : float
|
|
|
|
method add : calculator_add
|
1997-05-11 14:48:21 -07:00
|
|
|
method enter : float -> calculator
|
1997-01-19 16:05:21 -08:00
|
|
|
method equals : float
|
1997-05-11 14:48:21 -07:00
|
|
|
method sub : calculator_sub
|
1997-01-19 16:05:21 -08:00
|
|
|
end
|
|
|
|
# val calculator : calculator = <obj>
|
|
|
|
# - : float = 5
|
|
|
|
# - : float = 1.5
|
|
|
|
# - : float = 15
|
|
|
|
#
|