Skip to content

Commit 9ba9825

Browse files
cknittclaude
andcommitted
Keep the color palette, iterator entry points and Mod.mk as live
The first commit removed what no code used today, including parts of general APIs that new code is likely to need. These come back, marked [@@LiVe] with a comment so the dead-code check accepts them: - Misc.Color: the full ANSI palette (Black, Green, Blue, White) and background colors (BG), exported again so OCaml's unused-constructor warning does not fire. - Typedtree_iter.Make_iterator: iter_structure, iter_signature, iter_signature_item, iter_module_type and iter_pattern. - Ast_helper.Mod.mk: the builder the other Mod builders specialize. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Kbf3gLDo8mBJKpNE25WAwT Signed-off-by: Christoph Knittel <ck@cca.io>
1 parent fe3dfd9 commit 9ba9825

5 files changed

Lines changed: 39 additions & 3 deletions

File tree

‎compiler/ext/misc.ml‎

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -229,23 +229,31 @@ end)
229229
(* Color handling *)
230230
module Color = struct
231231
(* use ANSI color codes, see https://en.wikipedia.org/wiki/ANSI_escape_code *)
232-
type color = Red | Yellow | Magenta | Cyan
232+
(* The full ANSI palette, also the colors no message uses yet. *)
233+
type color = Black | Red | Green | Yellow | Blue | Magenta | Cyan | White
234+
[@@live]
233235

234236
type style =
235-
| FG of color
236-
(* foreground *)
237+
| FG of color (* foreground *)
238+
| BG of color (* background *)
237239
| Bold
238240
| Reset
239241
| Dim
242+
[@@live]
240243

241244
let ansi_of_color = function
245+
| Black -> "0"
242246
| Red -> "1"
247+
| Green -> "2"
243248
| Yellow -> "3"
249+
| Blue -> "4"
244250
| Magenta -> "5"
245251
| Cyan -> "6"
252+
| White -> "7"
246253

247254
let code_of_style = function
248255
| FG c -> "3" ^ ansi_of_color c
256+
| BG c -> "4" ^ ansi_of_color c
249257
| Bold -> "1"
250258
| Reset -> "0"
251259
| Dim -> "2"

‎compiler/ext/misc.mli‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,18 @@ module String_map : Map.S with type key = string
9595

9696
(* Color handling *)
9797
module Color : sig
98+
(* The full ANSI palette, also the colors no message uses yet. *)
99+
type color = Black | Red | Green | Yellow | Blue | Magenta | Cyan | White
100+
[@@live]
101+
102+
type style =
103+
| FG of color (* foreground *)
104+
| BG of color (* background *)
105+
| Bold
106+
| Reset
107+
| Dim
108+
[@@live]
109+
98110
type setting = Auto | Always | Never
99111

100112
val setup : setting option -> unit

‎compiler/ml/ast_helper.mli‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,10 @@ end
411411

412412
(** Module expressions *)
413413
module Mod : sig
414+
val mk : ?loc:loc -> ?attrs:attrs -> module_expr_desc -> module_expr
415+
[@@live]
416+
(** The builder the others specialize, as in every module of this file. *)
417+
414418
val ident : ?loc:loc -> ?attrs:attrs -> lid -> module_expr
415419
val structure : ?loc:loc -> ?attrs:attrs -> structure -> module_expr
416420
val functor_ :

‎compiler/ml/typedtree_iter.ml‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,15 @@ module type IteratorArgument = sig
7373
val enter_expression : expression -> unit
7474
end
7575

76+
(* The iterator's whole interface, also the entry points no pass uses yet. *)
7677
module Make_iterator (Iter : IteratorArgument) : sig
78+
val iter_structure : structure -> unit [@@live]
79+
val iter_signature : signature -> unit [@@live]
7780
val iter_structure_item : structure_item -> unit
81+
val iter_signature_item : signature_item -> unit [@@live]
7882
val iter_expression : expression -> unit
83+
val iter_module_type : module_type -> unit [@@live]
84+
val iter_pattern : pattern -> unit [@@live]
7985
end = struct
8086
let may_iter f v =
8187
match v with

‎compiler/ml/typedtree_iter.mli‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,15 @@ module type IteratorArgument = sig
6565
val enter_expression : expression -> unit
6666
end
6767

68+
(* The iterator's whole interface, also the entry points no pass uses yet. *)
6869
module Make_iterator : functor (_ : IteratorArgument) -> sig
70+
val iter_structure : structure -> unit [@@live]
71+
val iter_signature : signature -> unit [@@live]
6972
val iter_structure_item : structure_item -> unit
73+
val iter_signature_item : signature_item -> unit [@@live]
7074
val iter_expression : expression -> unit
75+
val iter_module_type : module_type -> unit [@@live]
76+
val iter_pattern : pattern -> unit [@@live]
7177
end
7278

7379
module Default_iterator_argument : IteratorArgumentDefaults

0 commit comments

Comments
 (0)