Shrinking and showing functions: (functional pearl)

Although quantification over functions in QuickCheck properties has been supported from the beginning, displaying and shrinking them as counter examples has not. The reason is that in general, functions are infinite objects, which means that there is no sensible show function for them, and shrinking an infinite object within a finite number of steps seems impossible. This paper presents a general technique with which functions as counter examples can be shrunk to finite objects, which can then be displayed to the user. The approach turns out to be practically usable, which is shown by a number of examples. The two main limitations are that higher-order functions cannot be dealt with, and it is hard to deal with terms that contain functions as subterms.

[1]  Conal Elliott,et al.  Functional Implementations of Continuos Modeled Animation , 1998, PLILP/ALP.

[2]  Koen Claessen,et al.  Testing Polymorphic Properties , 2010, ESOP.

[3]  Koen Claessen,et al.  QuickCheck: a lightweight tool for random testing of Haskell programs , 2011, SIGP.

[4]  Martín Hötzel Escardó,et al.  Infinite sets that admit fast exhaustive search , 2007, 22nd Annual IEEE Symposium on Logic in Computer Science (LICS 2007).

[5]  Ralf Hinze,et al.  Generalizing generalized tries , 2000, Journal of Functional Programming.

[6]  Colin Runciman,et al.  Smallcheck and lazy smallcheck: automatic exhaustive testing for small values , 2008, Haskell '08.