Declarative JSON data manipulation for OCaml
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

csv: rename from csvt

Drops the redundant "t" suffix. Library name, opam package, module
(Csvt -> Csv), and directory all rename in lockstep. Every downstream
reference in interop tests, libraries, and docs updated.

+17 -70
+1 -1
dune-project
··· 20 20 optional text-location tracking and layout preservation and is 21 21 compatible with effect-based concurrency.") 22 22 (depends 23 - (ocaml (>= 4.14)) 23 + (ocaml (>= 5.1)) 24 24 (dune (>= 3.21)) 25 25 (bytesrw (>= 0.1.0)) 26 26 (alcotest :with-test)
-31
lib/core.ml
··· 94 94 let c = String.get_uint8 h i in 95 95 Error (Printf.sprintf "%d: byte x%x not an ASCII hexadecimal digit" i c) 96 96 97 - (* Type identifiers. *) 98 - 99 - module Type = struct 100 - (* Can be removed once we require OCaml 5.1 *) 101 - type (_, _) eq = Equal : ('a, 'a) eq 102 - 103 - module Id = struct 104 - type _ id = .. 105 - 106 - module type ID = sig 107 - type t 108 - type _ id += Id : t id 109 - end 110 - 111 - type 'a t = (module ID with type t = 'a) 112 - 113 - let make (type a) () : a t = 114 - (module struct 115 - type t = a 116 - type _ id += Id : t id 117 - end) 118 - 119 - let provably_equal (type a b) ((module A) : a t) ((module B) : b t) : 120 - (a, b) eq option = 121 - match A.Id with B.Id -> Some Equal | _ -> None 122 - 123 - let uid (type a) ((module A) : a t) = 124 - Obj.Extension_constructor.id (Obj.Extension_constructor.of_val A.Id) 125 - end 126 - end 127 - 128 97 (* Resizable arrays *) 129 98 130 99 module Rarray = struct
-13
lib/core.mli
··· 9 9 val binary_string_of_hex : string -> (string, string) result 10 10 val binary_string_to_hex : string -> string 11 11 12 - (** Type identifiers. Can be removed once we require OCaml 5.1 *) 13 - module Type : sig 14 - type (_, _) eq = Equal : ('a, 'a) eq 15 - 16 - module Id : sig 17 - type 'a t 18 - 19 - val make : unit -> 'a t 20 - val uid : 'a t -> int 21 - val provably_equal : 'a t -> 'b t -> ('a, 'b) eq option 22 - end 23 - end 24 - 25 12 (** Resizable arrays. *) 26 13 module Rarray : sig 27 14 type 'a t
-1
lib/json.ml
··· 137 137 module Repr = struct 138 138 (* See the .mli for documentation *) 139 139 module String_map = Map.Make (String) 140 - module Type = Core.Type 141 140 142 141 type ('ret, 'f) dec_fun = 143 142 | Dec_fun : 'f -> ('ret, 'f) dec_fun
+16 -24
lib/json.mli
··· 903 903 (** {1:types JSON types} *) 904 904 905 905 val as_string_map : 906 - ?kind:string -> ?doc:string -> 'a codec -> 'a Stdlib.Map.Make(String).t codec 906 + ?kind:string -> 907 + ?doc:string -> 908 + 'a codec -> 909 + 'a Stdlib.Map.Make(String).t codec 907 910 (** [as_string_map t] maps object to key-value maps of type [t]. See also 908 911 {!Mems.string_map} and {!Json.json_mems}. *) 909 912 ··· 1032 1035 val set_meta : Meta.t -> t -> t 1033 1036 (** [set_meta m v] replaces [v]'s meta with [m]. *) 1034 1037 1035 - val copy_layout : t -> dst:json -> t 1038 + val copy_layout : t -> dst:t -> t 1036 1039 (** [copy_layout src ~dst] copies the layout of [src] and sets it on [dst] 1037 1040 using {!Meta.copy_ws}. *) 1038 1041 ··· 1197 1200 val json_object : t codec 1198 1201 (** [json_object] represents JSON objects by their generic representation. *) 1199 1202 1200 - val json_mems : (t, json, mem list) Object.Mems.map 1203 + val json_mems : (t, t, mem list) Object.Mems.map 1201 1204 (** [json_mems] is a members map collecting unknown members into a generic JSON 1202 1205 object. See {{!page-cookbook.keeping}this example}. *) 1203 1206 ··· 1233 1236 specified in which case this value is returned. Encodes a singleton array. 1234 1237 *) 1235 1238 1236 - val set_nth : 1237 - ?stub:json -> ?allow_absent:bool -> 'a codec -> int -> 'a -> t codec 1239 + val set_nth : ?stub:t -> ?allow_absent:bool -> 'a codec -> int -> 'a -> t codec 1238 1240 (** [set_nth t n v] on decodes sets the [n]th value of a JSON array to [v] 1239 1241 encoded by [t]. Other indices are left untouched. Errors if there is no such 1240 1242 index unless [~allow_absent:true] is specified in which case the index is ··· 1242 1244 {!Json.zero} applied to the value [v] encoded by [t] (i.e. the "natural 1243 1245 zero" of [v]'s encoding sort). Encodes like {!json_array} does. *) 1244 1246 1245 - val update_nth : ?stub:json -> ?absent:'a -> int -> 'a codec -> t codec 1247 + val update_nth : ?stub:t -> ?absent:'a -> int -> 'a codec -> t codec 1246 1248 (** [update_nth n t] on decode recodes the [n]th value of a JSON array with [t]. 1247 1249 Errors if there is no such index unless [absent] is specified in which case 1248 1250 the index is created with [absent], encoded with [t] and preceeded by as ··· 1292 1294 is left untouched. Encodes generic JSON objects like {!json_object} does. *) 1293 1295 1294 1296 val filter_map_object : 1295 - 'a codec -> 'b codec -> (Meta.t -> string -> 'a -> (name * 'b) option) -> t t 1297 + 'a codec -> 1298 + 'b codec -> 1299 + (Meta.t -> string -> 'a -> (name * 'b) option) -> 1300 + t codec 1296 1301 (** [filter_map_object a b f] maps the [a] members of a JSON object with [f] to 1297 1302 [(n, b)] members or deletes them on [None]. The meta given to [f] is the 1298 1303 meta of the member name. Encodes generic JSON arrays like {!json_object} ··· 1311 1316 val set_index : ?allow_absent:bool -> 'a codec -> Path.index -> 'a -> t codec 1312 1317 (** [set_index] uses {!set_nth} or {!set_mem} on the given index. *) 1313 1318 1314 - val update_index : ?stub:json -> ?absent:'a -> Path.index -> 'a codec -> t codec 1319 + val update_index : ?stub:t -> ?absent:'a -> Path.index -> 'a codec -> t codec 1315 1320 (** [update_index] uses {!update_nth} or {!update_mem} on the given index. *) 1316 1321 1317 1322 val delete_index : ?allow_absent:bool -> Path.index -> t codec ··· 1324 1329 {!Path.root} this is [t]. *) 1325 1330 1326 1331 val set_path : 1327 - ?stub:json -> ?allow_absent:bool -> 'a codec -> Path.t -> 'a -> t codec 1332 + ?stub:t -> ?allow_absent:bool -> 'a codec -> Path.t -> 'a -> t codec 1328 1333 (** [set_path t p v] {{!set_index}sets} the last index of [p]. If [p] is 1329 1334 {!Path.root} this encodes [v] with [t]. *) 1330 1335 1331 - val update_path : ?stub:json -> ?absent:'a -> Path.t -> 'a codec -> t codec 1336 + val update_path : ?stub:t -> ?absent:'a -> Path.t -> 'a codec -> t codec 1332 1337 (** [update_path p t] {{!update_index}updates} the last index of [p] with [t]. 1333 1338 On the root path this is [t]. *) 1334 1339 ··· 1414 1419 module String_map : Map.S with type key = string 1415 1420 (** A [Map.Make(String)] instance. *) 1416 1421 1417 - (** Type identifiers. Can be removed once we require OCaml 5.1 *) 1418 - module Type : sig 1419 - type (_, _) eq = Equal : ('a, 'a) eq 1420 - 1421 - module Id : sig 1422 - type 'a codec 1423 - 1424 - val make : unit -> 'a codec 1425 - val uid : 'a codec -> int 1426 - val provably_equal : 'a codec -> 'b codec -> ('a, 'b) eq option 1427 - end 1428 - end 1429 - 1430 1422 (** The type for decoding functions. *) 1431 1423 type ('ret, 'f) dec_fun = 1432 1424 | Dec_fun : 'f -> ('ret, 'f) dec_fun ··· 1464 1456 | Number : (float, 'a) base_map -> 'a codec (** Number maps. *) 1465 1457 | String : (string, 'a) base_map -> 'a codec (** String maps. *) 1466 1458 | Array : ('a, 'elt, 'builder) array_map -> 'a codec (** Array maps. *) 1467 - | Object : ('o, 'o) object_map -> 'o t (** Object maps. *) 1459 + | Object : ('o, 'o) object_map -> 'o codec (** Object maps. *) 1468 1460 | Any : 'a any_map -> 'a codec 1469 1461 (** Map for different sorts of JSON values. *) 1470 1462 | Map : ('b, 'a) map -> 'a codec