diff --git a/caqti.opam b/caqti.opam index 095f3fc1..12369e96 100644 --- a/caqti.opam +++ b/caqti.opam @@ -14,7 +14,6 @@ depends: [ "dune" {>= "1.11"} "logs" "ocaml" {>= "4.04.0"} - "ppx_deriving" "ptime" "uri" {>= "1.9.0"} ] diff --git a/lib/caqti_common_priv.ml b/lib/caqti_common_priv.ml index c415053b..22ca8090 100644 --- a/lib/caqti_common_priv.ml +++ b/lib/caqti_common_priv.ml @@ -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 = diff --git a/lib/caqti_common_priv.mli b/lib/caqti_common_priv.mli index 0007181e..cab4da1b 100644 --- a/lib/caqti_common_priv.mli +++ b/lib/caqti_common_priv.mli @@ -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 diff --git a/lib/caqti_query.ml b/lib/caqti_query.ml index 5c6c5a3b..fe951d61 100644 --- a/lib/caqti_query.ml +++ b/lib/caqti_query.ml @@ -14,12 +14,13 @@ * along with this library. If not, see . *) +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 @@ -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 diff --git a/lib/dune b/lib/dune index 90ab6271..41d111ec 100644 --- a/lib/dune +++ b/lib/dune @@ -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)