@@ -1843,15 +1843,15 @@ module Const = struct
18431843 end
18441844
18451845 module To_out_jkind_const : sig
1846- (* * Convert a [t] into a [Outcometree.out_jkind_const].
1847- The jkind is written in terms of the built-in jkind that requires the
1848- least amount of modes after the mod. For example, [value mod global many
1849- unique portable uncontended external_ non_null] could be written in
1850- terms of [value] (as it appears above), or in terms of [immediate]
1851- (which would just be [immediate]). Since the latter requires less modes
1852- to be printed, it is chosen.
1846+ (* * Convert a [t] into a [Outcometree.out_jkind_const]. If [expanded] is
1847+ [false], the jkind is written in terms of the built-in jkind that
1848+ requires the least amount of modes after the mod. For example,
1849+ [value mod global many unique portable uncontended external_ non_null]
1850+ could be written in terms of [value] (as it appears above), or in terms
1851+ of [immediate] (which would just be [immediate]). Since the latter
1852+ requires less modes to be printed, it is chosen.
18531853 *)
1854- val convert : 'd t -> Outcometree .out_jkind_const
1854+ val convert : expanded : bool -> 'd t -> Outcometree .out_jkind_const
18551855 end = struct
18561856 type printable_jkind =
18571857 { base : string ;
@@ -1982,15 +1982,18 @@ module Const = struct
19821982 | [out] -> Some out
19831983 | [] -> None
19841984
1985- let convert jkind =
1985+ let convert ~ expanded jkind =
19861986 (* For each primitive jkind, we try to print the jkind in terms of it
19871987 (this is possible if the primitive is a subjkind of it). We then choose
19881988 the "simplest". The "simplest" is taken to mean the one with the least
19891989 number of modes that need to follow the [mod]. *)
19901990 let simplest =
1991- Builtin. all
1992- |> List. filter_map (fun base -> convert_with_base ~base jkind)
1993- |> select_simplest
1991+ match expanded with
1992+ | false ->
1993+ Builtin. all
1994+ |> List. filter_map (fun base -> convert_with_base ~base jkind)
1995+ |> select_simplest
1996+ | true -> None
19941997 in
19951998 let printable_jkind =
19961999 match simplest with
@@ -2052,10 +2055,11 @@ module Const = struct
20522055 base with_tys
20532056 end
20542057
2055- let to_out_jkind_const jkind = To_out_jkind_const. convert jkind
2058+ let to_out_jkind_const jkind =
2059+ To_out_jkind_const. convert ~expanded: false jkind
20562060
2057- let format ppf jkind =
2058- To_out_jkind_const. convert jkind |> ! Oprint. out_jkind_const ppf
2061+ let format ~ expanded ppf jkind =
2062+ To_out_jkind_const. convert ~expanded jkind |> ! Oprint. out_jkind_const ppf
20592063
20602064 (* ******************************)
20612065 (* converting user annotations *)
@@ -2181,7 +2185,7 @@ module Desc = struct
21812185 (* CR layouts v2.8: This will probably need to be overhauled with
21822186 [with]-types. See also [Printtyp.out_jkind_of_desc], which uses the same
21832187 algorithm. Internal ticket 5096. *)
2184- let format ppf t =
2188+ let format_maybe_expanded ~ expanded ppf t =
21852189 let open Format in
21862190 let rec format_desc ~nested ppf (desc : _ t ) =
21872191 match desc.layout with
@@ -2194,10 +2198,12 @@ module Desc = struct
21942198 (List. map (fun layout -> { desc with layout }) lays)
21952199 | _ -> (
21962200 match get_const desc with
2197- | Some c -> Const. format ppf c
2201+ | Some c -> Const. format ~expanded ppf c
21982202 | None -> assert false (* handled above *) )
21992203 in
22002204 format_desc ppf ~nested: false t
2205+
2206+ let format ppf t = format_maybe_expanded ~expanded: false ppf t
22012207end
22022208
22032209module Jkind_desc = struct
@@ -3007,7 +3013,12 @@ let decompose_product ({ jkind; _ } as jk) =
30073013 doing so, because it teaches the user that e.g. [value mod local] is better
30083014 off spelled [value]. Possibly remove [jkind.annotation], but only after
30093015 we have a proper printing story. Internal ticket 5096. *)
3010- let format ppf jkind = Desc. format ppf (Jkind_desc. get jkind.jkind)
3016+ let format_maybe_expanded ~expanded ppf jkind =
3017+ Desc. format_maybe_expanded ~expanded ppf (Jkind_desc. get jkind.jkind)
3018+
3019+ let format ppf jkind = format_maybe_expanded ~expanded: false ppf jkind
3020+
3021+ let format_expanded ppf jkind = format_maybe_expanded ~expanded: true ppf jkind
30113022
30123023let printtyp_path = ref (fun _ _ -> assert false )
30133024
0 commit comments