Resto: export RPC_arg.eq
to the protocol.
This commit is contained in:
parent
1460aba927
commit
b6b30875e4
@ -26,3 +26,9 @@ val int: int arg
|
|||||||
val int32: int32 arg
|
val int32: int32 arg
|
||||||
val int64: int64 arg
|
val int64: int64 arg
|
||||||
val float: float arg
|
val float: float arg
|
||||||
|
val string: string arg
|
||||||
|
|
||||||
|
val like: 'a arg -> ?descr:string -> string -> 'a arg
|
||||||
|
|
||||||
|
type ('a, 'b) eq = Eq : ('a, 'a) eq
|
||||||
|
val eq: 'a arg -> 'b arg -> ('a, 'b) eq option
|
||||||
|
@ -7,4 +7,5 @@
|
|||||||
(* *)
|
(* *)
|
||||||
(**************************************************************************)
|
(**************************************************************************)
|
||||||
|
|
||||||
|
type ('i, 'j) eq = ('i, 'j) Resto.eq = Eq : ('a, 'a) eq
|
||||||
include Resto.Arg
|
include Resto.Arg
|
||||||
|
@ -7,4 +7,5 @@
|
|||||||
(* *)
|
(* *)
|
||||||
(**************************************************************************)
|
(**************************************************************************)
|
||||||
|
|
||||||
|
type ('i, 'j) eq = ('i, 'j) Resto.eq = Eq : ('a, 'a) eq
|
||||||
include (module type of struct include Resto.Arg end)
|
include (module type of struct include Resto.Arg end)
|
||||||
|
@ -233,7 +233,7 @@ module Make (Encoding : ENCODING) = struct
|
|||||||
Some (Suffixes (merge m1 m2))
|
Some (Suffixes (merge m1 m2))
|
||||||
| Arg (arg1, subt1), Arg (arg2, subt2) ->
|
| Arg (arg1, subt1), Arg (arg2, subt2) ->
|
||||||
begin
|
begin
|
||||||
try let Ty.Eq = Ty.eq arg1.id arg2.id in
|
try let Eq = Ty.eq arg1.id arg2.id in
|
||||||
let subt = merge (Dynamic arg1.descr :: path) subt1 subt2 in
|
let subt = merge (Dynamic arg1.descr :: path) subt1 subt2 in
|
||||||
Some (Arg (arg1, subt))
|
Some (Arg (arg1, subt))
|
||||||
with Ty.Not_equal ->
|
with Ty.Not_equal ->
|
||||||
@ -455,7 +455,7 @@ module Make (Encoding : ENCODING) = struct
|
|||||||
match Ty.eq iarg.id arg.id with
|
match Ty.eq iarg.id arg.id with
|
||||||
| exception Ty.Not_equal ->
|
| exception Ty.Not_equal ->
|
||||||
Lwt.return_none
|
Lwt.return_none
|
||||||
| Ty.Eq ->
|
| Eq ->
|
||||||
Lwt.return_some (dir : (_ * _) directory :> p directory)
|
Lwt.return_some (dir : (_ * _) directory :> p directory)
|
||||||
end
|
end
|
||||||
| Empty -> Lwt.return_none
|
| Empty -> Lwt.return_none
|
||||||
@ -472,7 +472,7 @@ module Make (Encoding : ENCODING) = struct
|
|||||||
match Ty.eq iarg.id arg.id with
|
match Ty.eq iarg.id arg.id with
|
||||||
| exception Ty.Not_equal ->
|
| exception Ty.Not_equal ->
|
||||||
Lwt.return_none
|
Lwt.return_none
|
||||||
| Ty.Eq ->
|
| Eq ->
|
||||||
Lwt.return_some (dir : (_ * _) directory :> p directory)
|
Lwt.return_some (dir : (_ * _) directory :> p directory)
|
||||||
end
|
end
|
||||||
| Empty -> Lwt.return_none
|
| Empty -> Lwt.return_none
|
||||||
@ -578,7 +578,7 @@ module Make (Encoding : ENCODING) = struct
|
|||||||
| Static { subdirs = Some (Arg (arg', dir)) ;
|
| Static { subdirs = Some (Arg (arg', dir)) ;
|
||||||
services } -> begin
|
services } -> begin
|
||||||
try
|
try
|
||||||
let Ty.Eq = Ty.eq arg.id arg'.id in
|
let Eq = Ty.eq arg.id arg'.id in
|
||||||
(dir :> k directory), services
|
(dir :> k directory), services
|
||||||
with Ty.Not_equal ->
|
with Ty.Not_equal ->
|
||||||
conflict path (CTypes (arg.descr, arg'.descr))
|
conflict path (CTypes (arg.descr, arg'.descr))
|
||||||
|
13
vendors/ocplib-resto/lib_resto/resto.ml
vendored
13
vendors/ocplib-resto/lib_resto/resto.ml
vendored
@ -28,13 +28,14 @@ let meth_of_string = function
|
|||||||
module MethMap = Map.Make(struct type t = meth let compare = compare end)
|
module MethMap = Map.Make(struct type t = meth let compare = compare end)
|
||||||
module StringMap = Map.Make(String)
|
module StringMap = Map.Make(String)
|
||||||
|
|
||||||
|
type (_, _) eq = Eq : ('a, 'a) eq
|
||||||
|
|
||||||
module Internal = struct
|
module Internal = struct
|
||||||
|
|
||||||
module Ty = struct
|
module Ty = struct
|
||||||
|
|
||||||
type 'a witness = ..
|
type 'a witness = ..
|
||||||
exception Not_equal
|
exception Not_equal
|
||||||
type (_, _) eq = Eq : ('a, 'a) eq
|
|
||||||
module type Ty = sig
|
module type Ty = sig
|
||||||
type t val witness : t witness
|
type t val witness : t witness
|
||||||
val eq: 'a witness -> ('a, t) eq
|
val eq: 'a witness -> ('a, t) eq
|
||||||
@ -217,6 +218,10 @@ module Arg = struct
|
|||||||
let string =
|
let string =
|
||||||
make ~name:"string" ~destruct:(fun x -> Ok x) ~construct:(fun x -> x) ()
|
make ~name:"string" ~destruct:(fun x -> Ok x) ~construct:(fun x -> x) ()
|
||||||
|
|
||||||
|
let eq a1 a2 =
|
||||||
|
try Some (Ty.eq a1.id a2.id)
|
||||||
|
with Internal.Ty.Not_equal -> None
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
module Path = struct
|
module Path = struct
|
||||||
@ -329,7 +334,7 @@ module Query = struct
|
|||||||
| F1 (Single field, fs) -> begin
|
| F1 (Single field, fs) -> begin
|
||||||
match StringMap.find field.name map with
|
match StringMap.find field.name map with
|
||||||
| Parsed (Single field', v) ->
|
| Parsed (Single field', v) ->
|
||||||
let Ty.Eq = Ty.eq field.ty.id field'.ty.id in
|
let Eq = Ty.eq field.ty.id field'.ty.id in
|
||||||
let v = match v with None -> field.default | Some v -> v in
|
let v = match v with None -> field.default | Some v -> v in
|
||||||
rebuild map fs (f v)
|
rebuild map fs (f v)
|
||||||
| Parsed _ -> assert false
|
| Parsed _ -> assert false
|
||||||
@ -337,7 +342,7 @@ module Query = struct
|
|||||||
| F1 (Opt field, fs) -> begin
|
| F1 (Opt field, fs) -> begin
|
||||||
match StringMap.find field.name map with
|
match StringMap.find field.name map with
|
||||||
| Parsed (Opt field', v) ->
|
| Parsed (Opt field', v) ->
|
||||||
let Ty.Eq = Ty.eq field.ty.id field'.ty.id in
|
let Eq = Ty.eq field.ty.id field'.ty.id in
|
||||||
let v = match v with None -> None | Some v -> v in
|
let v = match v with None -> None | Some v -> v in
|
||||||
rebuild map fs (f v)
|
rebuild map fs (f v)
|
||||||
| Parsed _ -> assert false
|
| Parsed _ -> assert false
|
||||||
@ -352,7 +357,7 @@ module Query = struct
|
|||||||
| F1 (Multi field, fs) -> begin
|
| F1 (Multi field, fs) -> begin
|
||||||
match StringMap.find field.name map with
|
match StringMap.find field.name map with
|
||||||
| Parsed (Multi field', v) ->
|
| Parsed (Multi field', v) ->
|
||||||
let Ty.Eq = Ty.eq field.ty.id field'.ty.id in
|
let Eq = Ty.eq field.ty.id field'.ty.id in
|
||||||
let v = match v with None -> [] | Some v -> v in
|
let v = match v with None -> [] | Some v -> v in
|
||||||
rebuild map fs (f v)
|
rebuild map fs (f v)
|
||||||
| Parsed _ -> assert false
|
| Parsed _ -> assert false
|
||||||
|
6
vendors/ocplib-resto/lib_resto/resto.mli
vendored
6
vendors/ocplib-resto/lib_resto/resto.mli
vendored
@ -17,6 +17,8 @@ module MethMap : Map.S with type key = meth
|
|||||||
module StringMap : Map.S with type 'a t = 'a Map.Make(String).t
|
module StringMap : Map.S with type 'a t = 'a Map.Make(String).t
|
||||||
and type key = string
|
and type key = string
|
||||||
|
|
||||||
|
type (_, _) eq = Eq : ('a, 'a) eq
|
||||||
|
|
||||||
(** Typed path argument. *)
|
(** Typed path argument. *)
|
||||||
module Arg : sig
|
module Arg : sig
|
||||||
|
|
||||||
@ -44,6 +46,8 @@ module Arg : sig
|
|||||||
|
|
||||||
val like: 'a arg -> ?descr:string -> string -> 'a arg
|
val like: 'a arg -> ?descr:string -> string -> 'a arg
|
||||||
|
|
||||||
|
val eq: 'a arg -> 'b arg -> ('a, 'b) eq option
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@ -181,8 +185,6 @@ module Internal : sig
|
|||||||
module Ty : sig
|
module Ty : sig
|
||||||
|
|
||||||
exception Not_equal
|
exception Not_equal
|
||||||
type (_, _) eq = Eq : ('a, 'a) eq
|
|
||||||
|
|
||||||
type 'a id
|
type 'a id
|
||||||
val eq : 'a id -> 'b id -> ('a, 'b) eq
|
val eq : 'a id -> 'b id -> ('a, 'b) eq
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user