Advertisement

Projections for polymorphic strictness analysis

  • John Hughes
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 389)

Abstract

We apply the categorical properties of polymorphic functions to compile-time analysis, specifically projection-based strictness analysis. First we interpret parameterised types as functors in a suitable category, and show that they preserve monics and epics. Then we define “strong” and “weak” polymorphism — the latter admitting certain projections that are not polymorphic in the usual sense. We prove that, under the right conditions, a weakly polymorphic function is characterised by a single instance. It follows that the strictness analysis of one simple instance of a polymorphic function yields results that apply to all. We show how this theory may be applied.

In comparison to earlier polymorphic strictness analysis methods, ours can apply polymorphic information to a particular instance very simply. The categorical approach simplifies our proofs, enabling them to be carried out at a higher level, and making them independent of the precise form of the programming language to be analysed.

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. [Abramsky85]
    S. Abramsky, Strictness Analysis and Polymorphic Invariance, Workshop on Programs as Data Objects, Copenhagen, Springer LNCS 217, 1985.Google Scholar
  2. [Abramsky88]
    S. Abramsky, Notes on Strictness Analysis for Polymorphic Functions, draft paper, 1988.Google Scholar
  3. [AH87]
    S. Abramsky and C. L. Hankin (eds.) Abstract Interpretation of Declarative Languages, Ellis-Horwood, 1987.Google Scholar
  4. [BHA85]
    G. L. Burn, C. L. Hankin, S. Abramsky, The Theory of Strictness Analysis for Higher-order Functions, Workshop on Programs as Data Objects, Copenhagen, Springer LNCS 217, 1985.Google Scholar
  5. [Clack85]
    C. Clack and S. L. Peyton-Jones, Strictness Analysis — a Practical Approach, in IFIP Conference on Functional Programming Languages and Computer Architecture, Nancy, France, Springer LNCS 201, 1985.Google Scholar
  6. [Dybjer87]
    P. Dybjer, Computing Inverse Images, in ICALP 1987.Google Scholar
  7. [Goldberg87]
    B. Goldberg, Detecting Sharing of Partial Applications in Functional Programs, in IFIP Conference on Functional Programming Languages and Computer Architecture, Portland, Oregon, Springer LNCS 274, 1987.Google Scholar
  8. [Hall87]
    C. Hall and D. S. Wise, Compiling Strictness into Streams, in ACM Symposium on Principles of Programming Languages, 1987.Google Scholar
  9. [Hudak86]
    P. Hudak and J. Young, Higher-order Strictness Analysis for Untyped Lambda Calculus, in ACM Symposium on Principles of Programming Languages, 1986.Google Scholar
  10. [Hudak87]
    P. Hudak, Abstract reference counting, in S. Abramsky and C. L. Hankin (eds.) Abstract Interpretation of Declarative Languages, Ellis-Horwood, 1987.Google Scholar
  11. [Hughes85]
    J. Hughes, Strictness Detection in Non-Flat Domains, Workshop on Programs as Data Objects, Copenhagen, Springer Verlag 217, 1985.Google Scholar
  12. [Hughes87a]
    J. Hughes, Analysing Strictness by Abstract Interpretation of Continuations, in S. Abramsky and C. L. Hankin (eds.) Abstract Interpretation of Declarative Languages, Ellis-Horwood, 1987.Google Scholar
  13. [Hughes87b]
    J. Hughes, Backwards Analysis of Functional Programs, IFIP Workshop on Partial Evaluation and Mixed Computation, Bjørner, Ershov and Jones (eds.), North-Holland, 1987.Google Scholar
  14. [Hughes88]
    J. Hughes, Abstract Interpretation of First-order Polymorphic Functions, Proc. Aspenæs Workshop on Graph Reduction, University of Gothenburg, 1988.Google Scholar
  15. [Hughes89]
    J. Hughes, Compile-time Analysis of Functional Languages, Proc. Year of Programming Summer School on Declarative Programming, University of Texas, 1989 (to appear).Google Scholar
  16. [Launchbury87]
    J. Launchbury, Projections for Specialisation, IFIP Workshop on Partial Evaluation and Mixed Computation, Bjørner, Ershov and Jones (eds.), North-Holland, 1987.Google Scholar
  17. [Launchbury89]
    J. Launchbury, Binding Time Aspects of Partial Evaluation, Ph.D. thesis, Glasgow University, in preparation.Google Scholar
  18. [Martin87]
    C. Martin and C. Hankin, Finding Fixed Points in Finite Lattices, IFIP Conference on Functional Programming Languages and Computer Architecture, Portland, Oregon, Springer LNCS 274, 1987.Google Scholar
  19. [Mycroft80]
    A. Mycroft, The Theory and Practice of Transforming Call-by-Need into Call-by-Value, Proc. International Symposium on Programming, Springer LNCS 83, 1980.Google Scholar
  20. [Rydeheard85]
    Tutorial on natural transformations, in Proc. Category Theory and Computer Programming, Springer LNCS 240, 1985.Google Scholar
  21. [Sheeran89]
    M. Sheeran, Categories for the Working Hardware Designer, to appear in Proc. Int. Workshop on Hardware Specification, Verification, and Synthesis: Mathematical Aspects, Cornell, Springer LNCS, 1989.Google Scholar
  22. [Wadler87a]
    P. Wadler and J. Hughes, Projections for Strictness Analysis, IFIP Conference on Functional Programming Languages and Computer Architecture, Portland, Oregon, Springer LNCS 274, 1987.Google Scholar
  23. [Wadler87b]
    P. Wadler, Strictness Analysis on Non-flat Domains (by Abstract Interpretation over Finite Domains), in S. Abramsky and C. L. Hankin (eds.) Abstract Interpretation of Declarative Languages, Ellis-Horwood, 1987.Google Scholar
  24. [Wadler88]
    P. Wadler, Strictness Analysis Aids Time Analysis, in ACM Symposium on Principles of Programming Languages, 1988.Google Scholar
  25. [Wadler89]
    P. Wadler, Theorems for Free!, to appear in IFIP Functional Programming Languages and Computer Architecture, London, Springer LNCS, 1989.Google Scholar
  26. [Wray86]
    S. C. Wray, Implementation and Programming Techniques for Functional Languages, Ph.D. thesis, University of Cambridge, 1986.Google Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 1989

Authors and Affiliations

  • John Hughes
    • 1
  1. 1.Department of Computing ScienceUniversity of GlasgowUK

Personalised recommendations