diff --git a/CHANGES.md b/CHANGES.md index ebcab2b..3bae4b4 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,7 @@ +## v0.14.1 + +- Depend on ppxlib >= v0.15.0. + ## v0.11 - Depend on ppxlib instead of (now deprecated) ppx\_core, ppx\_driver and diff --git a/expander/str_generate_sexp_grammar.ml b/expander/str_generate_sexp_grammar.ml index 90e8690..5029ac0 100644 --- a/expander/str_generate_sexp_grammar.ml +++ b/expander/str_generate_sexp_grammar.ml @@ -5,6 +5,11 @@ open! Sexp.Private.Raw_grammar module Var_name = String module Type_name = String +module Longident = struct + include Longident + include (val Comparator.make ~compare ~sexp_of_t) +end + let debug_s message values = Caml.prerr_endline (Sexp.to_string_hum (Sexp.message message values)) ;; @@ -214,8 +219,7 @@ end = struct let create rec_flag tds : t = Init { explicit = - List.map tds ~f:(fun td -> - td.ptype_name.txt, Explicit_type_variables.create td) + List.map tds ~f:(fun td -> td.ptype_name.txt, Explicit_type_variables.create td) |> Map.of_alist_exn (module Type_name) ; implicit = Map.empty (module Longident) ; rec_flag @@ -413,8 +417,7 @@ let type_of_core_type env0 type_name ctype = let rec type_of_core_type env ctype = match Opaque.create ctype with | Opaque -> unsupported_builtin ~loc:ctype.ptyp_loc "opaque" - | Not_opaque { ptyp_desc; ptyp_loc = loc; ptyp_attributes = _; ptyp_loc_stack = _ } - -> + | Not_opaque { ptyp_desc; ptyp_loc = loc; ptyp_attributes = _; ptyp_loc_stack = _ } -> (match ptyp_desc with | Ptyp_any -> (* For consistency with [%of_sexp: _] which treats [_] as unsatisfiable. *) @@ -423,8 +426,7 @@ let type_of_core_type env0 type_name ctype = | Ptyp_arrow (_, _, _) -> unsupported_builtin ~loc "fun" | Ptyp_tuple core_types -> List - (List.map core_types ~f:(fun core_type -> - One (type_of_core_type env core_type))) + (List.map core_types ~f:(fun core_type -> One (type_of_core_type env core_type))) | Ptyp_constr (ident, args) -> type_of_type_constructor ~loc @@ -470,9 +472,7 @@ let record_type_of_label_declarations env type_name lds ~allow_extra_fields = { allow_extra_fields ; fields = List.map lds ~f:(fun ld -> - let { pld_name; pld_mutable = _; pld_type; pld_loc; pld_attributes = _ } = - ld - in + let { pld_name; pld_mutable = _; pld_type; pld_loc; pld_attributes = _ } = ld in let field = match Attrs.Record_field_handler.Of_sexp.create ~loc:pld_loc ld with | None -> @@ -593,8 +593,8 @@ let collect_type_variables_of_polymorphic_grammar core_type = | { ptyp_desc = Ptyp_object _; _ } -> not_supported ~loc:core_type.ptyp_loc - "objects, except the syntax [%sexp_grammar: < for_all : 'a 'b . ... >] to \ - generate grammars of polymorphic types" + "objects, except the syntax [%sexp_grammar: < for_all : 'a 'b . ... >] to generate \ + grammars of polymorphic types" | _ -> [], core_type ;; @@ -721,8 +721,7 @@ let to_pat_and_expr { grammars; generic_group; group; loc; module_path } = = [%e generic_group] in - let ([%p Pattern.the_group ~loc] - : Ppx_sexp_conv_lib.Sexp.Private.Raw_grammar.group) + let ([%p Pattern.the_group ~loc] : Ppx_sexp_conv_lib.Sexp.Private.Raw_grammar.group) = [%e group] in diff --git a/test/expect/regular_vs_polymorphic_variants.diff b/test/expect/regular_vs_polymorphic_variants.diff index 312b295..b2b613e 100644 --- a/test/expect/regular_vs_polymorphic_variants.diff +++ b/test/expect/regular_vs_polymorphic_variants.diff @@ -10,8 +10,10 @@ -| ; ggid = "\239\242\007o\016\222\178\133\218\153\146w\129\255\167\208" +| ; ggid = "\133a\241\019; \198\184U\181\220#\191\190\200\b" @|============================================================ --| , Variant { ignore_capitalization = true; alts = [ "A", []; "B", [] ] } +-| , Variant { ignore_capitalization = true; alts = [ "A", []; "B", [] ] } ) +-| ) +| , Variant { ignore_capitalization = false; alts = [ "A", []; "B", [] ] } ++| ) ) @|============================================================ -| ; origin = "test_regular_variants.ml.Nullary" +| ; origin = "test_polymorphic_variants.ml.Nullary" @@ -56,8 +58,8 @@ -| | Sexp_list of int sexp_list [@warning "-3"] +| [ `Int of int +| | `List of int list -+| | `Sexp_dot_list of int list[@sexp.list] -+| | `Sexp_list of int sexp_list[@warning "-3"] ++| | `Sexp_dot_list of int list [@sexp.list] ++| | `Sexp_list of int sexp_list [@warning "-3"] +| ] @|============================================================ -| type t = With_sexp.t = @@ -68,8 +70,8 @@ +| type t = +| [ `Int of int +| | `List of int list -+| | `Sexp_dot_list of int list[@sexp.list] -+| | `Sexp_list of int sexp_list[@warning "-3"] ++| | `Sexp_dot_list of int list [@sexp.list] ++| | `Sexp_list of int sexp_list [@warning "-3"] +| ] @|============================================================ -| ; ggid = "\219\014J\247\148Iq\193\248\rk\216J\012\200\152" diff --git a/test/expect/test_polymorphic_record_fields.ml b/test/expect/test_polymorphic_record_fields.ml index 2124da8..f8191dd 100644 --- a/test/expect/test_polymorphic_record_fields.ml +++ b/test/expect/test_polymorphic_record_fields.ml @@ -140,8 +140,7 @@ module Inline_record = struct , [ Fields { allow_extra_fields = false ; fields = - [ ( "a" - , { optional = false; args = [ One (Union []) ] } ) + [ "a", { optional = false; args = [ One (Union []) ] } ] } ] ) diff --git a/test/expect/test_polymorphic_variants.ml b/test/expect/test_polymorphic_variants.ml index deb260c..21db3b5 100644 --- a/test/expect/test_polymorphic_variants.ml +++ b/test/expect/test_polymorphic_variants.ml @@ -108,8 +108,8 @@ module Sexp_list = struct type t = [ `Int of int | `List of int list - | `Sexp_dot_list of int list[@sexp.list] - | `Sexp_list of int sexp_list[@warning "-3"] + | `Sexp_dot_list of int list [@sexp.list] + | `Sexp_list of int sexp_list [@warning "-3"] ] [@@deriving sexp] end @@ -117,8 +117,8 @@ module Sexp_list = struct type t = [ `Int of int | `List of int list - | `Sexp_dot_list of int list[@sexp.list] - | `Sexp_list of int sexp_list[@warning "-3"] + | `Sexp_dot_list of int list [@sexp.list] + | `Sexp_list of int sexp_list [@warning "-3"] ] [@@deriving_inline sexp_grammar] diff --git a/test/expect/test_recursive_groups.ml b/test/expect/test_recursive_groups.ml index 8300a41..a4a02f5 100644 --- a/test/expect/test_recursive_groups.ml +++ b/test/expect/test_recursive_groups.ml @@ -14,9 +14,8 @@ module One_type = struct ; types = [ ( "t" , Variant - { ignore_capitalization = true - ; alts = [ "T", [ One (Implicit_var 0) ] ] - } ) + { ignore_capitalization = true; alts = [ "T", [ One (Implicit_var 0) ] ] } + ) ] } in diff --git a/test/expect/test_regular_variants.ml b/test/expect/test_regular_variants.ml index e646931..790e376 100644 --- a/test/expect/test_regular_variants.ml +++ b/test/expect/test_regular_variants.ml @@ -18,8 +18,8 @@ module Nullary = struct [ ( "t" , Explicit_bind ( [ "a" ] - , Variant { ignore_capitalization = true; alts = [ "A", []; "B", [] ] } - ) ) + , Variant { ignore_capitalization = true; alts = [ "A", []; "B", [] ] } ) + ) ] } in