skip to main content
10.1145/3475726.3475728acmotherconferencesArticle/Chapter ViewAbstractPublication PagessplashConference Proceedingsconference-collections
short-paper

Comprehending Monoids with Class

Published: 03 October 2021 Publication History

Abstract

Expressive high-level languages like Haskell and Scala let us define convenient embedded domain-specific languages (EDSL) for writing database queries, leveraging their rich type systems. The design of such EDSLs has traditionally relied on monadic comprehension a natural foundation for expressing queries over collections of data. We argue that monoid comprehension is an interesting alternative foundation for these embedded query languages. Using Haskell as our host language, we show that a generalized version of the monoid comprehension calculus can be naturally encoded in languages with support for type classes, and that this unlocks a new kind of expressive power — notably, it gives us an efficient grouping construct, and it allows queries mixing heterogeneous data types (lists, sets, multisets, infinite streams, maps, etc.), while using the type system to statically verify some desirable properties of these queries. We argue that for expressing queries over collections of data, our embedding of monoid comprehension can be more flexible, simpler, more efficient, and safer than its monadic counterpart.

References

[1]
Roland C Backhouse. 1988. An exploration of the Bird-Meertens formalism. University of Groningen, Department of Mathematics and Computing Science.
[2]
Alexander Bunkenburg. 1994. The Boom Hierarchy. Springer London, London, 1–8. https://doi.org/10.1007/978-1-4471-3236-3_1
[3]
Ezra Cooper, Sam Lindley, Philip Wadler, and Jeremy Yallop. 2007. Links: Web Programming Without Tiers. In Formal Methods for Components and Objects, Frank S. de Boer, Marcello M. Bonsangue, Susanne Graf, and Willem-Paul de Roever (Eds.). Springer Berlin Heidelberg, Berlin, Heidelberg, 266–296.
[4]
Leonidas Fegaras and David Maier. 1995. Towards an Effective Calculus for Object Query Languages. SIGMOD Rec. 24, 2 (May 1995), 47–58. https://doi.org/10.1145/568271.223789
[5]
Leonidas Fegaras and David Maier. 2000. Optimizing Object Queries Using an Effective Calculus. ACM Trans. Database Syst. 25, 4 (Dec. 2000), 457–516. https://doi.org/10.1145/377674.377676
[6]
Mary F. Fernandez, Jérôme Siméon, and Philip Wadler. 2001. A Semi-monad for Semi-structured Data. In Proceedings of the 8th International Conference on Database Theory(ICDT ’01). Springer-Verlag, London, UK, UK, 263–300.
[7]
Jeremy Gibbons. 2016. Comprehending Ringads: For Phil Wadler, on the Occasion of his 60th Birthday. In A List of Successes That Can Change the World(LNCS, Vol. 9600). Springer, 132–151.
[8]
George Giorgidze, Torsten Grust, Nils Schweinsberg, and Jeroen Weijers. 2011. Bringing Back Monad Comprehensions. In Proceedings of the 4th ACM Symposium on Haskell(Tokyo, Japan) (Haskell ’11). Association for Computing Machinery, New York, NY, USA, 13–22. https://doi.org/10.1145/2034675.2034678
[9]
Torsten Grust. 2004. Monad Comprehensions: A Versatile Representation for Queries. Springer Berlin Heidelberg, Berlin, Heidelberg, 288–311. https://doi.org/10.1007/978-3-662-05372-0_12
[10]
Kenneth E. Iverson. 1980. Notation As a Tool of Thought. Commun. ACM 23, 8 (Aug. 1980), 444–465. https://doi.org/10.1145/358896.358899
[11]
Simon Peyton Jones and Philip Wadler. 2007. Comprehensive Comprehensions. In Proceedings of the ACM SIGPLAN Workshop on Haskell Workshop (Freiburg, Germany) (Haskell ’07). Association for Computing Machinery, New York, NY, USA, 61–72. https://doi.org/10.1145/1291201.1291209
[12]
Erik Meijer, Brian Beckman, and Gavin Bierman. 2006. LINQ: Reconciling Object, Relations and XML in the.NET Framework(SIGMOD ’06). ACM, 706–706.
[13]
Phil Trinder. 1992. Comprehensions, a Query Notation for DBPLs. In Proceedings of the Third International Workshop on Database Programming Languages: Bulk Types & Persistent Data: Bulk Types & Persistent Data (Nafplion, Greece) (DBPL3). Morgan Kaufmann Publishers Inc., San Francisco, CA, USA, 55–68.
[14]
Philip Wadler. 1990. Comprehending Monads. In Proceedings of the 1990 ACM Conference on LISP and Functional Programming (Nice, France) (LFP ’90). Association for Computing Machinery, New York, NY, USA, 61–78. https://doi.org/10.1145/91556.91592
[15]
LIMSOON WONG. 2000. Kleisli, a functional query system. Journal of Functional Programming 10, 1 (2000), 19–56.

Cited By

View all

Recommendations

Comments

Information & Contributors

Information

Published In

cover image ACM Other conferences
DBPL '21: The 18th International Symposium on Database Programming Languages
August 2021
27 pages
ISBN:9781450386463
DOI:10.1145/3475726
Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than the author(s) must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected].

Publisher

Association for Computing Machinery

New York, NY, United States

Publication History

Published: 03 October 2021

Permissions

Request permissions for this article.

Check for updates

Qualifiers

  • Short-paper
  • Research
  • Refereed limited

Conference

DBPL '21

Acceptance Rates

Overall Acceptance Rate 10 of 15 submissions, 67%

Contributors

Other Metrics

Bibliometrics & Citations

Bibliometrics

Article Metrics

  • 0
    Total Citations
  • 68
    Total Downloads
  • Downloads (Last 12 months)20
  • Downloads (Last 6 weeks)2
Reflects downloads up to 13 Jan 2025

Other Metrics

Citations

Cited By

View all

View Options

Login options

View options

PDF

View or Download as a PDF file.

PDF

eReader

View online with eReader.

eReader

HTML Format

View this article in HTML Format.

HTML Format

Media

Figures

Other

Tables

Share

Share

Share this Publication link

Share on social media