A Formal Comparison of Approaches to Datatype-Generic Programming

Datatype-generic programming increases program abstraction and reuse by making functions operate uniformly across different types. Many approaches to generic programming have been proposed over the years, most of them for Haskell, but recently also for dependently typed languages such as Agda. Diffe...

Full description

Saved in:
Bibliographic Details
Published in:Electronic proceedings in theoretical computer science Vol. 76; no. Proc. MSFP 2012; pp. 50 - 67
Main Authors: Magalhães, José Pedro, Löh, Andres
Format: Journal Article
Language:English
Published: Open Publishing Association 11.02.2012
ISSN:2075-2180, 2075-2180
Online Access:Get full text
Tags: Add Tag
No Tags, Be the first to tag this record!
Abstract Datatype-generic programming increases program abstraction and reuse by making functions operate uniformly across different types. Many approaches to generic programming have been proposed over the years, most of them for Haskell, but recently also for dependently typed languages such as Agda. Different approaches vary in expressiveness, ease of use, and implementation techniques. Some work has been done in comparing the different approaches informally. However, to our knowledge there have been no attempts to formally prove relations between different approaches. We thus present a formal comparison of generic programming libraries. We show how to formalise different approaches in Agda, including a coinductive representation, and then establish theorems that relate the approaches to each other. We provide constructive proofs of inclusion of one approach in another that can be used to convert between approaches, helping to reduce code duplication across different libraries. Our formalisation also helps in providing a clear picture of the potential of each approach, especially in relating different generic views and their expressiveness.
AbstractList Datatype-generic programming increases program abstraction and reuse by making functions operate uniformly across different types. Many approaches to generic programming have been proposed over the years, most of them for Haskell, but recently also for dependently typed languages such as Agda. Different approaches vary in expressiveness, ease of use, and implementation techniques. Some work has been done in comparing the different approaches informally. However, to our knowledge there have been no attempts to formally prove relations between different approaches. We thus present a formal comparison of generic programming libraries. We show how to formalise different approaches in Agda, including a coinductive representation, and then establish theorems that relate the approaches to each other. We provide constructive proofs of inclusion of one approach in another that can be used to convert between approaches, helping to reduce code duplication across different libraries. Our formalisation also helps in providing a clear picture of the potential of each approach, especially in relating different generic views and their expressiveness.
Author Magalhães, José Pedro
Löh, Andres
Author_xml – sequence: 1
  givenname: José Pedro
  surname: Magalhães
  fullname: Magalhães, José Pedro
– sequence: 2
  givenname: Andres
  surname: Löh
  fullname: Löh, Andres
BookMark eNpNkE1rwkAURYdioda66S-YdSF2Mp-ZZUjVCkKF2vUwnzZiMmGSjf--UUvp27zHvXB4nEcwaWPrAXjO0YJiRF-Xu331uRB8we_AFCPBMpwXaPLvfgDzvj-icYjEVPIpKEu4iqnRJ1jFptOp7mMLY4Bl16Wo7bfv4RDhmx70cO58tvatT7WFuxQPSTdN3R6ewH3Qp97Pf_cMfK2W--o9236sN1W5zSxmfMh0YazIqXC5wUxKSQhxBnmJjEOcGh64R44g6hgN47--cObSI2mwk66wZAY2N66L-qi6VDc6nVXUtboGMR2UTkNtT14FZih2gtngBBU5NpYyj4QurPWCyTCyXm4sm2LfJx_-eDlSF5fq6lIJrjj5AVPDaFU
Cites_doi 10.4204/EPTCS.43.2
10.1007/978-3-540-76786-2_2
10.1145/2103786.2103795
10.1145/581690.581698
10.1145/263699.263763
10.1007/978-3-642-04652-0_5
10.1145/1863543.1863547
10.1007/11737414_3
10.1145/1706356.1706366
10.1017/S0956796803000315
10.1007/978-3-642-13321-3_8
10.1145/1596550.1596585
10.1017/S0956796811000098
10.1017/S0956796810000158
10.1007/11783596_14
10.1145/1411318.1411321
10.1017/S0956796810000183
10.1145/2036918.2036920
10.1017/S0956796809007345
10.1007/3540543961_7
10.1145/1707790.1707799
10.1007/BFb0054285
10.1145/1411286.1411301
10.1017/S0956796806006022
10.1007/978-3-540-76786-2_1
10.1016/j.scico.2007.10.006
10.1145/1863523.1863529
ContentType Journal Article
DBID AAYXX
CITATION
DOA
DOI 10.4204/EPTCS.76.6
DatabaseName CrossRef
Directory of Open Access Journals (DOAJ)
DatabaseTitle CrossRef
DatabaseTitleList
Database_xml – sequence: 1
  dbid: DOA
  name: DOAJ Directory of Open Access Journals
  url: https://www.doaj.org/
  sourceTypes: Open Website
DeliveryMethod fulltext_linktorsrc
Discipline Computer Science
EISSN 2075-2180
EndPage 67
ExternalDocumentID oai_doaj_org_article_f5b42d75cfd74712bc45e07a8cce759f
10_4204_EPTCS_76_6
GroupedDBID 5VS
AAYXX
ADBBV
ALMA_UNASSIGNED_HOLDINGS
BCNDV
CITATION
E3Z
GROUPED_DOAJ
KQ8
M~E
OK1
ID FETCH-LOGICAL-c256t-a8bc7147d1b25999333db0e90bd064b6f6e0d304d54f207e8dbdb0e09b2d9d8c3
IEDL.DBID DOA
ISICitedReferencesCount 5
ISICitedReferencesURI http://www.webofscience.com/api/gateway?GWVersion=2&SrcApp=Summon&SrcAuth=ProQuest&DestLinkType=CitingArticles&DestApp=WOS_CPL&KeyUT=000219685700007&url=https%3A%2F%2Fcvtisr.summon.serialssolutions.com%2F%23%21%2Fsearch%3Fho%3Df%26include.ft.matches%3Dt%26l%3Dnull%26q%3D
ISSN 2075-2180
IngestDate Fri Oct 03 12:36:37 EDT 2025
Sat Nov 29 02:04:59 EST 2025
IsDoiOpenAccess true
IsOpenAccess true
IsPeerReviewed false
IsScholarly true
Issue Proc. MSFP 2012
Language English
LinkModel DirectLink
MergedId FETCHMERGED-LOGICAL-c256t-a8bc7147d1b25999333db0e90bd064b6f6e0d304d54f207e8dbdb0e09b2d9d8c3
OpenAccessLink https://doaj.org/article/f5b42d75cfd74712bc45e07a8cce759f
PageCount 18
ParticipantIDs doaj_primary_oai_doaj_org_article_f5b42d75cfd74712bc45e07a8cce759f
crossref_primary_10_4204_EPTCS_76_6
PublicationCentury 2000
PublicationDate 2012-02-11
PublicationDateYYYYMMDD 2012-02-11
PublicationDate_xml – month: 02
  year: 2012
  text: 2012-02-11
  day: 11
PublicationDecade 2010
PublicationTitle Electronic proceedings in theoretical computer science
PublicationYear 2012
Publisher Open Publishing Association
Publisher_xml – name: Open Publishing Association
References Ralf Hinze (HinzeJeuringLoh:2007) 2007; 4719
José Pedro Magalhães (jpm:ogie:10) 2010
Ralf Hinze (GP3D) 2009; 74
Ulf Norell (norell2009dependently) 2009; 5832
José Pedro Magalhães (jpm:gdmh:10) 2010
Stefan Holdermans (GenericViews) 2006; 4014
Jeremy Gibbons (Gibbons2007:Datatype) 2007; 4719
Patrik Jansson (polyp) 1997
Stephanie Weirich (arity) 2010
Andreas Abel (MiniAgda) 2010
Nils Anders Danielsson (subtyping) 2010; 6120
Ralf Hinze (GM) 2006; 16
(haskellbook) 2003
Alexey Rodriguez Yakushev (multirec) 2009
Wendy Verbruggen (formalGH) 2010; 20
Dimitrios Vytiniotis (OutsideIn) 2011; 21
Thomas van Noort (1411321) 2008
James Chapman (levitation) 2010
Brent A. Yorgey (jpm:ghp:12) 2012
Andres Löh (jpm:gpif:11) 2011
Erik Meijer (bananas) 1991; 523
Thomas van Noort (jpm:ladgr:10) 2010; 20
Andres Löh (exploringGH) 2004
Shin-Cheng Mu (AoPA) 2009; 19
Ralf Hinze (SYBreloaded) 2006; 3945
Richard Bird (nested) 1998; 1422
Alexey Rodriguez Yakushev (UUCS2008010) 2008
James Cheney (LIGD) 2002
References_xml – volume-title: Proceedings Workshop on Partiality and Recursion in Interactive Theorem Provers
  year: 2010
  ident: MiniAgda
  article-title: MiniAgda: Integrating Sized and Dependent Types
  doi: 10.4204/EPTCS.43.2
– volume: 4719
  start-page: 72
  volume-title: Datatype-Generic Programming
  year: 2007
  ident: HinzeJeuringLoh:2007
  article-title: Comparing Approches to Generic Programming in Haskell
  doi: 10.1007/978-3-540-76786-2_2
– start-page: 53
  volume-title: Proceedings of the ACM SIGPLAN Workshop on Types in Language Design and Implementation
  year: 2012
  ident: jpm:ghp:12
  article-title: Giving Haskell a Promotion
  doi: 10.1145/2103786.2103795
– volume-title: Exploring Generic Haskell
  year: 2004
  ident: exploringGH
– start-page: 90
  volume-title: Proceedings of the ACM SIGPLAN Workshop on Haskell
  year: 2002
  ident: LIGD
  article-title: A lightweight implementation of generics and dynamics
  doi: 10.1145/581690.581698
– start-page: 470
  volume-title: Proceedings of the ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages
  year: 1997
  ident: polyp
  article-title: PolyP—a polytypic programming language extension
  doi: 10.1145/263699.263763
– volume: 5832
  start-page: 230
  volume-title: Advanced Functional Programming, 6th International School, AFP 2008, Revised Lectures
  year: 2009
  ident: norell2009dependently
  article-title: Dependently typed programming in Agda
  doi: 10.1007/978-3-642-04652-0_5
– start-page: 3
  volume-title: Proceedings of the ACM SIGPLAN International Conference on Functional Programming
  year: 2010
  ident: levitation
  article-title: The gentle art of levitation
  doi: 10.1145/1863543.1863547
– volume: 3945
  start-page: 13
  volume-title: Functional and Logic Programming
  year: 2006
  ident: SYBreloaded
  article-title: ``Scrap Your Boilerplate'' Reloaded
  doi: 10.1007/11737414_3
– start-page: 33
  volume-title: Proceedings of the ACM SIGPLAN Workshop on Partial Evaluation and Program Manipulation
  year: 2010
  ident: jpm:ogie:10
  article-title: Optimizing Generics Is Easy!
  doi: 10.1145/1706356.1706366
– volume-title: Haskell 98, Language and Libraries. The Revised Report
  year: 2003
  ident: haskellbook
  doi: 10.1017/S0956796803000315
– volume: 6120
  start-page: 100
  volume-title: Mathematics of Program Construction
  year: 2010
  ident: subtyping
  article-title: Subtyping, Declaratively
  doi: 10.1007/978-3-642-13321-3_8
– start-page: 233
  volume-title: Proceedings of the ACM SIGPLAN International Conference on Functional Programming
  year: 2009
  ident: multirec
  article-title: Generic programming with fixed points for mutually recursive datatypes
  doi: 10.1145/1596550.1596585
– volume: 21
  start-page: 333
  year: 2011
  ident: OutsideIn
  article-title: OutsideIn(X)—Modular type inference with local assumptions
  publication-title: Journal of Functional Programming
  doi: 10.1017/S0956796811000098
– volume: 20
  start-page: 213
  year: 2010
  ident: formalGH
  article-title: Formal polytypic programs and proofs
  publication-title: Journal of Functional Programming
  doi: 10.1017/S0956796810000158
– volume: 4014
  start-page: 209
  volume-title: Mathematics of Program Construction
  year: 2006
  ident: GenericViews
  article-title: Generic Views on Data Types
  doi: 10.1007/11783596_14
– start-page: 13
  volume-title: Proceedings of the ACM SIGPLAN Workshop on Generic Programming
  year: 2008
  ident: 1411321
  article-title: A lightweight approach to datatype-generic rewriting
  doi: 10.1145/1411318.1411321
– volume: 20
  start-page: 375
  year: 2010
  ident: jpm:ladgr:10
  article-title: A lightweight approach to datatype-generic rewriting
  publication-title: Journal of Functional Programming
  doi: 10.1017/S0956796810000183
– start-page: 1
  volume-title: Proceedings of the ACM SIGPLAN Workshop on Generic Programming
  year: 2011
  ident: jpm:gpif:11
  article-title: Generic programming with indexed functors
  doi: 10.1145/2036918.2036920
– volume: 19
  start-page: 545
  year: 2009
  ident: AoPA
  article-title: Algebra of programming in Agda: Dependent types for relational program derivation
  publication-title: Journal of Functional Programming
  doi: 10.1017/S0956796809007345
– volume: 523
  start-page: 124
  volume-title: Functional Programming Languages and Computer Architecture
  year: 1991
  ident: bananas
  article-title: Functional programming with bananas, lenses, envelopes and barbed wire
  doi: 10.1007/3540543961_7
– start-page: 15
  volume-title: Proceedings of the ACM SIGPLAN Workshop on Programming Languages meets Program Verification
  year: 2010
  ident: arity
  article-title: Arity-generic datatype-generic programming
  doi: 10.1145/1707790.1707799
– volume: 1422
  start-page: 52
  volume-title: Mathematics of Program Construction
  year: 1998
  ident: nested
  article-title: Nested datatypes
  doi: 10.1007/BFb0054285
– start-page: 111
  volume-title: Proceedings of the ACM SIGPLAN Symposium on Haskell
  year: 2008
  ident: UUCS2008010
  article-title: Comparing libraries for generic programming in Haskell
  doi: 10.1145/1411286.1411301
– volume: 16
  start-page: 451
  year: 2006
  ident: GM
  article-title: Generics for the Masses
  publication-title: Journal of Functional Programming
  doi: 10.1017/S0956796806006022
– volume: 4719
  start-page: 1
  volume-title: Spring School on Datatype-Generic Programming
  year: 2007
  ident: Gibbons2007:Datatype
  article-title: Datatype-Generic Programming
  doi: 10.1007/978-3-540-76786-2_1
– volume: 74
  start-page: 590
  year: 2009
  ident: GP3D
  article-title: Generic programming in 3D
  publication-title: Science of Computer Programming
  doi: 10.1016/j.scico.2007.10.006
– start-page: 37
  volume-title: Proceedings of the ACM Symposium on Haskell
  year: 2010
  ident: jpm:gdmh:10
  article-title: A generic deriving mechanism for Haskell
  doi: 10.1145/1863523.1863529
SSID ssj0000392496
Score 1.8567214
Snippet Datatype-generic programming increases program abstraction and reuse by making functions operate uniformly across different types. Many approaches to generic...
SourceID doaj
crossref
SourceType Open Website
Index Database
StartPage 50
Title A Formal Comparison of Approaches to Datatype-Generic Programming
URI https://doaj.org/article/f5b42d75cfd74712bc45e07a8cce759f
Volume 76
WOSCitedRecordID wos000219685700007&url=https%3A%2F%2Fcvtisr.summon.serialssolutions.com%2F%23%21%2Fsearch%3Fho%3Df%26include.ft.matches%3Dt%26l%3Dnull%26q%3D
hasFullText 1
inHoldings 1
isFullTextHit
isPrint
journalDatabaseRights – providerCode: PRVAON
  databaseName: DOAJ Directory of Open Access Journals
  customDbUrl:
  eissn: 2075-2180
  dateEnd: 20201231
  omitProxy: false
  ssIdentifier: ssj0000392496
  issn: 2075-2180
  databaseCode: DOA
  dateStart: 20090101
  isFulltext: true
  titleUrlDefault: https://www.doaj.org/
  providerName: Directory of Open Access Journals
– providerCode: PRVHPJ
  databaseName: ROAD: Directory of Open Access Scholarly Resources
  customDbUrl:
  eissn: 2075-2180
  dateEnd: 99991231
  omitProxy: false
  ssIdentifier: ssj0000392496
  issn: 2075-2180
  databaseCode: M~E
  dateStart: 20090101
  isFulltext: true
  titleUrlDefault: https://road.issn.org
  providerName: ISSN International Centre
link http://cvtisr.summon.serialssolutions.com/2.0.0/link/0/eLvHCXMwrV09a8MwEBUldOjS79JvBO2qRLZlyxrdNKFLQ6ApZDOWToJAm5TE7djf3pPshHTq0sXgD4x1Z997D87vCLmH1FXgjGUKuGWI14ZpLnE3MmCjyAkhqzBsQo5G-XSqxlujvnxPWGMP3ASu51ItYpCpceD1U6yNSC2XVW6MlalyvvpyqbbEVKjBidcVYbIcYiJDHOONN6mIuegNxpP-S1dm3ewXGm2Z9gd0GR6S_ZYW0qJ5nCOyY-fH5GA9coG2X-AJKQo69CzzjfY3AwTpwtGitQa3K1ov6GOFFBIFJgum0jNDx00X1jvi1Cl5HQ4m_SfWTkFgBulIzapcGxkJCZFGqYJ0IklAc6u4BqQTOnOZ5ZBwAalwuFibg_bnudIxKMhNckY688XcnhMqwUqtrP8rMBOSY82tHLcoQAyIiht7Qe7W0Sg_GrOLEkWCj1kZYlbKrMwuyIMP1OYKb1AdDmDayjZt5V9pu_yPm1yRPeQvsW-ijqJr0qmXn_aG7JqverZa3oY3ArfP34Mfe3O9bg
linkProvider Directory of Open Access Journals
openUrl ctx_ver=Z39.88-2004&ctx_enc=info%3Aofi%2Fenc%3AUTF-8&rfr_id=info%3Asid%2Fsummon.serialssolutions.com&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&rft.genre=article&rft.atitle=A+Formal+Comparison+of+Approaches+to+Datatype-Generic+Programming&rft.jtitle=Electronic+proceedings+in+theoretical+computer+science&rft.au=Jos%C3%A9+Pedro+Magalh%C3%A3es&rft.au=Andres+L%C3%B6h&rft.date=2012-02-11&rft.pub=Open+Publishing+Association&rft.issn=2075-2180&rft.eissn=2075-2180&rft.volume=76&rft.issue=Proc.+MSFP+2012&rft.spage=50&rft.epage=67&rft_id=info:doi/10.4204%2FEPTCS.76.6&rft.externalDBID=DOA&rft.externalDocID=oai_doaj_org_article_f5b42d75cfd74712bc45e07a8cce759f
thumbnail_l http://covers-cdn.summon.serialssolutions.com/index.aspx?isbn=/lc.gif&issn=2075-2180&client=summon
thumbnail_m http://covers-cdn.summon.serialssolutions.com/index.aspx?isbn=/mc.gif&issn=2075-2180&client=summon
thumbnail_s http://covers-cdn.summon.serialssolutions.com/index.aspx?isbn=/sc.gif&issn=2075-2180&client=summon