Locally-openable monads in Lwtreslib
The aim is to provide convenient locally-openable modules that bring functions related to one specific monad (i.e., none, lwt, result, lwt+result, option) into scope.
Before:
let f () =
… >>=? fun () ->
… >>=? fun x ->
… >>=? fun y ->
…
let g () =
… >>= fun x ->
… >>= fun blah ->
…
After:
let f () =
let open Infix_Lwt_and_Result in
… >>= fun () ->
… >>= fun x ->
… >>= fun y ->
…
let g () =
let open Infix_Lwt in
… >>= fun x ->
… >>= fun blah ->
…
Note that, on these examples, it doesn't improve things much. However,
- It'll make
ok,Lwt.return,returnmore uniform and more beginner friendly. Same forerrorandfail: which is which? - It'll avoid introducing differently suffixed monadic
lets for different monads. I.e., we canlet open Infix_lwt in let* x = … in …andlet open Infix_Lwt_and_Result in let* x = … in …instead of having to come up with different names for these different lets (let*=andlet*=?would be the logical choice following the current convention). - We can integrate (into the design) some features to help with changing from one monad to the other.