The type of a result. A result is either Ok x carrying the normal return value x or is Error e carrying some indication of an error. The value associated with a bad result is usually an exception (exn) that can be raised.
Execute a function and catch any exception as a result. This function encapsulates code that could throw an exception and returns that exception as a value.
val equal :
ok:('a->'a-> bool)->error:('e->'e-> bool)->('a, 'e)t->('a, 'e)t->
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 _.
since 3.0.0
val compare :
ok:('a->'a-> int)->error:('e->'e-> int)->('a, 'e)t->('a, 'e)t->
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.
to_seq r is r as a sequence. Ok v is the singleton sequence containing v and Error _ is the empty sequence.
since 3.0.0
The Result Monad
This monad is very similar to the option monad, but instead of being None when an error occurs, the first error in the sequence is preserved as the return value.