Closed hannesm closed 5 years ago
Nothing is "evaluated twice". >>=
doesn't evaluate its left hand side, it simply waits for it. If if was already evaluated, then nothing further happens.
As for the rest, your patch is incorrect, in that it doesn't execute the dependencies concurrently. Please read this thread: https://github.com/mirage/functoria/pull/104
When I look into a (mirage-)generated main.ml, I find the following code:
Which IMHO has two issues fixed in separate commits in this PR:
let ()
(bound tot
), once inmirage1
-- the reason is that Mirage'sP
(whereP.create
is called by Functoria) registers the initialization jobs as dependencies -- this is required, otherwise they are not part of functoria's graph, and it complains during configure step (if you can think of another way to handle this, please let me know -- I'd be more in favour of not having to passinit @ jobs
toP.create
, but instead onlyjobs
, and retain theLazy.force xxx >>= fun _
inlet ()
)__XX
, then Lwt-evaluated__XX >>= fun _X
, and then potentially applied to connect, using_X
. This is not really intuitive, since now variables which start with an underscore are passed to a function. Furthermore, if depending on the same job multiple times (i.e.noop1
above), these are unneccessarily forced twice and Lwt-evaluated twice.This patch generates instead the following code:
Please let me know what you think (esp. @Drup, but obviously other input welcome) /cc @linse