• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

bn-d / ppx_subliner / 120

pending completion
120

push

github

web-flow
Add deriver for enum (#30)

39 of 39 new or added lines in 8 files covered. (100.0%)

526 of 580 relevant lines covered (90.69%)

24.49 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

81.82
/src/deriver_enum.ml
1
open Ppxlib
2

3
(* generate structure for type declaration *)
4
let structure_of_type_decl ~loc:_ (_ : rec_flag) (td : type_declaration) :
5
    structure =
6
  let name = td.ptype_name and loc = td.ptype_loc in
1✔
7
  let () = Utils.check_params_empty name td.ptype_params in
8
  match td with
1✔
9
  | { ptype_kind = Ptype_variant cds; _ } ->
1✔
10
      (* type t = C of T | ... *)
11
      Enum.structure_of_const_decls ~loc name cds
12
  | _ -> Error.unsupported_type ~loc "type declaration" name
×
13

14
(* generate signature for type declaration *)
15
let signature_of_type_decl ~loc:_ (_ : rec_flag) (td : type_declaration) :
16
    signature =
17
  let name = td.ptype_name and loc = td.ptype_loc in
1✔
18
  let () = Utils.check_params_empty name td.ptype_params in
19
  match td with
1✔
20
  | { ptype_kind = Ptype_variant _; _ } ->
1✔
21
      (* type t = C of T | ... *)
22
      Enum.signature_of_const_decls ~loc name
23
  | _ -> Error.unsupported_type ~loc "type declaration" name
×
24

25
let str_type_decl = Utils.make_type_decl_generator structure_of_type_decl
14✔
26
let sig_type_decl = Utils.make_type_decl_generator signature_of_type_decl
14✔
27
let deriver = Deriving.add "subliner_enum" ~str_type_decl ~sig_type_decl
14✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc