Skip to content

Add Fiber.Result module#3430

Merged
rgrinberg merged 1 commit intoocaml:masterfrom
rgrinberg:add-fiber-result
Apr 28, 2020
Merged

Add Fiber.Result module#3430
rgrinberg merged 1 commit intoocaml:masterfrom
rgrinberg:add-fiber-result

Conversation

@rgrinberg
Copy link
Copy Markdown
Member

No description provided.

Signed-off-by: Rudi Grinberg <me@rgrinberg.com>
@rgrinberg rgrinberg requested a review from a user April 28, 2020 05:18
Copy link
Copy Markdown
Collaborator

@snowleopard snowleopard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fine to me, assuming there are use-cases.

@rgrinberg
Copy link
Copy Markdown
Member Author

Yes, this is being used in LSP which vendors fiber. Thanks you for the review!

@rgrinberg rgrinberg merged commit 4949d0c into ocaml:master Apr 28, 2020
@ghost
Copy link
Copy Markdown

ghost commented Apr 29, 2020

So, we have this for Deferred in Async and its usage is not unanimous. It's like marmite, some love it some hate it. @rgrinberg if this is only used in LSP, I'd rather that this code lives in LSP. It doesn't need to be part of the Fiber module.

@rgrinberg
Copy link
Copy Markdown
Member Author

rgrinberg commented Apr 30, 2020 via email

@snowleopard
Copy link
Copy Markdown
Collaborator

Presumably, if we want to discourage the use of Result.t Fiber.t for error handling, we should also remove fold_errors and collect_errors, which are currently provided by the interface but appear to be unused in Dune.

I personally don't feel strongly one way or another, but if we want to stick to with_error_handler as the idiomatic way of handling errors, we can replace collect_errors with something like:

val with_all_errors_handler :
  (unit -> 'a t) -> on_error:(Exn_with_backtrace.t list -> unit) -> 'a t

P.S.: In a parallel discussion with @jeremiedimino, we also thought that it would be useful to make with_error_handler deterministic, i.e. return not the earliest error (like now), but the first error in the order of parallel branches.

@rgrinberg
Copy link
Copy Markdown
Member Author

In a parallel discussion with @jeremiedimino, we also thought that it would be useful to make with_error_handler deterministic, i.e. return not the earliest error (like now), but the first error in the order of parallel branches.

Sounds like a good idea. Shall we make an issue for this at least?

@snowleopard
Copy link
Copy Markdown
Collaborator

@rgrinberg Done: #3439.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants