Skip to content

Commit

Permalink
Merge pull request #122 from issuu/andersfugmann/lwt_compat
Browse files Browse the repository at this point in the history
Forward compatibility with Lwt 5.7/6.0
  • Loading branch information
Leonidas-from-XIV authored Nov 1, 2022
2 parents 9351d4a + ee03f01 commit fb97e8f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
* Forward compatibility with Lwt 5.7/6.0 (#122, @andersfugmann)

5.2.0
---
* Remove dependency on StdInt (#121, @andersfugmann)
Expand Down
11 changes: 10 additions & 1 deletion zmq-lwt/src/deferred.ml
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
type 'a t = 'a Lwt.t

(* Define let_catch_result with the same signature as Lwt_result.catch
for lwt version >= 6.0. This function can be replaced by
Lwt_result.catch if/when we bump minimum required version of Lwt to >= 6.0.
See https://github.com/ocsigen/lwt/pull/965
*)
let lwt_result_catch f =
Lwt.catch (fun () -> Lwt_result.ok (f ())) Lwt_result.fail

module Deferred = struct
type 'a t = 'a Lwt.t
let return a = Lwt.return a
let catch f = Lwt_result.catch (f ())
let catch f = lwt_result_catch f
let don't_wait_for = Lwt.async
let sleepf secs = Lwt_unix.sleep secs
let fail exn = Lwt.fail exn
Expand Down

0 comments on commit fb97e8f

Please sign in to comment.