Skip to content

Commit

Permalink
✨ Implement logging and fix a bug (still more to fix)
Browse files Browse the repository at this point in the history
  • Loading branch information
Zeta611 committed Jun 30, 2024
1 parent c2f7949 commit 33d9eb4
Show file tree
Hide file tree
Showing 10 changed files with 583 additions and 122 deletions.
2 changes: 1 addition & 1 deletion bin/dune
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(executable
(public_name react_trace)
(name main)
(libraries react_trace))
(libraries react_trace base logs logs.fmt fmt fmt.tty))
77 changes: 76 additions & 1 deletion bin/main.ml
Original file line number Diff line number Diff line change
@@ -1 +1,76 @@
let () = print_endline "Hello, World!"
open! Base
open React_trace

(*let test_prog =*)
(* let open Syntax in*)
(* Prog.Expr Expr.(View [ Const Unit ])*)

(*let test_prog =*)
(* let open Syntax in*)
(* Prog.( *)
(* Comp*)
(* ( { name = "C"; param = "x"; body = Expr.(View [ Const Unit ]) },*)
(* Expr Expr.(View [ App { fn = Var "C"; arg = Const Unit } ]) ))*)

(*let test_prog =*)
(* let open Syntax in*)
(* Prog.( *)
(* Comp*)
(* ( {*)
(* name = "C";*)
(* param = "x";*)
(* body =*)
(* Expr.( *)
(* Stt*)
(* {*)
(* label = 0;*)
(* stt = "s";*)
(* set = "setS";*)
(* init = Fn { param = "s"; body = Const (Int 42) };*)
(* body =*)
(* Seq*)
(* ( App*)
(* {*)
(* fn = Var "setS";*)
(* arg = Fn { param = "s"; body = Const (Int 42) };*)
(* },*)
(* View [ Const Unit ] );*)
(* });*)
(* },*)
(* Expr Expr.(View [ App { fn = Var "C"; arg = Const Unit } ]) ))*)

let test_prog =
let open Syntax in
Prog.(
Comp
( {
name = "C";
param = "x";
body =
Expr.(
Stt
{
label = 0;
stt = "s";
set = "setS";
init = Fn { param = "s"; body = Const (Int 42) };
body =
Seq
( Eff
(App
{
fn = Var "setS";
arg = Fn { param = "s"; body = Const (Int 43) };
}),
View [ Const Unit ] );
});
},
Expr Expr.(View [ App { fn = Var "C"; arg = Const Unit } ]) ))

let () =
Fmt_tty.setup_std_outputs ();
Logs.set_reporter (Logs_fmt.reporter ());
Logs.set_level (Some Logs.Debug);
Sexp.pp_hum Stdlib.Format.std_formatter (Syntax.Prog.sexp_of_t test_prog);
Interp.run test_prog;
Stdlib.exit (if Logs.err_count () > 0 then 1 else 0)
1 change: 1 addition & 0 deletions dune-project
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
dune
(ocaml-variants (= 5.1.1+effect-syntax))
base
fmt
logs
stdio)
(tags
Expand Down
4 changes: 4 additions & 0 deletions lib/batched_queue.ml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,13 @@ module type S = sig
val to_list : t -> elt list
val fold : t -> init:'acc -> f:('acc -> elt -> 'acc) -> 'acc
val iter : t -> f:(elt -> unit) -> unit
val sexp_of_t : t -> Sexp.t
end

module M (T : sig
type t

val sexp_of_t : t -> Sexp.t
end) : S with type elt := T.t = struct
type elt = T.t
type t = { f : elt list; r : elt list }
Expand Down Expand Up @@ -46,4 +49,5 @@ end) : S with type elt := T.t = struct
let to_list { f; r } = f @ List.rev r
let fold q = List.fold (to_list q)
let iter q = List.iter (to_list q)
let sexp_of_t t = List.sexp_of_t T.sexp_of_t (to_list t)
end
Loading

0 comments on commit 33d9eb4

Please sign in to comment.