skip to main content
research-article
Open Access

Handling fibred algebraic effects

Published:27 December 2017Publication History
Skip Abstract Section

Abstract

We study algebraic computational effects and their handlers in the dependently typed setting. We describe computational effects using a generalisation of Plotkin and Pretnar's effect theories, whose dependently typed operations allow us to capture precise notions of computation, e.g., state with location-dependent store types and dependently typed update monads. Our treatment of handlers is based on an observation that their conventional term-level definition leads to unsound program equivalences being derivable in languages that include a notion of homomorphism. We solve this problem by giving handlers a novel type-based treatment via a new computation type, the user-defined algebra type, which pairs a value type (the carrier) with a set of value terms (the operations), capturing Plotkin and Pretnar's insight that effect handlers denote algebras. We then show that the conventional presentation of handlers can be routinely derived, and demonstrate that this type-based treatment of handlers provides a useful mechanism for reasoning about effectful computations. We also equip the resulting language with a sound denotational semantics based on families fibrations.

Skip Supplemental Material Section

Supplemental Material

handlingfibredalgebraiceffects.webm

References

  1. J. Adamek and J. Rosicky. 1994. Locally Presentable and Accessible Categories. Number 189 in London Mathematical Society Lecture Note Series. Cambridge Univ. Press. Google ScholarGoogle ScholarCross RefCross Ref
  2. D. Ahman. 2017. Fibred Computational Effects. Ph.D. Dissertation. School of Informatics, University of Edinburgh.Google ScholarGoogle Scholar
  3. D. Ahman, J. Chapman, and T. Uustalu. 2014. When is a container a comonad? Logical Methods in Computer Science 10, 3 (2014). Google ScholarGoogle ScholarCross RefCross Ref
  4. D. Ahman, N. Ghani, and G. D. Plotkin. 2016. Dependent Types and Fibred Computational Effects. In Proc. of 19th Int. Conf. on Foundations of Software Science and Computation Structures, FoSSaCS 2016 (LNCS), Vol. 9634. Springer, 1–19. Google ScholarGoogle ScholarCross RefCross Ref
  5. D. Ahman, C. Hriţcu, K. Maillard, G. Martínez, G. Plotkin, J. Protzenko, A. Rastogi, and N. Swamy. 2017. Dijkstra Monads for Free. In Proc. of 44th ACM SIGPLAN Symp. on Principles of Programming Languages, POPL 2017. ACM, 515–529. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. D. Ahman and S. Staton. 2013. Normalization by Evaluation and Algebraic Effects. In Proc. of 29th Conf. on the Mathematical Foundations of Programming Semantics, MFPS XXIX (ENTCS), Vol. 298. Elsevier, 51–69. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. D. Ahman and T. Uustalu. 2014. Update Monads: Cointerpreting Directed Containers. In Post-proc. of 19th Meeting “Types for Proofs and Programs", TYPES 2013 (LIPIcs), Vol. 26. Schloss Dagstuhl – Leibniz-Zentrum für Informatik, Dagstuhl Publishing, 1–23.Google ScholarGoogle Scholar
  8. A. Bauer and M. Pretnar. 2015. Programming with algebraic effects and handlers. J. Log. Algebr. Meth. Program. 84, 1 (2015), 108–123. Google ScholarGoogle ScholarCross RefCross Ref
  9. E. Brady. 2013. Programming and reasoning with algebraic effects and dependent types. In Proc. of 18th ACM SIGPLAN Int. Conf. on Functional Programming, ICFP 2013. ACM, 133–144. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. C. Casinghino. 2014. Combining Proofs and Programs. Ph.D. Dissertation. University of Pennsylvania.Google ScholarGoogle Scholar
  11. E. W. Dijkstra. 1975. Guarded Commands, Nondeterminacy and Formal Derivation of Programs. CACM 18, 8 (1975), 5.Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. P. Dybjer and A. Setzer. 1999. A Finite Axiomatization of Inductive-Recursive Definitions. In Proc. 4th Int. Conf. on Typed Lambda Calculi and Applications, TLCA’99 (LNCS), Vol. 1581. Springer, 129–146. Google ScholarGoogle ScholarCross RefCross Ref
  13. J. Egger, R. E. Møgelberg, and A. Simpson. 2014. The enriched effect calculus: syntax and semantics. J. Log. Comput. 24, 3 (2014), 615–654. Google ScholarGoogle ScholarCross RefCross Ref
  14. N. Ghani, L. Malatesta, F. N. Forsberg, and A. Setzer. 2013. Fibred Data Types. In Proc. of 28th Ann. Symp. on Logic in Computer Science, LICS 2013. IEEE Computer Society, 243–252. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. G. A. Grätzer. 1979. Universal Algebra (2nd ed.). Springer.Google ScholarGoogle Scholar
  16. P. Hancock and A. Setzer. 2000. Interactive programs in dependent type theory. In Proc. of 14th Ann. Conf. of the EACSL on Computer Science Logic, CSL 2000 (LNCS), Vol. 1862. Springer, 317–331. Google ScholarGoogle ScholarCross RefCross Ref
  17. M. Hedberg. 1998. A Coherence Theorem for Martin-Löf ’s Type Theory. J. Funct. Program. 8, 4 (1998), 413–436. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. D. Hillerström and S. Lindley. 2016. Liberating Effects with Rows and Handlers. In Proc. of 1st Wksh. on Type-Driven Development, TyDe 2016. ACM, 15–27. Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. M. Hofmann. 1995. Extensional concepts in intensional type theory. Ph.D. Dissertation. Laboratory for Foundations in Computer Science, University of Edinburgh.Google ScholarGoogle Scholar
  20. M. Hofmann. 1997. Syntax and Semantics of Dependent Types. In Semantics and Logics of Computation. Cambridge Univ. Press, 79–130. Google ScholarGoogle ScholarCross RefCross Ref
  21. K. Honda, V. T. Vasconcelos, and M. Kubo. 1998. Language Primitives and Type Discipline for Structured CommunicationBased Programming. In Proc. of 7th European Symp. on Programming, ESOP 1998 (LNCS), Vol. 1381. Springer, 122–138.Google ScholarGoogle Scholar
  22. M. Hyland, G. Plotkin, and J. Power. 2006. Combining effects: Sum and tensor. Theor. Comput. Sci. 357, 1–3 (2006), 70–99.Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. B. Jacobs. 1999. Categorical Logic and Type Theory. Number 141 in Studies in Logic and the Foundations of Mathematics. North Holland, Elsevier.Google ScholarGoogle Scholar
  24. O. Kammar, S. Lindley, and N. Oury. 2013. Handlers in Action. In Proc. of 18th ACM SIGPLAN Int. Conf. on Functional Programming, ICFP 2013. ACM, 145–158. Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. O. Kammar and G. D. Plotkin. 2012. Algebraic Foundations for Effect-dependent Optimisations. In Proc. of 39th ACM SIGPLAN-SIGACT Symp. on Principles of Programming Languages, POPL 2012. ACM, 349–360. Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. D. Leijen. 2017. Type Directed Compilation of Row-Typed Algebraic Effects. In Proc. of 44th ACM SIGPLAN Symp. on Principles of Programming Languages, POPL 2017. ACM, 486–499. Google ScholarGoogle ScholarDigital LibraryDigital Library
  27. P. B. Levy. 2004. Call-By-Push-Value: A Functional/Imperative Synthesis. Semantics Structures in Computation, Vol. 2. Springer.Google ScholarGoogle Scholar
  28. P. B. Levy. 2006. Monads and Adjunctions for Global Exceptions. ENTCS 158 (2006), 261–287. Google ScholarGoogle ScholarDigital LibraryDigital Library
  29. P. B. Levy. 2017. Contextual isomorphisms. In Proc. of 44th ACM SIGPLAN Symp. on Principles of Programming Languages, POPL 2017. ACM, 400–414. Google ScholarGoogle ScholarDigital LibraryDigital Library
  30. S. Lindley, C. McBride, and C. McLaughlin. 2017. Do Be Do Be Do. In Proc. of 44th ACM SIGPLAN Symp. on Principles of Programming Languages, POPL 2017. ACM, 500–514.Google ScholarGoogle Scholar
  31. P. Martin-Löf. 1975. An intuitionisitc theory of types, Predicative part. In Proc. of Logic Colloquium 1973. North-Holland, 73–118.Google ScholarGoogle Scholar
  32. P. Martin-Löf. 1984. Intuitionistic Type Theory. Bibliopolis.Google ScholarGoogle Scholar
  33. C. McBride. 2011. Functional Pearl: Kleisli arrows of outrageous fortune. J. Funct. Program. (2011). (To appear).Google ScholarGoogle Scholar
  34. E. Moggi. 1989. Computational Lambda-Calculus and Monads. In Proc. of 4th Ann. Symp. on Logic in Computer Science, LICS 1989. IEEE, 14–23. Google ScholarGoogle ScholarCross RefCross Ref
  35. E. Moggi. 1991. Notions of Computation and Monads. Inf. Comput. 93, 1 (1991), 55–92. Google ScholarGoogle ScholarDigital LibraryDigital Library
  36. G. Munch-Maccagnoni. 2013. Syntax and Models of a non-Associative Composition of Programs and Proofs. Ph.D. Dissertation. Univ. Paris Diderot.Google ScholarGoogle Scholar
  37. A. Nanevski, G. Morrisett, and L. Birkedal. 2008. Hoare Type Theory, polymorphism and separation. J. Funct. Program. 18, 5-6 (2008), 865–911.Google ScholarGoogle ScholarDigital LibraryDigital Library
  38. M. Okada and P. J. Scott. 1999. A Note on Rewriting Theory for Uniqueness of Iteration. Theory Appl. Categ. 6, 4 (1999), 47–64.Google ScholarGoogle Scholar
  39. P.-M. Pédrot and N. Tabareau. 2017. An Effectful Way to Eliminate Addiction to Dependence. In Proc. of 32nd Ann. Symp. on Logic in Computer Science, LICS 2017. 1–12. Google ScholarGoogle ScholarCross RefCross Ref
  40. A. M. Pitts. 1991. Evaluation Logic. In Proc. IVth Higher Order Workshop (Workshops in Computing). Springer, 162–189. Google ScholarGoogle ScholarCross RefCross Ref
  41. A. M. Pitts, J. Matthiesen, and J. Derikx. 2015. A Dependent Type Theory with Abstractable Names. In Proc. of 9th Wksh. on Logical and Semantic Frameworks, with Applications, LSFA 2014 (ENTCS), Vol. 312. Elsevier, 19–50. Google ScholarGoogle ScholarDigital LibraryDigital Library
  42. G. Plotkin and J. Power. 2001. Semantics for Algebraic Operations. In Proc. of 17th Conf. on the Mathematical Foundations of Programming Semantics, MFPS XVII (ENTCS), Vol. 45. Elsevier, 332–345. Google ScholarGoogle ScholarCross RefCross Ref
  43. G. D. Plotkin and J. Power. 2002. Notions of Computation Determine Monads. In Proc. of 5th Int. Conf. on Foundations of Software Science and Computation Structures, FOSSACS 2002 (LNCS), Vol. 2303. Springer, 342–356. Google ScholarGoogle ScholarCross RefCross Ref
  44. G. D. Plotkin and M. Pretnar. 2008. A Logic for Algebraic Effects. In Proc. of 23th Ann. IEEE Symp. on Logic in Computer Science, LICS 2008. IEEE, 118–129. Google ScholarGoogle ScholarDigital LibraryDigital Library
  45. G. D. Plotkin and M. Pretnar. 2013. Handling Algebraic Effects. Logical Methods in Computer Science 9, 4:23 (2013).Google ScholarGoogle Scholar
  46. J. Power. 2006. Countable Lawvere Theories and Computational Effects. In Proc. of 3rd Irish Conf. on the Mathematical Foundations of Computer Science and Information Technology, MFCSIT 2004 (ENTCS), Vol. 161. Elsevier, 59–71. Google ScholarGoogle ScholarCross RefCross Ref
  47. S. Staton. 2013. Instances of Computational Effects: An Algebraic Perspective. In Proc. of 28th Ann. ACM/IEEE Symp. on Logic in Computer Science, LICS 2013. IEEE, 519–519. Google ScholarGoogle ScholarDigital LibraryDigital Library
  48. T. Streicher. 1991. Semantics of Type Theory. Correctness, Completeness and Independence Results. Birkhäuser Boston. Google ScholarGoogle ScholarCross RefCross Ref
  49. The Agda Team. 2017. The Agda Wiki. Available at http://appserv.cs.chalmers.se/users/ulfn/wiki/agda.php . (2017).Google ScholarGoogle Scholar
  50. The Univalent Foundations Program. 2013. Homotopy Type Theory: Univalent Foundations of Mathematics. Institute for Advanced Study. Available at: https://homotopytypetheory.org/book/ .Google ScholarGoogle Scholar

Index Terms

  1. Handling fibred algebraic effects

              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

              Full Access

              PDF Format

              View or Download as a PDF file.

              PDF

              eReader

              View online with eReader.

              eReader
              About Cookies On This Site

              We use cookies to ensure that we give you the best experience on our website.

              Learn more

              Got it!