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.
References
S. Abramsky, Strictness Analysis and Polymorphic Invariance, Workshop on Programs as Data Objects, Copenhagen, Springer LNCS 217, 1985.
S. Abramsky, Notes on Strictness Analysis for Polymorphic Functions, draft paper, 1988.
S. Abramsky and C. L. Hankin (eds.) Abstract Interpretation of Declarative Languages, Ellis-Horwood, 1987.
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.
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.
P. Dybjer, Computing Inverse Images, in ICALP 1987.
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.
C. Hall and D. S. Wise, Compiling Strictness into Streams, in ACM Symposium on Principles of Programming Languages, 1987.
P. Hudak and J. Young, Higher-order Strictness Analysis for Untyped Lambda Calculus, in ACM Symposium on Principles of Programming Languages, 1986.
P. Hudak, Abstract reference counting, in S. Abramsky and C. L. Hankin (eds.) Abstract Interpretation of Declarative Languages, Ellis-Horwood, 1987.
J. Hughes, Strictness Detection in Non-Flat Domains, Workshop on Programs as Data Objects, Copenhagen, Springer Verlag 217, 1985.
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.
J. Hughes, Backwards Analysis of Functional Programs, IFIP Workshop on Partial Evaluation and Mixed Computation, Bjørner, Ershov and Jones (eds.), North-Holland, 1987.
J. Hughes, Abstract Interpretation of First-order Polymorphic Functions, Proc. Aspenæs Workshop on Graph Reduction, University of Gothenburg, 1988.
J. Hughes, Compile-time Analysis of Functional Languages, Proc. Year of Programming Summer School on Declarative Programming, University of Texas, 1989 (to appear).
J. Launchbury, Projections for Specialisation, IFIP Workshop on Partial Evaluation and Mixed Computation, Bjørner, Ershov and Jones (eds.), North-Holland, 1987.
J. Launchbury, Binding Time Aspects of Partial Evaluation, Ph.D. thesis, Glasgow University, in preparation.
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.
A. Mycroft, The Theory and Practice of Transforming Call-by-Need into Call-by-Value, Proc. International Symposium on Programming, Springer LNCS 83, 1980.
Tutorial on natural transformations, in Proc. Category Theory and Computer Programming, Springer LNCS 240, 1985.
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.
P. Wadler and J. Hughes, Projections for Strictness Analysis, IFIP Conference on Functional Programming Languages and Computer Architecture, Portland, Oregon, Springer LNCS 274, 1987.
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.
P. Wadler, Strictness Analysis Aids Time Analysis, in ACM Symposium on Principles of Programming Languages, 1988.
P. Wadler, Theorems for Free!, to appear in IFIP Functional Programming Languages and Computer Architecture, London, Springer LNCS, 1989.
S. C. Wray, Implementation and Programming Techniques for Functional Languages, Ph.D. thesis, University of Cambridge, 1986.
Author information
Authors and Affiliations
Editor information
Rights and permissions
Copyright information
© 1989 Springer-Verlag Berlin Heidelberg
About this paper
Cite this paper
Hughes, J. (1989). Projections for polymorphic strictness analysis. In: Pitt, D.H., Rydeheard, D.E., Dybjer, P., Pitts, A.M., Poigné, A. (eds) Category Theory and Computer Science. Lecture Notes in Computer Science, vol 389. Springer, Berlin, Heidelberg. https://doi.org/10.1007/BFb0018346
Download citation
DOI: https://doi.org/10.1007/BFb0018346
Published:
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-540-51662-0
Online ISBN: 978-3-540-46740-3
eBook Packages: Springer Book Archive