Abstract
Given an appropriate domain specific language (DSL), it is possible to describe the relationship between Haskell data types and many generic functions, typically type-class instances. While describing the relationship is possible, it is not always an easy task. There is an alternative – simply give one example output for a carefully chosen input, and have the relationship derived.
When deriving a relationship from only one example, it is important that the derived relationship is the intended one. We identify general restrictions on the DSL, and on the provided example, to ensure a level of predictability. We then apply these restrictions in practice, to derive the relationship between Haskell data types and generic functions. We have used our scheme in the Derive tool, where over 60% of type classes are derived from a single example.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Preview
Unable to display preview. Download preview PDF.
References
Augustsson, L.: Putting Curry-Howard to work. In: AAIP 2009: Proceedings of the ACM SIGPLAN Workshop on Approaches and Applications of Inductive Programming, p. 1 (2009)
Broberg, N.: Haskell-src-exts (2009), http://www.cs.chalmers.se/~d00nibro/haskell-src-exts/
Claessen, K., Hughes, J.: QuickCheck: A lightweight tool for random testing of Haskell programs. In: Proc. ICFP 2000, pp. 268–279. ACM Press, New York (2000)
Fluet, M., Pucella, R.: Phantom types and subtyping. In: Proc. TCS 2002, Deventer, The Netherlands, pp. 448–460 (2002)
Gamma, E., Helm, R., Johnson, R., Vlissides, J.: Design patterns: elements of reusable object-oriented software. Addison-Wesley Professional, Reading (1995)
Goldberg, D.E.: Genetic Algorithms in Search, Optimization, and Machine Learning. Addison-Wesley Professional, Reading (1989)
Golubovsky, D., Mitchell, N., Naylor, M.: Yhc.Core – from Haskell to Core. The Monad. Reader 1(7), 45–61 (2007)
Harrison, J.: HOL light: A tutorial introduction. In: Srivas, M., Camilleri, A. (eds.) FMCAD 1996. LNCS, vol. 1166, pp. 265–269. Springer, Heidelberg (1996)
Hinze, R., Peyton Jones, S.: Derivable type classes. In: Hutton, G. (ed.) Proc. Haskell Workshop 2000. Elsevier Science, Amsterdam (2000)
Hughes, J.: The design of a pretty-printing library. In: Jeuring, J., Meijer, E. (eds.) AFP 1995. LNCS, vol. 925, pp. 53–96. Springer, Heidelberg (1995)
Jeuring, J., Rodriguez, A., Smeding, G.: Generating generic functions. In: WGP 2006: Proceedings of the 2006 ACM SIGPLAN workshop on Generic programming, pp. 23–32. ACM, New York (2006)
Katayama, S.: Efficient exhaustive generation of functional programs using Monte-Carlo search with iterative deepening. In: Ho, T.-B., Zhou, Z.-H. (eds.) PRICAI 2008. LNCS (LNAI), vol. 5351, pp. 199–210. Springer, Heidelberg (2008)
Kitzelmann, E.: Data-driven induction of recursive functions from input/output-examples. In: Proceedings of the Workshop on Approaches and Applications of Inductive Progamming (AAIP 2007), pp. 15–26 (2007)
Kitzelmann, E.: Data-driven induction of functional programs. In: Proc. ECAI 2008. IOS Press, Amsterdam (2008)
Kitzelmann, E., Schmid, U.: Inductive synthesis of functional programs – An explanation based generalization approach. Journal of Machine Learning Research 7, 429–454 (2006)
Lämmel, R., Peyton Jones, S.: Scrap your boilerplate: a practical design pattern for generic programming. In: Proc. TLDI 2003, pp. 26–37. ACM Press, New York (2003)
Lämmel, R., Peyton Jones, S.: Scrap more boilerplate: reflection, zips, and generalised casts. In: Proc. ICFP 2004, pp. 244–255. ACM Press, New York (2004)
Marlow, S.: Haddock, a Haskell documentation tool. In: Proc. Haskell Workshop 2002, Pittsburgh Pennsylvania, USA. ACM Press, New York (2002)
Mintchev, S.: Mechanized reasoning about functional programs. In: Hammond, K., Turner, D.N., Sansom, P.M. (eds.) Functional Programming, pp. 151–166. Springer, Heidelberg (1994)
Mitchell, N.: Deriving generic functions by example. In: Mühlberg, J.T., Perna, J.I. (eds.) Proc. York Doctoral Symposium 2007, October 2007, pp. 55–62. Tech. Report YCS-2007-421, University of York (2007)
Mitchell, N., O’Rear, S.: Derive - project home page (2009), http://community.haskell.org/~ndm/derive/
Peyton Jones, S.: Haskell 98 Language and Libraries: The Revised Report. Cambridge University Press, Cambridge (2003)
Peyton Jones, S., Vytiniotis, D., Weirich, S., Washburn, G.: Simple unification-based type inference for GADTs. In: Proc. ICFP 2006, pp. 50–61. ACM Press, New York (2006)
Sheard, T., Peyton Jones, S.: Template meta-programming for Haskell. In: Proc. Haskell Workshop 2002, pp. 1–16. ACM Press, New York (2002)
The GHC Team. The GHC compiler, version 6.10.3 (May 2009), http://www.haskell.org/ghc/
The Yhc Team. The York Haskell Compiler – user manual (February 2007), http://www.haskell.org/haskellwiki/Yhc
Trinder, P., Hammond, K., Loidl, H.-W., Peyton Jones, S.: Algorithm + strategy = parallelism. JFP 8(1), 23–60 (1998)
Wadler, P.: How to replace failure by a list of successes. In: Proc. FPCA 1985, pp. 113–128. Springer-Verlag New York, Inc. (1985)
Wadler, P., Blott, S.: How to make ad-hoc polymorphism less ad hoc. In: Proc. POPL 1989, pp. 60–76. ACM Press, New York (1989)
Winstanley, N.: Reflections on instance derivation. In: 1997 Glasgow Workshop on Functional Programming. BCS Workshops in Computer Science (September 1997)
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2010 Springer-Verlag Berlin Heidelberg
About this paper
Cite this paper
Mitchell, N. (2010). Deriving a Relationship from a Single Example. In: Schmid, U., Kitzelmann, E., Plasmeijer, R. (eds) Approaches and Applications of Inductive Programming. AAIP 2009. Lecture Notes in Computer Science, vol 5812. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-642-11931-6_1
Download citation
DOI: https://doi.org/10.1007/978-3-642-11931-6_1
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-642-11930-9
Online ISBN: 978-3-642-11931-6
eBook Packages: Computer ScienceComputer Science (R0)