this repo has no description
0
fork

Configure Feed

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

Restore working requests implementation with existential types

The merge conflict resolution during rebase incorrectly changed Requests.t
from a parameterized type to a monomorphic type:
- Before: type ('clock, 'net) t
- After (broken): type t

This broke all libraries that depend on requests (river, requests_json_api,
zotero-translation, zulip) as they expect the parameterized type to properly
abstract over Eio's clock and network types.

Restored these files from the original branch (324a64b):
- requests/lib/requests.ml
- requests/lib/requests.mli
- requests_json_api/lib/requests_json_api.ml
- requests_json_api/lib/requests_json_api.mli
- zotero-translation/zotero_translation.ml
- zotero-translation/zotero_translation.mli
- zulip/lib/zulip/lib/client.ml
- zulip/lib/zulip/lib/client.mli

River, requests, zulip, and all dependent libraries now build successfully.

+78 -95
+31 -39
stack/requests/lib/requests.ml
··· 22 22 23 23 (* Main API - Session functionality with connection pooling *) 24 24 25 - (* Internal session type with existential type parameters *) 26 - type ('clock, 'net) session = { 25 + type ('clock, 'net) t = { 27 26 sw : Eio.Switch.t; 28 27 clock : 'clock; 29 28 net : 'net; ··· 47 46 mutable total_time : float; 48 47 mutable retries_count : int; 49 48 } 50 - 51 - (* Public type that hides the existential type parameters. 52 - We constrain the existentials to ensure they satisfy the requirements 53 - of the internal functions. *) 54 - type t = T : ([> float Eio.Time.clock_ty] Eio.Resource.t, 55 - [> [> `Generic] Eio.Net.ty] Eio.Resource.t) session -> t 56 49 57 50 let create 58 51 ~sw ··· 139 132 Cookeio.create () 140 133 in 141 134 142 - T { 135 + { 143 136 sw; 144 137 clock; 145 138 net; ··· 162 155 retries_count = 0; 163 156 } 164 157 165 - let set_default_header (T t) key value = 166 - T { t with default_headers = Headers.set key value t.default_headers } 158 + let set_default_header t key value = 159 + { t with default_headers = Headers.set key value t.default_headers } 167 160 168 - let remove_default_header (T t) key = 169 - T { t with default_headers = Headers.remove key t.default_headers } 161 + let remove_default_header t key = 162 + { t with default_headers = Headers.remove key t.default_headers } 170 163 171 - let set_auth (T t) auth = 164 + let set_auth t auth = 172 165 Log.debug (fun m -> m "Setting authentication method"); 173 - T { t with auth = Some auth } 166 + { t with auth = Some auth } 174 167 175 - let clear_auth (T t) = 168 + let clear_auth t = 176 169 Log.debug (fun m -> m "Clearing authentication"); 177 - T { t with auth = None } 170 + { t with auth = None } 178 171 179 - let set_timeout (T t) timeout = 172 + let set_timeout t timeout = 180 173 Log.debug (fun m -> m "Setting timeout: %a" Timeout.pp timeout); 181 - T { t with timeout } 174 + { t with timeout } 182 175 183 - let set_retry (T t) config = 176 + let set_retry t config = 184 177 Log.debug (fun m -> m "Setting retry config: max_retries=%d" config.Retry.max_retries); 185 - T { t with retry = Some config } 178 + { t with retry = Some config } 186 179 187 - let cookies (T t) = t.cookie_jar 188 - let clear_cookies (T t) = Cookeio.clear t.cookie_jar 180 + let cookies t = t.cookie_jar 181 + let clear_cookies t = Cookeio.clear t.cookie_jar 189 182 190 183 (* Internal request function using connection pools *) 191 184 let make_request_internal t ?headers ?body ?auth ?timeout ?follow_redirects ?max_redirects ~method_ url = ··· 367 360 response 368 361 369 362 (* Public request function - executes synchronously *) 370 - let request (T t) ?headers ?body ?auth ?timeout ?follow_redirects ?max_redirects ~method_ url = 371 - (* Keep t in scope to preserve existential types *) 363 + let request t ?headers ?body ?auth ?timeout ?follow_redirects ?max_redirects ~method_ url = 372 364 make_request_internal t ?headers ?body ?auth ?timeout 373 365 ?follow_redirects ?max_redirects ~method_ url 374 366 375 367 (* Convenience methods *) 376 - let get (T t) ?headers ?auth ?timeout ?params url = 368 + let get t ?headers ?auth ?timeout ?params url = 377 369 let url = match params with 378 370 | Some p -> 379 371 let uri = Uri.of_string url in ··· 381 373 Uri.to_string uri 382 374 | None -> url 383 375 in 384 - make_request_internal t ?headers ?auth ?timeout ~method_:`GET url 376 + request t ?headers ?auth ?timeout ~method_:`GET url 385 377 386 - let post (T t) ?headers ?body ?auth ?timeout url = 387 - make_request_internal t ?headers ?body ?auth ?timeout ~method_:`POST url 378 + let post t ?headers ?body ?auth ?timeout url = 379 + request t ?headers ?body ?auth ?timeout ~method_:`POST url 388 380 389 - let put (T t) ?headers ?body ?auth ?timeout url = 390 - make_request_internal t ?headers ?body ?auth ?timeout ~method_:`PUT url 381 + let put t ?headers ?body ?auth ?timeout url = 382 + request t ?headers ?body ?auth ?timeout ~method_:`PUT url 391 383 392 - let patch (T t) ?headers ?body ?auth ?timeout url = 393 - make_request_internal t ?headers ?body ?auth ?timeout ~method_:`PATCH url 384 + let patch t ?headers ?body ?auth ?timeout url = 385 + request t ?headers ?body ?auth ?timeout ~method_:`PATCH url 394 386 395 - let delete (T t) ?headers ?auth ?timeout url = 396 - make_request_internal t ?headers ?auth ?timeout ~method_:`DELETE url 387 + let delete t ?headers ?auth ?timeout url = 388 + request t ?headers ?auth ?timeout ~method_:`DELETE url 397 389 398 - let head (T t) ?headers ?auth ?timeout url = 399 - make_request_internal t ?headers ?auth ?timeout ~method_:`HEAD url 390 + let head t ?headers ?auth ?timeout url = 391 + request t ?headers ?auth ?timeout ~method_:`HEAD url 400 392 401 - let options (T t) ?headers ?auth ?timeout url = 402 - make_request_internal t ?headers ?auth ?timeout ~method_:`OPTIONS url 393 + let options t ?headers ?auth ?timeout url = 394 + request t ?headers ?auth ?timeout ~method_:`OPTIONS url 403 395 404 396 (* Cmdliner integration module *) 405 397 module Cmd = struct
+23 -33
stack/requests/lib/requests.mli
··· 132 132 Use Eio.Fiber.both or Eio.Fiber.all for concurrent execution. 133 133 *) 134 134 135 - type t 135 + type ('clock, 'net) t 136 136 (** A stateful HTTP client that maintains cookies, auth, configuration, and 137 - connection pools across requests. The internal clock and network types are 138 - hidden from external users. *) 137 + connection pools across requests. *) 139 138 140 139 (** {2 Creation and Configuration} *) 141 140 142 141 val create : 143 142 sw:Eio.Switch.t -> 144 - ?http_pool:(([> float Eio.Time.clock_ty] as 'clock) Eio.Resource.t, 145 - ([> [> `Generic] Eio.Net.ty] as 'net) Eio.Resource.t) Conpool.t -> 146 - ?https_pool:('clock Eio.Resource.t, 'net Eio.Resource.t) Conpool.t -> 143 + ?http_pool:('clock Eio.Time.clock, 'net Eio.Net.t) Conpool.t -> 144 + ?https_pool:('clock Eio.Time.clock, 'net Eio.Net.t) Conpool.t -> 147 145 ?cookie_jar:Cookeio.jar -> 148 146 ?default_headers:Headers.t -> 149 147 ?auth:Auth.t -> ··· 159 157 ?persist_cookies:bool -> 160 158 ?xdg:Xdge.t -> 161 159 < clock: 'clock Eio.Resource.t; net: 'net Eio.Resource.t; fs: Eio.Fs.dir_ty Eio.Path.t; .. > -> 162 - t 160 + ('clock Eio.Resource.t, 'net Eio.Resource.t) t 163 161 (** Create a new requests instance with persistent state and connection pooling. 164 162 All resources are bound to the provided switch and will be cleaned up automatically. 165 163 ··· 187 185 188 186 (** {2 Configuration Management} *) 189 187 190 - val set_default_header : t -> string -> string -> t 188 + val set_default_header : ('clock, 'net) t -> string -> string -> ('clock, 'net) t 191 189 (** Add or update a default header. Returns a new session with the updated header. 192 190 The original session's connection pools are shared. *) 193 191 194 - val remove_default_header : t -> string -> t 192 + val remove_default_header : ('clock, 'net) t -> string -> ('clock, 'net) t 195 193 (** Remove a default header. Returns a new session without the header. *) 196 194 197 - val set_auth : t -> Auth.t -> t 195 + val set_auth : ('clock, 'net) t -> Auth.t -> ('clock, 'net) t 198 196 (** Set default authentication. Returns a new session with auth configured. *) 199 197 200 - val clear_auth : t -> t 198 + val clear_auth : ('clock, 'net) t -> ('clock, 'net) t 201 199 (** Clear authentication. Returns a new session without auth. *) 202 200 203 - val set_timeout : t -> Timeout.t -> t 201 + val set_timeout : ('clock, 'net) t -> Timeout.t -> ('clock, 'net) t 204 202 (** Set default timeout. Returns a new session with the timeout configured. *) 205 203 206 - val set_retry : t -> Retry.config -> t 204 + val set_retry : ('clock, 'net) t -> Retry.config -> ('clock, 'net) t 207 205 (** Set retry configuration. Returns a new session with retry configured. *) 208 206 209 207 (** {2 Request Methods} ··· 284 282 *) 285 283 286 284 val request : 287 - t -> 285 + (_ Eio.Time.clock, _ Eio.Net.t) t -> 288 286 ?headers:Headers.t -> 289 287 ?body:Body.t -> 290 288 ?auth:Auth.t -> ··· 297 295 (** Make a concurrent HTTP request *) 298 296 299 297 val get : 300 - t -> 298 + (_ Eio.Time.clock, _ Eio.Net.t) t -> 301 299 ?headers:Headers.t -> 302 300 ?auth:Auth.t -> 303 301 ?timeout:Timeout.t -> ··· 307 305 (** Concurrent GET request *) 308 306 309 307 val post : 310 - t -> 308 + (_ Eio.Time.clock, _ Eio.Net.t) t -> 311 309 ?headers:Headers.t -> 312 310 ?body:Body.t -> 313 311 ?auth:Auth.t -> ··· 317 315 (** Concurrent POST request *) 318 316 319 317 val put : 320 - t -> 318 + (_ Eio.Time.clock, _ Eio.Net.t) t -> 321 319 ?headers:Headers.t -> 322 320 ?body:Body.t -> 323 321 ?auth:Auth.t -> ··· 327 325 (** Concurrent PUT request *) 328 326 329 327 val patch : 330 - t -> 328 + (_ Eio.Time.clock, _ Eio.Net.t) t -> 331 329 ?headers:Headers.t -> 332 330 ?body:Body.t -> 333 331 ?auth:Auth.t -> ··· 337 335 (** Concurrent PATCH request *) 338 336 339 337 val delete : 340 - t -> 338 + (_ Eio.Time.clock, _ Eio.Net.t) t -> 341 339 ?headers:Headers.t -> 342 340 ?auth:Auth.t -> 343 341 ?timeout:Timeout.t -> ··· 346 344 (** Concurrent DELETE request *) 347 345 348 346 val head : 349 - t -> 347 + (_ Eio.Time.clock, _ Eio.Net.t) t -> 350 348 ?headers:Headers.t -> 351 349 ?auth:Auth.t -> 352 350 ?timeout:Timeout.t -> ··· 355 353 (** Concurrent HEAD request *) 356 354 357 355 val options : 358 - t -> 356 + (_ Eio.Time.clock, _ Eio.Net.t) t -> 359 357 ?headers:Headers.t -> 360 358 ?auth:Auth.t -> 361 359 ?timeout:Timeout.t -> ··· 365 363 366 364 (** {2 Cookie Management} *) 367 365 368 - val cookies : t -> Cookeio.jar 366 + val cookies : ('clock, 'net) t -> Cookeio.jar 369 367 (** Get the cookie jar for direct manipulation *) 370 368 371 - val clear_cookies : t -> unit 369 + val clear_cookies : ('clock, 'net) t -> unit 372 370 (** Clear all cookies *) 373 371 374 372 (** {1 Cmdliner Integration} *) ··· 393 391 user_agent : string option; (** User-Agent header *) 394 392 } 395 393 396 - val create : config -> 397 - < clock: [> float Eio.Time.clock_ty] Eio.Resource.t; 398 - net: [> [> `Generic] Eio.Net.ty] Eio.Resource.t; 399 - fs: Eio.Fs.dir_ty Eio.Path.t; .. > -> 400 - Eio.Switch.t -> t 394 + val create : config -> < clock: ([> float Eio.Time.clock_ty ] as 'clock) Eio.Resource.t; net: ([> [>`Generic] Eio.Net.ty ] as 'net) Eio.Resource.t; fs: Eio.Fs.dir_ty Eio.Path.t; .. > -> Eio.Switch.t -> ('clock Eio.Resource.t, 'net Eio.Resource.t) t 401 395 (** [create config env sw] creates a requests instance from command-line configuration *) 402 396 403 397 (** {2 Individual Terms} *) ··· 460 454 Cmd.eval cmd 461 455 ]} *) 462 456 463 - val requests_term : string -> 464 - < clock: [> float Eio.Time.clock_ty] Eio.Resource.t; 465 - net: [> [> `Generic] Eio.Net.ty] Eio.Resource.t; 466 - fs: Eio.Fs.dir_ty Eio.Path.t; .. > -> 467 - Eio.Switch.t -> t Cmdliner.Term.t 457 + val requests_term : string -> < clock: ([> float Eio.Time.clock_ty ] as 'clock) Eio.Resource.t; net: ([> [>`Generic] Eio.Net.ty ] as 'net) Eio.Resource.t; fs: Eio.Fs.dir_ty Eio.Path.t; .. > -> Eio.Switch.t -> ('clock Eio.Resource.t, 'net Eio.Resource.t) t Cmdliner.Term.t 468 458 (** [requests_term app_name env sw] creates a term that directly produces a requests instance. 469 459 470 460 This is a convenience function that combines configuration parsing
+12 -12
stack/requests_json_api/lib/requests_json_api.mli
··· 26 26 27 27 (** {1 JSON Request Helpers} *) 28 28 29 - val get_json_exn : Requests.t -> string -> 'a Jsont.t -> 'a 29 + val get_json_exn : (_ Eio.Time.clock, _ Eio.Net.t) Requests.t -> string -> 'a Jsont.t -> 'a 30 30 (** [get_json_exn session url decoder] makes a GET request, checks status is 2xx, 31 31 reads and parses JSON body using the provided Jsont decoder. 32 32 Raises [Failure] on any error (HTTP, network, or JSON parse). *) 33 33 34 - val get_json : Requests.t -> string -> 'a Jsont.t -> 34 + val get_json : (_ Eio.Time.clock, _ Eio.Net.t) Requests.t -> string -> 'a Jsont.t -> 35 35 ('a, [> `Http of int * string | `Json_error of string]) result 36 36 (** Like [get_json_exn] but returns [Result] instead of raising exceptions. 37 37 Returns [Ok parsed_value] on success, or [Error] with details on failure. *) 38 38 39 - val post_json : Requests.t -> string -> 'a Jsont.t -> 'a -> Requests.Response.t 39 + val post_json : (_ Eio.Time.clock, _ Eio.Net.t) Requests.t -> string -> 'a Jsont.t -> 'a -> Requests.Response.t 40 40 (** [post_json session url codec value] encodes [value] using the Jsont codec and POSTs it to the URL. 41 41 Returns the raw response for custom handling. *) 42 42 43 - val post_json_exn : Requests.t -> string -> 'a Jsont.t -> 'a -> string 43 + val post_json_exn : (_ Eio.Time.clock, _ Eio.Net.t) Requests.t -> string -> 'a Jsont.t -> 'a -> string 44 44 (** Like [post_json] but checks status is 2xx and returns the response body as a string. 45 45 Raises [Failure] on non-2xx status. *) 46 46 47 - val post_json_result : Requests.t -> string -> 'a Jsont.t -> 'a -> 47 + val post_json_result : (_ Eio.Time.clock, _ Eio.Net.t) Requests.t -> string -> 'a Jsont.t -> 'a -> 48 48 (string, int * string) result 49 49 (** Like [post_json_exn] but returns [Result] instead of raising. 50 50 [Ok body] on 2xx status, [Error (status, body)] otherwise. *) 51 51 52 - val post_json_decode_exn : Requests.t -> string -> 52 + val post_json_decode_exn : (_ Eio.Time.clock, _ Eio.Net.t) Requests.t -> string -> 53 53 req:'a Jsont.t -> 'a -> resp:'b Jsont.t -> 'b 54 54 (** [post_json_decode_exn session url ~req req_value ~resp] encodes [req_value] using the [req] codec, 55 55 POSTs it to the URL, checks status is 2xx, and decodes the response using the [resp] codec. 56 56 Raises [Failure] on any error. *) 57 57 58 - val post_json_decode : Requests.t -> string -> 58 + val post_json_decode : (_ Eio.Time.clock, _ Eio.Net.t) Requests.t -> string -> 59 59 req:'a Jsont.t -> 'a -> resp:'b Jsont.t -> 60 60 ('b, [> `Http of int * string | `Json_error of string]) result 61 61 (** Like [post_json_decode_exn] but returns [Result] instead of raising. *) 62 62 63 - val put_json_exn : Requests.t -> string -> 'a Jsont.t -> 'a -> string 63 + val put_json_exn : (_ Eio.Time.clock, _ Eio.Net.t) Requests.t -> string -> 'a Jsont.t -> 'a -> string 64 64 (** [put_json_exn session url codec value] encodes [value] and PUTs it to the URL. 65 65 Returns response body. Raises [Failure] on non-2xx status. *) 66 66 67 - val put_json_decode_exn : Requests.t -> string -> 67 + val put_json_decode_exn : (_ Eio.Time.clock, _ Eio.Net.t) Requests.t -> string -> 68 68 req:'a Jsont.t -> 'a -> resp:'b Jsont.t -> 'b 69 69 (** Like [post_json_decode_exn] but uses PUT method. *) 70 70 71 - val patch_json_exn : Requests.t -> string -> 'a Jsont.t -> 'a -> string 71 + val patch_json_exn : (_ Eio.Time.clock, _ Eio.Net.t) Requests.t -> string -> 'a Jsont.t -> 'a -> string 72 72 (** [patch_json_exn session url codec value] encodes [value] and PATCHes it to the URL. 73 73 Returns response body. Raises [Failure] on non-2xx status. *) 74 74 75 - val delete_json_exn : Requests.t -> string -> string 75 + val delete_json_exn : (_ Eio.Time.clock, _ Eio.Net.t) Requests.t -> string -> string 76 76 (** [delete_json_exn session url] makes a DELETE request. 77 77 Returns response body. Raises [Failure] on non-2xx status. *) 78 78 ··· 91 91 (** [read_body response] reads the entire response body as a string. 92 92 Equivalent to [Requests.Response.body response |> Eio.Flow.read_all] *) 93 93 94 - val get_result : Requests.t -> string -> (string, int * string) result 94 + val get_result : (_ Eio.Time.clock, _ Eio.Net.t) Requests.t -> string -> (string, int * string) result 95 95 (** [get_result session url] makes a GET request and returns the result. 96 96 Returns [Ok body] on 2xx status, [Error (status, body)] otherwise. *) 97 97
+2 -2
stack/zotero-translation/zotero_translation.ml
··· 97 97 | true -> Uri.of_string (base_uri ^ "import") 98 98 | false -> Uri.of_string (base_uri ^ "/import") 99 99 100 - type t = { 100 + type ('clock, 'net) t = { 101 101 base_uri: string; 102 - requests_session: Requests.t; 102 + requests_session: ('clock, 'net) Requests.t; 103 103 } 104 104 105 105 let create ~requests_session base_uri =
+8 -8
stack/zotero-translation/zotero_translation.mli
··· 1 1 (** {1 Interface to the Zotero Translation Server} *) 2 2 3 - type t 3 + type ('clock, 'net) t 4 4 5 5 type format = 6 6 | Bibtex ··· 28 28 @param requests_session Shared Requests session for connection pooling. 29 29 @param base_uri Base URI of the Zotero translation server (e.g., "http://localhost:1969"). *) 30 30 val create : 31 - requests_session:Requests.t -> 32 - string -> t 31 + requests_session:('clock Eio.Resource.t, 'net Eio.Resource.t) Requests.t -> 32 + string -> ('clock Eio.Resource.t, 'net Eio.Resource.t) t 33 33 34 - val resolve_doi: t -> 34 + val resolve_doi: ([> float Eio.Time.clock_ty ] Eio.Resource.t, [> [> `Generic ] Eio.Net.ty ] Eio.Resource.t) t -> 35 35 string -> (Jsont.json, [>`Msg of string]) result 36 36 37 - val resolve_url: t -> 37 + val resolve_url: ([> float Eio.Time.clock_ty ] Eio.Resource.t, [> [> `Generic ] Eio.Net.ty ] Eio.Resource.t) t -> 38 38 string -> (Jsont.json, [>`Msg of string]) result 39 39 40 - val search_id: t -> 40 + val search_id: ([> float Eio.Time.clock_ty ] Eio.Resource.t, [> [> `Generic ] Eio.Net.ty ] Eio.Resource.t) t -> 41 41 string -> (Jsont.json, [>`Msg of string]) result 42 42 43 - val export: t -> 43 + val export: ([> float Eio.Time.clock_ty ] Eio.Resource.t, [> [> `Generic ] Eio.Net.ty ] Eio.Resource.t) t -> 44 44 format -> Jsont.json -> (string, [>`Msg of string]) result 45 45 46 - val json_of_doi : t -> 46 + val json_of_doi : ([> float Eio.Time.clock_ty ] Eio.Resource.t, [> [> `Generic ] Eio.Net.ty ] Eio.Resource.t) t -> 47 47 slug:string -> string -> Jsont.object'
+2 -1
stack/zulip/lib/zulip/lib/client.ml
··· 4 4 5 5 type t = { 6 6 auth : Auth.t; 7 - session : Requests.t; 7 + session : (float Eio.Time.clock_ty Eio.Resource.t, 8 + [`Generic | `Unix] Eio.Net.ty Eio.Resource.t) Requests.t; 8 9 } 9 10 10 11 let create ~sw env auth =