@@ -52,14 +52,13 @@ module FCMBasedHeap : HEAP = functor (Cell : CELL) -> struct
5252 (* [EFF] declares a pair of effect names [Get] and [Set]. *)
5353 module type EFF = sig
5454 type t
55- effect Get : t
56- effect Set : t -> unit
55+ type _ eff + = Get : t eff | Set : t -> unit eff
5756 end
5857 (* ['a t] is the type of first-class [EFF] modules.
5958 The effect-name declarations in [EFF] become first-class. *)
6059 type 'a t = (module EFF with type t = 'a )
6160
62- effect Ref : 'a -> 'a t
61+ type _ eff + = Ref : 'a -> 'a t unit
6362
6463 let ref init = perform (Ref init)
6564 let (!) : type a. a t -> a =
@@ -72,21 +71,20 @@ module FCMBasedHeap : HEAP = functor (Cell : CELL) -> struct
7271 let fresh (type a ) () : a t =
7372 (module struct
7473 type t = a
75- effect Get : t
76- effect Set : t -> unit
74+ type _ eff + = Get : t eff | Set : t -> unit eff
7775 end )
7876
7977 let run main =
8078 try main () with
81- effect (Ref init ) k ->
79+ effect (Ref init ), k ->
8280 (* trick to name the existential type introduced by the matching: *)
8381 (init, k) |> fun (type a ) (init , k : a * (a t, _) continuation ) ->
8482 let module E = (val (fresh () : a t)) in
8583 let module C = Cell (struct type t = a end ) in
8684 let main () =
8785 try continue k (module E ) with
88- | effect E. Get k -> continue k (C. get() : a)
89- | effect (E. Set y ) k -> continue k (C. set y)
86+ | effect E. Get , k -> continue k (C. get() : a)
87+ | effect (E. Set y ), k -> continue k (C. set y)
9088 in
9189 snd (C. run ~init main)
9290end
@@ -108,15 +106,15 @@ module RecordBasedHeap : HEAP = functor (Cell : CELL) -> struct
108106 get : unit -> 'a ;
109107 set : 'a -> unit ;
110108 }
111- effect Ref : 'a -> 'a t
109+ type _ eff + = Ref : 'a -> 'a t eff
112110
113111 let ref init = perform (Ref init)
114112 let (!) {get; _} = get()
115113 let (:=) {set; _} y = set y
116114
117115 let run main =
118116 try main () with
119- | effect (Ref init ) k ->
117+ | effect (Ref init ), k ->
120118 (init, k) |> fun (type a ) ((init , k ) : a * (a t , _ ) continuation ) ->
121119 let open Cell (struct type t = a end) in
122120 snd (run ~init (fun _ -> continue k {get; set}))
0 commit comments