Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop ppx deriving #50

Merged
merged 3 commits into from
Oct 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion caqti.opam
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ depends: [
"dune" {>= "1.11"}
"logs"
"ocaml" {>= "4.04.0"}
"ppx_deriving"
"ptime"
"uri" {>= "1.9.0"}
]
Expand Down
6 changes: 6 additions & 0 deletions lib/caqti_common_priv.ml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ module List = struct
let rec iter_r f = function
| [] -> Ok ()
| x :: xs -> (match f x with Ok () -> iter_r f xs | Error _ as r -> r)

let rec equal f xs ys =
(match xs, ys with
| [], [] -> true
| x :: xs', y :: ys' -> f x y && equal f xs' ys'
| [], _ :: _ | _ :: _, [] -> false)
end

let finally cleanup thunk =
Expand Down
1 change: 1 addition & 0 deletions lib/caqti_common_priv.mli
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ module List : sig
val fold : ('a -> 'b -> 'b) -> 'a list -> 'b -> 'b
val fold_r : ('a -> 'b -> ('b, 'e) result) -> 'a list -> 'b -> ('b, 'e) result
val iter_r : ('a -> (unit, 'e) result) -> 'a list -> (unit, 'e) result
val equal : ('a -> 'b -> bool) -> 'a list -> 'b list -> bool
end

val finally : (unit -> unit) -> (unit -> 'a) -> 'a
Expand Down
14 changes: 13 additions & 1 deletion lib/caqti_query.ml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@
* along with this library. If not, see <http://www.gnu.org/licenses/>.
*)

open Caqti_common_priv

type t =
| L of string
| Q of string
| P of int
| S of t list
[@@deriving eq]

let normal =
let rec collect acc = function
Expand All @@ -41,6 +42,17 @@ let normal =
| [q] -> q
| qs -> S qs)

let rec equal t1 t2 =
match t1, t2 with
| L s1, L s2 -> String.equal s1 s2
| Q s1, Q s2 -> String.equal s1 s2
| P i1, P i2 -> Int.equal i1 i2
| S ts1, S ts2 -> List.equal equal ts1 ts2
| L _, _ -> false
| Q _, _ -> false
| P _, _ -> false
| S _, _ -> false

let hash = Hashtbl.hash

let rec pp ppf = function
Expand Down
3 changes: 1 addition & 2 deletions lib/dune
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@
(private_modules
Caqti_compat)
(library_flags (:standard -linkall))
(libraries logs ptime uri)
(preprocess (pps ppx_deriving.eq)))
(libraries logs ptime uri))

(rule
(target caqti_compat.ml)
Expand Down