| 1 | open! Base |
| 2 | |
| 3 | module _ = struct |
| 4 | type t = { a : int } [@@sexp.allow_extra_fields] [@@deriving_inline sexp_grammar] |
| 5 | |
| 6 | let _ = fun (_ : t) -> () |
| 7 | |
| 8 | let (t_sexp_grammar : t Sexplib0.Sexp_grammar.t) = |
| 9 | { untyped = |
| 10 | Lazy |
| 11 | (lazy |
| 12 | (List |
| 13 | (Fields |
| 14 | { allow_extra_fields = true |
| 15 | ; fields = |
| 16 | [ No_tag |
| 17 | { name = "a" |
| 18 | ; required = true |
| 19 | ; args = Cons (int_sexp_grammar.untyped, Empty) |
| 20 | } |
| 21 | ] |
| 22 | }))) |
| 23 | } |
| 24 | ;; |
| 25 | |
| 26 | let _ = t_sexp_grammar |
| 27 | |
| 28 | [@@@end] |
| 29 | end |
| 30 | |
| 31 | module _ = struct |
| 32 | type t = { a : int } [@@deriving_inline sexp_grammar] |
| 33 | |
| 34 | let _ = fun (_ : t) -> () |
| 35 | |
| 36 | let (t_sexp_grammar : t Sexplib0.Sexp_grammar.t) = |
| 37 | { untyped = |
| 38 | Lazy |
| 39 | (lazy |
| 40 | (List |
| 41 | (Fields |
| 42 | { allow_extra_fields = false |
| 43 | ; fields = |
| 44 | [ No_tag |
| 45 | { name = "a" |
| 46 | ; required = true |
| 47 | ; args = Cons (int_sexp_grammar.untyped, Empty) |
| 48 | } |
| 49 | ] |
| 50 | }))) |
| 51 | } |
| 52 | ;; |
| 53 | |
| 54 | let _ = t_sexp_grammar |
| 55 | |
| 56 | [@@@end] |
| 57 | end |
| 58 | |
| 59 | module _ = struct |
| 60 | type t = |
| 61 | | Allow_extra_fields of { foo : int } [@sexp.allow_extra_fields] |
| 62 | | Forbid_extra_fields of { bar : int } |
| 63 | [@@deriving_inline sexp_grammar] |
| 64 | |
| 65 | let _ = fun (_ : t) -> () |
| 66 | |
| 67 | let (t_sexp_grammar : t Sexplib0.Sexp_grammar.t) = |
| 68 | { untyped = |
| 69 | Lazy |
| 70 | (lazy |
| 71 | (Variant |
| 72 | { case_sensitivity = Case_sensitive_except_first_character |
| 73 | ; clauses = |
| 74 | [ No_tag |
| 75 | { name = "Allow_extra_fields" |
| 76 | ; clause_kind = |
| 77 | List_clause |
| 78 | { args = |
| 79 | Fields |
| 80 | { allow_extra_fields = true |
| 81 | ; fields = |
| 82 | [ No_tag |
| 83 | { name = "foo" |
| 84 | ; required = true |
| 85 | ; args = Cons (int_sexp_grammar.untyped, Empty) |
| 86 | } |
| 87 | ] |
| 88 | } |
| 89 | } |
| 90 | } |
| 91 | ; No_tag |
| 92 | { name = "Forbid_extra_fields" |
| 93 | ; clause_kind = |
| 94 | List_clause |
| 95 | { args = |
| 96 | Fields |
| 97 | { allow_extra_fields = false |
| 98 | ; fields = |
| 99 | [ No_tag |
| 100 | { name = "bar" |
| 101 | ; required = true |
| 102 | ; args = Cons (int_sexp_grammar.untyped, Empty) |
| 103 | } |
| 104 | ] |
| 105 | } |
| 106 | } |
| 107 | } |
| 108 | ] |
| 109 | })) |
| 110 | } |
| 111 | ;; |
| 112 | |
| 113 | let _ = t_sexp_grammar |
| 114 | |
| 115 | [@@@end] |
| 116 | |
| 117 | let _ = Allow_extra_fields { foo = 1 } |
| 118 | let _ = Forbid_extra_fields { bar = 1 } |
| 119 | end |