package odoc
Install
Dune Dependency
Authors
Maintainers
Sources
sha256=ce84fa7e0cc5f3e8a54e6adeb10826152798b602057b9e46c5ae7e5d5206812b
sha512=9febd413450ca2e3824c9ef7e1c9ae8d8094aa72ed71327a69d8d6b42f6f197b3f3f40d674de0d11fa1242ee0df95c693b5d74467d530704e1339f3a523452f6
doc/odoc.odoc_utils/Odoc_utils/Result/index.html
Module Odoc_utils.Result
Source
include module type of struct include Result end
include module type of struct include Result end
Results
The type for result values. Either a value Ok v
or an error Error e
.
value r ~default
is v
if r
is Ok v
and default
otherwise.
bind r f
is f v
if r
is Ok v
and r
if r
is Error _
.
map f r
is Ok (f v)
if r
is Ok v
and r
if r
is Error _
.
map_error f r
is Error (f e)
if r
is Error e
and r
if r
is Ok _
.
fold ~ok ~error r
is ok v
if r
is Ok v
and error e
if r
is Error e
.
iter f r
is f v
if r
is Ok v
and ()
otherwise.
iter_error f r
is f e
if r
is Error e
and ()
otherwise.
Predicates and comparisons
val equal :
ok:('a -> 'a -> bool) ->
error:('e -> 'e -> bool) ->
('a, 'e) result ->
('a, 'e) result ->
bool
equal ~ok ~error r0 r1
tests equality of r0
and r1
using ok
and error
to respectively compare values wrapped by Ok _
and Error _
.
val compare :
ok:('a -> 'a -> int) ->
error:('e -> 'e -> int) ->
('a, 'e) result ->
('a, 'e) result ->
int
compare ~ok ~error r0 r1
totally orders r0
and r1
using ok
and error
to respectively compare values wrapped by Ok _
and Error _
. Ok _
values are smaller than Error _
values.
Converting
to_option r
is r
as an option, mapping Ok v
to Some v
and Error _
to None
.