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
|
type (_, _) t =
Any : ('a, 'b) t
| Eq : ('a, 'a) t
;;
module M :
sig
type s = private [> `A]
val eq : (s, [`A | `B]) t
end =
struct
type s = [`A | `B]
let eq = Eq
end;;
let f : (M.s, [`A | `B]) t -> string = function
| Any -> "Any"
;;
let () = print_endline (f M.eq) ;;
[%%expect{|
type (_, _) t = Any : ('a, 'b) t | Eq : ('a, 'a) t
module M : sig type s = private [> `A ] val eq : (s, [ `A | `B ]) t end
Line _, characters 39-64:
Warning 8: this pattern-matching is not exhaustive.
Here is an example of a case that is not matched:
Eq
val f : (M.s, [ `A | `B ]) t -> string = <fun>
Exception: Match_failure ("", 16, 39).
|}];;
module N :
sig
type s = private < a : int; .. >
val eq : (s, <a : int; b : bool>) t
end =
struct
type s = <a : int; b : bool>
let eq = Eq
end
;;
let f : (N.s, <a : int; b : bool>) t -> string = function
| Any -> "Any"
;;
[%%expect{|
module N :
sig
type s = private < a : int; .. >
val eq : (s, < a : int; b : bool >) t
end
Line _, characters 49-74:
Warning 8: this pattern-matching is not exhaustive.
Here is an example of a case that is not matched:
Eq
val f : (N.s, < a : int; b : bool >) t -> string = <fun>
|}];;
|