about summary refs log tree commit diff
path: root/users/wpcarro/scratch/compiler/inference.ml
diff options
context:
space:
mode:
authorWilliam Carroll <wpcarro@gmail.com>2022-10-24T21·51-0400
committerwpcarro <wpcarro@gmail.com>2022-10-25T03·59+0000
commit1e9c3955bf2c17206c6dd536ebaf96a7e6f4f22d (patch)
tree3ad05bbd2f8c6fc7ccfe8e6e507fe386d9957a75 /users/wpcarro/scratch/compiler/inference.ml
parenta8876a4cdaaf0a1f051fefad436e08d983b402e2 (diff)
refactor(wpcarro/compiler): Modularize debug fns r/5195
Define `debug.ml` and `prettify.ml` to clean-up some code.

Change-Id: Iee2e1ed666f2ccb5e56cc50054ca85b8ba513f3b
Reviewed-on: https://cl.tvl.fyi/c/depot/+/7078
Tested-by: BuildkiteCI
Reviewed-by: wpcarro <wpcarro@gmail.com>
Diffstat (limited to 'users/wpcarro/scratch/compiler/inference.ml')
-rw-r--r--users/wpcarro/scratch/compiler/inference.ml13
1 files changed, 7 insertions, 6 deletions
diff --git a/users/wpcarro/scratch/compiler/inference.ml b/users/wpcarro/scratch/compiler/inference.ml
index 52838f85e649..c9d4ba9c78ff 100644
--- a/users/wpcarro/scratch/compiler/inference.ml
+++ b/users/wpcarro/scratch/compiler/inference.ml
@@ -7,6 +7,7 @@
  ******************************************************************************)
 
 open Types
+open Debug
 
 (*******************************************************************************
  * Library
@@ -107,25 +108,25 @@ let rec unify (a : _type) (b : _type) : substitution option =
       let* s1 = unify a c in
       let* s2 = unify (substitute_type s1 b) (substitute_type s1 d) in
       let s3 = compose_substitutions [s1; s2] in
-      s1 |> Types.debug_substitution |> Printf.sprintf "s1: %s\n" |> print_string;
-      s2 |> Types.debug_substitution |> Printf.sprintf "s2: %s\n" |> print_string;
-      s3 |> Types.debug_substitution |> Printf.sprintf "s3: %s\n" |> print_string;
+      s1 |> Debug.substitution |> Printf.sprintf "s1: %s\n" |> print_string;
+      s2 |> Debug.substitution |> Printf.sprintf "s2: %s\n" |> print_string;
+      s3 |> Debug.substitution |> Printf.sprintf "s3: %s\n" |> print_string;
       Some s3
   | _ -> None
 
 let print_env (env : env) =
-  Printf.sprintf "env: %s\n" (Types.debug_env env)
+  Printf.sprintf "env: %s\n" (Debug.env env)
   |> print_string
 
 let print_val (x : value) =
-  Printf.sprintf "val: %s\n" (Types.debug_value x)
+  Printf.sprintf "val: %s\n" (Debug.value x)
   |> print_string
 
 let print_inference (x : inference option) =
   match x with
   | None -> "no inference\n" |> print_string
   | Some x ->
-     Printf.sprintf "inf: %s\n" (Types.debug_inference x)
+     Printf.sprintf "inf: %s\n" (Debug.inference x)
      |> print_string
 
 let rec infer (env : env) (x : value) : inference option =