Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

function request: Lwt.ignore #332

Closed
jrochel opened this issue Apr 7, 2017 · 10 comments
Closed

function request: Lwt.ignore #332

jrochel opened this issue Apr 7, 2017 · 10 comments

Comments

@jrochel
Copy link

jrochel commented Apr 7, 2017

Lwt.ignore = Lwt.map ignore

@jrochel jrochel changed the title function request: Lwt.ignore function request: Lwt.ignore Apr 7, 2017
@Drup
Copy link
Member

Drup commented Apr 7, 2017

There is already Lwt.ignore_result, do you really need the thread when you are ignoring ?

@jrochel
Copy link
Author

jrochel commented Apr 7, 2017

I thought such a function to be convenient in order to shorten code of the form:

let%lwt = some_lwt_action () in
Lwt.return_unit

to:

Lwt.ignore @@ some_lwt_action ()

which would be the lwt equivalence of

ignore @@ some_pure_action ()

While

some_lwt.action () >> Lwt.return_unit

would be fine too, >> is awkward to qualify.

@aantron
Copy link
Collaborator

aantron commented Apr 7, 2017

I typically write

some_lwt_action () >|= ignore

with Lwt.Infix open in scope. Is this not suitable?

@aantron
Copy link
Collaborator

aantron commented Apr 7, 2017

There is also

Lwt.async some_lwt_action    (* : unit *)

which is a bit different from Lwt.ignore_result, because Lwt.ignore_result can raise an exception immediately (whereas Lwt.async will confidently terminate your process unless you take steps to avoid that :p).

@Drup
Copy link
Member

Drup commented Apr 7, 2017

(well, Lwt.ignore_result is also a serious anti-pattern and people should probably never use it, but that's another discussion :p)

@jrochel
Copy link
Author

jrochel commented Apr 10, 2017

| some_lwt_action () >|= ignore

@aantron: It is suitable but... I guess as a Haskeller I'm still struggeling with... a cultural issue. Ater a year of OCaml programming I'm still trying to get a feel on the attitude of the OCaml community towards extending libraries with new generic functions. So far I percieve this attitude as very conservative. Personally I would love to have a common language shared by various "monads" such as Pervasives and Lwt, but I guess this is the cultural gap I have to learn to accept...

1 similar comment
@jrochel
Copy link
Author

jrochel commented Apr 10, 2017

| some_lwt_action () >|= ignore

@aantron: It is suitable but... I guess as a Haskeller I'm still struggeling with... a cultural issue. Ater a year of OCaml programming I'm still trying to get a feel on the attitude of the OCaml community towards extending libraries with new generic functions. So far I percieve this attitude as very conservative. Personally I would love to have a common language shared by various "monads" such as Pervasives and Lwt, but I guess this is the cultural gap I have to learn to accept...

@jrochel jrochel closed this as completed Apr 10, 2017
@aantron
Copy link
Collaborator

aantron commented Apr 10, 2017

It's definitely important to have a common language between monads. I wish this was the case, too. However, I think, unless people get together and explicitly make that a shared focus, it will have to wait until modular implicits are added to the language, or something like that.

For extending Lwt specifically, I'm not particularly against it in the long term. However, at this time, Lwt has quite a bit of technical debt, which consumes the time, and patience, of maintainers and potential contributors. I'm really focused on decreasing that, which makes me temporarily biased against adding new APIs or features. So, while Lwt has this inward focus, it will be more conservative than might otherwise be ideal.

@jrochel
Copy link
Author

jrochel commented Apr 10, 2017

I see. Thanks a lot for these explanations!

@aantron
Copy link
Collaborator

aantron commented May 18, 2017

@jrochel you may be interested to know about this PR, which you may have seen already. It is aimed at taking Lwt out of its stasis.

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

No branches or pull requests

3 participants