@@ -33,10 +33,27 @@ open Kcas
33
33
34
34
(* * {1 Common interface} *)
35
35
36
- type !'a t
36
+ (* * Tagged GADT for doubly-linked lists. *)
37
+ type ('a, _) tdt =
38
+ | List : {
39
+ lhs : 'a cursor Loc .t ;
40
+ rhs : 'a cursor Loc .t ;
41
+ }
42
+ -> ('a , [> `List ]) tdt
43
+ | Node : {
44
+ lhs : 'a cursor Loc .t ;
45
+ rhs : 'a cursor Loc .t ;
46
+ value : 'a ;
47
+ }
48
+ -> ('a , [> `Node ]) tdt
49
+
50
+ (* * Refers to either a {!Node} or to a doubly-linked {!List}. *)
51
+ and 'a cursor = At : ('a, [< `List | `Node ]) tdt -> 'a cursor [@@ unboxed]
52
+
53
+ type 'a t = ('a , [ `List ]) tdt
37
54
(* * Type of a doubly-linked list containing {!node}s of type ['a]. *)
38
55
39
- type ! 'a node
56
+ type 'a node = ( 'a , [ `Node ]) tdt
40
57
(* * Type of a node containing a value of type ['a]. *)
41
58
42
59
val create : unit -> 'a t
@@ -58,6 +75,7 @@ module Xt :
58
75
Dllist_intf. Ops
59
76
with type 'a t := 'a t
60
77
with type 'a node := 'a node
78
+ with type 'a cursor := 'a cursor
61
79
with type ('x , 'fn ) fn := xt :'x Xt. t -> 'fn
62
80
with type ('x , 'fn ) blocking_fn := xt :'x Xt. t -> 'fn
63
81
(* * Explicit transaction log passing on doubly-linked lists. *)
@@ -68,6 +86,7 @@ include
68
86
Dllist_intf. Ops
69
87
with type 'a t := 'a t
70
88
with type 'a node := 'a node
89
+ with type 'a cursor := 'a cursor
71
90
with type ('x, 'fn) fn := 'fn
72
91
with type ('x , 'fn ) blocking_fn := ?timeoutf :float -> 'fn
73
92
0 commit comments