Abstract
The naive combination of polymorphic effects and polymorphic type assignment has been well known to break type safety. Existing approaches to this problem are classified into two groups: one for restricting how effects are triggered and the other for restricting how they are implemented. This work explores a new approach to ensuring the safety of polymorphic effects in polymorphic type assignment. A novelty of our work lies in finding a restriction on effect interfaces. To formalize our idea, we employ algebraic effects and handlers, where an effect interface is given by a set of operations coupled with type signatures. We propose signature restriction, a new notion to restrict the type signatures of operations, and show that signature restriction is sufficient to ensure type safety of an effectful language equipped with unrestricted polymorphic type assignment. We also develop a type-and-effect system to enable the use of both operations that satisfy and do not satisfy the signature restriction in a single program.
Supplemental Material
Available for Download
This material includes the PDF file that provides the full definitions of the language, the polymorphic type system, and the type-and-effect system and the full proofs of the properties presented in the paper.
- Danel Ahman. 2017. Fibred Computational Efects. Ph.D. Dissertation. University of Edinburgh. https://danel.ahman.ee/ papers/phd-thesis.pdfGoogle Scholar
- Amal Ahmed, Derek Dreyer, and Andreas Rossberg. 2009. State-dependent representation independence. In Proceedings of the 36th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL 2009. 340-353. https: //doi.org/10.1145/1480881.1480925 Google Scholar
Digital Library
- Andrew W. Appel and David B. MacQueen. 1991. Standard ML of New Jersey. In Programming Language Implementation and Logic Programming, 3rd International Symposium, PLILP 1991, Proceedings. 1-13. https://doi.org/10.1007/3-540-54444-5_83 Google Scholar
Cross Ref
- Kenichi Asai and Yukiyoshi Kameyama. 2007. Polymorphic Delimited Continuations. In Programming Languages and Systems, 5th Asian Symposium, APLAS 2007, Proceedings. 239-254. https://doi.org/10.1007/978-3-540-76637-7_16 Google Scholar
Cross Ref
- Andrej Bauer and Matija Pretnar. 2015. Programming with algebraic efects and handlers. Journal of Logical and Algebraic Methods in Programming 84, 1 ( 2015 ), 108-123. https://doi.org/10.1016/j.jlamp. 2014. 02.001 Google Scholar
Cross Ref
- Dariusz Biernacki, Maciej Piróg, Piotr Polesiuk, and Filip Sieczkowski. 2020. Binders by day, labels by night: efect instances via lexically scoped handlers. PACMPL 4, POPL ( 2020 ), 48 : 1-48 : 29. https://doi.org/10.1145/3371116 Google Scholar
Digital Library
- Chris Casinghino, Vilhelm Sjöberg, and Stephanie Weirich. 2014. Combining proofs and programs in a dependently typed language. In The 41st Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL 2014. 33-46. https://doi.org/10.1145/2535838.2535883 Google Scholar
Digital Library
- William D. Clinger, Daniel P. Friedman, and Mitchell Wand. 1985. A Scheme for a Higher-Level Semantic Algebra. Cambridge University Press, 237-250.Google Scholar
- Youyou Cong and Kenichi Asai. 2018. Handling delimited continuations with dependent types. PACMPL 2, ICFP ( 2018 ), 69 : 1-69 : 31. https://doi.org/10.1145/3236764 Google Scholar
Digital Library
- Luís Damas and Robin Milner. 1982. Principal Type-Schemes for Functional Programs. In Conference Record of the Ninth Annual ACM Symposium on Principles of Programming Languages. 207-212. https://doi.org/10.1145/582153.582176 Google Scholar
Digital Library
- Olivier Danvy and Andrzej Filinski. 1990. Abstracting Control. In LISP and Functional Programming. 151-160. https: //doi.org/10.1145/91556.91622 Google Scholar
Digital Library
- Stephen Dolan, Spiros Eliopoulos, Daniel Hillerström, Anil Madhavapeddy, K. C. Sivaramakrishnan, and Leo White. 2017. Concurrent System Programming with Efect Handlers. In Trends in Functional Programming-18th International Symposium, TFP 2017, Revised Selected Papers. 98-117. https://doi.org/10.1007/978-3-319-89719-6_6 Google Scholar
Cross Ref
- Derek Dreyer, Georg Neis, and Lars Birkedal. 2010. The impact of higher-order state and control efects on local relational reasoning. In Proceeding of the 15th ACM SIGPLAN international conference on Functional programming, ICFP 2010. 143-156. https://doi.org/10.1145/1863543.1863566 Google Scholar
Digital Library
- Joshua Dunfield and Neelakantan R. Krishnaswami. 2013. Complete and easy bidirectional typechecking for higher-rank polymorphism. In ACM SIGPLAN International Conference on Functional Programming, ICFP 2013. 429-442. https: //doi.org/10.1145/2500365.2500582 Google Scholar
Digital Library
- Matthias Felleisen. 1988. The Theory and Practice of First-Class Prompts. In Conference Record of the Fifteenth Annual ACM Symposium on Principles of Programming Languages, POPL 1988. 180-190. https://doi.org/10.1145/73560.73576 Google Scholar
Digital Library
- Andrzej Filinski. 2010. Monads in action. In Proceedings of the 37th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL 2010. 483-494. https://doi.org/10.1145/1706299.1706354 Google Scholar
Digital Library
- Yannick Forster, Ohad Kammar, Sam Lindley, and Matija Pretnar. 2019. On the expressive power of user-defined efects: Efect handlers, monadic reflection, delimited control. J. Funct. Program. 29 ( 2019 ), e15. https://doi.org/10.1017/ S0956796819000121 Google Scholar
Cross Ref
- Jacques Garrigue. 2004. Relaxing the Value Restriction. In Functional and Logic Programming, 7th International Symposium, FLOPS 2004, Proceedings. 196-213. https://doi.org/10.1007/978-3-540-24754-8_15 Google Scholar
Cross Ref
- Michael J. C. Gordon, Robin Milner, and Christopher P. Wadsworth. 1979. Edinburgh LCF. Lecture Notes in Computer Science, Vol. 78. Springer. https://doi.org/10.1007/3-540-09724-4 Google Scholar
- Carl A. Gunter, Didier Rémy, and Jon G. Riecke. 1995. A Generalization of Exceptions and Control in ML-like Languages. In Proceedings of the seventh international conference on Functional programming languages and computer architecture, FPCA 1995. 12-23. https://doi.org/10.1145/224164.224173 Google Scholar
Digital Library
- Robert Harper and Mark Lillibridge. 1991. ML with callcc is unsound. Announcement on the types electronic forum. https://www.cis.upenn.edu/~bcpierce/types/archives/1991/msg00034.htmlGoogle Scholar
- Robert Harper and Mark Lillibridge. 1993a. Explicit Polymorphism and CPS Conversion. In Conference Record of the Twentieth Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages. 206-219. https://doi.org/10.1145/ 158511.158630 Google Scholar
Digital Library
- Robert Harper and Mark Lillibridge. 1993b. Polymorphic Type Assignment and CPS Conversion. Lisp and Symbolic Computation 6, 3-4 ( 1993 ), 361-380.Google Scholar
Digital Library
- My Hoang, John C. Mitchell, and Ramesh Viswanathan. 1993. Standard ML-NJ weak polymorphism and imperative constructs. In Proceedings of the Eighth Annual Symposium on Logic in Computer Science (LICS '93). 15-25. https: //doi.org/10.1109/LICS. 1993.287604 Google Scholar
Cross Ref
- Ohad Kammar, Sam Lindley, and Nicolas Oury. 2013. Handlers in action. In ACM SIGPLAN International Conference on Functional Programming, ICFP 2013. 145-158. https://doi.org/10.1145/2500365.2500590 Google Scholar
Digital Library
- Ohad Kammar and Matija Pretnar. 2017. No value restriction is needed for algebraic efects and handlers. Journal of Functional Programming 27 ( 2017 ), e7. https://doi.org/10.1017/S0956796816000320 Google Scholar
Cross Ref
- Daan Leijen. 2017. Type directed compilation of row-typed algebraic efects. In Proceedings of the 44th ACM SIGPLAN Symposium on Principles of Programming Languages, POPL 2017. 486-499. http://dl.acm.org/citation.cfm?id= 3009872Google Scholar
- Daniel Leivant. 1983. Polymorphic Type Inference. In Conference Record of the Tenth Annual ACM Symposium on Principles of Programming Languages, POPL 1983. 88-98. https://doi.org/10.1145/567067.567077 Google Scholar
Digital Library
- Xavier Leroy and Pierre Weis. 1991. Polymorphic Type Inference and Assignment. In Proceedings of the 18th Annual ACM Symposium on Principles of Programming Languages. 291-302. https://doi.org/10.1145/99583.99622 Google Scholar
Digital Library
- Paul Blain Levy. 2001. Call-by-push-value. Ph.D. Dissertation. Queen Mary University of London, UK. http://ethos.bl.uk/ OrderDetails.do?uin=uk. bl.ethos.369233Google Scholar
- Sam Lindley, Conor McBride, and Craig McLaughlin. 2017. Do be do be do. In Proceedings of the 44th ACM SIGPLAN Symposium on Principles of Programming Languages, POPL 2017. 500-514. http://dl.acm.org/citation.cfm?id= 3009897Google Scholar
Digital Library
- Robin Milner. 1978. A Theory of Type Polymorphism in Programming. J. Comput. Syst. Sci. 17, 3 ( 1978 ), 348-375. https://doi.org/10.1016/ 0022-0000 ( 78 ) 90014-4 Google Scholar
Cross Ref
- Robin Milner, Mads Tofte, and Robert Harper. 1990. The Definition of Standard ML. MIT Press.Google Scholar
Digital Library
- John C. Mitchell. 1988. Polymorphic Type Inference and Containment. Inf. Comput. 76, 2 /3 ( 1988 ), 211-249. https: //doi.org/10.1016/ 0890-5401 ( 88 ) 90009-0 Google Scholar
Digital Library
- Eugenio Moggi. 1991. Notions of Computation and Monads. Inf. Comput. 93, 1 ( 1991 ), 55-92. https://doi.org/10.1016/ 0890-5401 ( 91 ) 90052-4 Google Scholar
Digital Library
- Pierre-Marie Pédrot and Nicolas Tabareau. 2020. The fire triangle: how to mix substitution, dependent elimination, and efects. PACMPL 4, POPL ( 2020 ), 58 : 1-58 : 28. https://doi.org/10.1145/3371126 Google Scholar
Digital Library
- Simon L. Peyton Jones, Dimitrios Vytiniotis, Stephanie Weirich, and Mark Shields. 2007. Practical type inference for arbitrary-rank types. J. Funct. Program. 17, 1 ( 2007 ), 1-82. https://doi.org/10.1017/S0956796806006034 Google Scholar
Digital Library
- Simon L. Peyton Jones and Philip Wadler. 1993. Imperative Functional Programming. In Conference Record of the Twentieth Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages. 71-84. https://doi.org/10.1145/ 158511.158524 Google Scholar
Digital Library
- Andrew Pitts and Ian Stark. 1998. Operational Reasoning for Functions with Local State. In Higher Order Operational Techniques in Semantics, Andrew Gordon and Andrew Pitts (Eds.). Publications of the Newton Institute, Cambridge University Press, 227-273. http://www.inf.ed.ac.uk/~stark/operfl.htmlGoogle Scholar
Digital Library
- Gordon D. Plotkin and John Power. 2003. Algebraic Operations and Generic Efects. Applied Categorical Structures 11, 1 ( 2003 ), 69-94. https://doi.org/10.1023/A:1023064908962 Google Scholar
Cross Ref
- Gordon D. Plotkin and Matija Pretnar. 2009. Handlers of Algebraic Efects. In Programming Languages and Systems, 18th European Symposium on Programming, ESOP 2009, Held as Part of the Joint European Conferences on Theory and Practice of Software, ETAPS 2009, Proceedings. 80-94. https://doi.org/10.1007/978-3-642-00590-9_7 Google Scholar
Digital Library
- Gordon D. Plotkin and Matija Pretnar. 2013. Handling Algebraic Efects. Logical Methods in Computer Science 9, 4 ( 2013 ). https://doi.org/10.2168/LMCS-9( 4 :23) 2013 Google Scholar
Cross Ref
- John C. Reynolds. 1974. Towards a theory of type structure. In Programming Symposium, Proceedings Colloque sur la Programmation. 408-423. https://doi.org/10.1007/3-540-06859-7_148 Google Scholar
Cross Ref
- John C. Reynolds. 1983. Types, Abstraction and Parametric Polymorphism. In IFIP Congress. 513-523.Google Scholar
- Taro Sekiyama and Atsushi Igarashi. 2017. Stateful manifest contracts. In Proceedings of the 44th ACM SIGPLAN Symposium on Principles of Programming Languages, POPL 2017. 530-544. http://dl.acm.org/citation.cfm?id= 3009875Google Scholar
Digital Library
- Taro Sekiyama and Atsushi Igarashi. 2019. Handling Polymorphic Algebraic Efects. In Programming Languages and Systems-28th European Symposium on Programming, ESOP 2019, Held as Part of the European Joint Conferences on Theory and Practice of Software, ETAPS 2019, Proceedings. 353-380. https://doi.org/10.1007/978-3-030-17184-1_13 Google Scholar
Cross Ref
- Dorai Sitaram. 1993. Handling Control. In Proceedings of the ACM SIGPLAN'93 Conference on Programming Language Design and Implementation (PLDI). 147-155. https://doi.org/10.1145/155090.155104 Google Scholar
Digital Library
- Nikhil Swamy, Catalin Hritcu, Chantal Keller, Aseem Rastogi, Antoine Delignat-Lavaud, Simon Forest, Karthikeyan Bhargavan, Cédric Fournet, Pierre-Yves Strub, Markulf Kohlweiss, Jean Karim Zinzindohoue, and Santiago Zanella Béguelin. 2016. Dependent types and multi-monadic efects in F. In Proceedings of the 43rd Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL 2016. 256-270. https://doi.org/10.1145/2837614.2837655 Google Scholar
Digital Library
- Jerzy Tiuryn and Pawel Urzyczyn. 1996. The Subtyping Problem for Second-Order Types is Undecidable. In Proceedings, 11th Annual IEEE Symposium on Logic in Computer Science (LICS '96). 74-85. https://doi.org/10.1109/LICS. 1996.561306 Google Scholar
Cross Ref
- Mads Tofte. 1990. Type Inference for Polymorphic References. Inf. Comput. 89, 1 ( 1990 ), 1-34. https://doi.org/10.1016/ 0890-5401 ( 90 ) 90018-D Google Scholar
Digital Library
- Philip Wadler. 1992. The Essence of Functional Programming. In Conference Record of the Nineteenth Annual ACM SIGPLANSIGACT Symposium on Principles of Programming Languages. 1-14. https://doi.org/10.1145/143165.143169 Google Scholar
Digital Library
- J. B. Wells. 1994. Typability and Type-Checking in the Second-Order lambda-Calculus are Equivalent and Undecidable. In Proceedings of the Ninth Annual Symposium on Logic in Computer Science (LICS '94). 176-185. https://doi.org/10.1109/ LICS. 1994.316068 Google Scholar
Cross Ref
- Andrew K. Wright. 1995. Simple Imperative Polymorphism. Lisp and Symbolic Computation 8, 4 ( 1995 ), 343-355.Google Scholar
- Andrew K. Wright and Matthias Felleisen. 1994. A Syntactic Approach to Type Soundness. Inf. Comput. 115, 1 ( 1994 ), 38-94. https://doi.org/10.1006/inco. 1994.1093 Google Scholar
Digital Library
- Hongwei Xi. 2007. Dependent ML An approach to practical programming with dependent types. J. Funct. Program. 17, 2 ( 2007 ), 215-286. https://doi.org/10.1017/S0956796806006216 Google Scholar
Digital Library
Index Terms
Signature restriction for polymorphic algebraic effects
Recommendations
Polymorphic algebraic data type reconstruction
PPDP '06: Proceedings of the 8th ACM SIGPLAN international conference on Principles and practice of declarative programmingOne of the disadvantages of statically typed languages is the programming overhead caused by writing all the necessary type information: Both type declarations and type definitions are typically required. Traditional type inference aims at relieving the ...
Multiversal Polymorphic Algebraic Theories: Syntax, Semantics, Translations, and Equational Logic
LICS '13: Proceedings of the 2013 28th Annual ACM/IEEE Symposium on Logic in Computer ScienceWe formalise and study the notion of polymorphic algebraic theory, as understood in the mathematical vernacular as a theory presented by equations between polymorphically-typed terms with both type and term variable binding. The prototypical example of ...
On polymorphic gradual typing
We study an extension of gradual typing—a method to integrate dynamic typing and static typing smoothly in a single language—to parametric polymorphism and its theoretical properties, including conservativity of typing and semantics over both statically ...






Comments