skip to main content
research-article
Open Access
Artifacts Available
Artifacts Evaluated & Functional

Keep your laziness in check

Published:30 July 2018Publication History
Related Artifact: StrictCheck software https://doi.org/10.1145/3235039
Skip Abstract Section

Abstract

We introduce StrictCheck: a property-based random testing framework for observing, specifying, and testing the strictness of Haskell functions. Strictness is traditionally considered a non-functional property; StrictCheck allows it to be tested as if it were one, by reifying demands on data structures so they can be manipulated and examined within Haskell.

Testing strictness requires us to 1) precisely specify the strictness of functions, 2) efficiently observe the evaluation of data structures, and 3) correctly generate functions with random strictness. We tackle all three of these challenges, designing an efficient generic framework for precise dynamic strictness testing. StrictCheck can specify and test the strictness of any Haskell function---including higher-order ones---with only a constant factor of overhead, and requires no boilerplate for testing functions on Haskell-standard algebraic data types. We provide an expressive but low-level specification language as a foundation upon which to build future higher-level abstractions.

We demonstrate a non-trivial application of our library, developing a correct specification of a data structure whose properties intrinsically rely on subtle use of laziness: Okasaki's constant-time purely functional queue.

Skip Supplemental Material Section

Supplemental Material

a102-foner.webm

References

  1. Andreas Abel, Brigitte Pientka, David Thibodeau, and Anton Setzer. 2013. Copatterns: Programming Infinite Structures by Observations. In Proceedings of the 40th Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL ’13) . ACM, New York, NY, USA, 27–38. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. Nils Anders Danielsson and Patrik Jansson. 2004. Chasing Bottoms - a Case Study in Program Verification in the Presence of Partial and Infinite Values. (05 2004).Google ScholarGoogle Scholar
  3. Joachim Breitner. 2014. ghc-heap-view: Extract the heap representation of Haskell values and thunks. https://hackage. haskell.org/package/ghc-heap-view . (2014). {Online; accessed 14-March-2018}.Google ScholarGoogle Scholar
  4. Olaf Chitil. 2011. StrictCheck: a Tool for Testing Whether a Function is Unnecessarily Strict. Technical report 2-11. University of Kent, Kent, UK. 182–196 pages. http://kar.kent.ac.uk/30756/Google ScholarGoogle Scholar
  5. Koen Claessen and John Hughes. 2000. QuickCheck: A Lightweight Tool for Random Testing of Haskell Programs. SIGPLAN Not. 35, 9 (Sept. 2000), 268–279. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. Koen Claessen, Nicholas Smallbone, and John Hughes. 2010. QuickSpec: Guessing Formal Specifications Using Testing. In Tests and Proofs , Gordon Fraser and Angelo Gargantini (Eds.). Springer Berlin Heidelberg, Berlin, Heidelberg, 6–21. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. Edsko de Vries and Andres Löh. 2014. True sums of products. In [email protected]. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. Andy Gill. 2001. Debugging Haskell by Observing Intermediate Data Structures. Electronic Notes in Theoretical Computer Science 41, 1 (2001), 1.Google ScholarGoogle ScholarCross RefCross Ref
  9. Ralf Hinze. 2000. Memo Functions, Polytypically!. In Proceedings of the 2nd Workshop on Generic Programming, Ponte de. 17–32.Google ScholarGoogle Scholar
  10. J. Hughes. 1989. Why Functional Programming Matters. Comput. J. 32, 2 (1989), 98–107. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. Edward A. Kmett. 2017. recursion-schemes: Generalized bananas, lenses and barbed wire. http://hackage.haskell.org/ package/recursion-schemes . (2017). {Online; accessed 12-June-2018}.Google ScholarGoogle Scholar
  12. Erik Meijer, Maarten Fokkinga, and Ross Paterson. 1991. Functional Programming with Bananas, Lenses, Envelopes and Barbed Wire. Springer-Verlag, 124–144. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. Matt Morrow and Austin Seipp. 2009. vacuum: Graph representation of the GHC heap. https://hackage.haskell.org/package/ vacuum . (2009). {Online; accessed 16-March-2018}.Google ScholarGoogle Scholar
  14. Chris Okasaki. 1995. Simple and efficient purely functional queues and deques. JOURNAL OF FUNCTIONAL PROGRAMMING 5, 4 (1995), 583–592.Google ScholarGoogle ScholarCross RefCross Ref
  15. Chris Okasaki. 1998. Purely Functional Data Structures. Cambridge University Press, New York, NY, USA. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. Colin Runciman, Matthew Naylor, and Fredrik Lindblad. 2008. Smallcheck and Lazy Smallcheck: Automatic Exhaustive Testing for Small Values. In Proceedings of the First ACM SIGPLAN Symposium on Haskell (Haskell ’08). ACM, New York, NY, USA, 37–48. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Keep your laziness in check

      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

      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!