skip to main content
10.1145/1411286.1411293acmconferencesArticle/Chapter ViewAbstractPublication PagesicfpConference Proceedingsconference-collections
research-article

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

Published: 25 September 2008 Publication History

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.

Supplementary Material

JPG File (1411293.jpg)
index.html (index.html)
Slides from the presentation
Audio only (1411293.mp3)
Video (1411293.mp4)

References

[1]
Stephen Adams. Efficient sets - a balancing act. JFP, 3 (4): 553--561, 1993.
[2]
Alex Aiken and Brian Murphy. Static Type Inference in a Dynamically Typed Language. In Proc. POPL '91, pages 279--290. ACM Press, 1991.
[3]
John Horton Conway. Regular Algebra and Finite Machines. London Chapman and Hall, 1971.
[4]
Matthew Fluet and Riccardo Pucella. Phantom types and subtyping. In Proc. TCS '02, pages 448--460, Deventer, The Netherlands, 2002.
[5]
Dimitry Golubovsky, Neil Mitchell, and Matthew Naylor. Yhc.Core - from Haskell to Core. The Monad.Reader, 1 (7): 45--61, April 2007.
[6]
S. C. Johnson. Lint, a C program checker. Technical Report 65, Bell Laboratories, 1978.
[7]
C. Lee. Representation of switching circuits by binary decision diagrams. Bell System Technical Journal, 38: 985--999, 1959.
[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.
[9]
Luc Maranget. Warnings for pattern matching. JFP, 17 (3): 1--35, May 2007.
[10]
Conor McBride and James McKinna. The view from the left. JFP, 14 (1): 69--111, 2004.
[11]
Neil Mitchell. Transformation and Analysis of Functional Programs. PhD thesis, University of York, 2008.
[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.
[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.
[14]
Will Partain et al. The nofib Benchmark Suite of Haskell Programs. http://darcs.haskell.org/nofib/, 2008.
[15]
Simon Peyton Jones. Haskell 98 Language and Libraries: The Revised Report. Cambridge University Press, 2003.
[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.
[17]
John C. Reynolds. Definitional interpreters for higher-order programming languages. In Proc. ACM '72, pages 717--740. ACM Press, 1972.
[18]
David Roundy. Darcs: distributed version management in Haskell. In Proc. Haskell '05, pages 1--4. ACM Press, 2005.
[19]
Tim Sheard. Languages of the future. In Proc. OOPSLA '04, pages 116--119. ACM Press, 2004.
[20]
Don Stewart and Spencer Sjanssen. XMonad. In Proc. Haskell '07, pages 119--119. ACM Press, 2007.
[21]
The GHC Team. The GHC compiler, version 6.8.2. http://www.haskell.org/ghc/, December 2007.
[22]
Andrew Tolmach. An External Representation for the GHC Core Language. http://www.haskell.org/ghc/docs/papers/core.ps.gz, September 2001.
[23]
Akihiko Tozawa. Towards Static Type Checking for XSLT. In Proc. DocEng '01, pages 18--27. ACM Press, 2001.
[24]
David Turner. Total Functional Programming. Journal of Universal Computer Science, 10 (7): 751--768, July 2004.
[25]
Robert Virding, Claes Wikstrom, and Mike Williams. Concurrent programming in ERLANG. Prentice Hall, second edition, 1996.
[26]
Hongwei Xi and Frank Pfenning. Dependent types in practical programming. In Proc. POPL '99, pages 214--227. ACM Press, 1999.
[27]
Dana N. Xu. Extended static checking for Haskell. In Proc. Haskell '06, pages 48--59. ACM Press, 2006.
[28]
Dana N. Xu, Simon Peyton Jones, and Koen Claessen. Static contract checking for Haskell. In Proc. IFL 2007, pages 382--399, 2007.

Cited By

View all

Index Terms

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

    Recommendations

    Comments

    Information & Contributors

    Information

    Published In

    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
    • 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
    Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]

    Sponsors

    Publisher

    Association for Computing Machinery

    New York, NY, United States

    Publication History

    Published: 25 September 2008

    Permissions

    Request permissions for this article.

    Check for updates

    Author Tags

    1. automatic verification
    2. functional programming
    3. haskell
    4. pattern-match errors
    5. preconditions

    Qualifiers

    • Research-article

    Conference

    ICFP08
    Sponsor:

    Acceptance Rates

    Haskell '08 Paper Acceptance Rate 13 of 28 submissions, 46%;
    Overall Acceptance Rate 57 of 143 submissions, 40%

    Upcoming Conference

    ICFP '25
    ACM SIGPLAN International Conference on Functional Programming
    October 12 - 18, 2025
    Singapore , Singapore

    Contributors

    Other Metrics

    Bibliometrics & Citations

    Bibliometrics

    Article Metrics

    • Downloads (Last 12 months)3
    • Downloads (Last 6 weeks)1
    Reflects downloads up to 05 Mar 2025

    Other Metrics

    Citations

    Cited By

    View all
    • (2024)Haskelite: A Tracing Interpreter Based on a Pattern-Matching CalculusProceedings of the 17th ACM SIGPLAN International Haskell Symposium10.1145/3677999.3678274(1-13)Online publication date: 29-Aug-2024
    • (2024)Hybrid Verification of Declarative Programs with Arithmetic Non-fail ConditionsProgramming Languages and Systems10.1007/978-981-97-8943-6_6(109-129)Online publication date: 23-Oct-2024
    • (2024)Inferring Non-failure Conditions for Declarative ProgramsFunctional and Logic Programming10.1007/978-981-97-2300-3_10(167-187)Online publication date: 15-May-2024
    • (2021)Intensional datatype refinement: with application to scalable verification of pattern-match safetyProceedings of the ACM on Programming Languages10.1145/34343365:POPL(1-29)Online publication date: 4-Jan-2021
    • (2019)Lazy counterfactual symbolic executionProceedings of the 40th ACM SIGPLAN Conference on Programming Language Design and Implementation10.1145/3314221.3314618(411-424)Online publication date: 8-Jun-2019
    • (2018)Verifying Fail-Free Declarative ProgramsProceedings of the 20th International Symposium on Principles and Practice of Declarative Programming10.1145/3236950.3236957(1-13)Online publication date: 3-Sep-2018
    • (2015)GADTs meet their match: pattern-matching warnings that account for GADTs, guards, and lazinessACM SIGPLAN Notices10.1145/2858949.278474850:9(424-436)Online publication date: 29-Aug-2015
    • (2015)GADTs meet their match: pattern-matching warnings that account for GADTs, guards, and lazinessProceedings of the 20th ACM SIGPLAN International Conference on Functional Programming10.1145/2784731.2784748(424-436)Online publication date: 29-Aug-2015
    • (2015)Type-based Exception Analysis for Non-strict Higher-order Functional Languages with Imprecise Exception SemanticsProceedings of the 2015 Workshop on Partial Evaluation and Program Manipulation10.1145/2678015.2682542(127-138)Online publication date: 13-Jan-2015
    • (2014)LiquidHaskellACM SIGPLAN Notices10.1145/2775050.263336649:12(39-51)Online publication date: 3-Sep-2014
    • Show More Cited By

    View Options

    Login options

    View options

    PDF

    View or Download as a PDF file.

    PDF

    eReader

    View online with eReader.

    eReader

    Figures

    Tables

    Media

    Share

    Share

    Share this Publication link

    Share on social media