Abstract

We describe a new programming idiom for concurrency, based on Applicative Functors, where concurrency is implicit in the Applicative <*> operator. The result is that concurrent programs can be written in a natural applicative style, and they retain a high degree of clarity and modularity while executing with maximal concurrency. This idiom is particularly useful for programming against external data sources, where the application code is written without the use of explicit concurrency constructs, while the implementation is able to batch together multiple requests for data from the same source, and fetch data from multiple sources concurrently. Our abstraction uses a cache to ensure that multiple requests for the same data return the same result, which frees the programmer from having to arrange to fetch data only once, which in turn leads to greater modularity.
While it is generally applicable, our technique was designed with a particular application in mind: an internal service at Facebook that identifies particular types of content and takes actions based on it. Our application has a large body of business logic that fetches data from several different external sources. The framework described in this paper enables the business logic to execute efficiently by automatically fetching data concurrently; we present some preliminary results.
- S. Awodey. Category Theory, volume 49 of Oxford Logic Guides. Oxford University Press, 2006.Google Scholar
Cross Ref
- K. Claessen. A poor man's concurrency monad. J. Funct. Program., 9 (3): 313--323, May 1999. Google Scholar
Digital Library
- M. Eriksen. Your server as a function. In Proceedings of the Seventh Workshop on Programming Languages and Operating Systems, PLOS '13, pages 5:1--5:7. ACM, 2013. ISBN 978-1-4503-2460-1. Google Scholar
Digital Library
- W. L. Harrison. Cheap (but functional) threads. Submitted for publication, http://people.cs.missouri.edu/~harrisonwl/drafts/CheapThreads.pdf.Google Scholar
- P. Li and S. Zdancewic. Combining events and threads for scalable network services implementation and evaluation of monadic, application-level concurrency primitives. In Proceedings of the 2007 ACM SIGPLAN Conference on Programming Language Design and Implementation, PLDI '07, pages 189--199, 2007. Google Scholar
Digital Library
- S. Marlow. An extensible dynamically-typed hierarchy of exceptions. In Proceedings of the 2006 ACM SIGPLAN Workshop on Haskell, Haskell '06, pages 96--106, 2006. Google Scholar
Digital Library
- C. Mcbride and R. Paterson. Applicative programming with effects. J. Funct. Program., 18 (1): 1--13, Jan. 2008. ISSN 0956-7968. Google Scholar
Digital Library
- E. Meijer. Reactive extensions (Rx): Curing your asynchronous programming blues. In ACM SIGPLAN Commercial Users of Functional Programming, CUFP '10, pages 11:1--11:1. ACM, 2010. Google Scholar
Digital Library
- S. Peyton Jones, D. Vytiniotis, S. Weirich, and G. Washburn. Simple unification-based type inference for GADTs. In Proceedings of the Eleventh ACM SIGPLAN International Conference on Functional Programming, ICFP '06, pages 50--61. ACM, 2006. Google Scholar
Digital Library
- E. Scholz. A concurrency monad based on constructor primitives, or, being first-class is not enough. Technical report, Universität Berlin, 1995.Google Scholar
- T. Stein, E. Chen, and K. Mangla. Facebook immune system. In Proceedings of the 4th Workshop on Social Network Systems, SNS '11, pages 8:1--8:8. ACM, 2011. Google Scholar
Digital Library
- W. Swierstra and T. Altenkirch. Beauty in the beast. In Proceedings of the ACM SIGPLAN Workshop on Haskell Workshop, Haskell '07, pages 25--36, 2007. ISBN 978-1-59593-674-5. Google Scholar
Digital Library
- D. Syme, T. Petricek, and D. Lomov. The F# asynchronous programming model. In Practical Aspects of Declarative Languages, volume 6539 of Lecture Notes in Computer Science, pages 175--189. Springer Berlin Heidelberg, 2011. Google Scholar
Digital Library
- V. Venkataramani, Z. Amsden, N. Bronson, G. Cabrera III, P. Chakka, P. Dimov, H. Ding, J. Ferris, A. Giardullo, J. Hoon, S. Kulkarni, N. Lawrence, M. Marchukov, D. Petrov, and L. Puzar. TAO: How facebook serves the social graph. In Proceedings of the 2012 ACM SIGMOD International Conference on Management of Data, SIGMOD '12, pages 791--792, 2012. Google Scholar
Digital Library
- J. Vouillon. Lwt: A cooperative thread library. In Proceedings of the 2008 ACM SIGPLAN Workshop on ML, ML '08, pages 3--12. ACM, 2008. Google Scholar
Digital Library
Index Terms
There is no fork: an abstraction for efficient, concurrent, and concise data access
Recommendations
There is no fork: an abstraction for efficient, concurrent, and concise data access
ICFP '14: Proceedings of the 19th ACM SIGPLAN international conference on Functional programmingWe describe a new programming idiom for concurrency, based on Applicative Functors, where concurrency is implicit in the Applicative <*> operator. The result is that concurrent programs can be written in a natural applicative style, and they retain a ...
Concurrent orchestration in Haskell
Haskell '10: Proceedings of the third ACM Haskell symposium on HaskellWe present a concurrent scripting language embedded in Haskell, emulating the functionality of the Orc orchestration language by providing many-valued (real) non-determinism in the context of concurrent effects. We provide many examples of its use, as ...
Concurrent orchestration in Haskell
HASKELL '10We present a concurrent scripting language embedded in Haskell, emulating the functionality of the Orc orchestration language by providing many-valued (real) non-determinism in the context of concurrent effects. We provide many examples of its use, as ...







Comments