When Is a Container a Comonad?
- 696 Downloads
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.
- 4.Abbott, M.: Categories of Containers. Ph.D. thesis, University of Leicester (2003)Google Scholar
- 5.Altenkirch, T., Morris, P.: Indexed containers. In: Proc. of 24th Ann. IEEE Symp. on Logic in Computer Science, LICS 2009, pp. 277–285. IEEE CS Press (2009)Google Scholar
- 6.Brookes, S., Geva, S.: Computational comonads and intensional semantics. In: Fourman, M.P., Johnstone, P.T., Pitts, A.M. (eds.) Applications of Categories in Computer Science, London. Math. Society Lect. Note Series, vol. 77, pp. 1–44. Cambridge Univ. Press (1992)Google Scholar
- 7.Capobianco, S., Uustalu, T.: A categorical outlook on cellular automata. In: Kari, J. (ed.) Proc. of 2nd Symp. on Cellular Automata, JAC 2010. TUCS Lecture Note Series, vol. 13, pp. 88–89. Turku Centre for Comput. Sci. (2011)Google Scholar
- 10.Gambino, N., Kock, J.: Polynomial functors and polynomial monads. Tech. Rep. 867, Centre de Recerca Matemàtica, Barcelona (2009)Google Scholar
- 17.Morris, P.: Constructing Universes for Generic Programming. Ph.D. thesis, University of Nottingham (2007)Google Scholar
- 18.Norell, U.: Towards a Practical Programming Language Based on Dependent type Theory. Ph.D. thesis, Chalmers University of Technology (2007)Google Scholar
- 21.Uustalu, T., Vene, V.: Attribute evaluation is comonadic. In: van Eekelen, M. (ed.) Trends in Functional Programming, vol. 6, pp. 145–162. Intellect (2007)Google Scholar
- 22.Uustalu, T., Vene, V.: Comonadic notions of computation. In: Adámek, J., Kupke, C. (eds.) Proc. of 9th Int. Wksh. on Coalgebraic Methods in Computer Science, CMCS 2008. Electron. Notes in Theor. Comput. Sci., vol. 203(5), pp. 263–284. Elsevier (2008)Google Scholar