skip to main content
10.1145/2633628.2633634acmconferencesArticle/Chapter ViewAbstractPublication PagesicfpConference Proceedingsconference-collections
research-article

True sums of products

Published:26 August 2014Publication History

ABSTRACT

We introduce the sum-of-products (SOP) view for datatype-generic programming (in Haskell). While many of the libraries that are commonly in use today represent datatypes as arbitrary combinations of binary sums and products, SOP reflects the structure of datatypes more faithfully: each datatype is a single n-ary sum, where each component of the sum is a single n-ary product. This representation turns out to be expressible accurately in GHC with today's extensions. The resulting list-like structure of datatypes allows for the definition of powerful high-level traversal combinators, which in turn encourage the definition of generic functions in a compositional and concise style. A major plus of the SOP view is that it allows to separate function-specific metadata from the main structural representation and recombining this information later.

References

  1. Michael D. Adams and Thomas M. DuBuisson. Template your boilerplate: Using Template Haskell for efficient generic programming. In Haskell '12, pages 13--24. ACM, 2012. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. Artem Alimarine and Rinus Plasmeijer. A generic programming extension for Clean. In IFL, volume 2312 of LNCS, pages 168--185. Springer, 2001. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. Thorsten Altenkirch, Conor McBride, and Peter Morris. Generic programming with dependent types. In SSDGP '06, pages 209--257. Springer, 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. Lennart Augustsson. geniplate: Use Template Haskell to generate Uniplate-like functions, 2011. URL http://hackage.haskell.org/package/geniplate.Google ScholarGoogle Scholar
  5. Patrick Bahr and Tom Hvitved. Compositional data types. In WGP '11, pages 83--94. ACM, 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. Marcin Benke, Peter Dybjer, and Patrik Jansson. Universes for generic programs and proofs in dependent type theory. Nordic J. of Computing, 10 (4): 265--289, December 2003. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. Manuel M. T. Chakravarty, Gabriel C. Ditu, and Roman Leshchinskiy. Instant generics: Fast and easy, 2009. URL http://www.cse.unsw.edu.au/ chak/papers/CDL09.html.Google ScholarGoogle Scholar
  8. James Chapman, Pierre-Évariste Dagand, Conor McBride, and Peter Morris. The gentle art of levitation. In ICFP '10, pages 3--14. ACM, 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. Koen Claessen and John Hughes. QuickCheck: A lightweight tool for random testing of Haskell programs. In ICFP '00, pages 268--279. ACM, 2000. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. Richard A. Eisenberg. Defunctionalization for the win, 2013. URL http://typesandkinds.wordpress.com/2013/04/01/defunctionalization-for-the-win/.Google ScholarGoogle Scholar
  11. Richard A. Eisenberg and Stephanie Weirich. Dependently typed programming with singletons. In Haskell '12, pages 117--130. ACM, 2012. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. J. Nathan Foster, Michael B. Greenwald, Jonathan T. Moore, Benjamin C. Pierce, and Alan Schmitt. Combinators for bidirectional tree transformations: A linguistic approach to the view-update problem. ACM Trans. Program. Lang. Syst., 29 (3), May 2007. ISSN 0164-0925. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. Ralf Hinze. Polytypic values possess polykinded types. Science of Computer Programming, 43 (2--3): 129--159, 2002.Google ScholarGoogle ScholarCross RefCross Ref
  14. Ralf Hinze, Andres Löh, and Bruno C. d. S. Oliveira. ''Scrap Your Boilerplate'' reloaded. In FLOPS, volume 3945 of LNCS, pages 13--29. Springer, 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. Stefan Holdermans, Johan Jeuring, Andres Löh, and Alexey Rodriguez Yakushev. Generic views on data types. In MPC, volume 4014 of LNCS, pages 209--234. Springer, 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. Patrik Jansson and Johan Jeuring. PolyP--a polytypic programming language extension. In POPL '97, pages 470--482. ACM, 1997. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. Ralf Lämmel and Simon Peyton Jones. Scrap your boilerplate: a practical design pattern for generic programming. In TLDI '03, pages 26--37. ACM, 2003. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. Eelco Lempsink, Sean Leather, and Andres Löh. Type-safe diff for families of datatypes. In WGP '09, pages 61--72. ACM, 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. Andres Löh. Exploring Generic Haskell. PhD thesis, Universiteit Utrecht, 2004.Google ScholarGoogle Scholar
  20. José Pedro Magalhães. The right kind of generic programming. In WGP '12, pages 13--24. ACM, 2012. Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. José Pedro Magalhães, Atze Dijkstra, Johan Jeuring, and Andres Löh. A generic deriving mechanism for Haskell. In Haskell '10, pages 37--48. ACM, 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. José Pedro Magalhães and Andres Löh. Generic generic programming, 2013. URL http://www.andres-loeh.de/GenericGenericProgramming/. Unpublished original draft ofcitetGGP.Google ScholarGoogle Scholar
  23. José Pedro Magalhães and Andres Löh. Generic generic programming. In PADL, volume 8324 of LNCS, pages 216--231. Springer, 2014.Google ScholarGoogle Scholar
  24. Per Martin-Löf. Intuitionistic type theory. Bibliopolis, 1984.Google ScholarGoogle Scholar
  25. Conor McBride. Ornamental algebras, algebraic ornaments. 2010. Submitted to Journal of Functional Programming.Google ScholarGoogle Scholar
  26. Neil Mitchell and Colin Runciman. Uniform boilerplate and list processing. In Haskell '07, pages 49--60. ACM, 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  27. Noort, Alexey Rodriguez Yakushev, Stefan Holdermans, Johan Jeuring, Bastiaan Heeren, and José Pedro Magalhes. A lightweight approach to datatype-generic rewriting. Journal of Functional Programming, 20 (ãSpecial Issue 3-4): 375--413, 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  28. Russell O'Connor. Functor is to lens as applicative is to biplate: Introducing multiplate. CoRR, abs/1103.2841, 2011.Google ScholarGoogle Scholar
  29. Alexey Rodriguez Yakushev, Stefan Holdermans, Andres Löh, and Johan Jeuring. Generic programming with fixed points for mutually recursive datatypes. In ICFP '09, pages 233--244. ACM, 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  30. Neil Sculthorpe, Nicolas Frisby, and Andy Gill. The Kansas University Rewrite Engine: A Haskell-embedded strategic programming language with custom closed universes. Submitted to the Journal of Functional Programming, 2014. URL http://www.cs.swan.ac.uk/ csnas/papers_and_talks/kure.pdf.Google ScholarGoogle Scholar
  31. Tim Sheard and Simon Peyton Jones. Template meta-programming for Haskell. In Haskell '02, pages 1--16. ACM, December 2002. Google ScholarGoogle ScholarDigital LibraryDigital Library
  32. Martin Sulzmann, Manuel M. T. Chakravarty, Simon Peyton Jones, and Kevin Donnelly. System F with type equality coercions. In TLDI '07, pages 53--66. ACM, 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  33. Stephanie Weirich. RepLib: a library for derivable type classes. In Haskell '06, pages 1--12. ACM, 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  34. Brent A. Yorgey, Stephanie Weirich, Julien Cretin, Simon Peyton Jones, Dimitrios Vytiniotis, and José Pedro Magalhes. Giãving Haskell a promotion. In TLDI '12, pages 53--66. ACM, 2012. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. True sums of products

    Recommendations

    Comments

    Login options

    Check if you have access through your login credentials or your institution to get full access on this article.

    Sign in
    • Published in

      cover image ACM Conferences
      WGP '14: Proceedings of the 10th ACM SIGPLAN workshop on Generic programming
      August 2014
      102 pages
      ISBN:9781450330428
      DOI:10.1145/2633628
      • Program Chairs:
      • José Pedro Magalhäes,
      • Tiark Rompf

      Copyright © 2014 ACM

      Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than the author(s) must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected].

      Publisher

      Association for Computing Machinery

      New York, NY, United States

      Publication History

      • Published: 26 August 2014

      Permissions

      Request permissions about this article.

      Request Permissions

      Check for updates

      Qualifiers

      • research-article

      Acceptance Rates

      WGP '14 Paper Acceptance Rate8of9submissions,89%Overall Acceptance Rate30of43submissions,70%

      Upcoming Conference

      ICFP '24

    PDF Format

    View or Download as a PDF file.

    PDF

    eReader

    View online with eReader.

    eReader