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

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

Scrap more boilerplate: reflection, zips, and generalised casts

Published: 19 September 2004 Publication History

Abstract

Writing boilerplate code is a royal pain. Generic programming promises to alleviate this pain by allowing the programmer to write a generic "recipe" for boilerplate code, and use that recipe in many places. In earlier work we introduced the "Scrap your boilerplate" approach to generic programming, which exploits Haskell's existing type-class mechanism to support generic transformations and queries.This paper completes the picture. We add a few extra "introspective" or "reflective" facilities, that together support a rich variety of serialisation and de-serialisation. We also show how to perform generic "zips", which at first appear to be somewhat tricky in our framework. Lastly, we generalise the ability to over-ride a generic function with a type-specific one.All of this can be supported in Haskell with independently-useful extensions: higher-rank types and type-safe cast. The GHC implementation of Haskell readily derives the required type classes for user-defined data types.

References

[1]
T. Altenkirch and C. McBride. Generic programming within dependently typed programming. In Generic Programming, 2003. Proceedings of the IFIP TC2 Working Conference on Generic Programming, Schloss Dagstuhl, July 2002.
[2]
F. Atanassow, D. Clarke, and J. Jeuring. UUXML: A Type-Preserving XML Schema-Haskell Data Binding. In B. Jayaraman, editor, Practical Aspects of Declarative Languages: 6th International Symposium, PADL 2004, Dallas, TX, USA, June 18-19, 2004. Proceedings, volume 3057 of LNCS, pages 71--85. Springer-Verlag, May 2004.
[3]
K. Claessen and J. Hughes. QuickCheck: a lightweight tool for random testing of Haskell programs. In ICFP00 {11}, pages 268--279.
[4]
D. Clarke, J. Jeuring, and A. Löh. The Generic Haskell User's Guide, 2002. Version 1.23 - Beryl release.
[5]
D. Clarke and A. Löh. Generic Haskell, Specifically. In J. Gibbons and J. Jeuring, editors, Proc. of the IFIP TC2 Working Conference on Generic Programming. Kluwer Academic Publishers, 2003.
[6]
J. Harm and R. Lämmel. Two-dimensional Approximation Coverage. Informatica, 24(3):355--369, 2000.
[7]
R. Hinze. A generic programming extension for Haskell. In Proc. 3rd Haskell Workshop, Paris, France, 1999. Technical report of Universiteit Utrecht, UU-CS-1999-28.
[8]
R. Hinze. Generics for the masses. In these proceedings, 2004.
[9]
R. Hughes. A novel representation of lists and its application to the function reverse. Information Processing Letters, 22, 1986.
[10]
G. Hutton and E. Meijer. Functional pearl: Monadic parsing in Haskell. Journal of Functional Programming, 8(4):437--444, July 1998.
[11]
ACM SIGPLAN International Conference on Functional Programming (ICFP'00), Montreal, Sept. 2000. ACM.
[12]
P. Jansson and J. Jeuring. PolyLib-A library of polytypic functions. In R. Backhouse and T. Sheard, editors, Proc. of Workshop on Generic Programming, WGP'98, Marstrand, Sweden. Dept. of Comp. Science, Chalmers Univ. of Techn. and Göteborg Univ., June 1998.
[13]
C. B. Jay. The pattern calculus. http://www-staff.it.uts.edu.au/~cbj/Publications/pattern_calculus.ps, 2003. (accepted for publication by ACM TOPLAS.).
[14]
P. W. M. Koopman, A. Alimarine, J. Tretmans, and M. J. Plasmeijer. Gast: Generic Automated Software Testing. In R. Pena and T. Arts, editors, Implementation of Functional Languages, 14th International Workshop, IFL 2002, Madrid, Spain, September 16-18, 2002, Revised Selected Papers, volume 2670 of LNCS, pages 84--100. Springer-Verlag, 2003.
[15]
R. Lämmel and J. Harm. Test case characterisation by regular path expressions. In E. Brinksma and J. Tretmans, editors, Proc. Formal Approaches to Testing of Software (FATES'01), Notes Series NS-01-4, pages 109--124. BRICS, Aug. 2001.
[16]
R. Lämmel and S. Peyton Jones. Scrap your boilerplate: a practical design pattern for generic programming. ACM SIGPLAN Notices, 38(3):26--37, Mar. 2003. Proceedings of the ACM SIGPLAN Workshop on Types in Language Design and Implementation (TLDI 2003).
[17]
The "Scrap your boilerplate" web site: examples, browsable library, papers, background, 2003-2004. http://www.cs.vu.nl/boilerplate/.
[18]
D. Lelewer and D. Hirschberg. Data compression. ACM Computing Surveys, 19(3):261--296, Sept. 1987.
[19]
A. Löh, D. Clarke, and J. Jeuring. Dependency-style Generic Haskell. In C. Norris and J. J. B. Fenwick, editors, Proceedings of the Eighth ACM SIGPLAN International Conference on Functional Programming (ICFP-03), volume 38, 9 of ACM SIGPLAN Notices, pages 141--152, New York, Aug. 25-29 2003. ACM Press.
[20]
S. Peyton Jones and M. Shields. Practical type inference for higher-rank types. Unpublished manuscript, 2004.
[21]
M. Wallace and C. Runciman. Haskell and XML: Generic combinators or type-based translation. In ACM SIGPLAN International Conference on Functional Programming (ICFP'99), pages 148--159, Paris, Sept. 1999. ACM.
[22]
S. Weirich. Type-safe cast. In ICFP00 {11}, pages 58--67.
[23]
I. Witten, R. Neal, and J. Cleary. Arithmetic coding for data compression. CACM, 30(6):520--540, June 1987.

Cited By

View all
  • (2020)Staged sums of productsProceedings of the 13th ACM SIGPLAN International Symposium on Haskell10.1145/3406088.3409021(122-135)Online publication date: 27-Aug-2020
  • (2019)Reflection in attribute grammarsProceedings of the 18th ACM SIGPLAN International Conference on Generative Programming: Concepts and Experiences10.1145/3357765.3359517(48-60)Online publication date: 21-Oct-2019
  • (2018)Generic deriving of generic traversalsProceedings of the ACM on Programming Languages10.1145/32367802:ICFP(1-30)Online publication date: 30-Jul-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
ICFP '04: Proceedings of the ninth ACM SIGPLAN international conference on Functional programming
September 2004
264 pages
ISBN:1581139055
DOI:10.1145/1016850
  • cover image ACM SIGPLAN Notices
    ACM SIGPLAN Notices  Volume 39, Issue 9
    ICFP '04
    September 2004
    254 pages
    ISSN:0362-1340
    EISSN:1558-1160
    DOI:10.1145/1016848
    Issue’s Table of Contents
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: 19 September 2004

Permissions

Request permissions for this article.

Check for updates

Author Tags

  1. generic programming
  2. reflection
  3. type cast
  4. zippers

Qualifiers

  • Article

Conference

ICFP04
Sponsor:

Acceptance Rates

Overall Acceptance Rate 333 of 1,064 submissions, 31%

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)9
  • Downloads (Last 6 weeks)1
Reflects downloads up to 14 Dec 2024

Other Metrics

Citations

Cited By

View all
  • (2020)Staged sums of productsProceedings of the 13th ACM SIGPLAN International Symposium on Haskell10.1145/3406088.3409021(122-135)Online publication date: 27-Aug-2020
  • (2019)Reflection in attribute grammarsProceedings of the 18th ACM SIGPLAN International Conference on Generative Programming: Concepts and Experiences10.1145/3357765.3359517(48-60)Online publication date: 21-Oct-2019
  • (2018)Generic deriving of generic traversalsProceedings of the ACM on Programming Languages10.1145/32367802:ICFP(1-30)Online publication date: 30-Jul-2018
  • (2018)Gradually typed symbolic expressionsProceedings of the ACM SIGPLAN Workshop on Partial Evaluation and Program Manipulation - PEPM '1810.1145/3175493.3162068(15-29)Online publication date: 2018
  • (2017)Gradually typed symbolic expressionsProceedings of the ACM SIGPLAN Workshop on Partial Evaluation and Program Manipulation10.1145/3162068(15-29)Online publication date: 25-Dec-2017
  • (2017)Staged generic programmingProceedings of the ACM on Programming Languages10.1145/31102731:ICFP(1-29)Online publication date: 29-Aug-2017
  • (2015)Modular reifiable matching: a list-of-functors approach to two-level typesACM SIGPLAN Notices10.1145/2887747.280431550:12(82-93)Online publication date: 30-Aug-2015
  • (2015)Scrap your boilerplate with object algebrasACM SIGPLAN Notices10.1145/2858965.281427950:10(127-146)Online publication date: 23-Oct-2015
  • (2015)Scrap your boilerplate with object algebrasProceedings of the 2015 ACM SIGPLAN International Conference on Object-Oriented Programming, Systems, Languages, and Applications10.1145/2814270.2814279(127-146)Online publication date: 23-Oct-2015
  • (2015)Modular reifiable matching: a list-of-functors approach to two-level typesProceedings of the 2015 ACM SIGPLAN Symposium on Haskell10.1145/2804302.2804315(82-93)Online publication date: 30-Aug-2015
  • 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

Media

Figures

Other

Tables

Share

Share

Share this Publication link

Share on social media