skip to main content
research-article

Feat: functional enumeration of algebraic types

Authors Info & Claims
Published:13 September 2012Publication History
Skip Abstract Section

Abstract

In mathematics, an enumeration of a set S is a bijective function from (an initial segment of) the natural numbers to S. We define "functional enumerations" as efficiently computable such bijections. This paper describes a theory of functional enumeration and provides an algebra of enumerations closed under sums, products, guarded recursion and bijections. We partition each enumerated set into numbered, finite subsets.

We provide a generic enumeration such that the number of each part corresponds to the size of its values (measured in the number of constructors). We implement our ideas in a Haskell library called testing-feat, and make the source code freely available. Feat provides efficient "random access" to enumerated values. The primary application is property-based testing, where it is used to define both random sampling (for example QuickCheck generators) and exhaustive enumeration (in the style of SmallCheck). We claim that functional enumeration is the best option for automatically generating test cases from large groups of mutually recursive syntax tree types. As a case study we use Feat to test the pretty-printer of the Template Haskell library (uncovering several bugs).

References

  1. J. Christiansen and S. Fischer. Easycheck: test data for free. In FLOPS'08, pages 322--336. Springer, 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. K. Claessen and J. Hughes. QuickCheck: a lightweight tool for random testing of Haskell programs. In ICFP '00, pages 268--279. ACM, 2000. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. P. Duchon, P. Flajolet, G. Louchard, and G. Schaeffer. Boltzmann samplers for the random generation of combinatorial structures. Combinatorics, Probability and Computing, 13 (4--5): 577--625, 2004. 10.1017/S0963548304006315. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. J. Duregård. Agata: Random generation of test data. Master's thesis, Chalmers University of Technology, 2009.Google ScholarGoogle Scholar
  5. J. Duregård and P. Jansson. Embedded parser generators. In Haskell '11, pages 107--117. ACM, 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. P. Flajolet and B. Salvy. Computer algebra libraries for combinatorial structures. J. Symb. Comput., 20 (5/6): 653--671, 1995. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. M. Hanus et al. Curry: An Integrated Functional Logic Language, version 0.8.2 edition, 2006. Available from http://www.informatik.uni-kiel.de/~curry/report.html.Google ScholarGoogle Scholar
  8. M. H. Pałka, K. Claessen, A. Russo, and J. Hughes. Testing an optimising compiler by generating random lambda terms. In AST '11, pages 91--97. ACM, 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. S. Peyton Jones, S. Marlow, and C. Elliot. Stretching the storage manager: weak pointers and stable names in Haskell. In IFL'99, LNCS. Springer, 1999. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. C. Runciman, M. Naylor, and F. Lindblad. Smallcheck and lazy smallcheck: automatic exhaustive testing for small values. In Haskell '08, pages 37--48. ACM, 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. G. J. Uszkay and J. Carette. Available from http://hackage.haskell.org/package/gencheck.Google ScholarGoogle Scholar
  12. J. Wang. Generating random lambda calculus terms. Technical report, Boston University, 2005.Google ScholarGoogle Scholar
  13. A. R. Yakushev and J. Jeuring. Enumerating well-typed terms generically. In AAIP 2009, volume 5812 of LNCS, pages 93--116. Springer, 2009.Google ScholarGoogle Scholar
  14. B. A. Yorgey. Species and functors and types, oh my! In Haskell '10, pages 147--158. ACM, 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Feat: functional enumeration of algebraic types

      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 47, Issue 12
        Haskell '12
        December 2012
        157 pages
        ISSN:0362-1340
        EISSN:1558-1160
        DOI:10.1145/2430532
        Issue’s Table of Contents
        • cover image ACM Conferences
          Haskell '12: Proceedings of the 2012 Haskell Symposium
          September 2012
          168 pages
          ISBN:9781450315746
          DOI:10.1145/2364506

        Copyright © 2012 ACM

        Publisher

        Association for Computing Machinery

        New York, NY, United States

        Publication History

        • Published: 13 September 2012

        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!