From 89e2e30fb206e7638bd18f907b73c289054a5109 Mon Sep 17 00:00:00 2001 From: Josh Berdine Date: Tue, 5 Mar 2019 07:04:28 -0800 Subject: [PATCH] [sledge] Use more standard interface for Trace.parse Summary: `('a, exn) result` is a more widely used type than with something custom in place of `exn`, e.g. by the `Result` operations. Reviewed By: mbouaziz Differential Revision: D14322627 fbshipit-source-id: e2ed167ed --- sledge/src/config.ml | 6 +++++- sledge/src/trace/trace.ml | 2 +- sledge/src/trace/trace.mli | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/sledge/src/config.ml b/sledge/src/config.ml index 50e799ed9..58d319d78 100644 --- a/sledge/src/config.ml +++ b/sledge/src/config.ml @@ -8,6 +8,10 @@ (** Configuration options *) let trace_conv = + let parse s = + Trace.parse s + |> Result.map_error ~f:(fun _ -> `Msg ("Invalid trace spec: " ^ s)) + in let print fs {trace_all; trace_mods_funs} = let pf fmt = Format.fprintf fs fmt in if trace_all then pf "*" @@ -22,7 +26,7 @@ let trace_conv = if fun_enabled then pf "+%s.%s" mod_name fun_name else pf "-%s.%s" mod_name fun_name ) ) in - (Trace.parse, print) + (parse, print) type t = { compile_only: bool diff --git a/sledge/src/trace/trace.ml b/sledge/src/trace/trace.ml index b90460686..cae90f84c 100644 --- a/sledge/src/trace/trace.ml +++ b/sledge/src/trace/trace.ml @@ -75,7 +75,7 @@ let parse s = ~data:{trace_mod= Some enabled; trace_funs= default} ) in Ok {none with trace_mods_funs} - with Assert_failure _ -> Error (`Msg ("Invalid trace spec: " ^ s)) + with Assert_failure _ as exn -> Error exn let init ?(margin = 300) ~config:c () = Format.set_margin margin ; diff --git a/sledge/src/trace/trace.mli b/sledge/src/trace/trace.mli index 8fd32d7a3..66d5f80dd 100644 --- a/sledge/src/trace/trace.mli +++ b/sledge/src/trace/trace.mli @@ -23,7 +23,7 @@ type config = val none : config val all : config -val parse : string -> (config, [> `Msg of string]) result +val parse : string -> (config, exn) result val init : ?margin:int -> config:config -> unit -> unit (** Initialize the configuration of debug tracing. *)