diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml deleted file mode 100644 index 76ba361..0000000 --- a/.github/workflows/test.yml +++ /dev/null @@ -1,26 +0,0 @@ -name: Tests for ppx_deriving_yaml -on: [push, pull_request] -jobs: - test: - strategy: - matrix: - operating-system: [macos-latest, ubuntu-latest, windows-latest] - ocaml-version: [4.11.0, 4.10.0, 4.09.1] - runs-on: ${{ matrix.operating-system }} - steps: - - uses: actions/checkout@v2 - - uses: avsm/setup-ocaml@v1 - with: - ocaml-version: ${{ matrix.ocaml-version }} - - name: Pinning Package - run: opam pin add -yn ppx_deriving_yaml.dev './' - - name: Packages - run: opam depext -yt ppx_deriving_yaml.dev - - name: Dependencies - run: opam install -t -y . --deps-only - - name: Building - run: opam exec -- dune build - - name: Installing - run: opam exec -- dune install - - name: Testing - run: opam exec -- dune runtest diff --git a/.ocamlformat b/.ocamlformat index 3c20e39..2a9b329 100644 --- a/.ocamlformat +++ b/.ocamlformat @@ -1,4 +1,4 @@ -version=0.15.0 +version=0.20.1 break-infix=fit-or-vertical parse-docstrings=true indicate-multiline-delimiters=no \ No newline at end of file diff --git a/CHANGES.md b/CHANGES.md index 9246c6c..1d9c141 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,4 +1,4 @@ -## v0.1.1 +## v0.1.1 (28/02/2022) - Remove rresult dependency (#27, @patricoferris) diff --git a/lib/attrs.ml b/lib/attrs.ml index 8c67200..de0ff59 100644 --- a/lib/attrs.ml +++ b/lib/attrs.ml @@ -1,14 +1,11 @@ open Ppxlib + let key = - Attribute.declare - "yaml.key" - Attribute.Context.label_declaration + Attribute.declare "yaml.key" Attribute.Context.label_declaration Ast_pattern.(pstr (pstr_eval (estring __) nil ^:: nil)) (fun x -> x) - let name = - Attribute.declare - "yaml.name" - Attribute.Context.constructor_declaration - Ast_pattern.(pstr (pstr_eval (estring __) nil ^:: nil)) - (fun x -> x) \ No newline at end of file +let name = + Attribute.declare "yaml.name" Attribute.Context.constructor_declaration + Ast_pattern.(pstr (pstr_eval (estring __) nil ^:: nil)) + (fun x -> x) diff --git a/lib/attrs.mli b/lib/attrs.mli index 2cfc249..dbb7ac6 100644 --- a/lib/attrs.mli +++ b/lib/attrs.mli @@ -1,4 +1,4 @@ -open Ppxlib +open Ppxlib val key : (label_declaration, label) Attribute.t -val name : (constructor_declaration, string) Attribute.t \ No newline at end of file +val name : (constructor_declaration, string) Attribute.t diff --git a/lib/helpers.ml b/lib/helpers.ml index 977e2be..2d6cd7c 100644 --- a/lib/helpers.ml +++ b/lib/helpers.ml @@ -2,11 +2,8 @@ open Ppxlib open Ast_helper let arg n = "arg" ^ string_of_int n - let mkloc txt = { txt; loc = !Ast_helper.default_loc } - let suf_to = "to_yaml" - let suf_of = "of_yaml" let fold_right f type_decl acc = diff --git a/lib/helpers.mli b/lib/helpers.mli index 80cda41..1f146a4 100644 --- a/lib/helpers.mli +++ b/lib/helpers.mli @@ -1,19 +1,11 @@ open Ppxlib val mkloc : 'a -> 'a Ppxlib.loc - val arg : int -> string - val suf_to : string - val suf_of : string - val mangle_suf : ?fixpoint:string -> string -> Longident.t -> Longident.t - val poly_fun : loc:location -> type_declaration -> expression -> expression - val ptuple : loc:location -> pattern list -> pattern - val etuple : loc:location -> expression list -> expression - val map_bind : loc:location -> expression diff --git a/lib/value.ml b/lib/value.ml index 5d68e47..12401cd 100644 --- a/lib/value.ml +++ b/lib/value.ml @@ -200,7 +200,9 @@ let rec of_yaml_type_to_expr name typ = [ ( [%pat? `A lst], [%expr - let ( >>= ) v f = match v with Ok v -> f v | Error _ as e -> e in + let ( >>= ) v f = + match v with Ok v -> f v | Error _ as e -> e + in [%e Helpers.map_bind ~loc] [%e of_yaml_type_to_expr None typ] lst] ); ] @@ -209,7 +211,9 @@ let rec of_yaml_type_to_expr name typ = [ ( [%pat? `A lst], [%expr - let ( >>= ) v f = match v with Ok v -> f v | Error _ as e -> e in + let ( >>= ) v f = + match v with Ok v -> f v | Error _ as e -> e + in `A Array.( to_list ([%e Helpers.map_bind ~loc] [%e type_to_expr typ]))] diff --git a/lib/value.mli b/lib/value.mli index 71fd3d2..9da6629 100644 --- a/lib/value.mli +++ b/lib/value.mli @@ -7,9 +7,7 @@ val record_to_expr : typ:core_type -> loc:Location.t -> label_declaration list -> expression val type_decl_to_type : type_declaration -> core_type - val type_decl_of_type : type_declaration -> core_type - val of_yaml_type_to_expr : string option -> core_type -> expression val of_yaml_record_to_expr : diff --git a/ppx/ppx_deriving_yaml.ml b/ppx/ppx_deriving_yaml.ml index c1684ac..64cca80 100644 --- a/ppx/ppx_deriving_yaml.ml +++ b/ppx/ppx_deriving_yaml.ml @@ -4,7 +4,6 @@ open Ast_builder.Default open Ppx_deriving_yaml_lib let suf_to = Helpers.suf_to - let suf_of = Helpers.suf_of let mangle_name_label suff label = diff --git a/test/test.ml b/test/test.ml index 1ba6389..315c7e2 100644 --- a/test/test.ml +++ b/test/test.ml @@ -3,17 +3,14 @@ let yaml = Alcotest.testable Yaml.pp Yaml.equal type error = [ `Msg of string ] let pp_error ppf (`Msg x) = Fmt.string ppf x - let error = Alcotest.testable pp_error ( = ) type str = string [@@deriving yaml] - type flo = float [@@deriving yaml] let flo = Alcotest.testable Format.pp_print_float Stdlib.( = ) type integer = int [@@deriving yaml] - type boolean = bool [@@deriving yaml] let test_primitives () = @@ -150,7 +147,8 @@ type var = Alpha | Beta of int | Gamma of string * int [@@deriving yaml] let var = Alcotest.testable - (fun ppf -> function Alpha -> Fmt.string ppf "Alpha" + (fun ppf -> function + | Alpha -> Fmt.string ppf "Alpha" | Beta i -> Fmt.pf ppf "Beta %i" i | Gamma (s, i) -> Fmt.pf ppf "Gamma (%s,%i)" s i) Stdlib.( = ) @@ -183,7 +181,8 @@ type poly_var = [ `Alpha | `Beta of int | `Gamma of string * int ] let poly_var : poly_var Alcotest.testable = Alcotest.testable - (fun ppf -> function `Alpha -> Fmt.pf ppf "Alpha" + (fun ppf -> function + | `Alpha -> Fmt.pf ppf "Alpha" | `Beta i -> Fmt.pf ppf "Beta %i" i | `Gamma (s, i) -> Fmt.pf ppf "Gamma (%s, %i)" s i) Stdlib.( = )