Declarative CSV codecs
0
fork

Configure Feed

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

Fix cbort build: export read_argument_z/bignum/decode_half, remove broken Result.bind in empty-array error paths

The query refactor added functions to cbor_rw.ml that weren't
exported in the .mli. The tuple decoders had a bogus
Result.bind on the empty-array path that consumed nothing —
replaced with direct Error.

Also wires kind through csvt base_map so col_map ~kind is used.

+15 -4
+15 -4
lib/csvt.ml
··· 40 40 Column values are decoded into a heterogeneous [Dict] keyed by 41 41 [Type.Id.t] witnesses, then applied to the constructor via [apply_dict]. *) 42 42 43 - type ('a, 'b) base_map = { dec : 'a -> ('b, string) result; enc : 'b -> 'a } 43 + type ('a, 'b) base_map = { 44 + kind : string; 45 + dec : 'a -> ('b, string) result; 46 + enc : 'b -> 'a; 47 + } 44 48 45 49 type ('ret, 'f) dec_fun = 46 50 | Dec_fun : 'f -> ('ret, 'f) dec_fun ··· 100 104 let rec pp : type a. a t Fmt.t = 101 105 fun ppf t -> 102 106 match t with 103 - | String _ -> Fmt.string ppf "field" 107 + | String m -> Fmt.string ppf m.kind 104 108 | Map m -> pp ppf m.dom 105 109 | Obj m -> 106 110 let names = List.map (fun (Mem_dec mm) -> mm.name) m.mem_decs in ··· 129 133 130 134 (* {1 Base codecs} *) 131 135 132 - let string : string t = String { dec = (fun s -> Ok s); enc = Fun.id } 136 + let string : string t = 137 + String { kind = "string"; dec = (fun s -> Ok s); enc = Fun.id } 133 138 134 139 let int : int t = 135 140 String 136 141 { 142 + kind = "int"; 137 143 dec = 138 144 (fun s -> 139 145 match int_of_string_opt s with ··· 145 151 let float : float t = 146 152 String 147 153 { 154 + kind = "float"; 148 155 dec = 149 156 (fun s -> 150 157 match float_of_string_opt s with ··· 156 163 let bool : bool t = 157 164 String 158 165 { 166 + kind = "bool"; 159 167 dec = 160 168 (fun s -> 161 169 match String.lowercase_ascii s with ··· 170 178 let nullable_float : float t = 171 179 String 172 180 { 181 + kind = "nullable_float"; 173 182 dec = 174 183 (fun s -> 175 184 if is_null s then Ok Float.nan ··· 183 192 let nullable_int : int t = 184 193 String 185 194 { 195 + kind = "nullable_int"; 186 196 dec = 187 197 (fun s -> 188 198 if is_null s then Ok (-1) ··· 196 206 let option t = 197 207 String 198 208 { 209 + kind = "option"; 199 210 dec = 200 211 (fun s -> 201 212 if is_null s then Ok None ··· 203 214 enc = (function None -> "NULL" | Some v -> encode_field t v); 204 215 } 205 216 206 - let col_map ?kind:_ ~dec ~enc () = String { dec; enc } 217 + let col_map ?(kind = "custom") ~dec ~enc () = String { kind; dec; enc } 207 218 208 219 (* {1 Row builder} *) 209 220