The following code are from ocsigen-start:
let transaction_block db f =
Lwt_PGOCaml.begin_work db >>= fun _ ->
try_lwt
lwt r = f () in (*****A*****)
lwt () = Lwt_PGOCaml.commit db in
Lwt.return r
with e ->
lwt () = Lwt_PGOCaml.rollback db in
Lwt.fail e
let full_transaction_block f = (*****B*****)
Lwt_pool.use !pool (fun db -> transaction_block db (fun () -> f db)) (*****C*****)
Why the f at B gets wrapped to a fun () -> f db at C and passed to A?, couldn’t we just pass f at C and replace A with let r = f db?