For now, I am fixing the code to use some functions that don’t cause exceptions.
Before code was consisting of function compositions with
But now also some variables in the code return
(string, [ ``Msg of string ]) Stdlib.result instead of
To avoid using pattern matching here, I want to use
result binding too. Is there any way to do that?
Base64.decode x >>= fun x' -> (* here it should be result *) Base64.decode y >>= fun y' -> (* here it should be result *) some_processing x' y' bla foo >>= fun r -> (* Here it is a bind from Lwt *) more_processing r bar >>= fun q -> (* Here it is a bind from Lwt *) ...
I am asking about best idiomatic OCaml ways to do this, not just every single way possible.