Advertisement

Deriving a Relationship from a Single Example

  • Neil Mitchell
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 5812)

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.

Keywords

Data Type Type Class Sample Input Output Type Input Type 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. 1.
    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)Google Scholar
  2. 2.
    Broberg, N.: Haskell-src-exts (2009), http://www.cs.chalmers.se/~d00nibro/haskell-src-exts/
  3. 3.
    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)CrossRefGoogle Scholar
  4. 4.
    Fluet, M., Pucella, R.: Phantom types and subtyping. In: Proc. TCS 2002, Deventer, The Netherlands, pp. 448–460 (2002)Google Scholar
  5. 5.
    Gamma, E., Helm, R., Johnson, R., Vlissides, J.: Design patterns: elements of reusable object-oriented software. Addison-Wesley Professional, Reading (1995)Google Scholar
  6. 6.
    Goldberg, D.E.: Genetic Algorithms in Search, Optimization, and Machine Learning. Addison-Wesley Professional, Reading (1989)zbMATHGoogle Scholar
  7. 7.
    Golubovsky, D., Mitchell, N., Naylor, M.: Yhc.Core – from Haskell to Core. The Monad. Reader 1(7), 45–61 (2007)Google Scholar
  8. 8.
    Harrison, J.: HOL light: A tutorial introduction. In: Srivas, M., Camilleri, A. (eds.) FMCAD 1996. LNCS, vol. 1166, pp. 265–269. Springer, Heidelberg (1996)CrossRefGoogle Scholar
  9. 9.
    Hinze, R., Peyton Jones, S.: Derivable type classes. In: Hutton, G. (ed.) Proc. Haskell Workshop 2000. Elsevier Science, Amsterdam (2000)Google Scholar
  10. 10.
    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)Google Scholar
  11. 11.
    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)CrossRefGoogle Scholar
  12. 12.
    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)CrossRefGoogle Scholar
  13. 13.
    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)Google Scholar
  14. 14.
    Kitzelmann, E.: Data-driven induction of functional programs. In: Proc. ECAI 2008. IOS Press, Amsterdam (2008)Google Scholar
  15. 15.
    Kitzelmann, E., Schmid, U.: Inductive synthesis of functional programs – An explanation based generalization approach. Journal of Machine Learning Research 7, 429–454 (2006)MathSciNetGoogle Scholar
  16. 16.
    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)CrossRefGoogle Scholar
  17. 17.
    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)CrossRefGoogle Scholar
  18. 18.
    Marlow, S.: Haddock, a Haskell documentation tool. In: Proc. Haskell Workshop 2002, Pittsburgh Pennsylvania, USA. ACM Press, New York (2002)Google Scholar
  19. 19.
    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)Google Scholar
  20. 20.
    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)Google Scholar
  21. 21.
    Mitchell, N., O’Rear, S.: Derive - project home page (2009), http://community.haskell.org/~ndm/derive/
  22. 22.
    Peyton Jones, S.: Haskell 98 Language and Libraries: The Revised Report. Cambridge University Press, Cambridge (2003)Google Scholar
  23. 23.
    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)CrossRefGoogle Scholar
  24. 24.
    Sheard, T., Peyton Jones, S.: Template meta-programming for Haskell. In: Proc. Haskell Workshop 2002, pp. 1–16. ACM Press, New York (2002)CrossRefGoogle Scholar
  25. 25.
    The GHC Team. The GHC compiler, version 6.10.3 (May 2009), http://www.haskell.org/ghc/
  26. 26.
    The Yhc Team. The York Haskell Compiler – user manual (February 2007), http://www.haskell.org/haskellwiki/Yhc
  27. 27.
    Trinder, P., Hammond, K., Loidl, H.-W., Peyton Jones, S.: Algorithm + strategy = parallelism. JFP 8(1), 23–60 (1998)zbMATHCrossRefMathSciNetGoogle Scholar
  28. 28.
    Wadler, P.: How to replace failure by a list of successes. In: Proc. FPCA 1985, pp. 113–128. Springer-Verlag New York, Inc. (1985)Google Scholar
  29. 29.
    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)Google Scholar
  30. 30.
    Winstanley, N.: Reflections on instance derivation. In: 1997 Glasgow Workshop on Functional Programming. BCS Workshops in Computer Science (September 1997)Google Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2010

Authors and Affiliations

  • Neil Mitchell

There are no affiliations available

Personalised recommendations