Abstract
Generic programming is accepted by the functional programming community as a valuable tool for program development. Several functional languages have adopted the generic scheme of type-indexed values. This scheme works by specialization of a generic function to a concrete type. However, the generated code is extremely inefficient compared to its hand-written counterpart. The performance penalty is so big that the practical usefulness of generic programming is compromised. In this paper we present an optimization algorithm that is able to completely eliminate the overhead introduced by the specialization scheme for a large class of generic functions. The presented technique is based on consumer–producer elimination as exploited by fusion, a standard general purpose optimization method. We show that our algorithm is able to optimize many practical examples of generic functions.
Preview
Unable to display preview. Download preview PDF.
Similar content being viewed by others
References
Alimarine, A., Smetsers, S.: Fusing generic functions. Technical report NIII-R0434, University of Nijmegen (September 2004)
Alimarine, A., Smetsers, S.: Optimizing generic functions. In: Kozen, D. (ed.) MPC 2004. LNCS, vol. 3125, pp. 16–31. Springer, Heidelberg (2004)
van Arkel, D., van Groningen, J., Smetsers, S.: Fusion in practice. In: Peña, R., Arts, T. (eds.) IFL 2002. LNCS, vol. 2670, pp. 51–67. Springer, Heidelberg (2003)
Chin, W.-N.: Safe fusion of functional expressions II: further improvements. Journal of Functional Programming 4(4), 515–555 (1994)
Chin, W.-N., Khoo, S.-C.: Better consumers for program specializations. Journal of Functional and Logic Programming (4) (November 1996)
Hinze, R.: Generic programs and proofs. Habilitationsschrift, Universitat Bonn (October 2000)
Hinze, R., Jones, S.P.: Derivable type classes. In Hutton, G. (ed.): In: Proceedings of the 2000 ACM SIGPLAN Haskell Workshop. Electronic Notes in Theoretical Computer Science, vol. 41.1. Elsevier Science, Amsterdam (2001); The preliminary proceedings appeared as a University of Nottingham technical report
Jansson, P., Jeuring, J.: Polyp - a polytypic programming language extension. In: The 24th ACM Symposium on Principles of Programming Languages, POPL 1997, pp. 470–482. ACM Press, New York (1997)
Wadler, P.: Deforestation: transforming programs to eliminate trees. In: Ganzinger, H. (ed.) ESOP 1988. LNCS, vol. 300, pp. 344–358. Springer, Heidelberg (1988)
Author information
Authors and Affiliations
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2005 Springer-Verlag Berlin Heidelberg
About this paper
Cite this paper
Alimarine, A., Smetsers, S. (2005). Improved Fusion for Optimizing Generics. In: Hermenegildo, M.V., Cabeza, D. (eds) Practical Aspects of Declarative Languages. PADL 2005. Lecture Notes in Computer Science, vol 3350. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-540-30557-6_16
Download citation
DOI: https://doi.org/10.1007/978-3-540-30557-6_16
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-540-24362-5
Online ISBN: 978-3-540-30557-6
eBook Packages: Computer ScienceComputer Science (R0)