skip to main content
research-article

Embedding effect systems in Haskell

Published:03 September 2014Publication History
Skip Abstract Section

Abstract

Monads are now an everyday tool in functional programming for abstracting and delimiting effects. The link between monads and effect systems is well-known, but in their typical use, monads provide a much more coarse-grained view of effects. Effect systems capture fine-grained information about the effects, but monads provide only a binary view: effectful or pure.

Recent theoretical work has unified fine-grained effect systems with monads using a monad-like structure indexed by a monoid of effect annotations (called parametric effect monads). This aligns the power of monads with the power of effect systems.

This paper leverages recent advances in Haskell's type system (as provided by GHC) to embed this approach in Haskell, providing user-programmable effect systems. We explore a number of practical examples that make Haskell even better and safer for effectful programming. Along the way, we relate the examples to other concepts, such as Haskell's implicit parameters and coeffects.

References

  1. Robert Atkey. Parameterised notions of computation. In Proceedings of the Workshop on Mathematically Structured Functional Programming. Cambridge Univ. Press, 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. Andrej Bauer and Matija Pretnar. Programming with algebraic effects and handlers. Journal of Logical and Algebraic Methods in Programming, 2014.Google ScholarGoogle Scholar
  3. Max Bolingbroke. Constraint Kinds for GHC, 2011. http://blog.omega-prime.co.uk/?p=127 (Retreived 24/06/14).Google ScholarGoogle Scholar
  4. Aloıs Brunel, Marco Gaboardi, Damiano Mazza, and Steve Zdancewic. A core quantitative coeffect calculus. In Proceedings of ESOP, volume 8410 of LNCS, pages 351--370. Springer, 2014.Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. Manuel M. T. Chakravarty, Gabriele Keller, and Simon Peyton Jones. Associated type synonyms. In Proceedings of 10th International Conference on Functional Programming, pages 241--253. ACM, 2005. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. Nils Anders Danielsson. Lightweight semiformal time complexity analysis for purely functional data structures. In ACM SIGPLAN Notices, volume 43, pages 133--144. ACM, 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. Richard A Eisenberg, Dimitrios Vytiniotis, Simon Peyton Jones, and Stephanie Weirich. Closed type families with overlapping equations. In Proceedings of POPL 2014, pages 671--684, 2014. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. Dan R. Ghica and Alex I. Smith. Bounded linear types in a resource semiring. In Proceedings of ESOP, volume 8410 of LNCS, pages 331--350. Springer, 2014.Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. David K. Gifford and John M. Lucassen. Integrating functional and imperative programming. In Proceedings of Conference on LISP and func. prog., LFP '86, 1986. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. Pierre Jouvelot and David Gifford. Algebraic reconstruction of types and effects. In Proceedings of the symposium on Principles of Programming Languages, pages 303--310. ACM, 1991. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. Ohad Kammar, Sam Lindley, and Nicolas Oury. Handlers in action. In Proceedings of the 18th International Conference on Functional Programming, pages 145--158. ACM, 2013. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. Shin-ya Katsumata. Parametric effect monads and semantics of effect systems. In Proceedings of symposium Principles of Programming Languages, pages 633--646. ACM, 2014. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. Oleg Kiselyov, Amr Sabry, and Cameron Swords. Extensible effects: an alternative to monad transformers. In Proceedings of 2013 symposium on Haskell, pages 59--70. ACM, 2013. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. J.R. Lewis, J. Launchbury, E. Meijer, and M.B. Shields. Implicit parameters: Dynamic scoping with static types. In Proceedings of Principles of Programming Languages, page 118. ACM, 2000. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. Sheng Liang, Paul Hudak, and Mark Jones. Monad transformers and modular interpreters. In Proceedings of 22nd symposium on Principles of Programming Languages, pages 333--343. ACM, 1995. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. Conor McBride. Functional pearl: Kleisli arrows of outrageous fortune. Journal of Functional Programming (to appear), 2011.Google ScholarGoogle Scholar
  17. Flemming Nielson and Hanne Nielson. Type and effect systems. Correct System Design, pages 114--136, 1999. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. Dominic Orchard, Max Bolingbroke, and Alan Mycroft. Ypnos: declarative, parallel structured grid programming. In Proceedings of 5th workshop on Declarative Aspects of Multicore Programming, pages 15--24. ACM, 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. Dominic Orchard, Tomas Petricek, and Alan Mycroft. The semantic marriage of monads and effects. arXiv:1401.5391, 2014.Google ScholarGoogle Scholar
  20. Dominic Orchard and Tom Schrijvers. Haskell type constraints unleashed. In Functional and Logic Programming, volume 6009/2010, pages 56--71. Springer Berlin, 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. Tomas Petricek, Dominic A. Orchard, and Alan Mycroft. Coeffects: Unified static analysis of context-dependence. In ICALP (2), volume 7966 of LNCS, pages 385--397. Springer, 2013. Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. Simon Peyton Jones, Dimitrios Vytiniotis, Stephanie Weirich, and Geoffrey Washburn. Simple unification-based type inference for GADTs. In Proceedings of ICFP, pages 50--61. ACM, 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. G. Plotkin and M. Pretnar. A logic for algebraic effects. In Logic in Computer Science, 2008. LICS'08, pages 118--129. IEEE, 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. Philip Wadler and Peter Thiemann. The marriage of effects and monads. ACM Trans. Comput. Logic, 4:1--32, January 2003. Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. Brent A Yorgey, Stephanie Weirich, Julien Cretin, Simon Peyton Jones, Dimitrios Vytiniotis, and José Pedro Magalhães. Giving Haskell a promotion. In Proceedings of workshop on Types in language design and implementation, pages 53--66. ACM, 2012. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Embedding effect systems in Haskell

      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

      • Published in

        cover image ACM SIGPLAN Notices
        ACM SIGPLAN Notices  Volume 49, Issue 12
        Haskell '14
        December 2014
        141 pages
        ISSN:0362-1340
        EISSN:1558-1160
        DOI:10.1145/2775050
        • Editor:
        • Andy Gill
        Issue’s Table of Contents
        • cover image ACM Conferences
          Haskell '14: Proceedings of the 2014 ACM SIGPLAN symposium on Haskell
          September 2014
          154 pages
          ISBN:9781450330411
          DOI:10.1145/2633357

        Copyright © 2014 ACM

        Publisher

        Association for Computing Machinery

        New York, NY, United States

        Publication History

        • Published: 3 September 2014

        Check for updates

        Qualifiers

        • research-article

      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!