skip to main content
research-article

Not all patterns, but enough: an automatic verifier for partial but sufficient pattern matching

Published:25 September 2008Publication History
Skip Abstract Section

Abstract

We describe an automated analysis of Haskell 98 programs to check statically that, despite the possible use of partial (or non-exhaustive) pattern matching, no pattern-match failure can occur. Our method is an iterative backward analysis using a novel form of pattern-constraint to represent sets of data values. The analysis is defined for a core first-order language to which Haskell 98 programs are reduced. Our analysis tool has been successfully applied to a range of programs, and our techniques seem to scale well. Throughout the paper, methods are represented much as we have implemented them in practice, again in Haskell.

Skip Supplemental Material Section

Supplemental Material

Video

References

  1. Stephen Adams. Efficient sets - a balancing act. JFP, 3 (4): 553--561, 1993.Google ScholarGoogle ScholarCross RefCross Ref
  2. Alex Aiken and Brian Murphy. Static Type Inference in a Dynamically Typed Language. In Proc. POPL '91, pages 279--290. ACM Press, 1991. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. John Horton Conway. Regular Algebra and Finite Machines. London Chapman and Hall, 1971.Google ScholarGoogle Scholar
  4. Matthew Fluet and Riccardo Pucella. Phantom types and subtyping. In Proc. TCS '02, pages 448--460, Deventer, The Netherlands, 2002. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. Dimitry Golubovsky, Neil Mitchell, and Matthew Naylor. Yhc.Core - from Haskell to Core. The Monad.Reader, 1 (7): 45--61, April 2007.Google ScholarGoogle Scholar
  6. S. C. Johnson. Lint, a C program checker. Technical Report 65, Bell Laboratories, 1978.Google ScholarGoogle Scholar
  7. C. Lee. Representation of switching circuits by binary decision diagrams. Bell System Technical Journal, 38: 985--999, 1959.Google ScholarGoogle ScholarCross RefCross Ref
  8. Tobias Lindahl and Konstantinos Sagonas. Detecting software defects in telecom applications through lightweight static analysis: A war story. In Proc. APLAS '04, LNCS 3302, pages 91--106. Springer, November 2004.Google ScholarGoogle ScholarCross RefCross Ref
  9. Luc Maranget. Warnings for pattern matching. JFP, 17 (3): 1--35, May 2007.Google ScholarGoogle Scholar
  10. Conor McBride and James McKinna. The view from the left. JFP, 14 (1): 69--111, 2004. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. Neil Mitchell. Transformation and Analysis of Functional Programs. PhD thesis, University of York, 2008.Google ScholarGoogle Scholar
  12. Neil Mitchell and Colin Runciman. A static checker for safe pattern matching in Haskell. In Trends in Functional Programming (2005 Symposium), volume 6, pages 15--30. Intellect, 2007.Google ScholarGoogle Scholar
  13. Matthew Naylor and Colin Runciman. Finding inputs that reach a target expression. In Proc. SCAM '07, pages 133--142. IEEE Computer Society, September 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. Will Partain et al. The nofib Benchmark Suite of Haskell Programs. http://darcs.haskell.org/nofib/, 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. Simon Peyton Jones. Haskell 98 Language and Libraries: The Revised Report. Cambridge University Press, 2003.Google ScholarGoogle Scholar
  16. Simon Peyton Jones, Dimitrios Vytiniotis, Stephanie Weirich, and Geoffrey Washburn. Simple unification-based type inference for GADTs. In Proc. ICFP '06, pages 50--61. ACM Press, 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. John C. Reynolds. Definitional interpreters for higher-order programming languages. In Proc. ACM '72, pages 717--740. ACM Press, 1972. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. David Roundy. Darcs: distributed version management in Haskell. In Proc. Haskell '05, pages 1--4. ACM Press, 2005. Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. Tim Sheard. Languages of the future. In Proc. OOPSLA '04, pages 116--119. ACM Press, 2004. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. Don Stewart and Spencer Sjanssen. XMonad. In Proc. Haskell '07, pages 119--119. ACM Press, 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. The GHC Team. The GHC compiler, version 6.8.2. http://www.haskell.org/ghc/, December 2007.Google ScholarGoogle Scholar
  22. Andrew Tolmach. An External Representation for the GHC Core Language. http://www.haskell.org/ghc/docs/papers/core.ps.gz, September 2001.Google ScholarGoogle Scholar
  23. Akihiko Tozawa. Towards Static Type Checking for XSLT. In Proc. DocEng '01, pages 18--27. ACM Press, 2001. Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. David Turner. Total Functional Programming. Journal of Universal Computer Science, 10 (7): 751--768, July 2004.Google ScholarGoogle Scholar
  25. Robert Virding, Claes Wikstrom, and Mike Williams. Concurrent programming in ERLANG. Prentice Hall, second edition, 1996. Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. Hongwei Xi and Frank Pfenning. Dependent types in practical programming. In Proc. POPL '99, pages 214--227. ACM Press, 1999. Google ScholarGoogle ScholarDigital LibraryDigital Library
  27. Dana N. Xu. Extended static checking for Haskell. In Proc. Haskell '06, pages 48--59. ACM Press, 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  28. Dana N. Xu, Simon Peyton Jones, and Koen Claessen. Static contract checking for Haskell. In Proc. IFL 2007, pages 382--399, 2007.Google ScholarGoogle Scholar

Index Terms

  1. Not all patterns, but enough: an automatic verifier for partial but sufficient pattern matching

    Recommendations

    Comments

    Login options

    Check if you have access through your login credentials or your institution to get full access on this article.

    Sign in

    Full Access

    • Published in

      cover image ACM SIGPLAN Notices
      ACM SIGPLAN Notices  Volume 44, Issue 2
      HASKELL '08
      February 2009
      126 pages
      ISSN:0362-1340
      EISSN:1558-1160
      DOI:10.1145/1543134
      Issue’s Table of Contents
      • cover image ACM Conferences
        Haskell '08: Proceedings of the first ACM SIGPLAN symposium on Haskell
        September 2008
        134 pages
        ISBN:9781605580647
        DOI:10.1145/1411286
        • Program Chair:
        • Andy Gill

      Copyright © 2008 ACM

      Publisher

      Association for Computing Machinery

      New York, NY, United States

      Publication History

      • Published: 25 September 2008

      Check for updates

      Qualifiers

      • research-article

    PDF Format

    View or Download as a PDF file.

    PDF

    eReader

    View online with eReader.

    eReader
    About Cookies On This Site

    We use cookies to ensure that we give you the best experience on our website.

    Learn more

    Got it!