From 52deb33c5adf394c85717f07f0805160354d7b92 Mon Sep 17 00:00:00 2001 From: Frank Emrich Date: Tue, 17 Oct 2023 15:26:59 +0100 Subject: [PATCH 1/3] workaround --- lens/column.ml | 24 ++++++++++++++++-------- lens/database.ml | 34 ++++++++++++++++++++++++---------- lens/sort.ml | 22 +++++++++++++++------- lens/value.ml | 48 ++++++++++++++++++++++++++++-------------------- links.opam | 2 +- 5 files changed, 84 insertions(+), 46 deletions(-) diff --git a/lens/column.ml b/lens/column.ml index 5d9dcbaee..af5fc0e46 100644 --- a/lens/column.ml +++ b/lens/column.ml @@ -1,14 +1,22 @@ open Lens_utility module Type = Phrase_type -type t = { - table : string; - name : string; - alias : string; - typ : Type.t; - present : bool; -} -[@@deriving show, sexp] +include struct + (* Workaround for issue #1187 (i.e., the @@deriving sexp clause on t + below creates code triggering warning 40): + We disable warning 40 within this module, and immediately include it. *) + + [@@@ocaml.warning "-40"] + + type t = { + table : string; + name : string; + alias : string; + typ : Type.t; + present : bool; + } + [@@deriving show, sexp] +end let make ~table ~name ~alias ~typ ~present = { table; name; alias; typ; present } diff --git a/lens/database.ml b/lens/database.ml index 7ecb3c1a3..0e958ec19 100644 --- a/lens/database.ml +++ b/lens/database.ml @@ -2,15 +2,23 @@ open Operators open Lens_utility module LPV = Phrase_value -type t = { - serialize : unit -> string; - driver_name : unit -> string; - escape_string : string -> string; - quote_field : string -> string; - execute : string -> unit; - execute_select : - string -> field_types:(string * Phrase_type.t) list -> Phrase_value.t list; -} +include struct + (* Workaround for issue #1187 (i.e., the @@deriving sexp clause on t + below creates code triggering warning 40): + We disable warning 40 within this module, and immediately include it. *) + + [@@@ocaml.warning "-40"] + + type t = { + serialize : unit -> string; + driver_name : unit -> string; + escape_string : string -> string; + quote_field : string -> string; + execute : string -> unit; + execute_select : + string -> field_types:(string * Phrase_type.t) list -> Phrase_value.t list; + } +end module E = struct type t = @@ -48,7 +56,13 @@ let show _ = "" let pp f v = Format.fprintf f "%s" (show v) module Table = struct - type t = { name : string; keys : string list list } [@@deriving sexp] + include struct + (* Defining t withing a module and immediately including it as a way to + disable warning 40 exactly on the code generated for the + @@deriving clauses below *) + [@@@ocaml.warning "-40"] + type t = { name : string; keys : string list list } [@@deriving sexp] + end let name t = t.name end diff --git a/lens/sort.ml b/lens/sort.ml index 3a714607a..b02496ff6 100644 --- a/lens/sort.ml +++ b/lens/sort.ml @@ -2,13 +2,21 @@ open Lens_utility open Lens_utility.O module Column = Column -type t = { - fds : Fun_dep.Set.t; - predicate : Phrase.t option; - query : Phrase.t option; - cols : Column.t list; -} -[@@deriving show, sexp] +include struct + (* Workaround for issue #1187 (i.e., the @@deriving sexp clause on t + below creates code triggering warning 40): + We disable warning 40 within this module, and immediately include it. *) + + [@@@ocaml.warning "-40"] + + type t = { + fds : Fun_dep.Set.t; + predicate : Phrase.t option; + query : Phrase.t option; + cols : Column.t list; + } + [@@deriving show, sexp] +end let fds t = t.fds diff --git a/lens/value.ml b/lens/value.ml index 88f55411a..950bd3826 100644 --- a/lens/value.ml +++ b/lens/value.ml @@ -1,25 +1,33 @@ open Lens_utility -type t = - | Lens of { table : Database.Table.t; sort : Sort.t } - | LensMem of { records : Phrase_value.t list; sort : Sort.t } - | LensSelect of { lens : t; predicate : Phrase.t; sort : Sort.t } - | LensJoin of { - left : t; - right : t; - on : (string * string * string) list; - del_left : Phrase.t; - del_right : Phrase.t; - sort : Sort.t; - } - | LensDrop of { - lens : t; - drop : string; - key : string; - default : Phrase_value.t; - sort : Sort.t; - } -[@@deriving sexp] +include struct + (* Workaround for issue #1187 (i.e., the @@deriving sexp clause on t + below creates code triggering warning 40): + We disable warning 40 within this module, and immediately include it. *) + + [@@@ocaml.warning "-40"] + + type t = + | Lens of { table : Database.Table.t; sort : Sort.t } + | LensMem of { records : Phrase_value.t list; sort : Sort.t } + | LensSelect of { lens : t; predicate : Phrase.t; sort : Sort.t } + | LensJoin of { + left : t; + right : t; + on : (string * string * string) list; + del_left : Phrase.t; + del_right : Phrase.t; + sort : Sort.t; + } + | LensDrop of { + lens : t; + drop : string; + key : string; + default : Phrase_value.t; + sort : Sort.t; + } + [@@deriving sexp] +end let serialize v = let sexp = sexp_of_t v in diff --git a/links.opam b/links.opam index 8e3d8bebe..a9b2ee02d 100644 --- a/links.opam +++ b/links.opam @@ -35,7 +35,7 @@ depends: [ "result" "ocamlfind" "menhir" {>= "20210419"} - "ppx_sexp_conv" {<= "v0.15.1"} + "ppx_sexp_conv" "calendar" {>= "2.0.4"} "rdf_lwt" {>= "0.13.0"} ] From 72d8590d49c7d81bacf87023ba1f6b73299ec10d Mon Sep 17 00:00:00 2001 From: Frank Emrich Date: Wed, 18 Oct 2023 13:05:36 +0100 Subject: [PATCH 2/3] open Sexplib0.Sexp_conv instead --- lens/column.ml | 28 +++++++++++--------------- lens/database.ml | 38 +++++++++++++---------------------- lens/sort.ml | 26 ++++++++++-------------- lens/value.ml | 52 ++++++++++++++++++++++-------------------------- 4 files changed, 61 insertions(+), 83 deletions(-) diff --git a/lens/column.ml b/lens/column.ml index af5fc0e46..2fd3bd4e9 100644 --- a/lens/column.ml +++ b/lens/column.ml @@ -1,22 +1,18 @@ open Lens_utility module Type = Phrase_type -include struct - (* Workaround for issue #1187 (i.e., the @@deriving sexp clause on t - below creates code triggering warning 40): - We disable warning 40 within this module, and immediately include it. *) - - [@@@ocaml.warning "-40"] - - type t = { - table : string; - name : string; - alias : string; - typ : Type.t; - present : bool; - } - [@@deriving show, sexp] -end +(* Workaround for issue #1187 (i.e., the @@deriving sexp clause on t + below creates code triggering warning 40 otherwise) *) +open Sexplib0.Sexp_conv + +type t = { + table : string; + name : string; + alias : string; + typ : Type.t; + present : bool; +} +[@@deriving show, sexp] let make ~table ~name ~alias ~typ ~present = { table; name; alias; typ; present } diff --git a/lens/database.ml b/lens/database.ml index 0e958ec19..61e683f69 100644 --- a/lens/database.ml +++ b/lens/database.ml @@ -2,23 +2,19 @@ open Operators open Lens_utility module LPV = Phrase_value -include struct - (* Workaround for issue #1187 (i.e., the @@deriving sexp clause on t - below creates code triggering warning 40): - We disable warning 40 within this module, and immediately include it. *) - - [@@@ocaml.warning "-40"] - - type t = { - serialize : unit -> string; - driver_name : unit -> string; - escape_string : string -> string; - quote_field : string -> string; - execute : string -> unit; - execute_select : - string -> field_types:(string * Phrase_type.t) list -> Phrase_value.t list; - } -end +(* Workaround for issue #1187 (i.e., the @@deriving sexp clause on t + below creates code triggering warning 40 otherwise) *) +open Sexplib0.Sexp_conv + +type t = { + serialize : unit -> string; + driver_name : unit -> string; + escape_string : string -> string; + quote_field : string -> string; + execute : string -> unit; + execute_select : + string -> field_types:(string * Phrase_type.t) list -> Phrase_value.t list; +} module E = struct type t = @@ -56,13 +52,7 @@ let show _ = "" let pp f v = Format.fprintf f "%s" (show v) module Table = struct - include struct - (* Defining t withing a module and immediately including it as a way to - disable warning 40 exactly on the code generated for the - @@deriving clauses below *) - [@@@ocaml.warning "-40"] - type t = { name : string; keys : string list list } [@@deriving sexp] - end + type t = { name : string; keys : string list list } [@@deriving sexp] let name t = t.name end diff --git a/lens/sort.ml b/lens/sort.ml index b02496ff6..e24638de7 100644 --- a/lens/sort.ml +++ b/lens/sort.ml @@ -2,21 +2,17 @@ open Lens_utility open Lens_utility.O module Column = Column -include struct - (* Workaround for issue #1187 (i.e., the @@deriving sexp clause on t - below creates code triggering warning 40): - We disable warning 40 within this module, and immediately include it. *) - - [@@@ocaml.warning "-40"] - - type t = { - fds : Fun_dep.Set.t; - predicate : Phrase.t option; - query : Phrase.t option; - cols : Column.t list; - } - [@@deriving show, sexp] -end +(* Workaround for issue #1187 (i.e., the @@deriving sexp clause on t + below creates code triggering warning 40 otherwise) *) +open Sexplib0.Sexp_conv + +type t = { + fds : Fun_dep.Set.t; + predicate : Phrase.t option; + query : Phrase.t option; + cols : Column.t list; +} +[@@deriving show, sexp] let fds t = t.fds diff --git a/lens/value.ml b/lens/value.ml index 950bd3826..f5ea3fdb6 100644 --- a/lens/value.ml +++ b/lens/value.ml @@ -1,33 +1,29 @@ open Lens_utility -include struct - (* Workaround for issue #1187 (i.e., the @@deriving sexp clause on t - below creates code triggering warning 40): - We disable warning 40 within this module, and immediately include it. *) - - [@@@ocaml.warning "-40"] - - type t = - | Lens of { table : Database.Table.t; sort : Sort.t } - | LensMem of { records : Phrase_value.t list; sort : Sort.t } - | LensSelect of { lens : t; predicate : Phrase.t; sort : Sort.t } - | LensJoin of { - left : t; - right : t; - on : (string * string * string) list; - del_left : Phrase.t; - del_right : Phrase.t; - sort : Sort.t; - } - | LensDrop of { - lens : t; - drop : string; - key : string; - default : Phrase_value.t; - sort : Sort.t; - } - [@@deriving sexp] -end +(* Workaround for issue #1187 (i.e., the @@deriving sexp clause on t + below creates code triggering warning 40 otherwise) *) +open Sexplib0.Sexp_conv + +type t = + | Lens of { table : Database.Table.t; sort : Sort.t } + | LensMem of { records : Phrase_value.t list; sort : Sort.t } + | LensSelect of { lens : t; predicate : Phrase.t; sort : Sort.t } + | LensJoin of { + left : t; + right : t; + on : (string * string * string) list; + del_left : Phrase.t; + del_right : Phrase.t; + sort : Sort.t; + } + | LensDrop of { + lens : t; + drop : string; + key : string; + default : Phrase_value.t; + sort : Sort.t; + } +[@@deriving sexp] let serialize v = let sexp = sexp_of_t v in From 7ab3429e0f804e65c90b6275685a046db9c3bc14 Mon Sep 17 00:00:00 2001 From: Frank Emrich Date: Wed, 18 Oct 2023 13:33:03 +0100 Subject: [PATCH 3/3] require v0.16.0 or newer --- lens/column.ml | 3 ++- lens/database.ml | 3 ++- lens/sort.ml | 3 ++- lens/value.ml | 3 ++- links.opam | 2 +- 5 files changed, 9 insertions(+), 5 deletions(-) diff --git a/lens/column.ml b/lens/column.ml index 2fd3bd4e9..cc045fe99 100644 --- a/lens/column.ml +++ b/lens/column.ml @@ -3,7 +3,8 @@ module Type = Phrase_type (* Workaround for issue #1187 (i.e., the @@deriving sexp clause on t below creates code triggering warning 40 otherwise) *) -open Sexplib0.Sexp_conv +open Sexplib0.Sexp_conv_record.Fields +open Sexplib0.Sexp_conv_record.Kind type t = { table : string; diff --git a/lens/database.ml b/lens/database.ml index 61e683f69..1fb7f26d3 100644 --- a/lens/database.ml +++ b/lens/database.ml @@ -4,7 +4,8 @@ module LPV = Phrase_value (* Workaround for issue #1187 (i.e., the @@deriving sexp clause on t below creates code triggering warning 40 otherwise) *) -open Sexplib0.Sexp_conv +open Sexplib0.Sexp_conv_record.Fields +open Sexplib0.Sexp_conv_record.Kind type t = { serialize : unit -> string; diff --git a/lens/sort.ml b/lens/sort.ml index e24638de7..b3481727f 100644 --- a/lens/sort.ml +++ b/lens/sort.ml @@ -4,7 +4,8 @@ module Column = Column (* Workaround for issue #1187 (i.e., the @@deriving sexp clause on t below creates code triggering warning 40 otherwise) *) -open Sexplib0.Sexp_conv +open Sexplib0.Sexp_conv_record.Fields +open Sexplib0.Sexp_conv_record.Kind type t = { fds : Fun_dep.Set.t; diff --git a/lens/value.ml b/lens/value.ml index f5ea3fdb6..67a50cddd 100644 --- a/lens/value.ml +++ b/lens/value.ml @@ -2,7 +2,8 @@ open Lens_utility (* Workaround for issue #1187 (i.e., the @@deriving sexp clause on t below creates code triggering warning 40 otherwise) *) -open Sexplib0.Sexp_conv +open Sexplib0.Sexp_conv_record.Fields +open Sexplib0.Sexp_conv_record.Kind type t = | Lens of { table : Database.Table.t; sort : Sort.t } diff --git a/links.opam b/links.opam index a9b2ee02d..ae354ac9d 100644 --- a/links.opam +++ b/links.opam @@ -35,7 +35,7 @@ depends: [ "result" "ocamlfind" "menhir" {>= "20210419"} - "ppx_sexp_conv" + "ppx_sexp_conv" {>= "v0.16.0"} "calendar" {>= "2.0.4"} "rdf_lwt" {>= "0.13.0"} ]