Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
skip to main content
research-article
Open access

Signature restriction for polymorphic algebraic effects

Published: 03 August 2020 Publication History

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.

Supplementary Material

Auxiliary Archive (icfp20main-p98-p-archive.zip)
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.
Presentation at ICFP '20 (a117-sekiyama-presentation.mp4)

References

[1]
Danel Ahman. 2017. Fibred Computational Efects. Ph.D. Dissertation. University of Edinburgh. https://danel.ahman.ee/ papers/phd-thesis.pdf
[2]
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
[3]
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
[4]
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
[5]
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
[6]
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
[7]
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
[8]
William D. Clinger, Daniel P. Friedman, and Mitchell Wand. 1985. A Scheme for a Higher-Level Semantic Algebra. Cambridge University Press, 237-250.
[9]
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
[10]
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
[11]
Olivier Danvy and Andrzej Filinski. 1990. Abstracting Control. In LISP and Functional Programming. 151-160. https: //doi.org/10.1145/91556.91622
[12]
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
[13]
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
[14]
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
[15]
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
[16]
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
[17]
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
[18]
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
[19]
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
[20]
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
[21]
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.html
[22]
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
[23]
Robert Harper and Mark Lillibridge. 1993b. Polymorphic Type Assignment and CPS Conversion. Lisp and Symbolic Computation 6, 3-4 ( 1993 ), 361-380.
[24]
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
[25]
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
[26]
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
[27]
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= 3009872
[28]
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
[29]
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
[30]
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.369233
[31]
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= 3009897
[32]
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
[33]
Robin Milner, Mads Tofte, and Robert Harper. 1990. The Definition of Standard ML. MIT Press.
[34]
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
[35]
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
[36]
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
[37]
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
[38]
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
[39]
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.html
[40]
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
[41]
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
[42]
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
[43]
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
[44]
John C. Reynolds. 1983. Types, Abstraction and Parametric Polymorphism. In IFIP Congress. 513-523.
[45]
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= 3009875
[46]
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
[47]
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
[48]
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
[49]
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
[50]
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
[51]
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
[52]
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
[53]
Andrew K. Wright. 1995. Simple Imperative Polymorphism. Lisp and Symbolic Computation 8, 4 ( 1995 ), 343-355.
[54]
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
[55]
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

Cited By

View all
  • (2024)Abstracting Effect Systems for Algebraic Effect HandlersProceedings of the ACM on Programming Languages10.1145/36746418:ICFP(455-484)Online publication date: 15-Aug-2024
  • (2024)Signature restriction for polymorphic algebraic effectsJournal of Functional Programming10.1017/S095679682400005434Online publication date: 27-May-2024
  • (2021)CPS transformation with affine types for call-by-value implicit polymorphismProceedings of the ACM on Programming Languages10.1145/34736005:ICFP(1-30)Online publication date: 19-Aug-2021

Recommendations

Comments

Information & Contributors

Information

Published In

cover image Proceedings of the ACM on Programming Languages
Proceedings of the ACM on Programming Languages  Volume 4, Issue ICFP
August 2020
1070 pages
EISSN:2475-1421
DOI:10.1145/3415018
Issue’s Table of Contents
This work is licensed under a Creative Commons Attribution International 4.0 License.

Publisher

Association for Computing Machinery

New York, NY, United States

Publication History

Published: 03 August 2020
Published in PACMPL Volume 4, Issue ICFP

Permissions

Request permissions for this article.

Check for updates

Badges

Author Tags

  1. algebraic effects and handlers
  2. polymorphic effects
  3. polymorphic type assignment

Qualifiers

  • Research-article

Contributors

Other Metrics

Bibliometrics & Citations

Bibliometrics

Article Metrics

  • Downloads (Last 12 months)83
  • Downloads (Last 6 weeks)16
Reflects downloads up to 09 Nov 2024

Other Metrics

Citations

Cited By

View all
  • (2024)Abstracting Effect Systems for Algebraic Effect HandlersProceedings of the ACM on Programming Languages10.1145/36746418:ICFP(455-484)Online publication date: 15-Aug-2024
  • (2024)Signature restriction for polymorphic algebraic effectsJournal of Functional Programming10.1017/S095679682400005434Online publication date: 27-May-2024
  • (2021)CPS transformation with affine types for call-by-value implicit polymorphismProceedings of the ACM on Programming Languages10.1145/34736005:ICFP(1-30)Online publication date: 19-Aug-2021

View Options

View options

PDF

View or Download as a PDF file.

PDF

eReader

View online with eReader.

eReader

Get Access

Login options

Full Access

Media

Figures

Other

Tables

Share

Share

Share this Publication link

Share on social media