blob: 34f37b1c861d0df8e2b874690e9233a0f3a9bb34 (
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
|
(* TEST
* expect *)
module type Vector_space = sig
type t
type scalar
val scale : scalar -> t -> t
end;;
[%%expect{|
module type Vector_space =
sig type t type scalar val scale : scalar -> t -> t end
|}];;
module type Scalar = sig
type t
include Vector_space with type t := t
and type scalar = t
end;;
[%%expect{|
module type Scalar =
sig type t type scalar = t val scale : scalar -> t -> t end
|}];;
module type Linear_map = sig
type ('a, 'b) t
val scale :
(module Vector_space with type t = 'a and type scalar = 'l) ->
'l -> ('a, 'a) t
end;;
[%%expect{|
module type Linear_map =
sig
type ('a, 'b) t
val scale :
(module Vector_space with type scalar = 'l and type t = 'a) ->
'l -> ('a, 'a) t
end
|}];;
module Primitive(Linear_map : Linear_map) = struct
let f (type s) (s : (module Scalar with type t = s)) x =
Linear_map.scale s x
end;;
[%%expect{|
Line 3, characters 21-22:
3 | Linear_map.scale s x
^
Error: This expression has type (module Scalar with type t = s)
but an expression was expected of type
(module Vector_space with type scalar = 'a and type t = 'b)
|}];;
|