Commit | Line | Data |
---|---|---|
7f918cf1 CE |
1 | (* sharing.sml *) |
2 | ||
3 | (* Checks treatment of sharing constraints. *) | |
4 | ||
5 | signature S = | |
6 | sig | |
7 | type t | |
8 | type s = t | |
9 | sharing type t = s | |
10 | end; | |
11 | ||
12 | signature T = (* from SML/NJ doc *) | |
13 | sig | |
14 | type s | |
15 | structure A : | |
16 | sig | |
17 | datatype d = D of s | |
18 | datatype t = K | |
19 | end | |
20 | sharing type s = A.t | |
21 | end; | |
22 | ||
23 | (* Check that multiple sharing equations is all pairs. *) | |
24 | signature S = | |
25 | sig | |
26 | structure T: sig end | |
27 | structure U: sig type t = int end | |
28 | sharing T = U | |
29 | end | |
30 | ||
31 | functor F (structure A: sig type t end | |
32 | structure B: sig end | |
33 | structure C: sig type t end | |
34 | sharing A = B = C) = | |
35 | struct | |
36 | val _: A.t -> C.t = fn x => x | |
37 | end | |
38 | ||
39 | functor F (structure A: sig type t end | |
40 | structure B: sig type u end | |
41 | structure C: sig type t end | |
42 | structure D: sig type u end | |
43 | sharing A = B = C = D) = | |
44 | struct | |
45 | val _: A.t -> C.t = fn x => x | |
46 | val _: B.u -> D.u = fn x => x | |
47 | end | |
48 | ||
49 | (* Check that sharing doesn't mistakenly share structures that only differ in | |
50 | * free flexible tycons. | |
51 | *) | |
52 | ||
53 | signature T = | |
54 | sig | |
55 | type t | |
56 | structure U: | |
57 | sig | |
58 | val x: t | |
59 | end | |
60 | end | |
61 | ||
62 | structure S: | |
63 | sig | |
64 | structure T1: T | |
65 | structure T2: T | |
66 | sharing T1.U = T2.U | |
67 | end = | |
68 | struct | |
69 | structure T1 = | |
70 | struct | |
71 | type t = int | |
72 | structure U = | |
73 | struct | |
74 | val x = 13 | |
75 | end | |
76 | end | |
77 | structure T2 = | |
78 | struct | |
79 | type t = real | |
80 | structure U = | |
81 | struct | |
82 | val x = 13.0 | |
83 | end | |
84 | end | |
85 | end | |
86 | ; |