summaryrefslogtreecommitdiff
path: root/src/PrintPure.ml
diff options
context:
space:
mode:
authorSon Ho2022-03-03 17:36:33 +0100
committerSon Ho2022-03-03 17:36:33 +0100
commit00104884e101d3125e62dde9757b9c1cacb3feec (patch)
tree95714d86561013b328e00138f12bb9889576eca5 /src/PrintPure.ml
parent80d0d22f152386ffe28b48f42f42f8f736170014 (diff)
Make good progress on adding support for external and opaque
declarations
Diffstat (limited to '')
-rw-r--r--src/PrintPure.ml16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/PrintPure.ml b/src/PrintPure.ml
index f47a1f06..52215019 100644
--- a/src/PrintPure.ml
+++ b/src/PrintPure.ml
@@ -479,9 +479,13 @@ let fun_decl_to_string (fmt : ast_formatter) (def : fun_decl) : string =
let type_fmt = ast_to_type_formatter fmt in
let name = fun_name_to_string def.basename ^ fun_suffix def.back_id in
let signature = fun_sig_to_string fmt def.signature in
- let inputs = List.map (var_to_string type_fmt) def.inputs in
- let inputs =
- if inputs = [] then "" else " fun " ^ String.concat " " inputs ^ " ->\n"
- in
- let body = texpression_to_string fmt " " " " def.body in
- "let " ^ name ^ " :\n " ^ signature ^ " =\n" ^ inputs ^ " " ^ body
+ match def.body with
+ | None -> "val " ^ name ^ " :\n " ^ signature
+ | Some body ->
+ let inputs = List.map (var_to_string type_fmt) body.inputs in
+ let inputs =
+ if inputs = [] then ""
+ else " fun " ^ String.concat " " inputs ^ " ->\n"
+ in
+ let body = texpression_to_string fmt " " " " body.body in
+ "let " ^ name ^ " :\n " ^ signature ^ " =\n" ^ inputs ^ " " ^ body