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>
-
LLéo Andrès <contact@ndrs.fr>
-
AArthur Carcano <arthur.carcano@ocamlpro.com>
-
PPierre Chambart <pierre.chambart@ocamlpro.com>
-
JJosé Fragoso Santos <jose.fragoso@tecnico.ulisboa.pt>
Maintainers
Sources
md5=f8549c12d40e6a1dafcced7e319887a4
sha512=f147faa9e2519585cfe9b11654b750061259da4db0b2136d9047b4cb480abb562f6ac627545fd06461f4414acba57558713868de370f58131f3face308f7c7f0
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.
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 _.
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.