OK but you can write code golf in any language, OCaml provides every opportunity to write readable code. The second snippet you provided is incomplete, if we were to write it in Python terms it would be something like:
(resolve=lambda info: ...)
But let's say for the sake of argument that it's an argument to a function `f`:
f ~resolve:(fun info () -> ...)
One of the simplest ways to improve readability is to use argument name punning:
let resolve info () =
let sleep =
let open Lwt.Syntax in
let+ () = Lwt_unix.sleep duration in
duration
in
Lwt_result.ok sleep
in
f ~resolve
gavinray|3 years ago
With OCaml 5 looming you're better off just biting the bullet and writing OCaml if you're going to do it IMO.
For whatever reason, I really dislike the named-argument syntax -- and some of the operators make it hard to read compared to named alternatives IMO.Below examples showcases some of these:
yawaramin|3 years ago