Skip to content

Commit

Permalink
workaround
Browse files Browse the repository at this point in the history
  • Loading branch information
frank-emrich committed Oct 17, 2023
1 parent 0b45544 commit a34bb86
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 46 deletions.
24 changes: 16 additions & 8 deletions lens/column.ml
Original file line number Diff line number Diff line change
@@ -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 }
Expand Down
34 changes: 24 additions & 10 deletions lens/database.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down Expand Up @@ -48,7 +56,13 @@ let show _ = "<db_driver>"
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
Expand Down
22 changes: 15 additions & 7 deletions lens/sort.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
48 changes: 28 additions & 20 deletions lens/value.ml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion links.opam
Original file line number Diff line number Diff line change
Expand Up @@ -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"}
]

0 comments on commit a34bb86

Please sign in to comment.