Nothing Special   »   [go: up one dir, main page]

skip to main content
10.1145/1596550.1596589acmconferencesArticle/Chapter ViewAbstractPublication PagesicfpConference Proceedingsconference-collections
research-article

A concurrent ML library in concurrent Haskell

Published: 31 August 2009 Publication History

Abstract

In Concurrent ML, synchronization abstractions can be defined and passed as values, much like functions in ML. This mechanism admits a powerful, modular style of concurrent programming, called higher-order concurrent programming. Unfortunately, it is not clear whether this style of programming is possible in languages such as Concurrent Haskell, that support only first-order message passing. Indeed, the implementation of synchronization abstractions in Concurrent ML relies on fairly low-level, language-specific details. In this paper we show, constructively, that synchronization abstractions can be supported in a language that supports only first-order message passing. Specifically, we implement a library that makes Concurrent ML-style programming possible in Concurrent Haskell. We begin with a core, formal implementation of synchronization abstractions in the π-calculus. Then, we extend this implementation to encode all of Concurrent ML's concurrency primitives (and more!) in Concurrent Haskell. Our implementation is surprisingly efficient, even without possible optimizations. In several small, informal experiments, our library seems to outperform OCaml's standard library of Concurrent ML-style primitives. At the heart of our implementation is a new distributed synchronization protocol that we prove correct. Unlike several previous translations of synchronization abstractions in concurrent languages, we remain faithful to the standard semantics for Concurrent ML's concurrency primitives. For example, we retain the symmetry of choose, which can express selective communication. As a corollary, we establish that implementing selective communication on distributed machines is no harder than implementing first-order message passing on such machines.

Supplementary Material

JPG File (aconcurrentmllibraryinconcurrenthaskellonvimeo.jpg)
MP4 File (aconcurrentmllibraryinconcurrenthaskellonvimeo.mp4)

References

[1]
R. Bagrodia. A distributed algorithm to implement the generalized alternative command of CSP. In ICDCS'86: International Conference on Distributed Computing Systems, pages 422--427. IEEE, 1986.
[2]
R. Bornat. A protocol for generalized Occam. Software Practice and Experience, 16 (9): 783--799, 1986. ISSN 0038-0644.
[3]
G. N. Buckley and A. Silberschatz. An effective implementation for the generalized input-output construct of CSP. ACM Transactions on Programming Languages and Systems, 5 (2): 223--235, 1983. ISSN 0164-0925.
[4]
A. Chaudhuri. A Concurrent ML library in Concurrent Haskell, 2009. Links to proofs and experiments at http://www.cs.umd.edu/avik/projects/cmllch/.
[5]
Avik Chaudhuri and Benjamin Franksen. Hackagedb cml package, 2009. Available at http://hackage.haskell.org/cgi-bin/hackage-scripts/package/cml.
[6]
E. D. Demaine. Protocols for non-deterministic communication over synchronous channels. In IPPS/SPDP'98: Symposium on Parallel and Distributed Processing, pages 24--30. IEEE, 1998.
[7]
K. Donnelly and M. Fluet. Transactional events. In ICFP'06: International Conference on Functional Programming, pages 124--135. ACM, 2006.
[8]
L. Effinger-Dean, M. Kehrt, and D. Grossman. Transactional events for ML. In ICFP'08: International Conference on Functional Programming, pages 103--114. ACM, 2008.
[9]
M. Flatt and R. B. Findler. Kill-safe synchronization abstractions. In PLDI'04: Programming Language Design and Implementation, pages 47--58. ACM, 2004. ISBN 1-58113-807-5.
[10]
A. D. Gordon. Functional programming and Input/Output. Cambridge University, 1994. ISBN 0-521-47103-6.
[11]
C. A. R. Hoare. Communicating sequential processes. Communications of the ACM, 21 (8): 666--677, 1978.
[12]
F. Knabe. A distributed protocol for channel-based communication with choice. In PARLE'92: Parallel Architectures and Languages, Europe, pages 947--948. Springer, 1992. ISBN 3-540-55599-4.
[13]
X. Leroy, D. Doligez, J. Garrigue, D. Rémy, and J. Vouillon. The Objective Caml system documentation: Event module, 2008. Available at http://caml.inria.fr/pub/docs/manual-ocaml/libref/Event.html.
[14]
R. Milner, J. Parrow, and D. Walker. A calculus of mobile processes, parts I and II. Information and Computation, 100 (1): 1--77, 1992.
[15]
S. L. Peyton-Jones and P. Wadler. Imperative functional programming. In POPL'93: Principles of Programming Languages, pages 71--84. ACM, 1993.
[16]
S. L. Peyton-Jones, A. D. Gordon, and S. Finne. Concurrent Haskell. In POPL'96: Principles of Programming Languages, pages 295--308. ACM, 1996.
[17]
J. H. Reppy. Concurrent programming in ML. Cambridge University, 1999. ISBN 0-521-48089-2.
[18]
J. H. Reppy. Higher-order concurrency. PhD thesis, Cornell University, 1992. Technical Report 92-1852.
[19]
J. H. Reppy. First-class synchronous operations. In TPPP'94: Theory and Practice of Parallel Programming. Springer, 1994.
[20]
J. H. Reppy and Y. Xiao. Towards a parallel implementation of Concurrent ML. In DAMP'08: Declarative Aspects of Multicore Programming. ACM, 2008.
[21]
G. Russell. Events in Haskell, and how to implement them. In ICFP'01: International Conference on Functional Programming, pages 157--168. ACM, 2001. ISBN 1-58113-415-0.
[22]
D. Sangiorgi. From pi-calculus to higher-order pi-calculus, and back. In TAPSOFT'93: Theory and Practice of Software Development, pages 151--166. Springer, 1993.
[23]
Wikipedia. Sieve of Eratosthenes, 2009. See http://en.wikipedia.org/wiki/Sieve_of_Eratosthenes.

Cited By

View all
  • (2023)Special Delivery: Programming with Mailbox TypesProceedings of the ACM on Programming Languages10.1145/36078327:ICFP(78-107)Online publication date: 31-Aug-2023
  • (2022)Send to me first: Priority in synchronous message-passingJournal of Functional Programming10.1017/S095679682200011932Online publication date: 22-Dec-2022
  • (2021)Minimal Translations from Synchronous Communication to Synchronizing LocksElectronic Proceedings in Theoretical Computer Science10.4204/EPTCS.339.7339(59-75)Online publication date: 23-Aug-2021
  • Show More Cited By

Recommendations

Reviews

Matthew Mark Huntbach

Suppose we have a universe of potential actions, each guarded by a selector. Individual selectors can guard any number of actions. Actions have matching counter-actions. Each selector must pick one of its actions, discarding all others, and the action picked must be one whose counter-action is picked by another selector. The action and counter-action could be transmitting and receiving a message on a particular channel. Many abstract models of concurrent computation have synchronous channels, which require this agreement to take place at both ends of transmission, as their interaction mechanism. The paper describes an abstract protocol for selecting actions in this way, taking it as a model for the library of synchronization abstractions in Concurrent ML (CML), a programming language. It then re-describes this protocol in π-calculus, the minimalist language often used in concurrency theory. Finally, the result is translated into the programming language Concurrent Haskell. ML and Haskell are the leading academic functional programming languages. ML adds extra features to the functional core, but Haskell keeps to the pure model by using ingenious, purely functional ways to represent constructs that seemingly break the zero-assignment principle of pure functional programming. Translating impure extra ML features to pure Haskell, as shown in this paper, is part of showing that the pure model is sufficient for all needs. Although functional languages have been with us since the dawn of programming-first as Lisp-recent renewed attention to the paradigm, as an escape route from increasingly creaky Java, makes this more than an academic exercise. Online Computing Reviews Service

Access critical reviews of Computing literature here

Become a reviewer for Computing Reviews.

Comments

Please enable JavaScript to view thecomments powered by Disqus.

Information & Contributors

Information

Published In

cover image ACM Conferences
ICFP '09: Proceedings of the 14th ACM SIGPLAN international conference on Functional programming
August 2009
364 pages
ISBN:9781605583327
DOI:10.1145/1596550
  • cover image ACM SIGPLAN Notices
    ACM SIGPLAN Notices  Volume 44, Issue 9
    ICFP '09
    September 2009
    343 pages
    ISSN:0362-1340
    EISSN:1558-1160
    DOI:10.1145/1631687
    Issue’s Table of Contents
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 ACM 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]

Sponsors

Publisher

Association for Computing Machinery

New York, NY, United States

Publication History

Published: 31 August 2009

Permissions

Request permissions for this article.

Check for updates

Author Tags

  1. concurrent ML
  2. concurrent haskell
  3. distributed synchronization protocol
  4. pi calculus
  5. synchronization abstractions

Qualifiers

  • Research-article

Conference

ICFP '09
Sponsor:
ICFP '09: ACM SIGPLAN International Conference on Functional Programming
August 31 - September 2, 2009
Edinburgh, Scotland

Acceptance Rates

Overall Acceptance Rate 333 of 1,064 submissions, 31%

Upcoming Conference

ICFP '25
ACM SIGPLAN International Conference on Functional Programming
October 12 - 18, 2025
Singapore , Singapore

Contributors

Other Metrics

Bibliometrics & Citations

Bibliometrics

Article Metrics

  • Downloads (Last 12 months)6
  • Downloads (Last 6 weeks)0
Reflects downloads up to 28 Sep 2024

Other Metrics

Citations

Cited By

View all
  • (2023)Special Delivery: Programming with Mailbox TypesProceedings of the ACM on Programming Languages10.1145/36078327:ICFP(78-107)Online publication date: 31-Aug-2023
  • (2022)Send to me first: Priority in synchronous message-passingJournal of Functional Programming10.1017/S095679682200011932Online publication date: 22-Dec-2022
  • (2021)Minimal Translations from Synchronous Communication to Synchronizing LocksElectronic Proceedings in Theoretical Computer Science10.4204/EPTCS.339.7339(59-75)Online publication date: 23-Aug-2021
  • (2021)GraphRedex: Look at your researchSoftware: Practice and Experience10.1002/spe.295951:6(1322-1351)Online publication date: 3-Mar-2021
  • (2020)Correctly Implementing Synchronous Message Passing in the Pi-Calculus By Concurrent Haskell's MVarsElectronic Proceedings in Theoretical Computer Science10.4204/EPTCS.322.8322(88-105)Online publication date: 27-Aug-2020
  • (2018)Concurrent ML as an Alternative Parallel Programming Style for Image Processing2018 International Conference on Image and Vision Computing New Zealand (IVCNZ)10.1109/IVCNZ.2018.8634712(1-6)Online publication date: Nov-2018
  • (2014)MultiMLton: A multicore-aware runtime for standard MLJournal of Functional Programming10.1017/S095679681400016124:6(613-674)Online publication date: 18-Jun-2014
  • (2012)Run your researchProceedings of the 39th annual ACM SIGPLAN-SIGACT symposium on Principles of programming languages10.1145/2103656.2103691(285-296)Online publication date: 25-Jan-2012
  • (2012)Run your researchACM SIGPLAN Notices10.1145/2103621.210369147:1(285-296)Online publication date: 25-Jan-2012
  • (2011)Composable asynchronous eventsProceedings of the 32nd ACM SIGPLAN Conference on Programming Language Design and Implementation10.1145/1993498.1993572(628-639)Online publication date: 4-Jun-2011
  • Show More Cited By

View Options

Get Access

Login options

View options

PDF

View or Download as a PDF file.

PDF

eReader

View online with eReader.

eReader

Media

Figures

Other

Tables

Share

Share

Share this Publication link

Share on social media