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 2009Publication 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.

Skip Supplemental Material Section

Supplemental Material

aconcurrentmllibraryinconcurrenthaskellonvimeo.mp4

mp4

97 MB

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.Google ScholarGoogle Scholar
  2. R. Bornat. A protocol for generalized Occam. Software Practice and Experience, 16 (9): 783--799, 1986. ISSN 0038-0644. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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/.Google ScholarGoogle Scholar
  5. Avik Chaudhuri and Benjamin Franksen. Hackagedb cml package, 2009. Available at http://hackage.haskell.org/cgi-bin/hackage-scripts/package/cml.Google ScholarGoogle Scholar
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. K. Donnelly and M. Fluet. Transactional events. In ICFP'06: International Conference on Functional Programming, pages 124--135. ACM, 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. A. D. Gordon. Functional programming and Input/Output. Cambridge University, 1994. ISBN 0-521-47103-6. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. C. A. R. Hoare. Communicating sequential processes. Communications of the ACM, 21 (8): 666--677, 1978. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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.Google ScholarGoogle Scholar
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. S. L. Peyton-Jones and P. Wadler. Imperative functional programming. In POPL'93: Principles of Programming Languages, pages 71--84. ACM, 1993. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. J. H. Reppy. Concurrent programming in ML. Cambridge University, 1999. ISBN 0-521-48089-2. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. J. H. Reppy. Higher-order concurrency. PhD thesis, Cornell University, 1992. Technical Report 92-1852. Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. J. H. Reppy. First-class synchronous operations. In TPPP'94: Theory and Practice of Parallel Programming. Springer, 1994. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. J. H. Reppy and Y. Xiao. Towards a parallel implementation of Concurrent ML. In DAMP'08: Declarative Aspects of Multicore Programming. ACM, 2008.Google ScholarGoogle Scholar
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. Wikipedia. Sieve of Eratosthenes, 2009. See http://en.wikipedia.org/wiki/Sieve_of_Eratosthenes.Google ScholarGoogle Scholar

Index Terms

  1. A concurrent ML library in concurrent Haskell

          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

          Login options

          Check if you have access through your login credentials or your institution to get full access on this article.

          Sign in
          • 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

            Copyright © 2009 ACM

            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]

            Publisher

            Association for Computing Machinery

            New York, NY, United States

            Publication History

            • Published: 31 August 2009

            Permissions

            Request permissions about this article.

            Request Permissions

            Check for updates

            Qualifiers

            • research-article

            Acceptance Rates

            Overall Acceptance Rate333of1,064submissions,31%

            Upcoming Conference

            ICFP '24

          PDF Format

          View or Download as a PDF file.

          PDF

          eReader

          View online with eReader.

          eReader