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.
Supplemental Material
- 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 Scholar
Digital Library
- 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 Scholar
- 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 Scholar
- 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 Scholar
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- Edsko de Vries and Andres Löh. 2014. True sums of products. In [email protected]. Google Scholar
Digital Library
- Andy Gill. 2001. Debugging Haskell by Observing Intermediate Data Structures. Electronic Notes in Theoretical Computer Science 41, 1 (2001), 1.Google Scholar
Cross Ref
- Ralf Hinze. 2000. Memo Functions, Polytypically!. In Proceedings of the 2nd Workshop on Generic Programming, Ponte de. 17–32.Google Scholar
- J. Hughes. 1989. Why Functional Programming Matters. Comput. J. 32, 2 (1989), 98–107. Google Scholar
Digital Library
- 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 Scholar
- Erik Meijer, Maarten Fokkinga, and Ross Paterson. 1991. Functional Programming with Bananas, Lenses, Envelopes and Barbed Wire. Springer-Verlag, 124–144. Google Scholar
Digital Library
- 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 Scholar
- Chris Okasaki. 1995. Simple and efficient purely functional queues and deques. JOURNAL OF FUNCTIONAL PROGRAMMING 5, 4 (1995), 583–592.Google Scholar
Cross Ref
- Chris Okasaki. 1998. Purely Functional Data Structures. Cambridge University Press, New York, NY, USA. Google Scholar
Digital Library
- 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 Scholar
Digital Library
Index Terms
Keep your laziness in check
Recommendations
Binders unbound
ICFP '11: Proceedings of the 16th ACM SIGPLAN international conference on Functional programmingImplementors of compilers, program refactorers, theorem provers, proof checkers, and other systems that manipulate syntax know that dealing with name binding is difficult to do well. Operations such as α-equivalence and capture-avoiding substitution ...
Binders unbound
ICFP '11Implementors of compilers, program refactorers, theorem provers, proof checkers, and other systems that manipulate syntax know that dealing with name binding is difficult to do well. Operations such as α-equivalence and capture-avoiding substitution ...
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