When Is a Container a Comonad?

  • Danel Ahman
  • James Chapman
  • Tarmo Uustalu
Conference paper

DOI: 10.1007/978-3-642-28729-9_5

Part of the Lecture Notes in Computer Science book series (LNCS, volume 7213)
Cite this paper as:
Ahman D., Chapman J., Uustalu T. (2012) When Is a Container a Comonad?. In: Birkedal L. (eds) Foundations of Software Science and Computational Structures. FoSSaCS 2012. Lecture Notes in Computer Science, vol 7213. Springer, Berlin, Heidelberg

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.

Download to read the full conference paper text

Copyright information

© Springer-Verlag Berlin Heidelberg 2012

Authors and Affiliations

  • Danel Ahman
    • 1
  • James Chapman
    • 2
  • Tarmo Uustalu
    • 2
  1. 1.Computer LaboratoryUniversity of CambridgeCambridgeUnited Kingdom
  2. 2.Institute of CyberneticsTallinn University of TechnologyTallinnEstonia

Personalised recommendations