blob: 924d63b553cf8f80db93cf0457350890e460dfca (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
(* TEST
flags = "-dshape";
expect;
*)
(* We depart slightly from the example in the PLDI'19 paper, which actually
doesn't type... *)
module type Stringable = sig
type t
val to_string : t -> string
end
[%%expect{|
{
"Stringable"[module type] -> <.2>;
}
module type Stringable = sig type t val to_string : t -> string end
|}]
module Pair (X : Stringable) (Y : Stringable) = struct
type t = X.t * Y.t
let to_string (x, y) =
X.to_string x ^ " " ^ Y.to_string y
end
[%%expect{|
{
"Pair"[module] ->
Abs<.9>(X/281, Y/282, {
"t"[type] -> <.5>;
"to_string"[value] -> <.6>;
});
}
module Pair :
functor (X : Stringable) (Y : Stringable) ->
sig type t = X.t * Y.t val to_string : X.t * Y.t -> string end
|}]
module Int = struct
type t = int
let to_string i = string_of_int i
end
[%%expect{|
{
"Int"[module] -> {<.13>
"t"[type] -> <.10>;
"to_string"[value] -> <.11>;
};
}
module Int : sig type t = int val to_string : int -> string end
|}]
module String = struct
type t = string
let to_string s = s
end
[%%expect{|
{
"String"[module] -> {<.17>
"t"[type] -> <.14>;
"to_string"[value] -> <.15>;
};
}
module String : sig type t = string val to_string : 'a -> 'a end
|}]
module P = Pair(Int)(Pair(String)(Int))
[%%expect{|
{
"P"[module] -> {<.18>
"t"[type] -> <.5>;
"to_string"[value] -> <.6>;
};
}
module P :
sig
type t = Int.t * Pair(String)(Int).t
val to_string : Int.t * Pair(String)(Int).t -> string
end
|}];;
P.to_string (0, ("!=", 1))
[%%expect{|
{
}
- : string = "0 != 1"
|}]
|