Skip to main content

Dead Code Elimination through Dependent Types

  • Conference paper
  • First Online:
Practical Aspects of Declarative Languages (PADL 1999)

Part of the book series: Lecture Notes in Computer Science ((LNCS,volume 1551))

Included in the following conference series:

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.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 39.99
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 54.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. Alfred V. Aho, Ravi Sethi, and Jeffrey D. Ullman. Compilers. Addison-Wesley, Reading, Massachusetts, 1986.

    Google Scholar 

  2. Rowan Davies. Practical refinement-type checking. Thesis Proposal, November 1997.

    Google Scholar 

  3. 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.

    Google Scholar 

  4. 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.

    Google Scholar 

  5. F. Gecseg and M Steinb. Tree automata. Akademiai Kiado, 1991.

    Google Scholar 

  6. 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.

    Google Scholar 

  7. John Hughes. Compile-time analysis of functional programs. In D. Turner, editor, Research Topics in Functional Programming, pages 117–153. Addison-Wesley, 1990.

    Google Scholar 

  8. 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.

    Google Scholar 

  9. Gilles Kahn. Natural semantics. In Proceedings of the Symposium on Theoretical Aspects of Computer Science, pages 22–39. Springer-Verlag LNCS 247, 1987.

    Google Scholar 

  10. 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.

    Google Scholar 

  11. 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.

  12. Robin Milner, Mads Tofte, Robert W. Harper, and D. MacQueen. The Definition of Standard ML. MIT Press, Cambridge,Massachusetts, 1997.

    Google Scholar 

  13. Heintze Nevin. Set-based Program Analysis of ML programs. Ph. D dissertation, Carnegie Mellon University, 1992.

    Google Scholar 

  14. F. Tip. A survey of program slicing. Journal of Programming Languages, 3(3):121–189, 1995.

    Google Scholar 

  15. 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.

    Google Scholar 

  16. Pierre Weis and Xavier Leroy. Le langage Caml. InterEditions, Paris, 1993.

    Google Scholar 

  17. 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.

    Google Scholar 

  18. H. Xi and F. Pfenning. Dependent types in practical programming. In Proceedings of ACM SIGPLAN Symposium on Principles of Programming Languages, January 1999.

    Google Scholar 

  19. Hongwei Xi. Some examples of DML programming. Available at http://www.cs.cmu.edu/~hwxi/DML/examples/, November 1997.

  20. 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.

  21. 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.

    Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Editor information

Editors and Affiliations

Rights and permissions

Reprints 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

Publish with us

Policies and ethics