Hostname: page-component-cd9895bd7-jn8rn Total loading time: 0 Render date: 2024-12-26T06:01:21.888Z Has data issue: false hasContentIssue false

Explicit effect subtyping

Published online by Cambridge University Press:  08 June 2020

GEORGIOS KARACHALIAS
Affiliation:
Department of Computer Science, KU Leuven, Belgium Tweag I/O (e-mail: [email protected])
MATIJA PRETNAR
Affiliation:
Faculty of Mathematics and Physics, University of Ljubljana, Slovenia (e-mail: [email protected])
AMR HANY SALEH
Affiliation:
Department of Computer Science, KU Leuven, Belgium (e-mails: [email protected]; [email protected]; [email protected])
STIEN VANDERHALLEN
Affiliation:
Department of Computer Science, KU Leuven, Belgium (e-mails: [email protected]; [email protected]; [email protected])
TOM SCHRIJVERS
Affiliation:
Department of Computer Science, KU Leuven, Belgium (e-mails: [email protected]; [email protected]; [email protected])
Rights & Permissions [Opens in a new window]

Abstract

Core share and HTML view are not available for this content. However, as you have access to this content, a full PDF is available via the ‘Save PDF’ action button.

As popularity of algebraic effects and handlers increases, so does a demand for their efficient execution. Eff, an ML-like language with native support for handlers, has a subtyping-based effect system on which an effect-aware optimising compiler could be built. Unfortunately, in our experience, implementing optimisations for Eff is overly error-prone because its core language is implicitly typed, making code transformations very fragile. To remedy this, we present an explicitly typed polymorphic core calculus for algebraic effect handlers with a subtyping-based type-and-effect system. It reifies appeals to subtyping in explicit casts with coercions that witness the subtyping proof, quickly exposing typing bugs in program transformations. Our typing-directed elaboration comes with a constraint-based inference algorithm that turns an implicitly typed Eff-like language into our calculus. Moreover, all coercions and effect information can be erased in a straightforward way, demonstrating that coercions have no computational content. Additionally, we present a monadic translation from our calculus into a pure language without algebraic effects or handlers, using the effect information to introduce monadic constructs only where necessary.

Type
Research Article
Copyright
© The Author(s) 2020. Published by Cambridge University Press

References

Barendregt, H. (1981) The Lambda Calculus: Its Syntax and Semantics. Studies in Logic and the Foundations of Mathematics, vol. 103. North-Holland.Google Scholar
Bauer, A., Hofmann, M., Pretnar, M. & Yallop, J. (2016) From theory to practice of algebraic effects and handlers (dagstuhl seminar 16112). Dagstuhl Reports 6(3), 4458.Google Scholar
Bauer, A. & Pretnar, M. (2015) Programming with algebraic effects and handlers. J. Log. Alg. Program. 84(1), 108123.Google Scholar
Bi, X., Oliveira, B. C. d. S. & Schrijvers, T. (2018) The essence of nested composition. In 32nd European Conference on Object-Oriented Programming, ECOOP 2018, July 16–21, 2018, Amsterdam, The Netherlands, Millstein, T. D. (ed). LIPIcs, vol. 109. Schloss Dagstuhl - Leibniz-Zentrum fuer Informatik, pp. 22:1–22:33.Google Scholar
Breazu-Tannen, V., Coquand, T., Gunter, C. A. & Scedrov, A. (1991) Inheritance as implicit coercion. Inf. Comput. 93, 172221.CrossRefGoogle Scholar
Chandrasekaran, S. K., Leijen, D., Pretnar, M. & Schrijvers, T. (2018). Algebraic effect handlers go mainstream (dagstuhl seminar 18172). Dagstuhl Reports 8(4), 104125.Google Scholar
Crary, K. (2000). Typed compilation of inclusive subtyping. In Proceedings of the Fifth ACM SIGPLAN International Conference on Functional Programming. ICFP’00. NY, USA: ACM, pp. 6881.CrossRefGoogle Scholar
Damas, L. & Milner, R. (1982) Principal type-schemes for functional programs. In Proceedings of the 9th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages. POPL’82. NY, USA: ACM, pp. 207212.CrossRefGoogle Scholar
Dolan, S., White, L., Sivaramakrishnan, K. C., Yallop, J. & Madhavapeddy, A. (2015) Effective concurrency through algebraic effects. In OCaml Workshop.Google Scholar
Fuh, Y.-C. & Mishra, P. (1990) Type inference with subtypes. Theor. Comput. Sci. 73(2), 155175.CrossRefGoogle Scholar
Girard, J.-Y. (1972) Interprétation fonctionelle et élimination des coupures de larithmétique dordre supérieur. PhD thesis, Université Paris VII.Google Scholar
Girard, J.-Y., Taylor, P. & Lafont, Y. (1989) Proofs and Types. Cambridge University.Google Scholar
Henglein, F. (1994) Dynamic typing: Syntax and proof theory. In Selected Papers of the Symposium on Fourth European Symposium on Programming. ESOP’92. Amsterdam, The Netherlands: Elsevier Science Publishers B. V., pp. 197230.CrossRefGoogle Scholar
Hillerström, D. & Lindley, S. (2016) Liberating effects with rows and handlers. In Proceedings of the 1st International Workshop on Type-Driven Development, TyDe@ICFP 2016, Nara, Japan, September 18, 2016, Chapman, J. & Swierstra, W. (eds). ACM, pp. 15–27.CrossRefGoogle Scholar
Hindley, R. (1969) The principal type-scheme of an object in combinatory logic. Trans. Am. Math. Soc. 146, 2960.Google Scholar
Igarashi, A., Pierce, B. C. & Wadler, P. (2001) Featherweight java: A minimal core calculus for java and gj. ACM Trans. Program. Lang. Syst. 23(3), 396450.CrossRefGoogle Scholar
Jones, M. P. (1992) A theory of qualified types. In ESOP’92, 4th European Symposium on Programming, Rennes, France, February 26–28, 1992, Proceedings, Krieg-Brückner, B. (ed). Lecture Notes in Computer Science, vol. 582. Springer, pp. 287306.CrossRefGoogle Scholar
Kammar, O., Lindley, S. & Oury, N. (2013) Handlers in action. In Proceedings of the 18th ACM SIGPLAN International Conference on Functional programming. ICFP’14. ACM, pp. 145158.CrossRefGoogle Scholar
Kiselyov, O. & Sivaramakrishnan, K. C. (2016) Eff directly in OCaml. In OCaml Workshop.Google Scholar
Leijen, D. (2014) Koka: Programming with row polymorphic effect types. In Proceedings 5th Workshop on Mathematically Structured Functional Programming, MSFP@ETAPS 2014, Grenoble, France, 12 April 2014, Levy, P. & Krishnaswami, N. (eds). EPTCS, vol. 153, pp. 100126.CrossRefGoogle Scholar
Leijen, D. (2017) Type directed compilation of row-typed algebraic effects. In Proceedings of the 44th ACM SIGPLAN Symposium on Principles of Programming Languages, POPL 2017, Paris, France, January 18–20, 2017, Castagna, G. & Gordon, A. D. (eds). ACM, pp. 486–499.CrossRefGoogle Scholar
Lindley, S., McBride, C. & McLaughlin, C. (2017) Do be do be do. In Proceedings of the 44th ACM SIGPLAN Symposium on Principles of Programming Languages, POPL 2017, Paris, France, January 18–20, 2017, Castagna, G. & Gordon, A. D. (eds). ACM, pp. 500–514.CrossRefGoogle Scholar
Milner, R. (1978) A theory of type polymorphism in programming. J. Comput. Syst. Sci. 17, 348375.CrossRefGoogle Scholar
Mitchell, J. C. (1984) Coercion and type inference. In Proceedings of the 11th ACM SIGACT-SIGPLAN Symposium on Principles of Programming Languages. POPL’84. New York, NY, USA: ACM, pp. 175185.CrossRefGoogle Scholar
Jr, Morris., J. H. (1969) Lambda-Calculus Models of Programming Languages. PhD thesis, Massachusetts Institute of Technology.Google Scholar
Oliveira, B. C. d. S., Shi, Z. & Alpuim, J. (2016) Disjoint intersection types. In Proceedings of the 21st ACM SIGPLAN International Conference on Functional Programming, ICFP 2016, Nara, Japan, September 18–22, 2016, Garrigue, J., Keller, G. & Sumii, E. (eds). ACM, pp. 364–377.CrossRefGoogle Scholar
Peyton Jones, S., Vytiniotis, D., Weirich, S. & Washburn, G. (2006) Simple unification-based type inference for GADTs. In ICFP’06.Google Scholar
Plotkin, G. D. & Power, J. (2003) Algebraic operations and generic effects. Appl. Categor. Struct. 11(1), 6994.CrossRefGoogle Scholar
Plotkin, G. D. & Pretnar, M. (2013) Handling algebraic effects. Log. Methods Comput. Sci 9(4), 1–36.Please provide page range for “Plotkin & Pretnar (2013), Pretnar (2014).”CrossRefGoogle Scholar
Pottier, F. (2001) Simplifying subtyping constraints: A theory. Inf. Comput. 170(2), 153183.CrossRefGoogle Scholar
Pretnar, M. (2014) Inferring algebraic effects. Log. Methods Comput. Sci. 10(3), 143.CrossRefGoogle Scholar
Pretnar, M. (2015) An introduction to algebraic effects and handlers, invited tutorial. Electron. Notes Theor. Comput. Sci. 319, 1935.CrossRefGoogle Scholar
Pretnar, M., Saleh, A. H., Faes, A. & Schrijvers, T. (2017) Efficient Compilation of Algebraic Effects and Handlers. Technical report. CW 708. KU Leuven Department of Computer Science.Google Scholar
Reynolds, J. C. (1974) Towards a theory of type structure. In Programming Symposium, Proceedings Colloque Sur La Programmation. London, UK: Springer-Verlag, pp. 408423.CrossRefGoogle Scholar
Reynolds, J. C. (1983) Types, abstraction, and parametric polymorphism. In Information Processing, Mason, R.E.A. (ed), vol. 83, pp. 513523.Google Scholar
Saleh, A. H., Karachalias, G., Pretnar, M. & Schrijvers, T. (2018) Explicit effect subtyping. In ESOP. Lecture Notes in Computer Science, vol. 10801. Springer, pp. 327354.Google Scholar
Schrijvers, T., Peyton Jones, S., Chakravarty, M. & Sulzmann, M. (2008) Type checking with open type functions. In ICFP’08. ACM, pp. 5162.CrossRefGoogle Scholar
Simonet, V. (2003) Type inference with structural subtyping: A faithful formalization of an efficient constraint solver. In Programming Languages and Systems, First Asian Symposium, APLAS 2003, Beijing, China, November 27–29, 2003, Proceedings, Ohori, A. (ed), pp. 283–302. Springer.CrossRefGoogle Scholar
Sulzmann, M., Chakravarty, M. M. T., Peyton Jones, S. & Donnelly, K. (2007) System F with type equality coercions. In Proceedings of the 2007 ACM SIGPLAN International Workshop on Types in Languages Design and Implementation. TLDI’07. New York, NY, USA: ACM, pp. 5366.CrossRefGoogle Scholar
Traytel, D., Berghofer, S. & Nipkow, T. (2011) Extending hindley-milner type inference with coercive structural subtyping. In Programming Languages and Systems - 9th Asian Symposium, APLAS 2011, Kenting, Taiwan, December 5–7, 2011. Proceedings, Yang, H. (ed). Lecture Notes in Computer Science, vol. 7078. Springer, pp. 89–104.CrossRefGoogle Scholar
Wansbrough, K. & Peyton Jones, S. L. (1999) Once upon a polymorphic type. In POPL. ACM, pp. 1528.CrossRefGoogle Scholar
Submit a response

Discussions

No Discussions have been published for this article.