Nothing Special   »   [go: up one dir, main page]

skip to main content
10.1145/1292535.1292548acmconferencesArticle/Chapter ViewAbstractPublication PagesicfpConference Proceedingsconference-collections
Article

Practical generic programming in OCaml

Published: 02 October 2007 Publication History

Abstract

We describe deriving, a system of extensible generic functions for OCaml implemented as a preprocessor and supporting library. We argue that generating code from type-definitions has significant advantages over a combinator approach, taking serialisation as an example application: our generate-your-boilerplate design results in a system that is easy to use, has comprehensive coverage of types and handles cyclic values without imposing a burden on the user. Users can extend generic functions with specialised implementations at particular types; we show how this can lead to dramatically improved performance in the serialisation task without the user writing a single line of serialisation code.

References

[1]
John Billings and Peter Sewell and Mark Shinwell and Rok Strniaš Type-safe distributed programming for OCaml MCM SIGPLAN Workshop on ML, 2006.
[2]
Jacques Carette, Lydia E. van Dijk and Oleg Kiselyov. Syntactic extension for Monads in Ocaml. http://www.cas.mcmaster.ca/~carette/pa_monad/.
[3]
James Cheney and Ralf Hinze. A lightweight implementation of generics and dynamics. Haskell Workshop, 2002.
[4]
Albert Cohen and C. Herrmann. Towards a High-Productivity and High-Performance Marshaling Library for Compound Data. 2nd MetaOCaml Workshop, 2005.
[5]
Ezra Cooper, Sam Lindley, Philip Wadler, and Jeremy Yallop. Links: Web Programming Without Tiers. FMCO, 2006.
[6]
Derek Dreyer, Robert Harper, Manuel Chakravarti, and Gabriele Keller. Modular Type Classes. POPL, 2007.
[7]
Martin Elsman. Type-Specialized Serialization with Sharing. Trends in Functional Programming, 2005.
[8]
Andrzej Filinski. Controlling Effects. PhD Thesis, School of Computer Science, Carnegie Mellon University, May 1996.
[9]
Jacques Garrigue. Programming with Polymorphic Variants. ML Workshop, 1998.
[10]
Jeremy Gibbons. Design patterns as higher-order datatype-generic programs. Workshop on Generic Programming, 2006.
[11]
Ralf Hinze, Johan Jeuring, and Andres Löh. Comparing approaches to generic programming in Haskell. Spring School on Datatype-Generic Programming, 2006.
[12]
Ralf Hinze. Generics for the masses. ICFP, 2004.
[13]
Ralf Hinze, Andres Löh, and Bruno C. d. S. Oliveira. "Scrap Your Boilerplate" Reloaded FLOPS, 2006.
[14]
John Hughes. Why Functional Programming Matters. Computer Journal, 32(2), 1989.
[15]
Martin Jambon. json-static. http://martin.jambon.free.fr/json-static.html.
[16]
Martin Jambon. pa tryfinally. http://martin.jambon.free.fr/pa_tryfinally.ml.
[17]
Patrik Jansson and Johan Jeuring. PolyP -- a polytypic programming language extension. POPL, 1997.
[18]
Vesa Karvonen. Generics for the Working ML'er. ML Workshop, 2007.
[19]
R. Kelsey, W. Clinger, J. Rees (eds.). Revised5 Report on the Algorithmic Language Scheme. Higher-Order and Symbolic Computation, 11(1), 1998.
[20]
Andrew J. Kennedy. Functional Pearl: Pickler Combinators. JFP, 14(6), 2004.
[21]
Oleg Kiselyov. Post to Haskell list, August 2004. http://haskell.org/pipermail/haskell/2004-August/014463.html
[22]
Ralf Lämmel and Simon Peyton-Jones. Scrap your boilerplate: a practical design pattern for generic programming. TLDI, 2003.
[23]
Chuck Liang and Gopalan Nadathur. Tradeoffs in the Intensional Representation of Lambda Terms. RTA, 2002.
[24]
Neil Mitchell and Stefan O'Rear. Derive. http://www-users.cs.york.ac.uk/~ndm/derive/.
[25]
Simon Peyton Jones and John Hughes (editors). Haskell 98: A Non-strict, Purely Functional Language. February, 1999.
[26]
Daniel de Rauglaudre. IoXML. http://cristal.inria.fr/~ddr/IoXML/.
[27]
Martin Sandin. Tywith. http://tools.assembla.com/tywith/wiki.
[28]
Guido Tack, Leif Kornstaedt and Gert Smolka. Generic Pickling and Minimization. ML Workshop, 2005.
[29]
Philip Wadler The essence of functional programming. POPL, 1992.
[30]
Stefan Wehr. ML Modules and Haskell Type Classes: A Constructive Comparison. Master's thesis, Albert-Ludwigs-Universität, Freiburg, Germany, November 2005.
[31]
Stephanie Weirich. RepLib: A library for derivable type classes. Haskell Workshop, 2006.
[32]
Noel Winstanley. DrIFT. http://repetae.net/~john/computer/haskell/DrIFT/.
[33]
Programming languages - C. ISO/IEC 9899:1999.
[34]
American National Standard for Programming Language Common LISP. ANSI X3.226:1994. J13/SC22/WG16 Common LISP

Cited By

View all
  • (2019)Extending OCaml's 'open'Electronic Proceedings in Theoretical Computer Science10.4204/EPTCS.294.1294(1-14)Online publication date: 16-May-2019
  • (2018)Generic Programming in OCamlElectronic Proceedings in Theoretical Computer Science10.4204/EPTCS.285.3285(59-100)Online publication date: 31-Dec-2018
  • (2018)Typed Embedding of a Relational Language in OCamlElectronic Proceedings in Theoretical Computer Science10.4204/EPTCS.285.1285(1-22)Online publication date: 31-Dec-2018
  • Show More Cited By

Recommendations

Comments

Please enable JavaScript to view thecomments powered by Disqus.

Information & Contributors

Information

Published In

cover image ACM Conferences
ML '07: Proceedings of the 2007 workshop on Workshop on ML
October 2007
102 pages
ISBN:9781595936769
DOI:10.1145/1292535
  • General Chair:
  • Claudio Russo,
  • Program Chair:
  • Derek Dreyer
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 ACM 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]

Sponsors

Publisher

Association for Computing Machinery

New York, NY, United States

Publication History

Published: 02 October 2007

Permissions

Request permissions for this article.

Check for updates

Author Tags

  1. OCaml
  2. deriving
  3. generic programming

Qualifiers

  • Article

Conference

ICFP07
Sponsor:

Acceptance Rates

Overall Acceptance Rate 6 of 11 submissions, 55%

Upcoming Conference

ICFP '25
ACM SIGPLAN International Conference on Functional Programming
October 12 - 18, 2025
Singapore , Singapore

Contributors

Other Metrics

Bibliometrics & Citations

Bibliometrics

Article Metrics

  • Downloads (Last 12 months)10
  • Downloads (Last 6 weeks)1
Reflects downloads up to 04 Feb 2025

Other Metrics

Citations

Cited By

View all
  • (2019)Extending OCaml's 'open'Electronic Proceedings in Theoretical Computer Science10.4204/EPTCS.294.1294(1-14)Online publication date: 16-May-2019
  • (2018)Generic Programming in OCamlElectronic Proceedings in Theoretical Computer Science10.4204/EPTCS.285.3285(59-100)Online publication date: 31-Dec-2018
  • (2018)Typed Embedding of a Relational Language in OCamlElectronic Proceedings in Theoretical Computer Science10.4204/EPTCS.285.1285(1-22)Online publication date: 31-Dec-2018
  • (2017)Staged generic programmingProceedings of the ACM on Programming Languages10.1145/31102731:ICFP(1-29)Online publication date: 29-Aug-2017
  • (2012)Typing unmarshalling without marshalling typesACM SIGPLAN Notices10.1145/2398856.236456947:9(287-298)Online publication date: 9-Sep-2012
  • (2012)Typing unmarshalling without marshalling typesProceedings of the 17th ACM SIGPLAN international conference on Functional programming10.1145/2364527.2364569(287-298)Online publication date: 9-Sep-2012
  • (2010)Using functional programming within an industrial product groupACM SIGPLAN Notices10.1145/1932681.186355745:9(87-92)Online publication date: 27-Sep-2010
  • (2010)Using functional programming within an industrial product groupProceedings of the 15th ACM SIGPLAN international conference on Functional programming10.1145/1863543.1863557(87-92)Online publication date: 27-Sep-2010
  • (2009)Libraries for Generic Programming in HaskellAdvanced Functional Programming10.1007/978-3-642-04652-0_4(165-229)Online publication date: 2009
  • (2008)Libraries for generic programming in haskellProceedings of the 6th international conference on Advanced functional programming10.5555/1813347.1813351(165-229)Online publication date: 19-May-2008
  • Show More Cited By

View Options

Login options

View options

PDF

View or Download as a PDF file.

PDF

eReader

View online with eReader.

eReader

Figures

Tables

Media

Share

Share

Share this Publication link

Share on social media