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.
Chapter PDF
References
Abbott, M., Altenkirch, T., Ghani, N.: Containers: Constructing strictly positive types. Theor. Comput. Sci. 342(1), 3–27 (2005)
Abbott, M., Altenkirch, T., Ghani, N., McBride, C.: Constructing Polymorphic Programs with Quotient Types. In: Kozen, D. (ed.) MPC 2004. LNCS, vol. 3125, pp. 2–15. Springer, Heidelberg (2004)
Abbott, M., Altenkirch, T., Ghani, N., McBride, C.: δ for data: Differentiating data structures. Fund. Inform. 65(1-2), 1–28 (2005)
Abbott, M.: Categories of Containers. Ph.D. thesis, University of Leicester (2003)
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)
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)
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)
Dybjer, P.: Representing inductively defined sets by wellorderings in Martin-Löf’s type theory. Theor. Comput. Sci. 176(1-2), 329–335 (1997)
Gambino, N., Hyland, M.: Wellfounded Trees and Dependent Polynomial Functors. In: Berardi, S., Coppo, M., Damiani, F. (eds.) TYPES 2003. LNCS, vol. 3085, pp. 210–225. Springer, Heidelberg (2004)
Gambino, N., Kock, J.: Polynomial functors and polynomial monads. Tech. Rep. 867, Centre de Recerca Matemàtica, Barcelona (2009)
Girard, J.Y.: Normal functors, power series and lambda-calculus. Ann. of Pure and Appl. Logic 37(2), 129–177 (1988)
Hasuo, I., Jacobs, B., Uustalu, T.: Categorical Views on Computations on Trees. In: Arge, L., Cachin, C., Jurdziński, T., Tarlecki, A. (eds.) ICALP 2007. LNCS, vol. 4596, pp. 619–630. Springer, Heidelberg (2007)
Huet, G.: The zipper. J. of Funct. Program. 7, 549–554 (1997)
Joyal, A.: Foncteurs analytiques et espèces de structures. In: Labelle, G., Leroux, P. (eds.) Combinatoire énumerative. Lect. Notes in Math., vol. 1234, pp. 126–159. Springer, Heidelberg (1987)
Kock, J.: Polynomial functors and trees. Int. Math. Research Notices 2011(3), 609–673 (2011)
Moerdijk, I., Palmgren, E.: Wellfounded trees in categories. Ann. of Pure and Appl. Logic 104(1-3), 189–218 (2000)
Morris, P.: Constructing Universes for Generic Programming. Ph.D. thesis, University of Nottingham (2007)
Norell, U.: Towards a Practical Programming Language Based on Dependent type Theory. Ph.D. thesis, Chalmers University of Technology (2007)
Prince, R., Ghani, N., McBride, C.: Proving Properties about Lists using Containers. In: Garrigue, J., Hermenegildo, M. (eds.) FLOPS 2008. LNCS, vol. 4989, pp. 97–112. Springer, Heidelberg (2008)
Uustalu, T., Vene, V.: The Essence of Dataflow Programming. In: Yi, K. (ed.) APLAS 2005. LNCS, vol. 3780, pp. 2–18. Springer, Heidelberg (2005)
Uustalu, T., Vene, V.: Attribute evaluation is comonadic. In: van Eekelen, M. (ed.) Trends in Functional Programming, vol. 6, pp. 145–162. Intellect (2007)
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)
Author information
Authors and Affiliations
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2012 Springer-Verlag Berlin Heidelberg
About this paper
Cite this paper
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. https://doi.org/10.1007/978-3-642-28729-9_5
Download citation
DOI: https://doi.org/10.1007/978-3-642-28729-9_5
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-642-28728-2
Online ISBN: 978-3-642-28729-9
eBook Packages: Computer ScienceComputer Science (R0)