Parametric Compositional Data Types
Patrick Bahr (Department of Computer Science, University of, Copenhagen), Tom Hvitved (Department of Computer Science, University of, Copenhagen)

TL;DR
This paper enhances compositional data types (CDTs) in Haskell by integrating parametric higher-order abstract syntax (PHOAS) through difunctors, enabling modular, extendable AST manipulation with variable binders without exotic terms.
Contribution
It introduces a novel combination of CDTs with PHOAS via difunctors, improving modularity and handling variable binders without exotic terms.
Findings
Enables modular AST transformations with variable binders
Maintains CDT features while integrating PHOAS
Avoids exotic terms without abstract types
Abstract
In previous work we have illustrated the benefits that compositional data types (CDTs) offer for implementing languages and in general for dealing with abstract syntax trees (ASTs). Based on Swierstra's data types \'a la carte, CDTs are implemented as a Haskell library that enables the definition of recursive data types and functions on them in a modular and extendable fashion. Although CDTs provide a powerful tool for analysing and manipulating ASTs, they lack a convenient representation of variable binders. In this paper we remedy this deficiency by combining the framework of CDTs with Chlipala's parametric higher-order abstract syntax (PHOAS). We show how a generalisation from functors to difunctors enables us to capture PHOAS while still maintaining the features of the original implementation of CDTs, in particular its modularity. Unlike previous approaches, we avoid so-called…
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Videos
No videos yet. Explain this paper in a talk, walkthrough, or lecture? Add one.
