skip to main content
research-article

Freer monads, more extensible effects

Published:30 August 2015Publication History
Skip Abstract Section

Abstract

We present a rational reconstruction of extensible effects, the recently proposed alternative to monad transformers, as the confluence of efforts to make effectful computations compose. Free monads and then extensible effects emerge from the straightforward term representation of an effectful computation, as more and more boilerplate is abstracted away. The generalization process further leads to freer monads, constructed without the Functor constraint. The continuation exposed in freer monads can then be represented as an efficient type-aligned data structure. The end result is the algorithmically efficient extensible effects library, which is not only more comprehensible but also faster than earlier implementations. As an illustration of the new library, we show three surprisingly simple applications: non-determinism with committed choice (LogicT), catching IO exceptions in the presence of other effects, and the semi-automatic management of file handles and other resources through monadic regions. We extensively use and promote the new sort of `laziness', which underlies the left Kan extension: instead of performing an operation, keep its operands and pretend it is done.

References

  1. H. Apfelmus. The Operational monad tutorial. The Monad.Reader, 15:37–56, 2010.Google ScholarGoogle Scholar
  2. S. Awodey. Category Theory, volume 49 of Oxford Logic Guides. Oxford University Press, 2006.Google ScholarGoogle ScholarCross RefCross Ref
  3. P. Bahr. Composing and decomposing data types: a closed type families implementation of data types à la carte. In [email protected], pages 71–82. ACM Press, 31 Aug. 2014. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. A. Bauer and M. Pretnar. Programming with algebraic effects and handlers. arXiv:1203.1539 {cs.PL}, 2012.Google ScholarGoogle Scholar
  5. J.-P. Bernardy and N. Pouillard. Names for free: polymorphic views of names and binders. In Haskell {11}, pages 13–24. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. E. Brady. Programming and reasoning with algebraic effects and dependent types. In ICFP {15}, pages 133–144.. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. R. Cartwright and M. Felleisen. Extensible denotational language specifications. In M. Hagiya and J. C. Mitchell, editors, Theor. Aspects of Comp. Soft., number 789 in LNCS, pages 244–272. Springer, 1994. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. K. Claessen. Parallel parsing processes. J. Functional Programming, 14(6):741–757, 2004. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. O. Danvy and A. Filinski. Abstracting control. In Proceedings of the 1990 ACM Conference on Lisp and Functional Programming, pages 151–160. ACM Press, 27–29 June 1990. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. M. Fluet and J. G. Morrisett. Monadic regions. J. Functional Programming, 16(4–5):485–545, 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. Haskell. Haskell Symposium, 2013. ACM.Google ScholarGoogle Scholar
  12. Haskell. Haskell Symposium, 2014. ACM.Google ScholarGoogle Scholar
  13. R. Hinze. Deriving backtracking monad transformers. In ICFP ’00, pages 186–197. ACM Press, 2000. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. J. Hughes. The design of a pretty-printing library. In First Intl. Spring School on Adv. Functional Programming Techniques, pages 53–96, London, UK, UK, 1995. Springer-Verlag. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. ICFP. ICFP ’13, 2013. ACM Press.Google ScholarGoogle Scholar
  16. P. Johann and N. Ghani. Foundations for structured programming with GADTs. In POPL ’08, pages 297–308. ACM Press, 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. O. Kammar, S. Lindley, and N. Oury. Handlers in action. In ICFP Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. , pages 145–158.Google ScholarGoogle Scholar
  19. O. Kiselyov. Iteratees. In Proc. of the 11th International Symposium on Functional and Logic Programming, pages 166–181, 2012. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. O. Kiselyov and C.-c. Shan. Lightweight monadic regions. In Proc. 2008 Haskell Symposium, pages 1–12. ACM Press, 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. O. Kiselyov, C.-c. Shan, D. P. Friedman, and A. Sabry. Backtracking, interleaving, and terminating monad transformers (functional pearl). In ICFP ’05, pages 192–203. ACM Press, Sept. 2005. Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. O. Kiselyov, A. Sabry, and C. Swords. Extensible effects: an alternative to monad transformers. In Haskell {11}, pages 59–70.. Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. S. Liang, P. Hudak, and M. Jones. Monad transformers and modular interpreters. In POPL ’95, pages 333–343. ACM Press, 1995. Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. C.-k. Lin. Programming monads operationally with Unimo. In ICFP ’06, pages 274–285. ACM Press, 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. C. Lüth and N. Ghani. Composing monads using coproducts. In ICFP ’02, pages 133–144. ACM Press, 2002. Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. L. Naish. Pruning in logic programming. Technical Report 95/16, Department of Computer Science, University of Melbourne, 1995.Google ScholarGoogle Scholar
  27. G. Plotkin and M. Pretnar. Handlers of algebraic effects. In ESOP ’09, pages 80–94, Berlin, Heidelberg, 2009. Springer-Verlag. Google ScholarGoogle ScholarDigital LibraryDigital Library
  28. N. Sculthorpe, J. Bracker, G. Giorgidze, and A. Gill. The constrainedmonad problem. In ICFP {15}, pages 287–298. Google ScholarGoogle ScholarDigital LibraryDigital Library
  29. T. Sheard and E. Paˇsali´c. Two-level types and parameterized modules. J. Functional Programming, 14(5):547–587, Sept. 2004. Google ScholarGoogle ScholarDigital LibraryDigital Library
  30. G. L. Steele, Jr. Building interpreters by composing monads. In POPL ’94, pages 472–492. ACM Press, 1994. Google ScholarGoogle ScholarDigital LibraryDigital Library
  31. W. Swierstra. Data types à la carte. J. Funct. Program., 18(4):423– 436, July 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  32. A. van der Ploeg and O. Kiselyov. Reflection without remorse: revealing a hidden sequence to speed up monadic reflection. In Haskell {12}, pages 133–144.. Google ScholarGoogle ScholarDigital LibraryDigital Library
  33. N. Wu and T. Schrijvers. Fusion for free: Efficient algebraic effect handlers. In MPC 2015, 2015. URL /Research/papers/mpc2015.Google ScholarGoogle Scholar
  34. pdf.Google ScholarGoogle Scholar
  35. N. Wu, T. Schrijvers, and R. Hinze. Effect handlers in scope. In Haskell {12}, pages 1–12. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Freer monads, more extensible 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!