Skip to content

Commit

Permalink
🚧 Recorder is now a middleware intercepting effects
Browse files Browse the repository at this point in the history
  • Loading branch information
Zeta611 committed Nov 28, 2024
1 parent 18a0d27 commit 9656881
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 27 deletions.
19 changes: 10 additions & 9 deletions bin/js/recorder.ml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
open Stdlib.Effect
open Stdlib.Effect.Deep
open React_trace
open Interp_effects
include Recorder_intf

(* TODO: Replace the dummy string with an actual recording type *)
Expand All @@ -15,25 +16,25 @@ let event_h =
effc =
(fun (type a) (eff : a t) ->
match eff with
| Evt_update_st (path, label, (v, q)) ->
| Update_st (path, label, (v, q)) ->
Some
(fun (k : (a, _) continuation) ~(recording : recording) ->
ignore (path, label, v, q);
let () = perform (Update_st (path, label, (v, q))) in
continue k () ~recording)
| Evt_set_dec (path, dec) ->
| Set_dec (path, dec) ->
Some
(fun (k : (a, _) continuation) ~(recording : recording) ->
ignore (path, dec);
let () = perform (Set_dec (path, dec)) in
continue k () ~recording)
| Evt_enq_eff (path, clos) ->
| Enq_eff (path, clos) ->
Some
(fun (k : (a, _) continuation) ~(recording : recording) ->
ignore (path, clos);
let () = perform (Enq_eff (path, clos)) in
continue k () ~recording)
| Evt_alloc_pt path ->
| Alloc_pt ->
Some
(fun (k : (a, _) continuation) ~(recording : recording) ->
ignore path;
continue k () ~recording)
let path = perform Alloc_pt in
continue k path ~recording)
| _ -> None);
}
19 changes: 10 additions & 9 deletions lib/default_recorder.ml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
open Stdlib.Effect
open Stdlib.Effect.Deep
open Interp_effects
include Recorder_intf

type recording = unit
Expand All @@ -13,25 +14,25 @@ let event_h =
effc =
(fun (type a) (eff : a t) ->
match eff with
| Evt_update_st (path, label, (v, q)) ->
| Update_st (path, label, (v, q)) ->
Some
(fun (k : (a, _) continuation) ~(recording : recording) ->
ignore (path, label, v, q);
let () = perform (Update_st (path, label, (v, q))) in
continue k () ~recording)
| Evt_set_dec (path, dec) ->
| Set_dec (path, dec) ->
Some
(fun (k : (a, _) continuation) ~(recording : recording) ->
ignore (path, dec);
let () = perform (Set_dec (path, dec)) in
continue k () ~recording)
| Evt_enq_eff (path, clos) ->
| Enq_eff (path, clos) ->
Some
(fun (k : (a, _) continuation) ~(recording : recording) ->
ignore (path, clos);
let () = perform (Enq_eff (path, clos)) in
continue k () ~recording)
| Evt_alloc_pt path ->
| Alloc_pt ->
Some
(fun (k : (a, _) continuation) ~(recording : recording) ->
ignore path;
continue k () ~recording)
let path = perform Alloc_pt in
continue k path ~recording)
| _ -> None);
}
9 changes: 0 additions & 9 deletions lib/recorder_intf.ml
Original file line number Diff line number Diff line change
@@ -1,14 +1,5 @@
open! Core
open Stdlib.Effect
open Stdlib.Effect.Deep
open Syntax
open Concrete_domains

type _ Stdlib.Effect.t +=
| Evt_update_st : (Path.t * Label.t * (value * Job_q.t)) -> unit t
| Evt_set_dec : (Path.t * decision) -> unit t
| Evt_enq_eff : (Path.t * clos) -> unit t
| Evt_alloc_pt : Path.t -> unit t

module type Intf = sig
type recording
Expand Down

0 comments on commit 9656881

Please sign in to comment.