Traverse record declarations and generate typed field accessors

This commit is contained in:
sneeker committed 2019-03-08 17:28:32 +00:00
1 parent 3c792e169d
commit b6312ceae9
5 files changed
+73 -1

No files matched your search

+13
View File
@@ -0,0 +1,13 @@
module Colour = struct
type t = { red : int; green : int; blue : int } [@@fieldglass generate]
end
module Legacy = struct
type t = { value : string } [@@lens generate]
end
let () =
let colour = Colour.{ red = 3; green = 4; blue = 5 } in
assert (Colour.red colour = 3);
assert (Colour.green colour = 4);
assert (Legacy.value Legacy.{ value = "grey" } = "grey")