Stream: beginners

Topic: ✔ await keyword


view this post on Zulip Zeljko Nesic (Sep 26 2023 at 00:12):

Please feel free to move this question to another place:

I have been munching on Roc Editor Proposal document for some time and now I am burning midnight oil to complete first draft: and I am a bit hitting a brick wall with await keyword.
Could please somebody give a bit refresher what does it do exactly? I do understand that it handles async mechanism for Tasks, but I can't categorize it, so maybe somebody can help me out here ...

How should I think about it?

view this post on Zulip Brendan Hansknecht (Sep 26 2023 at 00:14):

It technically isn't a keyword at all. It is a function just like any other function

view this post on Zulip Brendan Hansknecht (Sep 26 2023 at 00:14):

The most important part of await is that it takes a callback as an argument.

view this post on Zulip Brendan Hansknecht (Sep 26 2023 at 00:15):

As such, await will give a task to the host. The host will run the task. Finally, the host will call the callback with any data from the running the task.

view this post on Zulip Zeljko Nesic (Sep 26 2023 at 00:42):

await : Task a err, (a -> Task b err) -> Task b err
:face_palm:

Thanks Brendan!

view this post on Zulip Notification Bot (Sep 26 2023 at 00:42):

Zeljko Nesic has marked this topic as resolved.


Last updated: Jul 06 2025 at 12:14 UTC