Skip to content

Commit

Permalink
open Sexplib0.Sexp_conv instead
Browse files Browse the repository at this point in the history
  • Loading branch information
frank-emrich committed Nov 9, 2023
1 parent 52deb33 commit 72d8590
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 83 deletions.
28 changes: 12 additions & 16 deletions lens/column.ml
Original file line number Diff line number Diff line change
@@ -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 }
Expand Down
38 changes: 14 additions & 24 deletions lens/database.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down Expand Up @@ -56,13 +52,7 @@ let show _ = "<db_driver>"
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
Expand Down
26 changes: 11 additions & 15 deletions lens/sort.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
52 changes: 24 additions & 28 deletions lens/value.ml
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 72d8590

Please sign in to comment.