Skip to content

Commit

Permalink
Added parentheses around tuples.
Browse files Browse the repository at this point in the history
  • Loading branch information
raphael-proust authored and hnrgrgr committed Mar 24, 2011
1 parent 3a9a236 commit 20d3f9c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/deriving_Show.ml
Expand Up @@ -73,7 +73,7 @@ module Show_option (S : Show) : Show with type a = S.a option =
type a = S.a option
let format formatter = function
| None -> Format.fprintf formatter "@[None@]"
| Some s -> Format.fprintf formatter "@[Some@;<1 2>%a@]" S.format s
| Some s -> Format.fprintf formatter "@[Some@;<1 2>(%a)@]" S.format s
end)

(* instance Show a => Show (a array) *)
Expand Down
8 changes: 7 additions & 1 deletion syntax/show_class.ml
Expand Up @@ -52,6 +52,12 @@ module InContext (L : Loc) : Class = struct
$e$;
Format.pp_close_box formatter () >>

let in_paren e =
<:expr<
Format.pp_print_string formatter "(";
$e$;
Format.pp_print_string formatter ")" >>

let in_hovbox ?(indent = 0) = in_a_box "pp_open_hovbox" indent
and in_box ?(indent = 0) = in_a_box "pp_open_box" indent

Expand All @@ -70,7 +76,7 @@ module InContext (L : Loc) : Class = struct
Format.pp_print_space formatter ();
$format_expr id ty$>> in
let exprs = format_expr id ty :: List.map2 format_expr' ids tys in
in_hovbox ~indent:1 (seq_list exprs)
in_paren (in_hovbox ~indent:1 (seq_list exprs))
| _ -> assert false

method tuple ctxt args =
Expand Down

0 comments on commit 20d3f9c

Please sign in to comment.