skip to main content

Signature restriction for polymorphic algebraic effects

Published:03 August 2020Publication History
Skip Abstract Section

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.

Skip Supplemental Material Section

Supplemental Material

Presentation at ICFP '20

References

  1. Danel Ahman. 2017. Fibred Computational Efects. Ph.D. Dissertation. University of Edinburgh. https://danel.ahman.ee/ papers/phd-thesis.pdfGoogle ScholarGoogle Scholar
  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 Google ScholarGoogle ScholarDigital LibraryDigital Library
  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 Google ScholarGoogle ScholarCross RefCross Ref
  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 Google ScholarGoogle ScholarCross RefCross Ref
  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 Google ScholarGoogle ScholarCross RefCross Ref
  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 Google ScholarGoogle ScholarDigital LibraryDigital Library
  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 Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. William D. Clinger, Daniel P. Friedman, and Mitchell Wand. 1985. A Scheme for a Higher-Level Semantic Algebra. Cambridge University Press, 237-250.Google ScholarGoogle Scholar
  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 Google ScholarGoogle ScholarDigital LibraryDigital Library
  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 Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. Olivier Danvy and Andrzej Filinski. 1990. Abstracting Control. In LISP and Functional Programming. 151-160. https: //doi.org/10.1145/91556.91622 Google ScholarGoogle ScholarDigital LibraryDigital Library
  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 Google ScholarGoogle ScholarCross RefCross Ref
  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 Google ScholarGoogle ScholarDigital LibraryDigital Library
  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 Google ScholarGoogle ScholarDigital LibraryDigital Library
  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 Google ScholarGoogle ScholarDigital LibraryDigital Library
  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 Google ScholarGoogle ScholarDigital LibraryDigital Library
  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 Google ScholarGoogle ScholarCross RefCross Ref
  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 Google ScholarGoogle ScholarCross RefCross Ref
  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 Google ScholarGoogle Scholar
  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 Google ScholarGoogle ScholarDigital LibraryDigital Library
  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.htmlGoogle ScholarGoogle Scholar
  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 Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. Robert Harper and Mark Lillibridge. 1993b. Polymorphic Type Assignment and CPS Conversion. Lisp and Symbolic Computation 6, 3-4 ( 1993 ), 361-380.Google ScholarGoogle ScholarDigital LibraryDigital Library
  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 Google ScholarGoogle ScholarCross RefCross Ref
  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 Google ScholarGoogle ScholarDigital LibraryDigital Library
  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 Google ScholarGoogle ScholarCross RefCross Ref
  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= 3009872Google ScholarGoogle Scholar
  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 Google ScholarGoogle ScholarDigital LibraryDigital Library
  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 Google ScholarGoogle ScholarDigital LibraryDigital Library
  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.369233Google ScholarGoogle Scholar
  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= 3009897Google ScholarGoogle ScholarDigital LibraryDigital Library
  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 Google ScholarGoogle ScholarCross RefCross Ref
  33. Robin Milner, Mads Tofte, and Robert Harper. 1990. The Definition of Standard ML. MIT Press.Google ScholarGoogle ScholarDigital LibraryDigital Library
  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 Google ScholarGoogle ScholarDigital LibraryDigital Library
  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 Google ScholarGoogle ScholarDigital LibraryDigital Library
  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 Google ScholarGoogle ScholarDigital LibraryDigital Library
  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 Google ScholarGoogle ScholarDigital LibraryDigital Library
  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 Google ScholarGoogle ScholarDigital LibraryDigital Library
  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.htmlGoogle ScholarGoogle ScholarDigital LibraryDigital Library
  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 Google ScholarGoogle ScholarCross RefCross Ref
  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 Google ScholarGoogle ScholarDigital LibraryDigital Library
  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 Google ScholarGoogle ScholarCross RefCross Ref
  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 Google ScholarGoogle ScholarCross RefCross Ref
  44. John C. Reynolds. 1983. Types, Abstraction and Parametric Polymorphism. In IFIP Congress. 513-523.Google ScholarGoogle Scholar
  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= 3009875Google ScholarGoogle ScholarDigital LibraryDigital Library
  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 Google ScholarGoogle ScholarCross RefCross Ref
  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 Google ScholarGoogle ScholarDigital LibraryDigital Library
  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 Google ScholarGoogle ScholarDigital LibraryDigital Library
  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 Google ScholarGoogle ScholarCross RefCross Ref
  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 Google ScholarGoogle ScholarDigital LibraryDigital Library
  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 Google ScholarGoogle ScholarDigital LibraryDigital Library
  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 Google ScholarGoogle ScholarCross RefCross Ref
  53. Andrew K. Wright. 1995. Simple Imperative Polymorphism. Lisp and Symbolic Computation 8, 4 ( 1995 ), 343-355.Google ScholarGoogle Scholar
  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 Google ScholarGoogle ScholarDigital LibraryDigital Library
  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 Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Signature restriction for polymorphic algebraic effects

          Recommendations

          Comments

          Login options

          Check if you have access through your login credentials or your institution to get full access on this article.

          Sign in

          Full Access

          PDF Format

          View or Download as a PDF file.

          PDF

          eReader

          View online with eReader.

          eReader
          About Cookies On This Site

          We use cookies to ensure that we give you the best experience on our website.

          Learn more

          Got it!