skip to main content
research-article

Bringing back monad comprehensions

Authors Info & Claims
Published:22 September 2011Publication History
Skip Abstract Section

Abstract

This paper is about a Glasgow Haskell Compiler (GHC) extension that generalises Haskell's list comprehension notation to monads. The monad comprehension notation implemented by the extension supports generator and filter clauses, as was the case in the Haskell 1.4 standard. In addition, the extension generalises the recently proposed parallel and SQL-like list comprehension notations to monads. The aforementioned generalisations are formally defined in this paper. The extension will be available in GHC 7.2.

This paper gives several instructive examples that we hope will facilitate wide adoption of the extension by the Haskell community. We also argue why the do notation is not always a good fit for monadic libraries and embedded domain-specific languages, especially for those that are based on collection monads. Should the question of how to integrate the extension into the Haskell standard arise, the paper proposes a solution to the problem that led to the removal of the monad comprehension notation from the language standard.

Skip Supplemental Material Section

Supplemental Material

_talk2.mp4

References

  1. Database-Supported Haskell. http://hackage.haskell.org/package/DSH.Google ScholarGoogle Scholar
  2. Hugs - a functional programming system based on Haskell 98. http://www.haskell.org/hugs/.Google ScholarGoogle Scholar
  3. The Glasgow Haskell Compiler. http://www.haskell.org/ghc/.Google ScholarGoogle Scholar
  4. Haskell 1.4: A Non-Strict, Purely Functional Language, 1997.Google ScholarGoogle Scholar
  5. Guy Blelloch. Scans as Primitive Parallel Operations. IEEE Transactions on Computers, 38(11), 1989. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. Guy Blelloch. NESL: A nested data-parallel language. Technical report, Pittsburgh, PA, USA, 1992. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. Peter Buneman, Leonid Libkin, Dan Suciu, Val Tannen, and Limsoon Wong. Comprehension Syntax. SIGMOD Record, 23:87--96, 1994. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. Rod Burstall and John Darlington. Transformation Systems for Developing Recursive Programs. Journal of the ACM, 24(1):44--67, 1977. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. Manuel M. T. Chakravarty, Roman Leshchinskiy, Simon Peyton Jones, Gabriele Keller, and Simon Marlow. Data Parallel Haskell: A Status Report. In Proceedings of the 2007 Workshop on Declarative Aspects of Multicore Programming, DAMP '07, pages 10--18, Nice, France, 2007. ACM. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. Martin Erwig. Comprehending ADTs. Unpublished draft, http://web.engr.oregonstate.edu/~erwig/adtfold/compr.pdf, 2011.Google ScholarGoogle Scholar
  11. Leonidas Fegaras and David Maier. Towards an Effective Calculus for Object Query Languages. In Proceedings of the SIGMOD Conference, San Jose, CA, USA, 1995. ACM. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. George Giorgidze, Torsten Grust, Tom Schreiber, and Jeroen Weijers. Haskell boards the Ferry: Database-supported program execution for Haskell. In Revised selected papers of the 22nd international symposium on Implementation and Application of Functional Languages, Alphen aan den Rijn, Netherlands, volume 6647 of Lecture Notes in Computer Science. Springer, 2010. Peter Landin Prize for the best paper at IFL 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. Torsten Grust. How to Comprehend Queries Functionally. Intelligent Information Systems, 12(2/3):191--218, 1999. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. Torsten Grust. Monad Comprehensions: A Versatile Representation for Queries. In Peter M.D. Gray, Larry Kerschberg, Peter J.H. King, and Alexandra Poulovassilis, editors, The Functional Approach to Data Management. Springer, 2003.Google ScholarGoogle Scholar
  15. Paul Hudak, John Hughes, Simon Peyton Jones, and Philip Wadler. A History of Haskell: Being Lazy with Class. In Proceedings of the third ACM SIGPLAN Conference on History of Programming Languages, HOPL III, pages 1--55, San Diego, CA, USA, 2007. ACM. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. Graham Hutton and Erik Meijer. Monadic Parser Combinators. Technical Report NOTTCS-TR-96-4, University of Nottingham, Nottingham, UK, 1996.Google ScholarGoogle Scholar
  17. Mark Jones. The Implementation of the Gofer Functional Programming System. Technical Report YALEU/DCS/RR-1030, Yale University, New Haven, CT, USA, 1994.Google ScholarGoogle Scholar
  18. Won Kim. On Optimizing an SQL-like Nested Query. Transactions on Database Systems (TODS), 7(3), 1982. Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. Jeff Lewis. Cryptol: specification, implementation and verification of high-grade cryptographic applications. In Proceedings of the 2007 ACM workshop on Formal methods in security engineering, FMSE '07, pages 41--41, New York, NY, USA, 2007. ACM. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. Conor McBride and Ross Paterson. Applicative programming with effects. Journal of Functional Programming, 18(01):1--13, 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. Erik Meijer and Brian Beckman. XLinq: XML Programming Refactored (The Return of the Monoids). In Proceedings of the XML Conference, Atlanta, GA, USA, 2005.Google ScholarGoogle Scholar
  22. Erik Meijer, Brian Beckman, and Gavin Bierman. LINQ: Reconciling Objects, Relations, and XML in the .NET Framework. In Proceedings of the SIGMOD Conference, Chicago, IL, USA, 2006. ACM. Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. Tomas Petricek. Fun with parallel monad comprehensions. The Monad Reader Issue 18, 2011. http://themonadreader.wordpress.com/.Google ScholarGoogle Scholar
  24. Simon Peyton Jones, editor. Haskell 98 Language and Libraries -- The Revised Report. Cambridge University Press, Cambridge, England, 2003.Google ScholarGoogle Scholar
  25. Simon Peyton Jones and Philip Wadler. Comprehensive Comprehensions. In Proceedings of the ACM SIGPLAN Workshop on Haskell, pages 61--72, Freiburg, Germany, 2007. ACM. Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. Phil Trinder. Comprehensions, a Query Notation for DBPLs. In Proceedings of the 3rd International Workshop on Database Programming Languages, DBPL, Nafplion, Greece, 1991. Google ScholarGoogle ScholarDigital LibraryDigital Library
  27. David Turner. The Semantic Elegance of Applicative Languages. In Proceedings of the Conference on Functional Programming Languages and Computer Architecture, FPCA. ACM, 1981. Google ScholarGoogle ScholarDigital LibraryDigital Library
  28. Philip Wadler. Comprehending Monads. In Proceedings of the 1990 ACM Conference on LISP and Functional Programming, LFP '90, pages 61--78, Nice, France, 1990. ACM. Google ScholarGoogle ScholarDigital LibraryDigital Library
  29. Limsoon Wong. Querying Nested Collections. PhD thesis, University of Pennsylvania, Philadelphia, PA, USA, 1994. Google ScholarGoogle ScholarDigital LibraryDigital Library
  30. Limsoon Wong. Kleisli, A Functional Query System. Journal of Functional Programming, 10(1):19--56, 2000. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Bringing back monad comprehensions

        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 46, Issue 12
          Haskell '11
          December 2011
          129 pages
          ISSN:0362-1340
          EISSN:1558-1160
          DOI:10.1145/2096148
          Issue’s Table of Contents
          • cover image ACM Conferences
            Haskell '11: Proceedings of the 4th ACM symposium on Haskell
            September 2011
            136 pages
            ISBN:9781450308601
            DOI:10.1145/2034675

          Copyright © 2011 ACM

          Publisher

          Association for Computing Machinery

          New York, NY, United States

          Publication History

          • Published: 22 September 2011

          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!