ABSTRACT
Effects and coeffects are two general, complementary aspects of program behaviour. They roughly correspond to computations which change the execution context (effects) versus computations which make demands on the context (coeffects). Effectful features include partiality, non-determinism, input-output, state, and exceptions. Coeffectful features include resource demands, variable access, notions of linearity, and data input requirements. The effectful or coeffectful behaviour of a program can be captured and described via type-based analyses, with fine grained information provided by monoidal effect annotations and semiring coeffects. Various recent work has proposed models for such typed calculi in terms of graded (strong) monads for effects and graded (monoidal) comonads for coeffects. Effects and coeffects have been studied separately so far, but in practice many computations are both effectful and coeffectful, e.g., possibly throwing exceptions but with resource requirements. To remedy this, we introduce a new general calculus with a combined effect-coeffect system. This can describe both the changes and requirements that a program has on its context, as well as interactions between these effectful and coeffectful features of computation. The effect-coeffect system has a denotational model in terms of effect-graded monads and coeffect-graded comonads where interaction is expressed via the novel concept of graded distributive laws. This graded semantics unifies the syntactic type theory with the denotational model. We show that our calculus can be instantiated to describe in a natural way various different kinds of interaction between a program and its evaluation context.
- M. Abadi, A. Banerjee, N. Heintze, and J. Riecke. A core calculus of dependency. In POPL ’99, pp. 147–160. ACM, 1999. Google ScholarDigital Library
- D. Ahman and T. Uustalu. Distributive laws of directed containers. Progr. in Inf., 10, pp. 3–18, 2013.Google ScholarCross Ref
- D. Ahman and T. Uustalu. Update monads: cointerpreting directed containers. In TYPES 2013, v. 13 of Leibniz Int. Proc. in Comput. Sci., pp. 1–23. Dagstuhl Publishing, 2014.Google Scholar
- R. Atkey. Parameterised notions of computation. J. of Funct. Program., 19(3–4), pp. 335–376, 2009. Google ScholarDigital Library
- N. Benton, A. Kennedy, M. Hofmann, and V. Nigam. Counting successes: effects and transformations for non-deterministic programs. In A List of Successes That Can Change the World, v. 9600 of LNCS, pp. 56–72. Springer, 2016.Google Scholar
- F. Breuvart and M. Pagani. Modelling coeffects in the relational semantics of linear logic. In CSL 2015, v. 41 of Leibniz Int. Proc. in Comput. Sci., pp. 567–581. Dagstuhl Publishing, 2015.Google Scholar
- S. Brookes and K. V. Stone. Monads and comonads in intensional semantics. Techn. rep. CMU-CS-93-140. Carnegie-Mellon Univ., 1993. Google ScholarDigital Library
- A. Brunel, M. Gaboardi, D. Mazza, and S. Zdancewic. A core quantitative coeffect calculus. In ESOP 2014, v. 8410 of LNCS, pp. 351–370. Springer, 2014. Google ScholarDigital Library
- P. Curien, M. P. Fiore, and G. Munch-Maccagnoni. A theory of effects and resources: adjunction models and polarised calculi. In POPL ’16, pp. 44–56. ACM, 2016. Google ScholarDigital Library
- U. Dal Lago and M. Gaboardi. Linear dependent types and relative completeness. In LICS ’11, pp. 133–142. IEEE, 2011. Google ScholarDigital Library
- A. Filinski. Representing layered monads. In POPL ’99, pp. 175–188. ACM, 1999. Google ScholarDigital Library
- S. Fujii, S.-y. Katsumata, and P.-A. Melliès. Towards a formal theory of graded monads. In FoSSaCS 2016, v. 9634 of LNCS, pp. 513–530. Springer, 2016.Google Scholar
- M. Gaboardi, A. Haeberlen, J. Hsu, A. Narayan, and B. C. Pierce. Linear dependent types for differential privacy. In POPL ’13, pp. 357– 370. ACM, 2013. Google ScholarDigital Library
- M. Gaboardi, S. Katsumata, D. Orchard, F. Breuvart, T. Uustalu. Combining Effects and Coeffects via Grading: Technical Report http: //dx.doi.org/10.17863/CAM.730Google Scholar
- D. R. Ghica and A. I. Smith. Bounded linear types in a resource semiring. In ESOP 2014, v. 8410 of LNCS, pp. 331–350. Springer, 2014. Google ScholarDigital Library
- J. Gibbons. Comprehending ringads. In A List of Successes That Can Change the World, v. 9600 of LNCS, pp. 132–151. Springer, 2016.Google Scholar
- D. K. Gifford and J. M. Lucassen. Integrating functional and imperative programming. In LISP and Funct. Prog. ’86, pp. 28–38. ACM, 1986. Google ScholarDigital Library
- J.-Y. Girard. Linear logic. Theor. Comput. Sci., 50, pp. 1–102, 1987. Google ScholarDigital Library
- J.-Y. Girard, A. Scedrov, and P. J. Scott. Bounded linear logic: a modular approach to polynomial-time computability. Theor. Comput. Sci., 97(1), pp. 1–66, 1992. Google ScholarDigital Library
- R. Harmer, M. Hyland, and P.-A. Melliès. Categorical combinatorics for innocent strategies. In LICS ’07, pp. 379–388. IEEE, 2007. Google ScholarDigital Library
- M. Hicks, G. M. Bierman, N. Guts, D. Leijen, and N. Swamy. Polymonadic programming. In MSFP 2014, v. 153 of Electron. Proc. in Theor. Comput. Sci., pp. 79–99. Open Publ. Assoc., 2014.Google Scholar
- P. Jouvelot and D. Gifford. Algebraic reconstruction of types and effects. In POPL ’91, pp. 303–310. ACM, 1991. Google ScholarDigital Library
- C. Kassel. Quantum Groups. Graduate Texts in Mathematics. Springer, 1994.Google Scholar
- S. Katsumata. Parametric effect monads and semantics of effect systems. In POPL ’14, pp. 633–646. ACM, 2014. Google ScholarDigital Library
- J. Lucassen and D. Gifford. Polymorphic effect systems. In POPL ’98, pp. 47–57. ACM, 1988. Google ScholarDigital Library
- C. McBride. I Got Plenty o’ Nuttin’. In A List of Successes That Can Change the World, v. 9600 of LNCS, pp. 207–233. Springer, 2016.Google Scholar
- P. Melliès, N. Tabareau, and C. Tasson. An explicit formula for the free exponential modality of linear logic. In ICALP 2009, Part II, v. 5556 of LNCS, pp. 247–260. Springer, 2009. Google ScholarDigital Library
- P.-A. Melliès. Parametric monads and enriched adjunctions. Draft, 2012. http://www.pps.univ-paris-diderot.fr/~mellies/ tensorial-logic/.Google Scholar
- S. Milius, D. Pattinson, and L. Schröder. Generic trace semantics and graded monads. In CALCO 2015, v. 35 of Leibniz Int. Proc. in Comput. Sci., pp. 253–269. Dagstuhl Publishing, 2015.Google Scholar
- E. Moggi. Computational lambda-calculus and monads. In LICS ’89, pp. 14–23. IEEE, 1989. Google ScholarDigital Library
- E. Moggi. Notions of computation and monads. Inf. and Comput., 93(1), pp. 55–92, 1991. Google ScholarDigital Library
- A. Mycroft, D. Orchard, and T. Petricek. Effect systems revisited – control-flow algebra and semantics. In Semantics, Logics, and Calculi, v. 9560 of LNCS pp. 1–32. Springer, 2016. Google ScholarDigital Library
- A. Nanevski. From dynamic binding to state via modal possibility. In PPDP 2003, pp. 207–218. ACM, 2003. Google ScholarDigital Library
- A. Nanevski, F. Pfenning, and B. Pientka. Contextual modal type theory. ACM Trans. on Comput. Log., 9(3), article 23, 2008. Google ScholarDigital Library
- F. Nielson, H. R. Nielson, and C. L. Hankin. Principles of Program Analysis. Springer, 1999. Google ScholarDigital Library
- D. Orchard. Programming Contextual Computations. PhD thesis, Univ. of Cambridge, 2014.Google Scholar
- D. Orchard and T. Petricek. Embedding effect systems in Haskell. In Haskell 2014, pp. 13–24. ACM, 2014. Google ScholarDigital Library
- D. Orchard, T. Petricek, and A. Mycroft. The semantic marriage of monads and effects. arXiv preprint 1401.5391, 2014.Google Scholar
- T. Petricek. Context-Aware Programming Languages. Forthcoming PhD thesis, Univ. of Cambridge, 2016.Google Scholar
- T. Petricek, D. Orchard, and A. Mycroft. Coeffects: unified static analysis of context-dependence. In ICALP 2013, Part II, v. 7966 of LNCS, pp. 385–397. Springer, 2013. Google ScholarDigital Library
- T. Petricek, D. Orchard, and A. Mycroft. Coeffects: a calculus of context-dependent computation. In ICFP ’14, pp. 123–135. ACM, 2014. Google ScholarDigital Library
- G. Plotkin and J. Power. Adequacy for algebraic effects. In FOSSACS 2001, v. 2030 of LNCS, pp. 1–24. Springer, 2001. Google ScholarDigital Library
- G. Plotkin and J. Power. Algebraic operations and generic effects. Appl. Categ. Struct., 11(1), pp. 69–94, 2003.Google ScholarCross Ref
- G. D. Plotkin and M. Pretnar. Handlers of algebraic effects. In ESOP 2009, v. 5502 of LNCS, pp. 80–94. Springer, 2009. Google ScholarDigital Library
- J. Power and H. Watanabe. Combining a monad and a comonad. Theor. Comput. Sci., 280(1–2), pp. 137–162, 2002. Google ScholarDigital Library
- J.-P. Talpin and P. Jouvelot. The type and effect discipline. Inf. and Comput., 111(2), pp. 245–296, 1994. Google ScholarDigital Library
- R. Tate. The sequential semantics of producer effect systems. In POPL ’13, pp. 15–26. ACM, 2013. Google ScholarDigital Library
- K. Terui. Light affine lambda calculus and polytime strong normalization. In LICS ’01, pp. 209–220. IEEE, 2001.Google Scholar
- T. Uustalu and V. Vene. Comonadic notions of computation. Electron. Notes in Theor. Comput. Sci., 203(5), pp. 263–284, 2008. Google ScholarDigital Library
- T. Uustalu and V. Vene. The essence of dataflow programming. In CEFP 2005, v. 4164 of LNCS, pp. 135–167. Springer, 2006.Google ScholarDigital Library
- P. Wadler. The essence of functional programming. In POPL ’92, pp. 1–14. ACM, 1992. Google ScholarDigital Library
- P. Wadler. The marriage of effects and monads. In ICFP ’98, pp. 63–74. ACM, 1998. Google ScholarDigital Library
- P. Wadler and P. Thiemann. The marriage of effects and monads. ACM Trans. on Comput. Logic, 4(1), pp. 1–32, 2003. Google ScholarDigital Library
- H. Xi and F. Pfenning. Dependent types in practical programming. In POPL ’99, pp. 214–227. ACM, 1999. Google ScholarDigital Library
Index Terms
- Combining effects and coeffects via grading
Recommendations
Coeffects: a calculus of context-dependent computation
ICFP '14: Proceedings of the 19th ACM SIGPLAN international conference on Functional programmingThe notion of context in functional languages no longer refers just to variables in scope. Context can capture additional properties of variables (usage patterns in linear logics; caching requirements in dataflow languages) as well as additional ...
Combining effects and coeffects via grading
ICFP '16Effects and coeffects are two general, complementary aspects of program behaviour. They roughly correspond to computations which change the execution context (effects) versus computations which make demands on the context (coeffects). Effectful ...
Recursive coalgebras from comonads
Special issue: Seventh workshop on coalgebraic methods in computer science 2004The concept of recursive coalgebra of a functor was introduced in the 1970s by Osius in his work on categorical set theory to discuss the relationship between wellfounded induction and recursively specified functions. In this paper, we motivate the use ...
Comments