skip to main content
10.1145/3406088.3409022acmconferencesArticle/Chapter ViewAbstractPublication PagesicfpConference Proceedingsconference-collections
research-article
Artifacts Available / v1.1

Effect handlers in Haskell, evidently

Published:09 August 2020Publication History

ABSTRACT

Algebraic effect handlers offer an alternative to monads to incorporate effects in Haskell. In recent work Xie _et al._ show how to give semantics to effect handlers in terms of plain polymorphic lambda calculus through _evidence translation_. Besides giving precise semantics, this translation also allows for potentially more efficient implementations. Here we present the first implementation of this technique as a library for effect handlers in Haskell. We show how the design naturally leads to a concise effect interface and how evidence translation enables evaluating _tail resumptive_ operations _in-place_. We give detailed benchmark results where our library performs well with respect to other approaches.

Skip Supplemental Material Section

Supplemental Material

3406088.3409022.mp4

mp4

35.2 MB

References

  1. Dariusz Biernacki, Maciej Piróg, Piotr Polesiuk, and Filip Sieczkowski. Dec. 2017. Handle with Care: Relational Interpretation of Algebraic Efects and Handlers. Proc. ACM Program. Lang. 2 ( POPL '17 issue): 8 : 1-8 : 30. doi: 10.1145/3158096.Google ScholarGoogle Scholar
  2. Lukas Convent, Sam Lindley, Conor McBride, and Craig McLaughlin. Jan. 2020. Doo Bee Doo Bee Doo. In the Journal of Functional Programming, January. To appear in the special issue on algebraic efects and handlers.Google ScholarGoogle Scholar
  3. R Kent Dyvbig, Simon Peyton Jones, and Amr Sabry. 2007. A Monadic Framework for Delimited Continuations. Journal of Functional Programming 17 ( 6 ). Cambridge University Press: 687-730. doi: 10.1017/S0956796807006259.Google ScholarGoogle Scholar
  4. Richard Eisenberg. Dec. 2012. Decidable Propositional Equality in Haskell. https://typesandkinds.wordpress.com/ 2012 /12/01/decidablepropositional-equality-in-haskell.Google ScholarGoogle Scholar
  5. Richard Eisenberg, and Stephanie Weirich. 2012. Dependently Typed Programming with Singletons. In Proceedings of the 2012 Haskell Symposium, 117-130. Haskell ' 12. Copenhagen, Denmark. doi: 10.1145/2364506.2364522.Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. Ben R. Gaster, and Mark P. Jones. 1996. A Polymorphic Type System for Extensible Records and Variants. NOTTCS-TR-96-3. University of Nottingham.Google ScholarGoogle Scholar
  7. Ohad Kammar, Sam Lindley, and Nicolas Oury. 2013. Handlers in Action. In Proceedings of the 18th ACM SIGPLAN International Conference on Functional Programming, 145-158. ICFP '13. ACM, New York, NY, USA. doi: 10.1145/2500365.2500590.Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. Ohad Kammar, and Matija Pretnar. Jan. 2017. No Value Restriction Is Needed for Algebraic Efects and Handlers. Journal of Functional Programming 27 ( 1 ). Cambridge University Press. doi: 10.1017/S0956796816000320.Google ScholarGoogle Scholar
  9. Alexis King. May 2020. Ef: Screaming Fast Extensible Efects for Less. https://github.com/hasura/eff.Google ScholarGoogle Scholar
  10. Oleg Kiselyov, and Hiromi Ishii. 2015. Freer Monads, More Extensible Efects. In Proceedings of the 2015 ACM SIGPLAN Symposium on Haskell, 94-105. Haskell' 15. Vancouver, BC, Canada. doi: 10.1145/2804302.2804319.Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. Oleg Kiselyov, Ralf Lämmel, and Keean Schupke. 2004. Strongly Typed Heterogeneous Collections. In Proceedings of the 2004 ACM SIGPLAN Workshop on Haskell, 96-107. Haskell ' 04. Association for Computing Machinery, New York, NY, USA. doi: 10.1145/1017472.1017488.Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. Oleg Kiselyov, Amr Sabry, and Cameron Swords. 2013. Extensible Efects: An Alternative to Monad Transformers. In Proceedings of the 2013 ACM SIGPLAN Symposium on Haskell, 59-70. Haskell ' 13. Boston, Massachusetts, USA. doi: 10.1145/2503778.2503791.Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. Oleg Kiselyov, and KC Sivaramakrishnan. Dec. 2017. Ef Directly in OCaml. In ML Workshop 2016. http://kcsrk.info/papers/caml-eff17.pdf. Extended version.Google ScholarGoogle Scholar
  14. Daan Leijen. 2005. Extensible Records with Scoped Labels. In Proceedings of the 2005 Symposium on Trends in Functional Programming, 297-312.Google ScholarGoogle Scholar
  15. Daan Leijen. Sep. 2008. HMF: Simple Type Inference for First-Class Polymorphism. In Proceedings of the 13th ACM Symposium of the International Conference on Functional Programming. ICFP'08. Victoria, Canada. doi: 10.1145/1411204.1411245.Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. Daan Leijen. 2014. Koka: Programming with Row Polymorphic Efect Types. In MSFP'14, 5th Workshop on Mathematically Structured Functional Programming. doi:10.4204/EPTCS.153.8.Google ScholarGoogle Scholar
  17. Daan Leijen. Jan. 2017. Type Directed Compilation of Row-Typed Algebraic Efects. In Proceedings of the 44th ACM SIGPLAN Symposium on Principles of Programming Languages (POPL'17), 486-499. Paris, France. doi: 10.1145/3009837.3009872.Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. Daan Leijen. 2018. First Class Dynamic Efect Handlers: Or, Polymorphic Heaps with Dynamic Efect Handlers. In Proceedings of the 3rd ACM SIGPLAN International Workshop on Type-Driven Development, 51-64. TyDe 2018. St. Louis, MO, USA. doi: 10.1145/3240719.3241789.Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. Daan Leijen, and Erik Meijer. 2000. Domain Specific Embedded Compilers. In Proceedings of the 2nd Conference on Domain-Specific Languages, 109-122. DSL ' 99. Austin, Texas, USA. doi: 10.1145/331960.331977.Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. Sheng Liang, Paul Hudak, and Mark Jones. 1995. Monad Transformers and Modular Interpreters. In Proceedings of the 22nd ACM SIGPLANSIGACT Symposium on Principles of Programming Languages, 333-343. POPL '95. Association for Computing Machinery, New York, NY, USA. doi: 10.1145/199448.199528.Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. Simon Peyton Jones, and John Launchbury. 1995. State in Haskell. Lisp and Symbolic Comp. 8 ( 4 ): 293-341. doi: 10.1007/BF01018827.Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. Simon Peyton Jones, Dimitrios Vytiniotis, Stephanie Weirich, and Mark Shields. Jan. 2007. Practical Type Inference for Arbitrary-Rank Types. J. Funct. Program. 17 ( 1 ). Cambridge University Press, USA: 1-82. doi: 10.1017/S0956796806006034.Google ScholarGoogle Scholar
  23. Gordon D. Plotkin, and John Power. 2003. Algebraic Operations and Generic Efects. Applied Categorical Structures 11 ( 1 ): 69-94. doi: 10.1023/A: 1023064908962.Google ScholarGoogle ScholarCross RefCross Ref
  24. Gordon D. Plotkin, and Matija Pretnar. 2013. Handling Algebraic Efects. In Logical Methods in Computer Science, volume 9. 4. doi: 10.2168/ LMCS9 (4:23) 2013.Google ScholarGoogle ScholarCross RefCross Ref
  25. Tom Schrijvers, Simon Peyton Jones, Manuel Chakravarty, and Martin Sulzmann. 2008. Type Checking with Open Type Functions. In Proceedings of the 13th ACM SIGPLAN International Conference on Functional Programming, 51-62. ICFP '08. Association for Computing Machinery, New York, NY, USA. doi: 10.1145/1411204.1411215.Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. Tom Schrijvers, Maciej Piróg, Nicolas Wu, and Mauro Jaskeliof. 2019. Monad Transformers and Modular Algebraic Efects: What Binds Them Together. In Proceedings of the 12th ACM SIGPLAN International Symposium on Haskell, 98-113. Haskell 2019. Association for Computing Machinery, New York, NY, USA. doi: 10.1145/3331545.3342595.Google ScholarGoogle ScholarDigital LibraryDigital Library
  27. Wouter Swierstra. Jul. 2008. Data Types à La Carte. Journal of Functional Programming 18 ( 4 ): 423-436. doi: 10.1017/S0956796808006758.Google ScholarGoogle ScholarDigital LibraryDigital Library
  28. Nicolas Wu, and Tom Schrijvers. 2015a. Fusion for Free: Eficient Algebraic Efect Handlers. In Proceedings of the International Conference on Mathematics of Program Construction. MPC'15. doi:10.1.1.723.5577.Google ScholarGoogle ScholarCross RefCross Ref
  29. Nicolas Wu, and Tom Schrijvers. 2015b. Fusion for Free: Eficient Algebraic Efect Handlers. In Proceedings of the 12th International Conference on Mathematics of Program Construction, 9129 : 302. Springer, Königswinter, Germany.Google ScholarGoogle Scholar
  30. Nicolas Wu, Tom Schrijvers, and Ralf Hinze. 2014. Efect Handlers in Scope. In Proceedings of the 2014 ACM SIGPLAN Symposium on Haskell, 1-12. Haskell ' 14. Göthenburg, Sweden. doi: 10.1145/2633357.2633358.Google ScholarGoogle ScholarDigital LibraryDigital Library
  31. Li-yao Xia. Jun. 2018. Heterogeneous Lists with Dependent Types in Haskell. https://blog.poisson.chat/posts/2018-06-06-hlistsdependent-haskell.html.Google ScholarGoogle Scholar
  32. Ningning Xie, Jonathan Brachthäuser, Phillip Schuster, Daniel Hillerström, and Daan Leijen. Aug. 2020. Efect Handlers, Evidently. In 25th ACM SIGPLAN International Conference on Functional Programming (ICFP' 2020 ). Jersey City, NJ. doi: 10.1145/3408981.Google ScholarGoogle Scholar
  33. Hongwei Xi, Chiyan Chen, and Gang Chen. 2003. Guarded Recursive Datatype Constructors. In Proceedings of the 30th ACM SIGPLANSIGACT Symposium on Principles of Programming Languages, 224-235. POPL '03. Association for Computing Machinery, New York, NY, USA. doi: 10.1145/604131.604150.Google ScholarGoogle ScholarDigital LibraryDigital Library
  34. Brent A. Yorgey, Stephanie Weirich, Julien Cretin, Simon Peyton Jones, Dimitrios Vytiniotis, and José Pedro Magalhães. 2012. Giving Haskell a Promotion. In Proceedings of the 8th ACM SIGPLAN Workshop on Types in Language Design and Implementation, 53-66. TLDI '12. Association for Computing Machinery, New York, NY, USA. doi: 10.1145/2103786.2103795.Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Effect handlers in Haskell, evidently

      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

      PDF Format

      View or Download as a PDF file.

      PDF

      eReader

      View online with eReader.

      eReader