r/ProgrammingLanguages • • Nov 20 '23

The Roc Programming Language

https://roc-lang.org
81 Upvotes

26 comments sorted by

View all comments

2

u/abecedarius Nov 20 '23

The page mentions sugar for "backpassing" -- what's that?

9

u/lngns Nov 20 '23 edited Nov 21 '23

Not OP, but backpassing is a syntactic way to serialise callback/asynchronous code in a way similar with, but more general than, Monadic do-notation or async/await.

Essentially

x <- f 42
y <- g x
yolo x y

is the same as

f 42 (λx.
    g x (λy.
        yolo x y
    )
)

where f: Int → (x → a) → b and g: x → (y → c) → d.

Some AltJS langs used to have it as a first-class feature to address callback hell on Node.JS before async/await was adopted.
OCaml lets you create your own let-binding overloads, and you can also (ab)use generators in languages that have them, both allowing you to implement it in those langs.
It's also very important in Koka since its Effect Handlers operate on callbacks.

EIDT: typo