Skip to content

Commit a9ebfca

Browse files
Remove type duplication
1 parent ddac131 commit a9ebfca

File tree

3 files changed

+9
-22
lines changed

3 files changed

+9
-22
lines changed

lib/part.ml

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -35,19 +35,11 @@ let rec remove_empty_heads = function
3535
let trim_empty_rev l = remove_empty_heads (List.rev (remove_empty_heads l))
3636

3737
module Parse_parts = struct
38-
type part_meta = Ocaml_delimiter.part_meta = {
39-
sep_indent : string;
40-
name : string;
41-
}
42-
43-
type t = Ocaml_delimiter.t =
44-
| Content of string
45-
| Compat_attr of part_meta
46-
(* ^^^^ This is for compat with the [[@@@part name]] delimiters *)
47-
| Part_begin of part_meta
48-
| Part_end
38+
type part_meta = Ocaml_delimiter.part_meta
39+
type t = Ocaml_delimiter.t
4940

50-
let next_part { name; sep_indent } ~is_begin_end_part lines_rev =
41+
let next_part Ocaml_delimiter.{ name; sep_indent } ~is_begin_end_part
42+
lines_rev =
5143
let body =
5244
if is_begin_end_part then String.concat "\n" (List.rev lines_rev)
5345
else "\n" ^ String.concat "\n" (trim_empty_rev lines_rev)
@@ -87,7 +79,7 @@ module Parse_parts = struct
8779
let* parts, make_part, current_part, part_lines, lineno = acc in
8880
let lineno = lineno + 1 in
8981
match (parse_part, current_part) with
90-
| Content line, _ ->
82+
| Ocaml_delimiter.Content line, _ ->
9183
Ok (parts, make_part, current_part, line :: part_lines, lineno)
9284
| Part_end, Some _ ->
9385
let part = make_part ~is_begin_end_part:true part_lines in

lib/part.mli

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,8 @@ val replace : file -> part:string option -> lines:string list -> file
3838
(* Exposed for test purposes only *)
3939

4040
module Parse_parts : sig
41-
type part_meta = { sep_indent : string; name : string }
42-
43-
type t =
44-
| Content of string
45-
| Compat_attr of part_meta
46-
(* ^^^^ This is for compat with the [[@@@part name]] delimiters *)
47-
| Part_begin of part_meta
48-
| Part_end
41+
type part_meta = Ocaml_delimiter.part_meta
42+
type t = Ocaml_delimiter.t
4943

5044
val parse_line : string -> t list
5145
end

test/lib/test_part.ml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
open Mdx.Part
2+
module D = Mdx.Ocaml_delimiter
23

34
let parse_parts =
45
let equal = ( = ) in
56
let pp fmt = function
6-
| Parse_parts.Content s -> Fmt.pf fmt "Content: %S" s
7+
| D.Content s -> Fmt.pf fmt "Content: %S" s
78
| Compat_attr { name; sep_indent } ->
89
Fmt.pf fmt "Compat_attr {name=%S; sep_indent=%S}" name sep_indent
910
| Part_begin { name; sep_indent } ->

0 commit comments

Comments
 (0)