@@ -3457,7 +3457,8 @@ and fmt_class_params c ctx params =
34573457 ( wrap_fits_breaks c.conf " [" " ]" (list_fl params fmt_param)
34583458 $ space_break ) )
34593459
3460- and fmt_type_declaration c ?(pre = " " ) ?name ?(eq = " =" ) {ast = decl ; _} =
3460+ and fmt_type_declaration c ?(kw = " " ) ?(nonrec_kw = " " ) ?name ?(eq = " =" )
3461+ {ast = decl ; _} =
34613462 protect c (Td decl)
34623463 @@
34633464 let { ptype_name= {txt; loc}
@@ -3497,10 +3498,10 @@ and fmt_type_declaration c ?(pre = "") ?name ?(eq = "=") {ast= decl; _} =
34973498 in
34983499 let box_manifest k =
34993500 hvbox c.conf.fmt_opts.type_decl_indent.v
3500- ( str pre
3501+ ( str kw
35013502 $ fmt_extension_suffix c ext
35023503 $ fmt_attributes c attrs_before
3503- $ str " "
3504+ $ str nonrec_kw $ str " "
35043505 $ hvbox_if
35053506 (not (List. is_empty ptype_params))
35063507 0
@@ -4265,12 +4266,12 @@ and fmt_module_statement c ~attributes ?keyword mod_expr =
42654266
42664267and fmt_with_constraint c ctx ~pre = function
42674268 | Pwith_type (lid , td ) ->
4268- fmt_type_declaration ~pre : (pre ^ " type" ) c ~name: lid (sub_td ~ctx td)
4269+ fmt_type_declaration ~kw : (pre ^ " type" ) c ~name: lid (sub_td ~ctx td)
42694270 | Pwith_module (m1 , m2 ) ->
42704271 str pre $ str " module " $ fmt_longident_loc c m1 $ str " = "
42714272 $ fmt_longident_loc c m2
42724273 | Pwith_typesubst (lid , td ) ->
4273- fmt_type_declaration ~pre : (pre ^ " type" ) c ~eq: " :=" ~name: lid
4274+ fmt_type_declaration ~kw : (pre ^ " type" ) c ~eq: " :=" ~name: lid
42744275 (sub_td ~ctx td)
42754276 | Pwith_modsubst (m1 , m2 ) ->
42764277 str pre $ str " module " $ fmt_longident_loc c m1 $ str " := "
@@ -4550,10 +4551,12 @@ and fmt_type c ?eq rec_flag decls ctx =
45504551 let is_rec = Asttypes. is_recursive rec_flag in
45514552 let fmt_decl c ctx ~prev ~next :_ decl =
45524553 let first = Option. is_none prev in
4553- let pre =
4554- if first then if is_rec then " type" else " type nonrec" else " and"
4554+ let kw, nonrec_kw =
4555+ if first then
4556+ if is_rec then (" type" , None ) else (" type" , Some " nonrec" )
4557+ else (" and" , None )
45554558 in
4556- fmt_type_declaration c ~pre ?eq (sub_td ~ctx decl)
4559+ fmt_type_declaration c ~kw ?nonrec_kw ?eq (sub_td ~ctx decl)
45574560 in
45584561 let ast x = Td x in
45594562 fmt_item_list c ctx update_config ast fmt_decl decls
0 commit comments