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.
- Robert Atkey. Parameterised notions of computation. In Proceedings of the Workshop on Mathematically Structured Functional Programming. Cambridge Univ. Press, 2006. Google Scholar
Digital Library
- Andrej Bauer and Matija Pretnar. Programming with algebraic effects and handlers. Journal of Logical and Algebraic Methods in Programming, 2014.Google Scholar
- Max Bolingbroke. Constraint Kinds for GHC, 2011. http://blog.omega-prime.co.uk/?p=127 (Retreived 24/06/14).Google Scholar
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- Conor McBride. Functional pearl: Kleisli arrows of outrageous fortune. Journal of Functional Programming (to appear), 2011.Google Scholar
- Flemming Nielson and Hanne Nielson. Type and effect systems. Correct System Design, pages 114--136, 1999. Google Scholar
Digital Library
- 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 Scholar
Digital Library
- Dominic Orchard, Tomas Petricek, and Alan Mycroft. The semantic marriage of monads and effects. arXiv:1401.5391, 2014.Google Scholar
- Dominic Orchard and Tom Schrijvers. Haskell type constraints unleashed. In Functional and Logic Programming, volume 6009/2010, pages 56--71. Springer Berlin, 2010. Google Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- G. Plotkin and M. Pretnar. A logic for algebraic effects. In Logic in Computer Science, 2008. LICS'08, pages 118--129. IEEE, 2008. Google Scholar
Digital Library
- Philip Wadler and Peter Thiemann. The marriage of effects and monads. ACM Trans. Comput. Logic, 4:1--32, January 2003. Google Scholar
Digital Library
- 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 Scholar
Digital Library
Index Terms
Embedding effect systems in Haskell
Recommendations
Embedding effect systems in Haskell
Haskell '14: Proceedings of the 2014 ACM SIGPLAN symposium on HaskellMonads 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 ...
Polymorphic Iterable Sequential Effect Systems
Effect systems are lightweight extensions to type systems that can verify a wide range of important properties with modest developer burden. But our general understanding of effect systems is limited primarily to systems where the order of effects is ...
Type-Safe Code Transformations in Haskell
The use of typed intermediate languages can significantly increase the reliability of a compiler. By type-checking the code produced at each transformation stage, one can identify bugs in the compiler that would otherwise be much harder to find. We ...







Comments