Abstract
Koka is a functional programming language with native support for algebraic effects and handlers. To implement effect handler operations efficiently, Koka employs a semantics where the handlers in scope are passed down to each function as an evidence vector. At runtime, these evidence vectors are adjusted using the open constructs to match the evidence for a particular function. All these adjustments can cause significant runtime overhead. In this paper, we present a novel transformation on the Koka core calculus that we call open floating. This transformation aims to float up open constructs and combine them in order to minimize the adjustments needed at runtime. Open floating improves performance by 2.5\(\times \) in an experiment. Furthermore, we formalize an aspect of row-based effect typing, including the closed prefix relation on effect rows, which clarifies the constraint on open floating.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Similar content being viewed by others
Notes
- 1.
Kind annotations directly relate their types to the specific symbols associated with them, such as \({\mu {}}\) and \({{ c _ l }}\). This allows us to use these symbols just as aliases.
- 2.
References
Brachthäuser, J.I., Schuster, P., Ostermann, K.: Lightweight effect polymorphism for handlers. Technical report. University of Tübingen, Germany, Effekt (2020)
Dolan, S., White, L., Sivaramakrishnan, K.C., Yallop, J., Madhavapeddy, A.: Effective Concurrency through algebraic effects. In: OCaml Workshop, vol. 13 (2015)
Felleisen, M.: The theory and practice of first-class prompts. In: Proceedings of the 15th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, pp. 180–190. POPL ’88. Association for Computing Machinery, New York, NY, USA (1988). 10.1145/73560.73576
Gaster, B.R., Jones, M.P.: A Polymorphic Type System for Extensible Records and Variants. NOTTCS-TR-96-3. University of Nottingham (1996)
Jones, M.P.: A theory of qualified types. In: Krieg-Brückner, B. (ed.) ESOP 1992. LNCS, vol. 582, pp. 287–306. Springer, Heidelberg (1992). https://doi.org/10.1007/3-540-55253-7_17
Jones, M.P.: Simplifying and improving qualified types. In: Proceedings of the 7th International Conference on Functional Programming Languages and Computer Architecture, pp. 160–169. FPCA ’95. La Jolla, California, USA (1995). 10.1145/224164.224198
Leijen, D.: Koka: programming with row polymorphic effect types. In: MSFP’14, 5th Workshop on Mathematically Structured Functional Programming (2014). 10.4204/EPTCS.153.8
Leijen, D.: Structured asynchrony with algebraic effects. In: Proceedings of the 2nd ACM SIGPLAN International Workshop on Type-Driven Development, TyDe 2017. Oxford, UK, pp. 16–29 (2017). 10.1145/3122975.3122977
Leijen, D.: Type directed compilation of row-typed algebraic effects. In: Proceedings of the 44th ACM SIGPLAN Symposium on Principles of Programming Languages, pp. 486–499 (2017)
Leijen, D.: Type directed compilation of row-typed algebraic effects. In: Proceedings of the 44th ACM SIGPLAN Symposium on Principles of Programming Languages (POPL’17), Paris, France, pp. 486–499 (2017). 10.1145/3009837.3009872
Leijen, D.: Koka repository (2019). https://github.com/koka-lang/koka
Morris, J.G., McKinna, J.: Abstracting extensible data types: or, rows by any other name. In: Proceedings of the ACM on Programming Languages, vol. 3 (POPL). ACM New York, NY, USA, pp. 1–28 (2019)
Jones, S.P., Jones, M., Meijer, E.: Type classes: an exploration of the design space. In: Haskell Workshop (1997)
Plotkin, G.D., Pretnar, M.: Handling algebraic effects. In: Logical Methods in Computer Science, vol. 9, no. 4 (2013). 10.2168/LMCS-9(4:23)2013
Pretnar, M., Saleh, A.H., Faes, A., Schrijvers, T.: Efficient compilation of algebraic effects and handlers. CW Reports. Department of Computer Science, KU Leuven, Leuven, Belgium (2017). https://lirias.kuleuven.be/retrieve/472230
Saleh, A.H., Karachalias, G., Pretnar, M., Schrijvers, T.: Explicit effect subtyping. In: Ahmed, A. (ed.) ESOP 2018. LNCS, vol. 10801, pp. 327–354. Springer, Cham (2018). https://doi.org/10.1007/978-3-319-89884-1_12
Shields, M., Meijer, E.: Type-indexed rows. In: Proceedings of the 28th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL’01, London, United Kingdom, pp. 261–275 (2001) 10.1145/360204.360230
Wadler, P., Blott, S.: How to make ad-hoc polymorphism less ad hoc. In: Proceedings of the 16th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL ’89. ACM, Austin, Texas, USA, pp. 60–76 (1989). 10.1145/75277.75283
Xie, N., Brachthäuser, J.I., Hillerström, D., Schuster, P., Leijen, D.: Effect handlers, evidently. In: Proceedings of the ACM on Programming Languages, vol. 4 (ICFP). ACM New York, NY, USA, pp. 1–29 (2020)
Xie, N., Leijen, D.: Generalized evidence passing for effect handlers: efficient compilation of effect handlers to C. In: Proceedings of the ACM Programming Languages, vol. 5 (ICFP). Association for Computing Machinery, New York, NY, USA (2021). 10.1145/3473576
Acknowledgement
We acknowledge the reviewers’ efforts put into evaluation of our paper. We also appreciate the FLOPS 2022 reviewers’ feedback on an earlier version of the paper. Lastly, we thank members of Masuhara laboratory. This work was supported in part by JSPS KAKENHI under Grant No. JP19K24339.
Author information
Authors and Affiliations
Corresponding author
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2022 Springer Nature Switzerland AG
About this paper
Cite this paper
Furudono, N., Cong, Y., Masuhara, H., Leijen, D. (2022). Towards Efficient Adjustment of Effect Rows. In: Swierstra, W., Wu, N. (eds) Trends in Functional Programming. TFP 2022. Lecture Notes in Computer Science, vol 13401. Springer, Cham. https://doi.org/10.1007/978-3-031-21314-4_9
Download citation
DOI: https://doi.org/10.1007/978-3-031-21314-4_9
Published:
Publisher Name: Springer, Cham
Print ISBN: 978-3-031-21313-7
Online ISBN: 978-3-031-21314-4
eBook Packages: Computer ScienceComputer Science (R0)