Module Lwt_result
Contents
Instructions: Use this module in your project
In the IDE (CLion, Visual Studio Code, Xcode, etc.) you use for your DkSDK project:
Add the following to your project's
dependencies/CMakeLists.txt
:DkSDKProject_DeclareAvailable(lwt CONSTRAINT "= 5.6.1" FINDLIBS lwt lwt.unix) DkSDKProject_MakeAvailable(lwt)
Add the
Findlib::lwt
library to any desired targets insrc/*/CMakeLists.txt
:target_link_libraries(YourPackage_YourLibraryName # ... existing libraries, if any ... Findlib::lwt)
Click your IDE's
Build
button
Not using DkSDK?
FIRST, do one or all of the following:
Run:
opam install lwt.5.6.1
Edit your
dune-project
and add:(package (name YourExistingPackage) (depends ; ... existing dependenices ... (lwt (>= 5.6.1))))
Then run:
dune build *.opam # if this fails, run: dune build
Edit your
<package>.opam
file and add:depends: [ # ... existing dependencies ... "lwt" {>= "5.6.1"} ]
Then run:
opam install . --deps-only
FINALLY, add the lwt
library to any desired (library)
and/or (executable)
targets in your **/dune
files:
(library
(name YourLibrary)
; ... existing library options ...
(libraries
; ... existing libraries ...
lwt))
(executable
(name YourExecutable)
; ... existing executable options ...
(libraries
; ... existing libraries ...
lwt))
This module provides helpers for values of type ('a, 'b) result Lwt.t
.
The module is experimental and may change in the future.
val
return :
'a
->
``(
'a
,
_
)``
t
val
fail :
'b
->
``(
_
,
'b
)``
t
catch x
behaves like return y
if x
evaluates to y
, and like
fail e
if x
raises e
Lwt.both p_1 p_2
returns a promise that is pending until both
promises p_1
and p_2
become resolved. If only p_1
is Error e
,
the promise is resolved with Error e
, If only p_2
is Error e
, the
promise is resolved with Error e
, If both p_1
and p_2
resolve with
Error _
, the promise is resolved with the error that occurred first.
iter f r
is f v
if r
is a promise resolved with Ok v
, and
Lwt.return_unit
otherwise.
- since Lwt 5.6.0
iter_error f r
is f v
if r
is a promise resolved with Error v
,
and Lwt.return_unit
otherwise.
- since Lwt 5.6.0
module
Infix
:
sig
...
end
module
Let_syntax
:
sig
...
end
module
Syntax
:
sig
...
end
include
module
type
of
Infix
Deprecated
-
deprecated
Alias to
map_error
since 5.6.0.
-
deprecated
Alias to
bind_lwt_error
since 5.6.0.