skip to main content
10.1145/2951913.2951939acmconferencesArticle/Chapter ViewAbstractPublication PagesicfpConference Proceedingsconference-collections
research-article

Combining effects and coeffects via grading

Published:04 September 2016Publication History

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.

References

  1. M. Abadi, A. Banerjee, N. Heintze, and J. Riecke. A core calculus of dependency. In POPL ’99, pp. 147–160. ACM, 1999. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. D. Ahman and T. Uustalu. Distributive laws of directed containers. Progr. in Inf., 10, pp. 3–18, 2013.Google ScholarGoogle ScholarCross RefCross Ref
  3. 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 ScholarGoogle Scholar
  4. R. Atkey. Parameterised notions of computation. J. of Funct. Program., 19(3–4), pp. 335–376, 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. 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 ScholarGoogle Scholar
  6. 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 ScholarGoogle Scholar
  7. S. Brookes and K. V. Stone. Monads and comonads in intensional semantics. Techn. rep. CMU-CS-93-140. Carnegie-Mellon Univ., 1993. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  9. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  10. U. Dal Lago and M. Gaboardi. Linear dependent types and relative completeness. In LICS ’11, pp. 133–142. IEEE, 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. A. Filinski. Representing layered monads. In POPL ’99, pp. 175–188. ACM, 1999. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. 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 ScholarGoogle Scholar
  13. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  14. 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 ScholarGoogle Scholar
  15. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  16. J. Gibbons. Comprehending ringads. In A List of Successes That Can Change the World, v. 9600 of LNCS, pp. 132–151. Springer, 2016.Google ScholarGoogle Scholar
  17. D. K. Gifford and J. M. Lucassen. Integrating functional and imperative programming. In LISP and Funct. Prog. ’86, pp. 28–38. ACM, 1986. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. J.-Y. Girard. Linear logic. Theor. Comput. Sci., 50, pp. 1–102, 1987. Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  20. R. Harmer, M. Hyland, and P.-A. Melliès. Categorical combinatorics for innocent strategies. In LICS ’07, pp. 379–388. IEEE, 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. 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 ScholarGoogle Scholar
  22. P. Jouvelot and D. Gifford. Algebraic reconstruction of types and effects. In POPL ’91, pp. 303–310. ACM, 1991. Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. C. Kassel. Quantum Groups. Graduate Texts in Mathematics. Springer, 1994.Google ScholarGoogle Scholar
  24. S. Katsumata. Parametric effect monads and semantics of effect systems. In POPL ’14, pp. 633–646. ACM, 2014. Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. J. Lucassen and D. Gifford. Polymorphic effect systems. In POPL ’98, pp. 47–57. ACM, 1988. Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. 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 ScholarGoogle Scholar
  27. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  28. P.-A. Melliès. Parametric monads and enriched adjunctions. Draft, 2012. http://www.pps.univ-paris-diderot.fr/~mellies/ tensorial-logic/.Google ScholarGoogle Scholar
  29. 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 ScholarGoogle Scholar
  30. E. Moggi. Computational lambda-calculus and monads. In LICS ’89, pp. 14–23. IEEE, 1989. Google ScholarGoogle ScholarDigital LibraryDigital Library
  31. E. Moggi. Notions of computation and monads. Inf. and Comput., 93(1), pp. 55–92, 1991. Google ScholarGoogle ScholarDigital LibraryDigital Library
  32. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  33. A. Nanevski. From dynamic binding to state via modal possibility. In PPDP 2003, pp. 207–218. ACM, 2003. Google ScholarGoogle ScholarDigital LibraryDigital Library
  34. A. Nanevski, F. Pfenning, and B. Pientka. Contextual modal type theory. ACM Trans. on Comput. Log., 9(3), article 23, 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  35. F. Nielson, H. R. Nielson, and C. L. Hankin. Principles of Program Analysis. Springer, 1999. Google ScholarGoogle ScholarDigital LibraryDigital Library
  36. D. Orchard. Programming Contextual Computations. PhD thesis, Univ. of Cambridge, 2014.Google ScholarGoogle Scholar
  37. D. Orchard and T. Petricek. Embedding effect systems in Haskell. In Haskell 2014, pp. 13–24. ACM, 2014. Google ScholarGoogle ScholarDigital LibraryDigital Library
  38. D. Orchard, T. Petricek, and A. Mycroft. The semantic marriage of monads and effects. arXiv preprint 1401.5391, 2014.Google ScholarGoogle Scholar
  39. T. Petricek. Context-Aware Programming Languages. Forthcoming PhD thesis, Univ. of Cambridge, 2016.Google ScholarGoogle Scholar
  40. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  41. T. Petricek, D. Orchard, and A. Mycroft. Coeffects: a calculus of context-dependent computation. In ICFP ’14, pp. 123–135. ACM, 2014. Google ScholarGoogle ScholarDigital LibraryDigital Library
  42. G. Plotkin and J. Power. Adequacy for algebraic effects. In FOSSACS 2001, v. 2030 of LNCS, pp. 1–24. Springer, 2001. Google ScholarGoogle ScholarDigital LibraryDigital Library
  43. G. Plotkin and J. Power. Algebraic operations and generic effects. Appl. Categ. Struct., 11(1), pp. 69–94, 2003.Google ScholarGoogle ScholarCross RefCross Ref
  44. G. D. Plotkin and M. Pretnar. Handlers of algebraic effects. In ESOP 2009, v. 5502 of LNCS, pp. 80–94. Springer, 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  45. J. Power and H. Watanabe. Combining a monad and a comonad. Theor. Comput. Sci., 280(1–2), pp. 137–162, 2002. Google ScholarGoogle ScholarDigital LibraryDigital Library
  46. J.-P. Talpin and P. Jouvelot. The type and effect discipline. Inf. and Comput., 111(2), pp. 245–296, 1994. Google ScholarGoogle ScholarDigital LibraryDigital Library
  47. R. Tate. The sequential semantics of producer effect systems. In POPL ’13, pp. 15–26. ACM, 2013. Google ScholarGoogle ScholarDigital LibraryDigital Library
  48. K. Terui. Light affine lambda calculus and polytime strong normalization. In LICS ’01, pp. 209–220. IEEE, 2001.Google ScholarGoogle Scholar
  49. T. Uustalu and V. Vene. Comonadic notions of computation. Electron. Notes in Theor. Comput. Sci., 203(5), pp. 263–284, 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  50. T. Uustalu and V. Vene. The essence of dataflow programming. In CEFP 2005, v. 4164 of LNCS, pp. 135–167. Springer, 2006.Google ScholarGoogle ScholarDigital LibraryDigital Library
  51. P. Wadler. The essence of functional programming. In POPL ’92, pp. 1–14. ACM, 1992. Google ScholarGoogle ScholarDigital LibraryDigital Library
  52. P. Wadler. The marriage of effects and monads. In ICFP ’98, pp. 63–74. ACM, 1998. Google ScholarGoogle ScholarDigital LibraryDigital Library
  53. P. Wadler and P. Thiemann. The marriage of effects and monads. ACM Trans. on Comput. Logic, 4(1), pp. 1–32, 2003. Google ScholarGoogle ScholarDigital LibraryDigital Library
  54. H. Xi and F. Pfenning. Dependent types in practical programming. In POPL ’99, pp. 214–227. ACM, 1999. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Combining effects and coeffects via grading

    Recommendations

    Comments

    Login options

    Check if you have access through your login credentials or your institution to get full access on this article.

    Sign in
    • Published in

      cover image ACM Conferences
      ICFP 2016: Proceedings of the 21st ACM SIGPLAN International Conference on Functional Programming
      September 2016
      501 pages
      ISBN:9781450342193
      DOI:10.1145/2951913

      Copyright © 2016 ACM

      Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than the author(s) must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected].

      Publisher

      Association for Computing Machinery

      New York, NY, United States

      Publication History

      • Published: 4 September 2016

      Permissions

      Request permissions about this article.

      Request Permissions

      Check for updates

      Qualifiers

      • research-article

      Acceptance Rates

      Overall Acceptance Rate333of1,064submissions,31%

      Upcoming Conference

      ICFP '24

    PDF Format

    View or Download as a PDF file.

    PDF

    eReader

    View online with eReader.

    eReader