Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
favonia committed Oct 18, 2024
1 parent 0cdaae2 commit 4f8b7b2
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
9 changes: 5 additions & 4 deletions src/Debugger.ml
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
include DebuggerSigs

module Make () = struct
type 'a Effect.t +=
| Debug : Loctext.t -> unit Effect.t
| CallBegin : Loctext.t -> unit Effect.t
| CallEnd : Loctext.t -> unit Effect.t
type 'a Effect.t += Act : action -> unit Effect.t

let act ?loc s = emit_loctext @@ Loctext.make ?loc s

let emit_loctext t = Effect.perform @@ Debug t
let emit ?loc s = emit_loctext @@ Loctext.make ?loc s
Expand All @@ -21,4 +20,6 @@ module Make () = struct
Text.kmakef @@ fun t f ->
trace_open_loctext (Range.locate_opt loc t);
Fun.protect f ~finally:(fun () -> trace_close_loctext (Range.locate_opt loc t))

let run : act:(action -> unit) -> ('a ->
end
8 changes: 8 additions & 0 deletions src/DebuggerSigs.ml
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
module AttributeMap

type entry =
| Event of Loctext.t * Map
|
| Trace of [`Open | `Close] * Loctext.t

module type S =
sig
val log : entry -> unit
val emit : ?loc:Range.t -> string -> unit
val emitf : ?loc:Range.t -> ('a, Format.formatter, unit, unit) format4 -> 'a
val trace : ?loc:Range.t -> string -> (unit -> 'a) -> 'a
Expand Down
4 changes: 2 additions & 2 deletions src/Reporter.ml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ open Bwd.Infix

include ReporterSigs

module Make (Message : Message) : S with module Message := Message =
module Make (Message : Message) (*: S with module Message := Message*) =
struct

(* Backtraces *)
Expand Down Expand Up @@ -67,7 +67,7 @@ struct

(* Algebraic effects *)

let run ?init_loc ?(init_backtrace=Emp) ~emit ~fatal f =
let run ?init_loc ?(init_backtrace=Emp) ?debug ~emit ~fatal f =
Traces.run ~env:(init_loc, init_backtrace) @@ fun () ->
Effect.Deep.match_with f () @@ handler ~emit ~fatal

Expand Down

0 comments on commit 4f8b7b2

Please sign in to comment.