diff options
| author | Brian Campbell | 2019-05-24 16:08:14 +0100 |
|---|---|---|
| committer | Brian Campbell | 2019-05-24 16:08:14 +0100 |
| commit | feb7562e12659bc6e112ca9e9165b8abf6bf62bb (patch) | |
| tree | b249ba21bf449f508e8fa1fc5a24d4849c085d5d /src/pretty_print_coq.ml | |
| parent | e4498f776de81dd84bb6e8235e279fdeb3350253 (diff) | |
Coq: support if-then-throw typechecking special case
Diffstat (limited to 'src/pretty_print_coq.ml')
| -rw-r--r-- | src/pretty_print_coq.ml | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/pretty_print_coq.ml b/src/pretty_print_coq.ml index d45967a6..af40578c 100644 --- a/src/pretty_print_coq.ml +++ b/src/pretty_print_coq.ml @@ -2082,6 +2082,31 @@ let doc_exp, doc_let = let epp = liftR (separate space [string assert_fn; expY assert_e1; expY assert_e2]) in let epp = infix 0 1 (string mid) epp (top_exp new_ctxt false e2) in if aexp_needed then parens (align epp) else align epp + | _, + (E_aux (E_if (if_cond, + ( E_aux (E_throw _,_) + | E_aux (E_block [E_aux (E_throw _,_)],_) as throw_exp), + else_exp),_)), _ + when condition_produces_constraint ctxt if_cond -> + let cond_pp = expY if_cond in + let throw_pp = expN throw_exp in + (* Push non-trivial else branches below *) + let e2 = + match else_exp with + | E_aux (E_internal_return (E_aux (E_lit (L_aux (L_unit,_)),_)),_) + | E_aux (E_internal_return + (E_aux (E_cast (_, E_aux (E_lit (L_aux (L_unit,_)),_)),_)),_) + -> e2 + | _ -> E_aux (E_internal_plet (pat,else_exp,e2),(l,annot)) + in + (* TODO: capture avoid *) + let hyp = string "_non_throw_hyp" in + group (parens (string "match sumbool_of_bool " ^^ space ^^ cond_pp ^^ space ^^ string "with" ^/^ + group (string "| left _ =>" ^/^ throw_pp) ^/^ + group (string "| right " ^^ hyp ^^ string " =>" ^/^ + string "returnm " ^^ hyp) ^/^ string "end")) ^/^ + string " >>= fun _ => " ^/^ + top_exp new_ctxt false e2 | _ -> let epp = let middle = |
