diff --git a/src/ast/binary_encoder.ml b/src/ast/binary_encoder.ml index e8b361e4..02bbc7e4 100644 --- a/src/ast/binary_encoder.ml +++ b/src/ast/binary_encoder.ml @@ -762,15 +762,11 @@ let encode let write_file outfile filename content = let _dir, filename = Fpath.split_base filename in let filename = Fpath.set_ext "wasm" filename in - match outfile with - | Some name -> Bos.OS.File.write name content - | None -> Bos.OS.File.write filename content + Bos.OS.File.write (Option.value outfile ~default:filename) content let convert (outfile : Fpath.t option) (filename : Fpath.t) ~unsafe ~optimize m = Log.debug0 "bin encoding ...@\n"; - let+ m = Compile.Text.until_optimize ~unsafe ~optimize m in + let* m = Compile.Text.until_optimize ~unsafe ~optimize m in let content = encode m in - match write_file outfile filename content with - | Error _ -> raise Exit - | Ok _ -> () + write_file outfile filename content diff --git a/src/cmd/cmd_opt.ml b/src/cmd/cmd_opt.ml index 9be58f58..42fe99fa 100644 --- a/src/cmd/cmd_opt.ml +++ b/src/cmd/cmd_opt.ml @@ -16,6 +16,4 @@ let print_or_emit ~unsafe file outfile = let cmd debug unsafe file outfile = if debug then Log.debug_on := true; - match print_or_emit ~unsafe file outfile with - | Error _ -> raise Exit - | Ok _ -> Ok () + Result.bind (print_or_emit ~unsafe file outfile) (fun _ -> Ok ())