-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
35 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
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 | ||
|
||
let emit_loctext t = Effect.perform @@ Debug t | ||
let emit ?loc s = emit_loctext @@ Loctext.make ?loc s | ||
let emitf ?loc = Loctext.kmakef ?loc emit_loctext | ||
|
||
let trace_open_loctext t = Effect.perform @@ CallBegin t | ||
let trace_close_loctext t = Effect.perform @@ CallEnd t | ||
|
||
let trace ?loc s f = | ||
trace_open_loctext (Loctext.make ?loc s); | ||
Fun.protect f | ||
~finally:(fun () -> trace_close_loctext (Loctext.make ?loc s)) | ||
let tracef ?loc = | ||
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)) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
include module type of DebuggerSigs | ||
|
||
module Make () : S |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
module type S = | ||
sig | ||
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 | ||
val tracef : ?loc:Range.t -> ('b, Format.formatter, unit, (unit -> 'a) -> 'a) format4 -> 'b | ||
val run : emit:(Loctext.t -> unit) -> trace:([`Open | `Close] -> Loctext.t -> unit) -> (unit -> 'a) -> 'a | ||
end |