Joinads: A Retargetable Control-Flow Construct for Reactive, Parallel and Concurrent Programming

  • Tomas Petricek
  • Don Syme
Part of the Lecture Notes in Computer Science book series (LNCS, volume 6539)

Abstract

Modern challenges led to a design of a wide range of programming models for reactive, parallel and concurrent programming, but these are often difficult to encode in general purpose languages. We present an abstract type of computations called joinads together with a syntactic language extension that aims to make it easier to use joinads in modern functional languages.

Our extension generalizes pattern matching to work on abstract computations. It keeps a familiar syntax and semantics of pattern matching making it easy to reason about code, even in a non-standard programming model. We demonstrate our extension using three important programming models – a reactive model based on events; a concurrent model based on join calculus and a parallel model using futures. All three models are implemented as libraries that benefit from our syntactic extension. This makes them easier to use and also opens space for exploring new useful programming models.

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. 1.
    Syme, D., Granicz, A., Cisternino, A.: Expert F#, ch. 9. Apress (2007)Google Scholar
  2. 2.
    Wadler, P.: Monads for functional programming. In: Jeuring, J., Meijer, E. (eds.) AFP 1995. LNCS, vol. 925. Springer, Heidelberg (1995)CrossRefGoogle Scholar
  3. 3.
    Syme, D.: F# Language Specification, http://tinyurl.com/fsspec
  4. 4.
    Petricek, T.: Reactive Programming with Events (Master thesis), Charles University (2010)Google Scholar
  5. 5.
    Fournet, C., Gonthier, G.: The reflexive CHAM and the join-calculus. In: POPL 1996 (1996)Google Scholar
  6. 6.
    Fournet, C., Le Fessant, F., Maranget, L., Schmitt, A.: JoCaml: A language for concurrent distributed and mobile programming. In: Jeuring, J., Jones, S.L.P. (eds.) AFP 2002. LNCS, vol. 2638, pp. 129–158. Springer, Heidelberg (2003)CrossRefGoogle Scholar
  7. 7.
    Benton, N., Cardelli, L., Fournet, C.: Modern concurrency abstractions for C#. ACM Trans. Program. Lang. Syst 26(5), 769–804 (2004)CrossRefMATHGoogle Scholar
  8. 8.
    Russo, C.: The Joins concurrency library. In: Hanus, M. (ed.) PADL 2007. LNCS, vol. 4354, pp. 260–274. Springer, Heidelberg (2006)CrossRefGoogle Scholar
  9. 9.
    Yorgey, B.: The Typeclassopedia. The Monad.Reader Issue 13, http://tinyurl.com/tycls
  10. 10.
    Haller, P., Van Cutsem, T.: Implementing Joins Using Extensible Pattern Matching. In: Wang, A.H., Tennenholtz, M. (eds.) COORDINATION 2008. LNCS, vol. 5052, pp. 135–152. Springer, Heidelberg (2008)CrossRefGoogle Scholar
  11. 11.
    Tullsen, M.: First class patterns. In: Pontelli, E., Santos Costa, V. (eds.) PADL 2000. LNCS, vol. 1753, p. 1. Springer, Heidelberg (2000)Google Scholar
  12. 12.
    Fluet, M., Rainey, M., Reppy, J., Shaw, A.: Implicitly-threaded parallelism in Manticore. In: Proceedings of ICFP 2008 (2008)Google Scholar
  13. 13.
    Syme, D., Neverov, G., Margetson, J.: Extensible Pattern Matching via a Lightweight Language Extension. In: ICFP (2007)Google Scholar
  14. 14.
    Wadler, P: Views: A way for pattern matching to cohabit with data abstraction. In: POPL 1987 (1987) Google Scholar
  15. 15.
    Peyton Jones, S.: Wearing the hair shirt - A retrospective on Haskell. Invited talk POPL (2003), Slides available online at http://tinyurl.com/haskellretro
  16. 16.
    McBride, C., Paterson, R.: Applicative programming with effects. Journal of Func. Programming 18 (2008)Google Scholar
  17. 17.
    Scholz, E.: Imperative streams - a monadic combinator library for synchronous programming. In: Proc. ICFP (1998)Google Scholar
  18. 18.
    Peyton Jones, S. (ed.): Haskell 98 Language and Libraries—The Revised Report. Cambridge University Press, Cambridge (2003)MATHGoogle Scholar
  19. 19.
    Emir, B., Odersky, M., Williams, J.: Matching Objects with Patterns. In: Bateni, M. (ed.) ECOOP 2007. LNCS, vol. 4609, pp. 273–298. Springer, Heidelberg (2007)CrossRefGoogle Scholar
  20. 20.
    King, D., Wadler, P.: Combining Monads. In: Proceedings of Glasgow Workshop on Functional Programming (1992)Google Scholar
  21. 21.
    Okasaki, C.: Views for Standard ML. In: Proc. of Workshop on ML, pp. 14–23 (1998)Google Scholar
  22. 22.
    Hughes, J.: Generalising Monads to Arrows. Sci. of Comput. Prog. 37, 67–111 (2000)MathSciNetCrossRefMATHGoogle Scholar
  23. 23.
    Elliott, C.: Declarative event-oriented programming. In: Proceedings of PPDP 2000 (2000)Google Scholar
  24. 24.
    Liu, H., Cheng, E., Hudak, P.: Causal commutative arrows and their optimization. In: ICFP 2009 (2009)Google Scholar
  25. 25.
    Bierman, G.M., Meijer, E., Torgersen, M.: Lost In Translation: Formalizing Proposed Extensions to C#. In: Proc. of OOPSLA 2007 (2007)Google Scholar
  26. 26.
    Lindley, S., Wadler, P., Yallop, J.: The arrow calculus, Technical Report EDI-INF-RR-1258, School of Informatics, University of Edinburgh (2008)Google Scholar
  27. 27.
    Petricek, T., Syme, D.: Joinads (Extended version), http://tinyurl.com/joinads

Copyright information

© Springer-Verlag Berlin Heidelberg 2011

Authors and Affiliations

  • Tomas Petricek
    • 1
  • Don Syme
    • 2
  1. 1.Faculty of Mathematics and PhysicsCharles UniversityPragueCzech Republic
  2. 2.Microsoft ResearchCambridgeUnited Kingdom

Personalised recommendations