package linol
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=174bb8cad5b8b0c260d62b0a85da13c4f5caba4fcee042ee58284b09de7896ea
sha512=77460788407c72a33fbe289ec9c78421117543594b3524a5c8fe836f0e272c5ceb1e1074b91c1d1f476f89b75b6f63847a8021675a782ff36457c9626121a7f4
doc/linol.lsp/Linol_lsp/Import/Result/index.html
Module Import.ResultSource
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.
Syntax
Binding operators.