Clean up crazy state-future-result-monad-we-must-go-deeper tangle
commitaeefacc9ea903f802b40d56f2455bb0cd0a5c5b0
authorAlexander Chow <achow@fb.com>
Wed, 9 Nov 2016 23:15:49 +0000 (9 15:15 -0800)
committerHhvm Bot <hhvm-bot-bot@fb.com>
Wed, 9 Nov 2016 23:23:02 +0000 (9 15:23 -0800)
tree67ae61c1b6708e7fb5331c3a7458cb613cf1d892
parent1843a5598f3692c959eccee9981ae03ffc2e47b6
Clean up crazy state-future-result-monad-we-must-go-deeper tangle

Summary:
This cleans up a crazy state-future-result-monad double wrapping that was
hard to reason about. In making it "more obviously correct" I remove
an unintuitive use of join (move it from "the types don't match so I'll
just use join" into a "I am joining because clearly I'm double-wrapping
the monad via try-with), an uncessary use of lift, and gratuitous closures
created just to satisfy the monadic interface.

In short, I change the type from
(unit -> unit -> (Relative_path.Set.t * 'a, exn) Result.t, exn) Result.t
to
(unit -> (unit -> Relative_path.Set.t * 'a, exn) Result.t, exn) Result.t

Note the second function is contained within the inner result, since it only
makes sense if the first stage of computation succeeds anyways.

No functional changes.

Reviewed By: oulgen

Differential Revision: D4151057

fbshipit-source-id: b6e053ab8aad922453dacda8b4086ba5ebc9c4b2
hphp/hack/src/server/serverInit.ml