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.
Supplemental Material
Available for Download
- Stephen Adams. Efficient sets - a balancing act. JFP, 3 (4): 553--561, 1993.Google ScholarCross Ref
- Alex Aiken and Brian Murphy. Static Type Inference in a Dynamically Typed Language. In Proc. POPL '91, pages 279--290. ACM Press, 1991. Google ScholarDigital Library
- John Horton Conway. Regular Algebra and Finite Machines. London Chapman and Hall, 1971.Google Scholar
- Matthew Fluet and Riccardo Pucella. Phantom types and subtyping. In Proc. TCS '02, pages 448--460, Deventer, The Netherlands, 2002. Google ScholarDigital Library
- Dimitry Golubovsky, Neil Mitchell, and Matthew Naylor. Yhc.Core - from Haskell to Core. The Monad.Reader, 1 (7): 45--61, April 2007.Google Scholar
- S. C. Johnson. Lint, a C program checker. Technical Report 65, Bell Laboratories, 1978.Google Scholar
- C. Lee. Representation of switching circuits by binary decision diagrams. Bell System Technical Journal, 38: 985--999, 1959.Google ScholarCross Ref
- 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 ScholarCross Ref
- Luc Maranget. Warnings for pattern matching. JFP, 17 (3): 1--35, May 2007.Google Scholar
- Conor McBride and James McKinna. The view from the left. JFP, 14 (1): 69--111, 2004. Google ScholarDigital Library
- Neil Mitchell. Transformation and Analysis of Functional Programs. PhD thesis, University of York, 2008.Google Scholar
- 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 Scholar
- 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 ScholarDigital Library
- Will Partain et al. The nofib Benchmark Suite of Haskell Programs. http://darcs.haskell.org/nofib/, 2008. Google ScholarDigital Library
- Simon Peyton Jones. Haskell 98 Language and Libraries: The Revised Report. Cambridge University Press, 2003.Google Scholar
- 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 ScholarDigital Library
- John C. Reynolds. Definitional interpreters for higher-order programming languages. In Proc. ACM '72, pages 717--740. ACM Press, 1972. Google ScholarDigital Library
- David Roundy. Darcs: distributed version management in Haskell. In Proc. Haskell '05, pages 1--4. ACM Press, 2005. Google ScholarDigital Library
- Tim Sheard. Languages of the future. In Proc. OOPSLA '04, pages 116--119. ACM Press, 2004. Google ScholarDigital Library
- Don Stewart and Spencer Sjanssen. XMonad. In Proc. Haskell '07, pages 119--119. ACM Press, 2007. Google ScholarDigital Library
- The GHC Team. The GHC compiler, version 6.8.2. http://www.haskell.org/ghc/, December 2007.Google Scholar
- Andrew Tolmach. An External Representation for the GHC Core Language. http://www.haskell.org/ghc/docs/papers/core.ps.gz, September 2001.Google Scholar
- Akihiko Tozawa. Towards Static Type Checking for XSLT. In Proc. DocEng '01, pages 18--27. ACM Press, 2001. Google ScholarDigital Library
- David Turner. Total Functional Programming. Journal of Universal Computer Science, 10 (7): 751--768, July 2004.Google Scholar
- Robert Virding, Claes Wikstrom, and Mike Williams. Concurrent programming in ERLANG. Prentice Hall, second edition, 1996. Google ScholarDigital Library
- Hongwei Xi and Frank Pfenning. Dependent types in practical programming. In Proc. POPL '99, pages 214--227. ACM Press, 1999. Google ScholarDigital Library
- Dana N. Xu. Extended static checking for Haskell. In Proc. Haskell '06, pages 48--59. ACM Press, 2006. Google ScholarDigital Library
- Dana N. Xu, Simon Peyton Jones, and Koen Claessen. Static contract checking for Haskell. In Proc. IFL 2007, pages 382--399, 2007.Google Scholar
Index Terms
Not all patterns, but enough: an automatic verifier for partial but sufficient pattern matching
Recommendations
Not all patterns, but enough: an automatic verifier for partial but sufficient pattern matching
HASKELL '08We 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 ...
Strength Induction in a Haskell Program Verifier
Haskell employs a melange of strict and non-strict evaluation semantics, hence a Haskell verifier should be capable of checking assumptions that program variables may or may not denote well-defined values. The paper introduces a new strategy, called ...
Layout-sensitive language extensibility with SugarHaskell
Haskell '12: Proceedings of the 2012 Haskell SymposiumProgrammers need convenient syntax to write elegant and concise programs. Consequently, the Haskell standard provides syntactic sugar for some scenarios (e.g., do notation for monadic code), authors of Haskell compilers provide syntactic sugar for more ...
Comments