TY - GEN
T1 - Typing Composable Coroutines
AU - Gu, Qiqi
AU - Ke, Wei
N1 - Publisher Copyright:
© 2023 IEEE.
PY - 2023
Y1 - 2023
N2 - Coroutine, as a powerful programming construct, is widely used in asynchronous applications to replace thread-based programming or the callback hell. Using coroutines makes code more readable and maintainable, for its ability to transfer control while keeping the literal scope. However, reasoning about coroutine behavior can be challenging without proper typing. We propose a type notation and calculus for composing asymmetric, first-class, stackless coroutines. Given the types of a list of coroutines, we can compute a composed type matching the collective behavior of the coroutines, so that the input and output can be type-checked by a type system. Our coroutine types can model the data received by or yielded from a coroutine, which be of coroutine types as well. On top of our type calculus, we discuss its soundness and evaluation issues, then provide four application scenarios of our coroutine types. Not only can our types be used in modern programming languages, such as Python, but also model program behaviors in OCaml and even Prolog.
AB - Coroutine, as a powerful programming construct, is widely used in asynchronous applications to replace thread-based programming or the callback hell. Using coroutines makes code more readable and maintainable, for its ability to transfer control while keeping the literal scope. However, reasoning about coroutine behavior can be challenging without proper typing. We propose a type notation and calculus for composing asymmetric, first-class, stackless coroutines. Given the types of a list of coroutines, we can compute a composed type matching the collective behavior of the coroutines, so that the input and output can be type-checked by a type system. Our coroutine types can model the data received by or yielded from a coroutine, which be of coroutine types as well. On top of our type calculus, we discuss its soundness and evaluation issues, then provide four application scenarios of our coroutine types. Not only can our types be used in modern programming languages, such as Python, but also model program behaviors in OCaml and even Prolog.
KW - Asynchronous programming
KW - Coroutines
KW - Dependent types
KW - Type Theory
UR - http://www.scopus.com/inward/record.url?scp=85195675232&partnerID=8YFLogxK
U2 - 10.1109/TechDev61156.2023.00011
DO - 10.1109/TechDev61156.2023.00011
M3 - Conference contribution
AN - SCOPUS:85195675232
T3 - Proceedings - 2023 12th International Conference on Computer Technologies and Development, TechDev 2023
SP - 16
EP - 23
BT - Proceedings - 2023 12th International Conference on Computer Technologies and Development, TechDev 2023
PB - Institute of Electrical and Electronics Engineers Inc.
T2 - 12th International Conference on Computer Technologies and Development, TechDev 2023
Y2 - 14 October 2023 through 16 October 2023
ER -