Skip to main content



When Is a Container a Comonad?

Danel Ahman, James Chapman, and Tarmo Uustalu

Presented by Andrew K. Hirsch on April 8, 2016

Note

This is about the same paper that Andrew is presenting at PLDG this week. We'll try to go into some more technical depth, reading sections 2.2-2.4, 3.2-3.4, and 5. It would be good if people were at the PLDG talk to have an intuition for what is going on, as well as come prepared to talk about the more interesting technical details.

Abstract

Abbott, Altenkirch, Ghani and others have taught us that many parameterized datatypes (set functors) can be usefully analyzed via container representations in terms of a set of shapes and a set of positions in each shape. This paper builds on the observation that datatypes often carry additional structure that containers alone do not account for. We introduce directed containers to capture the common situation where every position in a datastructure determines another datastructure, informally, the sub-datastructure rooted by that position. Some natural examples are non-empty lists and node-labelled trees, and datastructures with a designated position (zippers). While containers denote set functors via a fully-faithful functor, directed containers interpret fully-faithfully into comonads. But more is true: every comonad whose underlying functor is a container is represented by a directed container. In fact, directed containers are the same as containers that are comonads. We also describe some constructions of directed containers. We have formalized our development in the dependently typed programming language Agda.

PDF@SpringerLink