package smtml
Install
dune-project
Dependency
Authors
-
JJoão Pereira <joaomhmpereira@tecnico.ulisboa.pt>
-
FFilipe Marques <filipe.s.marques@tecnico.ulisboa.pt>
-
HHichem Rami Ait El Hara <hra@ocamlpro.com>
-
Rredianthus <redopam@pm.me>
-
AArthur Carcano <arthur.carcano@ocamlpro.com>
-
PPierre Chambart <pierre.chambart@ocamlpro.com>
-
JJosé Fragoso Santos <jose.fragoso@tecnico.ulisboa.pt>
Maintainers
Sources
md5=25a38c1470173f0214ea3c33e665998c
sha512=bc7c921dd307d5673154c47e00aa3b124621f8651f22ad86ff80cf02eb2aca201ae93a4172e9bb591d1891d5e6a5b9b5649466cf65b456464d98b8544a8b7932
doc/smtml.prelude/Smtml_prelude/Result/index.html
Module Smtml_prelude.ResultSource
include module type of struct include Prelude.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.
get_ok' is like get_ok but in case of error uses the error message for raising Invalid_argument.
error_to_failure r is v if r is Ok v and raises Failure e if r is Error e.
bind r f is f v if r is Ok v and r if r is Error _.
join rr is r if rr is Ok r and rr if rr is Error _.
map f r is Ok (f v) if r is Ok v and r if r is Error _.
product r0 r1 is Ok (v0, v1) if r0 is Ok v0 and r1 is Ok v2 and otherwise returns the error of r0, if any, or the error of r1.
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 ->
boolequal ~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 ->
intcompare ~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.
to_seq r is r as a sequence. Ok v is the singleton sequence containing v and Error _ is the empty sequence.