# compdata: Compositional Data Types

This library implements the ideas of Data types a la carte as outlined in the paper Compositional data types. The purpose of this library is to allow the programmer to construct data types -- as well as the functions defined on them -- in a modular fashion. The underlying idea is to separate the signature of a data type from the fixed point construction that produces its recursive structure. Signatures can then be composed and decomposed freely.

Building on that foundation, this library provides additional
extensions and (run-time) optimisations which make compositional data types
usable for practical implementations. In particular, it
provides an excellent framework for manipulating and analysing
abstract syntax trees in a type-safe manner. Thus, it is perfectly
suited for programming language implementations, especially, in an environment
consisting of a family of tightly interwoven *domain-specific languages*.

In concrete terms, this library provides the following features:

Compositional data types in the style of Wouter Swierstra's Functional Pearl

*Data types a la carte*. The implementation of signature subsumption is based on the paper*Composing and Decomposing Data Types*(Workshop on Generic Programming, 2014, to appear), which makes signature composition more flexible.Modular definition of functions on compositional data types through catamorphisms and anamorphisms as well as more structured recursion schemes such as primitive recursion and co-recursion, and course-of-value iteration and co-iteration.

Support for monadic computations via monadic variants of all recursion schemes.

Support of a succinct programming style over compositional data types via generic programming combinators that allow various forms of generic transformations and generic queries.

Generalisation of compositional data types (terms) to compositional data types "with holes" (contexts). This allows flexible reuse of a wide variety of catamorphisms (called

*term homomorphisms*) as well as an efficient composition of them.Operations on signatures, for example, to add and remove annotations of abstract syntax trees. This includes combinators to propagate annotations fully automatically through certain term homomorphisms.

Optimisation of the implementation of recursion schemes. This includes

*short-cut fusion*style optimisation rules which yield a performance boost of up to factor six.Automatic derivation of instances of all relevant type classes for using compositional data types via

*Template Haskell*. This includes instances of`Prelude.Eq`

,`Prelude.Ord`

and`Prelude.Show`

that are derived via instances for functorial variants of them. Additionally, also*smart constructors*, which allow to easily construct inhabitants of compositional data types, are automatically generated.*Mutually recursive data types*and*generalised algebraic data types (GADTs)*. All of the above is also lifted to families of mutually recursive data types and (more generally) GADTs. This extension resides in the module Data.Comp.Multi.

Examples of using (generalised) compositional data types are bundled
with the package in the folder `examples`

.

There are some supplementary packages, some of which were included in previous versions of this package:

compdata-param: a parametric variant of compositional data types to deal with variable binders in a systematic way.

compdata-automata: advanced recursion schemes derived from tree automata that allow for a higher degree of modularity and make it possible to apply fusion.

compdata-dags: recursion schemes on directed acyclic graphs.

## Modules

[Index] [Quick Jump]

*Data*- Data.Comp
- Data.Comp.Algebra
- Data.Comp.Annotation
- Data.Comp.Arbitrary
- Data.Comp.Decompose
- Data.Comp.DeepSeq
- Data.Comp.Derive
- Data.Comp.Desugar
- Data.Comp.Equality
- Data.Comp.Generic
- Data.Comp.Mapping
- Data.Comp.Matching
- Data.Comp.Multi
- Data.Comp.Multi.Algebra
- Data.Comp.Multi.Annotation
- Data.Comp.Multi.Derive
- Data.Comp.Multi.Desugar
- Data.Comp.Multi.Equality
- Data.Comp.Multi.Generic
- Data.Comp.Multi.HFoldable
- Data.Comp.Multi.HFunctor
- Data.Comp.Multi.HTraversable
- Data.Comp.Multi.Mapping
- Data.Comp.Multi.Ops
- Data.Comp.Multi.Ordering
- Data.Comp.Multi.Projection
- Data.Comp.Multi.Show
- Data.Comp.Multi.Sum
- Data.Comp.Multi.Term
- Data.Comp.Multi.Variables

- Data.Comp.Ops
- Data.Comp.Ordering
- Data.Comp.Projection
- Data.Comp.Render
- Data.Comp.Show
- Data.Comp.Sum
- Data.Comp.Term
- Data.Comp.TermRewriting
- Data.Comp.Thunk
- Data.Comp.Unification
- Data.Comp.Variables

- Data.Comp

## Downloads

- compdata-0.13.1.tar.gz [browse] (Cabal source package)
- Package description (revised from the package)

Note: This package has metadata revisions in the cabal description newer than included in the tarball. To unpack the package including the revisions, use 'cabal get'.

#### Maintainer's Corner

For package maintainers and hackage trustees

Candidates

- No Candidates

Versions [RSS] | 0.1, 0.2, 0.3, 0.4, 0.4.1, 0.5, 0.5.1, 0.5.2, 0.5.3, 0.6, 0.6.1, 0.6.1.1, 0.6.1.2, 0.6.1.3, 0.6.1.4, 0.7, 0.7.0.1, 0.7.0.2, 0.8, 0.8.0.1, 0.8.1.0, 0.8.1.1, 0.8.1.2, 0.8.1.3, 0.9, 0.10, 0.10.1, 0.11, 0.12, 0.12.1, 0.13.0, 0.13.1 |
---|---|

Change log | CHANGELOG.md |

Dependencies | base (>=4.16 && <4.20), containers (>=0.6.5 && <0.8), deepseq (>=1.4 && <1.6), mtl (>=2.2.2 && <2.4), QuickCheck (>=2.14.3 && <2.15), template-haskell (>=2.17 && <2.22), th-expand-syns (>=0.4.11 && <0.5), transformers (>=0.5.6 && <0.7), tree-view (>=0.5.1 && <0.6) [details] |

License | BSD-3-Clause |

Author | Patrick Bahr, Tom Hvitved |

Maintainer | paba@itu.dk |

Revised | Revision 1 made by PatrickBahr at 2023-10-20T15:42:21Z |

Category | Generics |

Bug tracker | https://github.com/pa-ba/compdata/issues |

Source repo | head: git clone https://github.com/pa-ba/compdata |

Uploaded | by PatrickBahr at 2023-10-16T18:01:03Z |

Distributions | LTSHaskell:0.13.1, NixOS:0.13.1, Stackage:0.13.1 |

Reverse Dependencies | 11 direct, 4 indirect [details] |

Downloads | 26309 total (145 in the last 30 days) |

Rating | (no votes yet) [estimated by Bayesian average] |

Your Rating | |

Status | Docs available [build log] Last success reported on 2023-10-16 [all 1 reports] |