Abstract
Randomized property-based testing has gained much attention recently, but most frameworks stop short at polymorphic properties. Although Bernardy et al. have developed a theory to reduce a wide range of polymorphic properties to monomorphic ones, it relies upon ad-hoc embedding-projection pairs to massage the types into a particular form. This paper skips the embedding-projection pairs and presents a mechanical monomorphization for a general class of polymorphic functions, a step towards automatic testing for polymorphic properties. The calculation of suitable types for monomorphization turns out to be logarithm.
Supplemental Material
Available for Download
Full proofs of a variant of Lemma 3.2 and Theorem 4.1 from the main article.
- Michael Abbott, Thorsten Altenkirch, and Neil Ghani. 2003. Categories of containers. In International Conference on Foundations of Software Science and Computation Structures. 23–38. https://doi.org/10.1007/3-540-36576-1_2 Google Scholar
Cross Ref
- Thorsten Altenkirch, Neil Ghani, Peter Hancock, Conor McBride, and Peter Morris. 2015. Indexed containers. Journal of Functional Programming, 25, e5. https://doi.org/10.1017/S095679681500009X Google Scholar
Cross Ref
- Jean-Philippe Bernardy. 2017. A dual view of testing of (polymorphic) programs. https://jyp.github.io/posts/polytest-two.htmlGoogle Scholar
- Jean-Philippe Bernardy, Patrik Jansson, and Koen Claessen. 2010. Testing Polymorphic Properties. In Programming Languages and Systems. Springer Berlin Heidelberg, Berlin, Heidelberg. 125–144. isbn:978-3-642-11957-6 https://doi.org/10.1007/978-3-642-11957-6_8 Google Scholar
Digital Library
- Richard Bird and Lambert Meertens. 1998. Nested datatypes. In International Conference on Mathematics of Program Construction. 52–67. https://doi.org/10.1007/BFb0054285 Google Scholar
Cross Ref
- Koen Claessen and John Hughes. 2000. QuickCheck: A Lightweight Tool for Random Testing of Haskell Programs. In Proceedings of the Fifth ACM SIGPLAN International Conference on Functional Programming (ICFP ’00). ACM, New York, NY, USA. 268–279. isbn:1-58113-202-6 https://doi.org/10.1145/351240.351266 Google Scholar
Digital Library
- CMU 15-210 Staff. 2018. The SEQUENCE signature. http://www.cs.cmu.edu/afs/cs/academic/class/15210-f15/www/docs/sig/sequence/SEQUENCE.htmlGoogle Scholar
- Peter Hancock. 2019. Personal communication, along with some notes.Google Scholar
- Ralf Hinze and Ross Paterson. 2006. Finger trees: a simple general-purpose data structure. Journal of functional programming, 16, 2 (2006), 197–217. https://doi.org/10.1017/S0956796805005769 Google Scholar
Digital Library
- Kuen-Bang Hou (Favonia) and Zhuyang Wang. 2021. Replication Package for Article: Logarithm and Program Testing. https://doi.org/10.1145/3462305 Google Scholar
Digital Library
- Jane Street Group. 2018. Ppxlib - Meta-programming for OCaml. https://github.com/ocaml-ppx/ppxlibGoogle Scholar
- C Barry Jay. 1995. A semantics for shape. Science of Computer Programming, 25, 2-3 (1995), 251–283. https://doi.org/10.1016/0167-6423(95)00015-1 Selected Papers of ESOP’94, the 5th European Symposium on Programming Google Scholar
Digital Library
- John C Reynolds. 1983. Types, abstraction and parametric polymorphism. In Information Processing 83, Proceedings of the IFIP 9th World Computer Congres. 513–523.Google Scholar
- 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. isbn:978-1-60558-064-7 https://doi.org/10.1145/1411286.1411292 Google Scholar
Digital Library
- Janis Voigtländer. 2008. Much Ado About Two (Pearl): A Pearl on Parallel Prefix Computation. In Proceedings of the 35th Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL ’08). ACM, New York, NY, USA. 29–35. isbn:978-1-59593-689-9 https://doi.org/10.1145/1328438.1328445 Google Scholar
Digital Library
- Philip Wadler. 1989. Theorems for Free!. In Proceedings of the Fourth International Conference on Functional Programming Languages and Computer Architecture (FPCA ’89). ACM, New York, NY, USA. 347–359. isbn:0-89791-328-0 https://doi.org/10.1145/99370.99404 Google Scholar
Digital Library
- Zhuyang Wang. 2021. PolyCheck: Testing Polymorphic Functions. https://github.com/hawnzug/polycheckGoogle Scholar
- Li-yao Xia. 2017. A terminal view of testing polymorphic functions. https://blog.poisson.chat/posts/2017-06-29-terminal-monomorphization.htmlGoogle Scholar
- Li-yao Xia. 2017. Test Polymorphic Functions with Metamorph. https://github.com/Lysxia/metamorphGoogle Scholar
Index Terms
Logarithm and program testing
Recommendations
Graduality and parametricity: together again for the first time
Parametric polymorphism and gradual typing have proven to be a difficult combination, with no language yet produced that satisfies the fundamental theorems of each: parametricity and graduality. Notably, Toro, Labrada, and Tanter (POPL 2019) conjecture ...
Gradual parametricity, revisited
Bringing the benefits of gradual typing to a language with parametric polymorphism like System F, while preserving relational parametricity, has proven extremely challenging: first attempts were formulated a decade ago, and several designs were recently ...
Testing polymorphic properties
ESOP'10: Proceedings of the 19th European conference on Programming Languages and SystemsThis paper is concerned with testing properties of polymorphic functions. The problem is that testing can only be performed on specific monomorphic instances, whereas parametrically polymorphic functions are expected to work for any type. We present a ...






Comments