Skip to content

Commit

Permalink
feat(Scope): add register_printer
Browse files Browse the repository at this point in the history
  • Loading branch information
favonia committed Sep 21, 2023
1 parent f0edb79 commit 57fd043
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Scope.ml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@ struct

let try_with = Mod.try_with

let register_printer = Mod.register_printer

(* This overrides the default printer registered by Mod. *)
let () = register_printer @@ fun _ -> Some "Unhandled yuujinchou effect; use Yuujinchou.Scope.run"

module type Perform = Mod.Perform
module Perform = Mod.Perform
module Silence = Mod.Silence
Expand Down
3 changes: 3 additions & 0 deletions src/ScopeSigs.ml
Original file line number Diff line number Diff line change
Expand Up @@ -200,4 +200,7 @@ section {
A consequence of the semantic difference between {!val:run} and [try_with] is that
{!val:run} starts a fresh empty scope while [try_with] stays in the current scope.
*)

val register_printer : ([ `NotFound of context option * Trie.bwd_path | `Shadow of context option * Trie.bwd_path * (data * tag) * (data * tag) | `Hook of context option * Trie.bwd_path * hook * (data, tag) Trie.t ] -> string option) -> unit
(** [register_printer f] registers a printer [p] via {!val:Printexc.register_printer} to turn unhandled internal effects into strings for the OCaml runtime system to display them. See {!val:Yuujinchou.Modifier.S.register_printer}. *)
end

0 comments on commit 57fd043

Please sign in to comment.