@@ -33,10 +33,27 @@ open Kcas
3333
3434(* * {1 Common interface} *)
3535
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
3754(* * Type of a doubly-linked list containing {!node}s of type ['a]. *)
3855
39- type ! 'a node
56+ type 'a node = ( 'a , [ `Node ]) tdt
4057(* * Type of a node containing a value of type ['a]. *)
4158
4259val create : unit -> 'a t
@@ -58,6 +75,7 @@ module Xt :
5875 Dllist_intf. Ops
5976 with type 'a t := 'a t
6077 with type 'a node := 'a node
78+ with type 'a cursor := 'a cursor
6179 with type ('x , 'fn ) fn := xt :'x Xt. t -> 'fn
6280 with type ('x , 'fn ) blocking_fn := xt :'x Xt. t -> 'fn
6381(* * Explicit transaction log passing on doubly-linked lists. *)
@@ -68,6 +86,7 @@ include
6886 Dllist_intf. Ops
6987 with type 'a t := 'a t
7088 with type 'a node := 'a node
89+ with type 'a cursor := 'a cursor
7190 with type ('x, 'fn) fn := 'fn
7291 with type ('x , 'fn ) blocking_fn := ?timeoutf :float -> 'fn
7392
0 commit comments