Skip to main content

Comprehending Ringads

For Phil Wadler, on the Occasion of his 60th Birthday

  • Chapter
  • First Online:

Part of the book series: Lecture Notes in Computer Science ((LNTCS,volume 9600))

Abstract

List comprehensions are a widely used programming construct, in languages such as Haskell and Python and in technologies such as Microsoft’s Language Integrated Query. They generalize from lists to arbitrary monads, yielding a lightweight idiom of imperative programming in a pure functional language. When the monad has the additional structure of a so-called ringad, corresponding to ‘empty’ and ‘union’ operations, then it can be seen as some kind of collection type, and the comprehension notation can also be extended to incorporate aggregations. Ringad comprehensions represent a convenient notation for expressing database queries. The ringad structure alone does not provide a good explanation or an efficient implementation of relational joins; but by allowing heterogeneous comprehensions, involving both bag and indexed table ringads, we show how to accommodate these too.

This is a preview of subscription content, log in via an institution.

Buying options

Chapter
USD   29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD   39.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD   54.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Learn about institutional subscriptions

References

  • Backhouse, R.: An exploration of the Bird-Meertens formalism. Technical report CS 8810, Department of Computer Science, Groningen University (1988). http://www.cs.nott.ac.uk/psarb2/papers/abstract.html#exploration

  • Boiten, E., Hoogendijk, P.: A database calculus based on strong monads and partial functions, March 1995. Submitted to DBPL

    Google Scholar 

  • Boiten, E., Hoogendijk, P.: Nested collections and polytypism. Technical report 96/17, Eindhoven (1996)

    Google Scholar 

  • Breuer, P.T.:. Applicative query languages. University Computing, the Universities and Colleges Information Systems Association of the UK (UCISA) Bulletin of Academic Computing and Information Systems (1989). https://www.academia.edu/2499641/Applicative_Query_Languages

  • Buneman, P., Navqi, S., Tannen, V., Wong, L.: Principles of programming with collections and complex object types. Theor. Comput. Sci. 149(1), 3–48 (1995)

    Article  MATH  Google Scholar 

  • Cooper, E., Lindley, S., Yallop, J.: Links: web programming without tiers. In: de Boer, F.S., Bonsangue, M.M., Graf, S., de Roever, W.-P. (eds.) FMCO 2006. LNCS, vol. 4709, pp. 266–296. Springer, Heidelberg (2007)

    Chapter  Google Scholar 

  • Fegaras, L., Maier, D.: Optimizing object queries using an effective calculus. ACM Trans. Database Syst. 25(4), 457–516 (2000). doi:10.1145/377674.377676

    Article  MATH  Google Scholar 

  • Fernandez, M., Simeon, J., Wadler, P.: A semi-monad for semi-structured data. In: International Conference on Database Theory, pp. 263–300 (2001)

    Google Scholar 

  • Maarten, M.: Tupling and mutumorphisms. Squiggolist 1(4), 81–82 (1990)

    Google Scholar 

  • Fujii, S., Katsumata, S., Melliès, P.-A.: Towards a formal theory of graded monads. In: Foundations of Software Science and Computation Structures. Lecture Notes in Computer Science. Springer (2016, to appear)

    Google Scholar 

  • GHC 5.0. Glasgow Haskell Compiler users’ guide, version 5.00, April 2001. https://downloads.haskell.org/~ghc/5.00/docs/set/book-users-guide.html

  • GHC 7.10. Glasgow Haskell Compiler users’ guide, version 7.10, July 2015. https://downloads.haskell.org/~ghc/7.10.1/docs/html/users_guide/

  • Giorgidze, G., Grust, T., Schweinsberg, N., Weijers, J.: Bringing back monad comprehensions. In: Haskell Symposium, pp. 13–22 (2011)

    Google Scholar 

  • Grust, T.: Comprehending queries. Ph.D. thesis, Universität Konstanz (1999)

    Google Scholar 

  • Haskell 2010. Haskell 2010 language report, April 2010. https://www.haskell.org/onlinereport/haskell2010/

  • Henglein, F., Larsen, K.F.: Generic multiset programming with discrimination-based joins, symbolic cartesian products. High.-Order Symb. Comput. 23(3), 337–370 (2010). doi:10.1007/s10990-011-9078-8

    Article  MathSciNet  MATH  Google Scholar 

  • Katsumata, S.: Parametric effect monads and semantics of effect systems. In: Principles of Programming Languages, pp. 633–645 (2014)

    Google Scholar 

  • Kiselyov, O.: Laws of MonadPlus, January 2015. http://okmij.org/ftp/Computation/monads.html#monadplus

  • Luposchainsky, D.: MonadFail proposal, June 2015. https://github.com/quchen/articles/blob/master/monad_fail.md

  • Meijer, E.: The world according to LINQ. Commun. ACM 54(10), 45–51 (2011)

    Article  Google Scholar 

  • Milius, S., Pattinson, D., Schröder, L.: Generic trace semantics and graded monads. In: Moss, L., Sobocinski, P., (eds.) 6th International Conference on Algebra and Coalgebra in Computer Science (CALCO 2015), pp. 251–266 (2015)

    Google Scholar 

  • Moggi, E.: Notions of computation and monads. Inf. Comput. 93(1), 55–92 (1991)

    Article  MathSciNet  MATH  Google Scholar 

  • Nikhil, R.S.: The semantics of update in a functional database programming language. In: Bancilhon, F., Buneman, P., (eds.) Advances in Database Programming Languages (DBPL-1, 1987), pp. 403–421. ACM Press/Addison-Wesley (1990)

    Google Scholar 

  • Orchard, D., Yoshida, N.: Effects as sessions, sessions as effects. In: Principles of Programming Languages (2016)

    Google Scholar 

  • Orchard, D., Petricek, T., Mycroft, A.: The semantic marriage of monads, effects (2014). arXiv:1401.5391

  • Petricek, T.: Fun with parallel monad comprehensions. Monad Reader (18), (2011). https://themonadreader.wordpress.com/2011/07/05/issue-18/

  • Peyton Jones, S.: The Implementation of Functional Programming Languages. Prentice Hall, New Jersey (1987)

    MATH  Google Scholar 

  • Plasmeijer, R., van Eekelen, M.: Concurrent clean language report (version 1.0). Technical report, University of Nijmegen (1995). ftp://ftp.science.ru.nl/pub/Clean/old/Clean10/doc/refman.ps.gz

  • Poulovassilis, A.: FDL: an integration of the functional data model and the functional computational model. In: British National Conference on Databases, pp. 215–236 (1988)

    Google Scholar 

  • Schwartz, J.T., Dewar, R.B.K., Dubinsky, E., Schonberg, E.: Programming with Sets: An Introduction to SETL. Springer, New York (1986)

    Book  MATH  Google Scholar 

  • Schwartz, J.T.: On programming: an interim report on the SETL project. Technical report, Courant Institute of Mathematical Sciences, New York University, June 1975

    Google Scholar 

  • Suciu, D.: Fixpoints and bounded fixpoints for complex objects. Technical report MS-CIS-93-32, University of Pennsylvania (1993a)

    Google Scholar 

  • Suciu, D.: Queries on databases with user-defined functions. Technical report MS-CIS-93-62, University of Pennsylvania (1993b)

    Google Scholar 

  • Suzuki, K., Kiselyov, O., Kameyama, Y.: Finally, safely-extensible and efficient language-integrated query. In: Partial Evaluation and Program Manipulation (2016)

    Google Scholar 

  • Trinder, P.: Comprehensions: a query notation for DBPLs. In: Database Programming Languages (1991)

    Google Scholar 

  • Trinder, P., Wadler, P.: Improving list comprehension database queries. In: TENCON 1989: Fourth IEEE Region 10 International Conference. IEEE (1989)

    Google Scholar 

  • Uustalu, T.: A divertimento on MonadPlus and nondeterminism. J. Logical Algebr. Methods Program (2015, to appear). Special issue in honour of José Nuno Oliveira’s 60th birthday. Extended abstract in HOpPE

    Google Scholar 

  • Wadler, P.: Notes on monads and ringads. Internal Document, CS Department, University of Glasgow, September 1990

    Google Scholar 

  • Wadler, P.: Comprehending monads. Math. Struct. Comput. Sci. 2, 461–493 (1992a)

    Article  MathSciNet  MATH  Google Scholar 

  • Wadler, P.: Monads for functional programming. In: Broy, M. (ed.) Marktoberdorf Summer School on Program Design Calculi. NATO ASI Series F: Computer and Systems Sciences, vol. 118. Springer, Heidelberg (1992b). Also In: Jeuring, J., Meijer, E. (eds.) Advanced Functional Programming. LNCS, vol. 925. Springer (1995)

    Google Scholar 

  • Wadler, P.: Laws for monads with zero and plus. Post to Haskell Mailing List, May 1997

    Google Scholar 

  • Wadler, P.: Monads and ringads. Personal communication, August 2011

    Google Scholar 

  • Wadler, P., Jones, S.P.: Comprehensive comprehensions: comprehensions with ‘order by’ and ‘group by’. In: Haskell Symposium, pp. 61–72 (2007)

    Google Scholar 

  • Watt, D., Trinder, P.: Towards a theory of bulk types. FIDE technical report 91/26, Glasgow University, July 1991

    Google Scholar 

  • Williams, T.: Map comprehensions, June 2014. http://www.timphilipwilliams.com/posts/2014-06-05-map-comprehensions.html

  • Wong, L.: Querying nested collections. Ph.D. thesis, University of Pennsylvania (1994)

    Google Scholar 

  • Wong, L.: Kleisli, a functional query system. J. Funct. Program. 10(1), 19–56 (2000)

    Article  Google Scholar 

Download references

Acknowledgements

I am very grateful to Ralf Hinze, Nicolas Wu, Fritz Henglein, Tarmo Uustalu, and Oleg Kiselyov for their helpful discussions, to Eerke Boiten for finding a copy of Wadler’s note (Wadler 1990), to Shin-ya Katsumata for sharing unpublished work (Fujii et al. 2016) on graded monads, and to the anonymous reviewers for constructive criticism. This work was partially supported by EPSRC grants Unifying Theories of Generic Programming (EP/J010995/1) and A Theory of Least Change for Bidirectional Transformations (EP/K020919/1).

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Jeremy Gibbons .

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2016 Springer International Publishing Switzerland

About this chapter

Cite this chapter

Gibbons, J. (2016). Comprehending Ringads. In: Lindley, S., McBride, C., Trinder, P., Sannella, D. (eds) A List of Successes That Can Change the World. Lecture Notes in Computer Science(), vol 9600. Springer, Cham. https://doi.org/10.1007/978-3-319-30936-1_7

Download citation

  • DOI: https://doi.org/10.1007/978-3-319-30936-1_7

  • Published:

  • Publisher Name: Springer, Cham

  • Print ISBN: 978-3-319-30935-4

  • Online ISBN: 978-3-319-30936-1

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics