Skip to content

Commit

Permalink
Remove github workflows and upgrade ocamlformat (#28)
Browse files Browse the repository at this point in the history
  • Loading branch information
patricoferris authored Feb 28, 2022
1 parent 221b82a commit 7df5bfc
Show file tree
Hide file tree
Showing 11 changed files with 20 additions and 60 deletions.
26 changes: 0 additions & 26 deletions .github/workflows/test.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .ocamlformat
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version=0.15.0
version=0.20.1
break-infix=fit-or-vertical
parse-docstrings=true
indicate-multiline-delimiters=no
2 changes: 1 addition & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## v0.1.1
## v0.1.1 (28/02/2022)

- Remove rresult dependency (#27, @patricoferris)

Expand Down
15 changes: 6 additions & 9 deletions lib/attrs.ml
Original file line number Diff line number Diff line change
@@ -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)
let name =
Attribute.declare "yaml.name" Attribute.Context.constructor_declaration
Ast_pattern.(pstr (pstr_eval (estring __) nil ^:: nil))
(fun x -> x)
4 changes: 2 additions & 2 deletions lib/attrs.mli
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
open Ppxlib
open Ppxlib

val key : (label_declaration, label) Attribute.t
val name : (constructor_declaration, string) Attribute.t
val name : (constructor_declaration, string) Attribute.t
3 changes: 0 additions & 3 deletions lib/helpers.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
8 changes: 0 additions & 8 deletions lib/helpers.mli
Original file line number Diff line number Diff line change
@@ -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
8 changes: 6 additions & 2 deletions lib/value.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
);
]
Expand All @@ -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]))]
Expand Down
2 changes: 0 additions & 2 deletions lib/value.mli
Original file line number Diff line number Diff line change
Expand Up @@ -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 :
Expand Down
1 change: 0 additions & 1 deletion ppx/ppx_deriving_yaml.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
9 changes: 4 additions & 5 deletions test/test.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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 () =
Expand Down Expand Up @@ -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.( = )
Expand Down Expand Up @@ -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.( = )
Expand Down

0 comments on commit 7df5bfc

Please sign in to comment.