skip to main content
research-article

Causal commutative arrows and their optimization

Published:31 August 2009Publication History
Skip Abstract Section

Abstract

Arrows are a popular form of abstract computation. Being more general than monads, they are more broadly applicable, and in particular are a good abstraction for signal processing and dataflow computations. Most notably, arrows form the basis for a domain specific language called Yampa, which has been used in a variety of concrete applications, including animation, robotics, sound synthesis, control systems, and graphical user interfaces. Our primary interest is in better understanding the class of abstract computations captured by Yampa. Unfortunately, arrows are not concrete enough to do this with precision. To remedy this situation we introduce the concept of commutative arrows that capture a kind of non-interference property of concurrent computations. We also add an init operator, and identify a crucial law that captures the causal nature of arrow effects. We call the resulting computational model causal commutative arrows. To study this class of computations in more detail, we define an extension to the simply typed lambda calculus called causal commutative arrows (CCA), and study its properties. Our key contribution is the identification of a normal form for CCA called causal commutative normal form (CCNF). By defining a normalization procedure we have developed an optimization strategy that yields dramatic improvements in performance over conventional implementations of arrows. We have implemented this technique in Haskell, and conducted benchmarks that validate the effectiveness of our approach. When combined with stream fusion, the overall methodology can result in speed-ups of greater than two orders of magnitude.

Skip Supplemental Material Section

Supplemental Material

causalcommutativearrowsandtheiroptimizationonvimeo.mp4

References

  1. Pascalin Amagbegnon, Loc Besnard, and Paul Le Guernic. Implementation of the data-flow synchronous language signal. In In Conference on Programming Language Design and Implementation, pages 163--173. ACM Press, 1995. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. Robert Atkey. What is a categorical model of arrows? In Mathematically Structured Functional Programming, 2008.Google ScholarGoogle Scholar
  3. Per Bjesse, Koen Claessen, Mary Sheeran, and Satnam Singh. Lava: Hardware design in haskell. In ICFP, pages 174--184, 1998. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. P. Caspi, N. Halbwachs, D. Pilaud, and J.A. Plaice. Lustre: A declarative language for programming synchronous systems. In 14th ACM Symp. on Principles of Programming Languages, January 1987. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. Paul Caspi and Marc Pouzet. A Co-iterative Characterization of Synchronous Stream Functions. In Coalgebraic Methods in Computer Science (CMCS'98), Electronic Notes in Theoretical Computer Science, March 1998. Extended version available as a VERIMAG tech. report no. 97--07 at www.lri.fr/~pouzet.Google ScholarGoogle Scholar
  6. Eric Cheng and Paul Hudak. Look ma, no arrows -- a functional reactive real-time sound synthesis framework. Technical Report YALEU/DCS/RR-1405, Yale University, May 2008.Google ScholarGoogle Scholar
  7. Mun Hon Cheong. Functional programming and 3d games, November 2005. also see www.haskell.org/haskellwiki/Frag.Google ScholarGoogle Scholar
  8. Jean-Louis Colaço, Alain Girault, Grégoire Hamon, and Marc Pouzet. Towards a higher-order synchronous data-flow language. In EMSOFT '04: Proceedings of the 4th ACM international conference on Embedded software, pages 230--239, New York, NY, USA, 2004. ACM. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. Antony Courtney. Modelling User Interfaces in a Functional Language. PhD thesis, Department of Computer Science, Yale University, May 2004. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. Antony Courtney and Conal Elliott. Genuinely functional user interfaces. In Proc. of the 2001 Haskell Workshop, September 2001.Google ScholarGoogle Scholar
  11. Antony Courtney, Henrik Nilsson, and John Peterson. The Yampa arcade. In Proceedings of the 2003 ACM SIGPLAN Haskell Workshop (Haskell'03), pages 7--18, Uppsala, Sweden, August 2003. ACM Press. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. Duncan Coutts, Roman Leshchinskiy, and Don Stewart. Stream fusion: From lists to streams to nothing at all. In Proceedings of the ACM SIGPLAN International Conference on Functional Programming, ICFP 2007, April 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. Conal Elliott and Paul Hudak. Functional reactive animation. In International Conference on Functional Programming, pages 263--273, June 1997. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. G. H. Mealy. A method for synthesizing sequential circuits. Bell System Technical Journal, 34(5):1045--1079, 1955.Google ScholarGoogle ScholarCross RefCross Ref
  15. George Giorgidze and Henrik Nilsson. Switched-on yampa. In Paul Hudak and David Scott Warren, editors, Practical Aspects of Declarative Languages, 10th International Symposium, PADL 2008, San Francisco, CA, USA, January 7-8, 2008, volume 4902 of Lecture Notes in Computer Science, pages 282--298. Springer, 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. N. Halbwachs, P. Raymond, and C. Ratel. Generating efficient code from data-flow programs. In J. Maluszy'nski and M. Wirsing, editors, Proceedings of the Third International Symposium on Programming Language Implementation and Logic Programming, number 528, pages 1--13207--218. Springer Verlag, 1991.Google ScholarGoogle ScholarCross RefCross Ref
  17. Masahito Hasegawa. Recursion from cyclic sharing: traced monoidal categories and models of cyclic lambda calculi. pages 196--213. Springer Verlag, 1997. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. L. Huang, P. Hudak, and J. Peterson. Hporter: Using arrows to compose parallel processes. In Proc. Practical Aspects of Declarative Languages, pages 275--289. Springer Verlag LNCS 4354, January 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. P. Hudak. Building domain specific embedded languages. ACM Computing Surveys, 28A:(electronic), December 1996. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. Paul Hudak. Modular domain specific languages and tools. In Proceedings of Fifth International Conference on Software Reuse, pages 134--142. IEEE Computer Society, June 1998. Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. Paul Hudak, Antony Courtney, Henrik Nilsson, and John Peterson. Arrows, robots, and functional reactive programming. In Summer School on Advanced Functional Programming 2002, Oxford University, volume 2638 of Lecture Notes in Computer Science, pages 159--187. Springer-Verlag, 2003.Google ScholarGoogle Scholar
  22. Paul Hudak, Paul Liu, Michael Stern, and Ashish Agarwal. Yampa meets the worm. Technical Report YALEU/DCS/RR-1408, Yale University, July 2008.Google ScholarGoogle Scholar
  23. John Hughes. Generalising monads to arrows. Science of Computer Programming, 37:67--111, May 2000. Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. John Hughes. Programming with arrows. In Advanced Functional Programming, pages 73--129, 2004. Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. Patrik Jansson and Johan Jeuring. Polytypic compact printing and parsing. In ESOP, pages 273--287, 1999. Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. Sam Lindley, Philip Wadler, and Jeremy Yallop. The arrow calculus (functional pearl). Draft, 2008.Google ScholarGoogle Scholar
  27. Hai Liu and Paul Hudak. Plugging a space leak with an arrow. Electronic Notes in Theoretical Computer Science, 193:29--45, nov 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  28. Conor McBride and Ross Paterson. Applicative programming with effects. J. Funct. Program., 18(1):1--13, 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  29. Eugenio Moggi. Notions of computation and monads. Inf. Comput., 93(1):55--92, 1991. Google ScholarGoogle ScholarDigital LibraryDigital Library
  30. Henrik Nilsson. Dynamic optimization for functional reactive programming using generalized algebraic data types. In ICFP, pages 54--65, 2005. Google ScholarGoogle ScholarDigital LibraryDigital Library
  31. Clemens Oertel. RatTracker: A Functional-Reactive Approach to Flexible Control of Behavioural Conditioning Experiments. PhD thesis, Wilhelm-Schickard-Institute for Computer Science at the University of Tübingen, May 2006.Google ScholarGoogle Scholar
  32. Ross Paterson. A new notation for arrows. In ICFP'01: International Conference on Functional Programming, pages 229--240, Firenze, Italy, 2001. Google ScholarGoogle ScholarDigital LibraryDigital Library
  33. John Peterson, Gregory Hager, and Paul Hudak. A language for declarative robotic programming. In International Conference on Robotics and Automation, 1999.Google ScholarGoogle ScholarCross RefCross Ref
  34. John Peterson, Paul Hudak, and Conal Elliott. Lambda in motion: Controlling robots with Haskell. In First International Workshop on Practical Aspects of Declarative Languages. SIGPLAN, Jan 1999. Google ScholarGoogle ScholarDigital LibraryDigital Library
  35. John Peterson, Zhanyong Wan, Paul Hudak, and Henrik Nilsson. Yale FRP User's Manual. Department of Computer Science, Yale University, January 2001. Available at http://www.haskell.org/frp/manual.html.Google ScholarGoogle Scholar
  36. Simon Peyton Jones et al. The Haskell 98 language and libraries: The revised report. Journal of Functional Programming, 13(1):0--255, Jan 2003. http://www.haskell.org/definition/. Google ScholarGoogle ScholarDigital LibraryDigital Library
  37. John Power and Hayo Thielecke. Closed freyd- and kappa-categories. In ICALP, pages 625--634, 1999. Google ScholarGoogle ScholarDigital LibraryDigital Library
  38. Jan J. M. M. Rutten. Algebraic specification and coalgebraic synthesis of mealy automata. Electr. Notes Theor. Comput. Sci, 160:305--319, 2006.Google ScholarGoogle ScholarCross RefCross Ref
  39. Robert Stephens. A survey of stream processing. Acta Informatica, 34(7):491--541, 1997.Google ScholarGoogle ScholarCross RefCross Ref
  40. Ross Howard Street, A. Joyal, and D. Verity. Traced monoidal categories. Mathematical Proceedings of the Cambridge Philosophical Society, 119(3):425--446, 1996.Google ScholarGoogle Scholar
  41. William Thies, Michal Karczmarek, and Saman P. Amarasinghe. Streamit: A language for streaming applications. In CC '02: Proceedings of the 11th International Conference on Compiler Construction, pages 179--196, London, UK, 2002. Springer-Verlag. Google ScholarGoogle ScholarDigital LibraryDigital Library
  42. Tarmo Uustalu and Varmo Vene. The essence of dataflow programming. In Zoltán Horváth, editor, CEFP, volume 4164 of Lecture Notes in Computer Science, pages 135--167. Springer, 2005. Google ScholarGoogle ScholarDigital LibraryDigital Library
  43. William W. Wadge and Edward A. Ashcroft. LUCID, the dataflow programming language. Academic Press Professional, Inc., San Diego, CA, USA, 1985. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Causal commutative arrows and their optimization

    Recommendations

    Comments

    Login options

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

    Sign in

    Full Access

    PDF Format

    View or Download as a PDF file.

    PDF

    eReader

    View online with eReader.

    eReader
    About Cookies On This Site

    We use cookies to ensure that we give you the best experience on our website.

    Learn more

    Got it!