Parse labelled configuration and customise record prefixes

This commit is contained in:
milner committed 2019-03-28 12:03:58 +00:00
1 parent 8f45e6669e
commit c6dddc3568
2 files changed
+57 -5

No files matched your search

+14
View File
@@ -69,3 +69,17 @@ let () =
assert (Prefixed.red Prefixed.{ paint_colour_red = 3; paint_colour_green = 4 } = 3);
assert (Unprefixed.yes Unprefixed.{ yes = true; yellow = false });
assert (Single.paint_red Single.{ paint_red = 3 } = 3)
module Named = struct
type t = { item_colour : string; item_size : int }
[@@fieldglass generate ~field_prefix:swatch]
end
module Typed = struct
type swatch = { item_colour : string; item_size : int }
[@@fieldglass generate ~field_prefix_from_type]
end
let () =
assert (Named.swatch_colour Named.{ item_colour = "grey"; item_size = 3 } = "grey");
assert (Typed.swatch_size Typed.{ item_colour = "grey"; item_size = 3 } = 3)