Skip to main content

An Approach to Fast Arrays in Haskell

  • Chapter
Advanced Functional Programming (AFP 2002)

Part of the book series: Lecture Notes in Computer Science ((LNCS,volume 2638))

Included in the following conference series:


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.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

USD 16.99
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 16.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. Blelloch, G.E., Sabot, G.W.: Compiling collection-oriented languages onto massively parallel computers. Journal of Parallel and Distributed Computing 8, 119–134 (1990)

    Article  Google Scholar 

  2. 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)

    Chapter  Google Scholar 

  3. 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)

    Chapter  Google Scholar 

  4. 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)

    Chapter  Google Scholar 

  5. Clarke, D., Löh, A.: Generic haskell, specifically. In: Proceedings of the IFIP WG2.1 Working Conference on Generic Programming (2002)

    Google Scholar 

  6. 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)

    Google Scholar 

  7. Duff, I.S., Erisman, A.M., Reid, J.K.: Direct Methods for Sparse Matrices. Oxford Science Publications (1986)

    Google Scholar 

  8. 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)

    Google Scholar 

  9. Haskell core libraries, base package (2002),

  10. Hinze, R.: Generalizing generalized tries. Journal of Functional Programming 10(4), 327–351 (2000)

    Article  MATH  MathSciNet  Google Scholar 

  11. Hinze, R., Jeuring, J., Löh, A.: Type-indexed datatypes. In: Proceedings of the 6th Mathematics of Program Construction Conference. Springer, Heidelberg (2002)

    Google Scholar 

  12. 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)

    Chapter  Google Scholar 

  13. 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)

    Google Scholar 

  14. Jones, M.: Type classes with functional dependencies. In: Smolka, G. (ed.) ESOP 2000. LNCS, vol. 1782, p. 230. Springer, Heidelberg (2000)

    Chapter  Google Scholar 

  15. 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)

    Google Scholar 

  16. Jones, S.P., Launchbury, J.: State in Haskell. Lisp and Symbolic Computation 8(4), 293–341 (1995)

    Article  Google Scholar 

  17. 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)

    Chapter  Google Scholar 

  18. 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)

    Google Scholar 

  19. Wadler, P.: Deforestation. In: Ganzinger, H. (ed.) ESOP 1988. LNCS, vol. 300. Springer, Heidelberg (1988)

    Google Scholar 

Download references

Author information

Authors and Affiliations


Editor information

Editors and Affiliations

Rights and permissions

Reprints 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.

Download citation

  • DOI:

  • Publisher Name: Springer, Berlin, Heidelberg

  • Print ISBN: 978-3-540-40132-2

  • Online ISBN: 978-3-540-44833-4

  • eBook Packages: Springer Book Archive

Publish with us

Policies and ethics