Skip to content

Commit

Permalink
v0.14.1
Browse files Browse the repository at this point in the history
  • Loading branch information
cwong-ocaml committed Aug 27, 2020
1 parent ef6002c commit 8b6ad3d
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 29 deletions.
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
25 changes: 12 additions & 13 deletions expander/str_generate_sexp_grammar.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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))
;;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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. *)
Expand All @@ -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
Expand Down Expand Up @@ -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 ->
Expand Down Expand Up @@ -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
;;

Expand Down Expand Up @@ -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
Expand Down
12 changes: 7 additions & 5 deletions test/expect/regular_vs_polymorphic_variants.diff
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 =
Expand All @@ -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"
Expand Down
3 changes: 1 addition & 2 deletions test/expect/test_polymorphic_record_fields.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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 []) ] }
]
}
] )
Expand Down
8 changes: 4 additions & 4 deletions test/expect/test_polymorphic_variants.ml
Original file line number Diff line number Diff line change
Expand Up @@ -108,17 +108,17 @@ 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

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]

Expand Down
5 changes: 2 additions & 3 deletions test/expect/test_recursive_groups.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions test/expect/test_regular_variants.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 8b6ad3d

Please sign in to comment.