File: deep.ml

package info (click to toggle)
ocaml 5.4.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 44,372 kB
  • sloc: ml: 370,196; ansic: 52,820; sh: 27,396; asm: 5,462; makefile: 3,679; python: 974; awk: 278; javascript: 273; perl: 59; fortran: 21; cs: 9
file content (98 lines) | stat: -rw-r--r-- 2,702 bytes parent folder | download | duplicates (3)
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
87
88
89
90
91
92
93
94
95
96
97
98
(* TEST
 expect;
*)

module M : sig
  val x : bool * int
end = struct
  let x = false , "not an int"
end
[%%expect{|
Lines 3-5, characters 6-3:
3 | ......struct
4 |   let x = false , "not an int"
5 | end
Error: Signature mismatch:
       Modules do not match:
         sig val x : bool * string end
       is not included in
         sig val x : bool * int end
       Values do not match:
         val x : bool * string
       is not included in
         val x : bool * int
       The type "bool * string" is not compatible with the type "bool * int"
       Type "string" is not compatible with type "int"
|}]

module T : sig
  val f : int -> (float * string option) list
end = struct
  let f x = x + List.length [0.0, Some true]
end
[%%expect{|
Lines 3-5, characters 6-3:
3 | ......struct
4 |   let f x = x + List.length [0.0, Some true]
5 | end
Error: Signature mismatch:
       Modules do not match:
         sig val f : int -> int end
       is not included in
         sig val f : int -> (float * string option) list end
       Values do not match:
         val f : int -> int
       is not included in
         val f : int -> (float * string option) list
       The type "int -> int" is not compatible with the type
         "int -> (float * string option) list"
       Type "int" is not compatible with type "(float * string option) list"
|}]

(* Alpha-equivalence *)
module T : sig
  val f : ('a list * 'b list -> int)
end = struct
  let f : ('c list * 'd option  -> int) = assert false
end
[%%expect{|
Lines 3-5, characters 6-3:
3 | ......struct
4 |   let f : ('c list * 'd option  -> int) = assert false
5 | end
Error: Signature mismatch:
       Modules do not match:
         sig val f : 'c list * 'd option -> int end
       is not included in
         sig val f : 'a list * 'b list -> int end
       Values do not match:
         val f : 'c list * 'd option -> int
       is not included in
         val f : 'a list * 'b list -> int
       The type "'a list * 'b option -> int" is not compatible with the type
         "'a list * 'c list -> int"
       Type "'b option" is not compatible with type "'c list"
|}]

module T : sig
  type t = int * float
end = struct
  type t = bool * float
end
[%%expect{|
Lines 3-5, characters 6-3:
3 | ......struct
4 |   type t = bool * float
5 | end
Error: Signature mismatch:
       Modules do not match:
         sig type t = bool * float end
       is not included in
         sig type t = int * float end
       Type declarations do not match:
         type t = bool * float
       is not included in
         type t = int * float
       The type "bool * float" is not equal to the type "int * float"
       Type "bool" is not equal to type "int"
|}]