Abstract
We study a number of embedded DSLs for autonomous ordinary differential equations (autonomous ODEs) in Haskell. A naive implementation based on the lazy tower of derivatives is straightforward but has serious time and space leaks due to the loss of sharing when handling cyclic and infinite data structures. In seeking a solution to fix this problem, we explore a number of DSLs ranging from shallow to deep embeddings, and middle-grounds in between. We advocate a solution based on arrows, an abstract notion of computation that offers both a succinct representation and an effective implementation. Arrows are ubiquitous in their combinator style that happens to capture both sharing and recursion elegantly. We further relate our arrow-based DSL to a more constrained form of arrows called causal commutative arrows, the normalization of which leads to a staged compilation technique improving ODE performance by orders of magnitude.
Preview
Unable to display preview. Download preview PDF.
Similar content being viewed by others
References
Bird, R.S., Paterson, R.: de Bruijn notation as a nested datatype. J. Funct. Program. 9(1), 77–91 (1999)
Bjesse, P., Claessen, K., Sheeran, M., Singh, S.: Lava: Hardware design in haskell. In: ICFP 1998: International Conference on Functional Programming, pp. 174–184. ACM, New York (1998)
Claessen, K., Sands, D.: Observable sharing for functional circuit description. In: Thiagarajan, P.S., Yap, R.H.C. (eds.) ASIAN 1999. LNCS, vol. 1742, pp. 62–73. Springer, Heidelberg (1999)
Courtney, A., Elliott, C.: Genuinely functional user interfaces. In: Proc. of the 2001 ACM SIGPLAN Haskell Workshop. ACM, New York (2001)
Elliott, C.M.: Beautiful differentiation. In: ICFP 2009: International Conference on Functional Programming, pp. 191–202. ACM, New York (2009)
Fegaras, L., Sheard, T.: Revisiting catamorphisms over datatypes with embedded functions (or, programs from outer space). In: POPL 1996: the 23th symposium on Principles of Programming Languages, pp. 284–294. ACM, New York (1996)
Ghani, N., Hamana, M., Uustalu, T., Vene, V.: Representing cyclic structures as nested datatypes. In: Proc. of 7th Symposium on Trends in Functional Programming (TFP 2006), pp. 173–188 (2006)
Gill, A.: Type-safe observable sharing in Haskell. In: Proc. of the 2009 ACM SIGPLAN Haskell Symposium. ACM, New York (2009)
Hughes, J.: Generalising monads to arrows. Science of Computer Programming 37, 67–111 (2000)
Karczmarczuk, J.: Functional differentiation of computer programs. In: ICFP 1998: International Conference on Functional Programming, pp. 195–203 (1998)
Liu, H., Hudak, P.: Plugging a space leak with an arrow. Electronic Notes in Theoretical Computer Science 193, 29–45 (2007)
Liu, H., Cheng, E., Hudak, P.: Causal commutative arrows and their optimization. In: ICFP 2009: International Conference on Functional Programming, pp. 35–46. ACM, New York (2009)
Michie, D.: Memo functions and machine learning. Nature 218(5136), 19–22 (1968)
Nilsson, H., Courtney, A., Peterson, J.: Functional Reactive Programming, continued. In: Proc. of ACM SIGPLAN 2002 Haskell Workshop. ACM, New York (2002)
O’Donnell, J.T.: Generating netlists from executable circuit specifications in a pure functional language. In: Functional Programming Workshops in Computing, pp. 178–194. Springer, Heidelberg (1992)
Paterson, R.: A new notation for arrows. In: ICFP 2001: International Conference on Functional Programming, pp. 229–240. ACM, New York (2001)
Turner, D.A.: A new implementation technique for applicative languages. Software-Practice and Experience 9, 31–49 (1979)
Author information
Authors and Affiliations
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2010 Springer-Verlag Berlin Heidelberg
About this paper
Cite this paper
Liu, H., Hudak, P. (2010). An Ode to Arrows. In: Carro, M., Peña, R. (eds) Practical Aspects of Declarative Languages. PADL 2010. Lecture Notes in Computer Science, vol 5937. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-642-11503-5_14
Download citation
DOI: https://doi.org/10.1007/978-3-642-11503-5_14
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-642-11502-8
Online ISBN: 978-3-642-11503-5
eBook Packages: Computer ScienceComputer Science (R0)