Abstract
Pattern matching is an important feature in various functional programming languages such as SML, Caml, Haskell, etc. In these languages, unreachable or redundant matching clauses, which can be regarded as a special form of dead code, are a rich source for program errors. Therefore, eliminating unreachable matching clauses at compiletime can significantly enhance program error detection. Furthermore, this can also lead to significantly more efficient code at run-time.
We present a novel approach to eliminating unreachable matching clauses through the use of the dependent type system of DML, a functional programming language that enriches ML with a restricted form of dependent types. We then prove the correctness of the approach, which consists of the major technical contribution of the paper. In addition, we demonstrate the applicability of our approach to dead code elimination through some realistic examples. This constitutes a practical application of dependent types to functional programming, and in return it provides us with further support for the methodology adopted in our research on dependent types in practical programming.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Preview
Unable to display preview. Download preview PDF.
References
Alfred V. Aho, Ravi Sethi, and Jeffrey D. Ullman. Compilers. Addison-Wesley, Reading, Massachusetts, 1986.
Rowan Davies. Practical refinement-type checking. Thesis Proposal, November 1997.
Manuel Fähndrich and Alexander Aiken. Program analysis using mixed term and set constraints. In Proceedings of the 4th International Static Analysis Symposium, September 1997.
Tim Freeman and Frank Pfenning. Refinement types for ML. In ACM SIGPLAN Conference on Programming Language Design and Implementation, pages 268–277, Toronto, Ontario, 1991.
F. Gecseg and M Steinb. Tree automata. Akademiai Kiado, 1991.
Paul Hudak, S. L. Peyton Jones, and Philip Wadler. Report on the programming language Haskell, a non-strict purely-functional programming language, Version 1.2. SIGPLAN Notices, 27(5), May 1992.
John Hughes. Compile-time analysis of functional programs. In D. Turner, editor, Research Topics in Functional Programming, pages 117–153. Addison-Wesley, 1990.
N. Jones and S. Muchnick. Flow analysis and optimization of lisp-like structures. In Conference Record of 6th ACM SIGPLAN Symposium on Principles of Programming Languages, pages 244–256, January 1979.
Gilles Kahn. Natural semantics. In Proceedings of the Symposium on Theoretical Aspects of Computer Science, pages 22–39. Springer-Verlag LNCS 247, 1987.
J. Knoop, O. Rüthing, and B. Steffen. Partial dead code elimination. In Proceedings of the ACM SIGPLAN Conference on Programming Language Implementation and Design, pages 147–158, June 1994.
Y. Liu and D. Stoller. Dead code elimination using program-based regular tree grammars. Available at ftp://ftp.cs.indiana.edu/pub/liu/ElimDeadRec-TR97.ps.Z.
Robin Milner, Mads Tofte, Robert W. Harper, and D. MacQueen. The Definition of Standard ML. MIT Press, Cambridge,Massachusetts, 1997.
Heintze Nevin. Set-based Program Analysis of ML programs. Ph. D dissertation, Carnegie Mellon University, 1992.
F. Tip. A survey of program slicing. Journal of Programming Languages, 3(3):121–189, 1995.
P. Wadler and J. Hughes. Projections for strictness analysis. In Proceedings of the 3rd International Conference on Functional Programming and Computer Architecture, volume 274 of Lecture Notes in Computer Science, pages 385–407. Springer-Verlag, 1987.
Pierre Weis and Xavier Leroy. Le langage Caml. InterEditions, Paris, 1993.
H. Xi and F. Pfenning. Eliminating array bound checking through dependent types. In Proceedings of ACM SIGPLAN Conference on Programming Language Design and Implementation, pages 249–257, June 1998.
H. Xi and F. Pfenning. Dependent types in practical programming. In Proceedings of ACM SIGPLAN Symposium on Principles of Programming Languages, January 1999.
Hongwei Xi. Some examples of DML programming. Available at http://www.cs.cmu.edu/~hwxi/DML/examples/, November 1997.
Hongwei Xi. Dependent Types in Practical Programming. PhD thesis, Carnegie Mellon University, 1998. pp. viii+189. Forthcoming. The current version is available as http://www.cs.cmu.edu/~hwxi/DML/thesis.ps.
K. Yi and S. Ryu. Towards a cost-effective estimation of uncaught exceptions in standard ml programs. In Proceedings of the 4th International Static Analysis Symposium, September 1997.
Author information
Authors and Affiliations
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 1998 Springer-Verlag Berlin Heidelberg
About this paper
Cite this paper
Xi, H. (1998). Dead Code Elimination through Dependent Types. In: Gupta, G. (eds) Practical Aspects of Declarative Languages. PADL 1999. Lecture Notes in Computer Science, vol 1551. Springer, Berlin, Heidelberg. https://doi.org/10.1007/3-540-49201-1_16
Download citation
DOI: https://doi.org/10.1007/3-540-49201-1_16
Published:
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-540-65527-5
Online ISBN: 978-3-540-49201-6
eBook Packages: Springer Book Archive