Abstract
Many array-centric algorithms from computational science and engineering, especially those based on dynamic and irregular data structures, can be coded rather elegantly in a purely functional style. The challenge, when compared to imperative array languages, is performance.
These lecture notes discuss the shortcomings of Haskell’s standard arrays in this context and present an alternative approach that decouples array from list processing and is based on program transformation and generic programming. In particular, we will present (1) an array library that uses type analysis to achieve unboxing and flattening of data structures as well as (2) equational array fusion based on array combinators and compiler-driven rewrite rules. We will make use of a range of advanced language extensions to Haskell, such as multi-parameter type classes, functional dependencies, rewrite rules, unboxed values, and locally state-based computations.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Preview
Unable to display preview. Download preview PDF.
References
Blelloch, G.E., Sabot, G.W.: Compiling collection-oriented languages onto massively parallel computers. Journal of Parallel and Distributed Computing 8, 119–134 (1990)
Cheney, J., Hinze, R.: Poor man’s dynamics and generics. In: Chakravarty, M.M.T. (ed.) Proceedings of the ACM SIGPLAN 2002 Haskell Workshop, pp. 90–104. ACM Press, New York (2002)
Chakravarty, M.M.T., Keller, G.: More types for nested data parallel programming. In: Wadler, P. (ed.) Proceedings of the Fifth ACM SIGPLAN International Conference on Functional Programming (ICFP 2000), pp. 94–105. ACM Press, New York (2000)
Chakravarty, M.M.T., Keller, G.: Functional array fusion. In: Leroy, X. (ed.) Proceedings of the Sixth ACM SIGPLAN International Conference on Functional Programming (ICFP 2001), pp. 205–216. ACM Press, New York (2001)
Clarke, D., Löh, A.: Generic haskell, specifically. In: Proceedings of the IFIP WG2.1 Working Conference on Generic Programming (2002)
Chatterjee, S., Prins, J.F., Simons, M.: Expressing irregular computations in modern Fortran dialects. In: Fourth Workshop on Languages, Compilers, and Run-Time Systems for Scalable Computers. LNCS. Springer, Heidelberg (1998)
Duff, I.S., Erisman, A.M., Reid, J.K.: Direct Methods for Sparse Matrices. Oxford Science Publications (1986)
Gill, A.J., Launchbury, J., Jones, S.L.P.: A short cut to deforestation. In: Arvind (ed.) Functional Programming and Computer Architecture, pp. 223–232. ACM, New York (1993)
Haskell core libraries, base package (2002), http://haskell.org/ghc/docs/latest/html/base/index.html
Hinze, R.: Generalizing generalized tries. Journal of Functional Programming 10(4), 327–351 (2000)
Hinze, R., Jeuring, J., Löh, A.: Type-indexed datatypes. In: Proceedings of the 6th Mathematics of Program Construction Conference. Springer, Heidelberg (2002)
Harper, R., Morrisett, G.: Compiling polymorphism using intensional type analysis. In: 22nd ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, pp. 130–141. ACM Press, New York (1995)
Hinze, R., Jones, S.P.: Derivable type classes. In: Hutton, G. (ed.) Proceedings of the 2000 ACM SIGPLAN Haskell Workshop. Electronic Notes in Theoretical Computer Science, vol. 41.1. Elsevier Science, Amsterdam (2001)
Jones, M.: Type classes with functional dependencies. In: Smolka, G. (ed.) ESOP 2000. LNCS, vol. 1782, p. 230. Springer, Heidelberg (2000)
Jones, S.P., Hoare, T., Tolmach, A.: Playing by the rules: rewriting as a practical optimisation technique. In: Proceedings of the ACM SIGPLAN 2001 Haskell Workshop (2001)
Jones, S.P., Launchbury, J.: State in Haskell. Lisp and Symbolic Computation 8(4), 293–341 (1995)
Prins, J., Palmer, D.: Transforming high-level data-parallel programs into vector operations. In: Proceedings of the Fourth ACM SIGPLAN Symposium on Principles and Practice of Parallel Programming, San Diego, CA, May 19-22, pp. 119–128. ACM Press, New York (1993)
Tarditi, D., Morrisett, G., Cheng, P., Stone, C., Harper, R., Lee, P.: TIL: A type-directed optimizing compiler for ML. In: SIGPLAN Conference on Programming Language Design and Implementation (1996)
Wadler, P.: Deforestation. In: Ganzinger, H. (ed.) ESOP 1988. LNCS, vol. 300. Springer, Heidelberg (1988)
Author information
Authors and Affiliations
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2003 Springer-Verlag Berlin Heidelberg
About this chapter
Cite this chapter
Chakravarty, M.M.T., Keller, G. (2003). An Approach to Fast Arrays in Haskell. In: Jeuring, J., Jones, S.L.P. (eds) Advanced Functional Programming. AFP 2002. Lecture Notes in Computer Science, vol 2638. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-540-44833-4_2
Download citation
DOI: https://doi.org/10.1007/978-3-540-44833-4_2
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-540-40132-2
Online ISBN: 978-3-540-44833-4
eBook Packages: Springer Book Archive