A Binding Scope Analysis for Generic Programs on Arrays

  • Clemens Grelck
  • Sven-Bodo Scholz
  • Alex Shafarenko
Part of the Lecture Notes in Computer Science book series (LNCS, volume 4015)


Performance of generic array programs crucially relies on program specialisation wrt. shape information. Traditionally, this is done in a rather ad hoc fashion by propagating all shape information that is available. When striving for a compositional programming style that adheres to good software engineering principles this approach turns out to be insufficient. Instead, static value information needs to be propagated as well which introduces all the well known problems of partial evaluation in general.

In this paper, we propose a static analysis that identifies to what extent specialisation needs to be employed in order to achieve a certain level of shape information. This narrows the scope of specialisation far enough to make specialisation for shape information feasible despite a compositional programming style. Some examples to this effect are presented.


Propagation Vector Generic Program Partial Evaluation Shape Information Inference Algorithm 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. [Ali05]
    Alimarine, A.: Generic Functional Programming. PhD thesis, Radboud University of Nijmegen, Netherlands (2005)Google Scholar
  2. [AS04]
    Alimarine, A., Smetsers, S.: Optimizing generic functions. In: Kozen, D. (ed.) MPC 2004. LNCS, vol. 3125, pp. 16–31. Springer, Heidelberg (2004)CrossRefGoogle Scholar
  3. [Can89]
    Cann, D.C.: Compilation Techniques for High Performance Applicative Computation. Technical Report CS-89-108, Lawrence Livermore National Laboratory, LLNL, Livermore California (1989)Google Scholar
  4. [CHJ+01]
    Clarke, D., Hinze, R., Jeuring, J., Löh, A., de Witt, J.: The Generic Haskell User’s Guide (2001)Google Scholar
  5. [GS99]
    Grelck, C., Scholz, S.B.: Accelerating APL Programs with SAC. SIGAPL Quote Quad 29(2), 50–58 (1999)CrossRefGoogle Scholar
  6. [GT04]
    Grelck, C., Trojahner, K.: Implicit Memory Management for SaC. In: Grelck, C., Huch, F., Michaelson, G.J., Trinder, P. (eds.) IFL 2004. LNCS, vol. 3474, pp. 335–348. Springer, Heidelberg (2005)CrossRefGoogle Scholar
  7. [HP00]
    Hinze, R., Peyton Jones, S.: Derivable type classes. In: Hutton, G. (ed.) Proceedings of the 4th Haskell Workshop (2000)Google Scholar
  8. [Hui95]
    Hui, R.: Rank and Uniformity. APL Quote Quad 25(4), 83–90 (1995)CrossRefMathSciNetGoogle Scholar
  9. [JGS93]
    Jones, N.D., Gomard, C.K., Sestoft, P.: Partial Evaluation and Automatic Program Generation. Prentice-Hall, Englewood Cliffs (1993)MATHGoogle Scholar
  10. [JMB98]
    Jay, C.B., Moggi, E., Bellè, G.: Functors, Types and Shapes. In: Backhouse, R., Sheard, T. (eds.) Workshop on Generic Programming: Marstrand, Sweden, Chalmers University of Technology, June 18, 1998, pp. 21–24 (1998)Google Scholar
  11. [Jon96]
    Jones, N.D.: An Introduction to Partial Evaluation. ACM Computing Surveys 28(3) (1996)Google Scholar
  12. [JS98]
    Jay, C.B., Steckler, P.A.: The functional imperative: Shape! In: Hankin, C. (ed.) ESOP 1998. LNCS, vol. 1381, pp. 139–153. Springer, Heidelberg (1998)CrossRefGoogle Scholar
  13. [Kre03]
    Kreye, D.J.: A Compiler Backend for Generic Programming with Arrays. PhD thesis, Institut für Informatik und Praktische Mathematik, Universität Kiel (2003)Google Scholar
  14. [LLS98]
    Lewis, E.C., Lin, C., Snyder, L.: The Implementation and Evaluation of Fusion and Contraction in Array Languages. In: Proceedings of the ACM SIGPLAN 1998 Conference on Programming Language Design and Implementation. ACM, New York (1998)Google Scholar
  15. [Pie02]
    Pierce, B.C.: Types and Programming Languages. MIT Press, Cambridge (2002)Google Scholar
  16. [Sch03]
    Scholz, S.-B.: Single Assignment C — efficient support for high-level array operations in a functional setting. Journal of Functional Programming 13(6), 1005–1059 (2003)MATHCrossRefMathSciNetGoogle Scholar
  17. [Vel98]
    Veldhuizen, T.L.: Arrays in blitz++. In: Caromel, D., Oldehoeft, R.R., Tholburn, M. (eds.) ISCOPE 1998. LNCS, vol. 1505, pp. 223–230. Springer, Heidelberg (1998)CrossRefGoogle Scholar
  18. [Vel99]
    Veldhuizen, T.L.: C++ Templates as Partial Evaluation. In: Danvy, O. (ed.) Proceedings of PEPM 1999, The ACM SIGPLAN Workshop on Partial Evaluation and Semantics-Based Program Manipulation, University of Aarhus, Dept. of Computer Science, pp. 13–18 (1999)Google Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2006

Authors and Affiliations

  • Clemens Grelck
    • 1
  • Sven-Bodo Scholz
    • 2
  • Alex Shafarenko
    • 2
  1. 1.Inst. of Software Technology and Programming LanguagesUniversity of LübeckGermany
  2. 2.Dept of Computer ScienceUniversity of HertfordshireUnited Kingdom

Personalised recommendations