Because the pattern of having a result inside a promise is so common (e.g. an HTTP request that might fail), Async provides a “Deferred.Result” monad where the type is a Result.t Deferred.t
, with the associated infix operators and let-syntax. And if it’s awkward to open that module, then there are also infix bind and map operators >>=?
and >>|?
exposed in Async
itself. So one option would be to implement the equivalent of those functions for Lwt, assuming they don’t exist already.