Advertisement

Resource-Dependent Algebraic Effects

  • Edwin Brady
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 8843)

Abstract

There has been significant interest in recent months in finding new ways to implement composable and modular effectful programs using handlers of algebraic effects. In my own previous work, I have shown how an algebraic effect system (called effects) can be embedded directly in a dependently typed host language. Using dependent types ought to allow precise reasoning about programs; however, the reasoning capabilities of effects have been limited to simple state transitions which are known at compile-time. In this paper, I show how effects can be extended to support reasoning in the presence of run-time state transitions, where the result may depend on run-time information about resource usage (e.g. whether opening a file succeeded). I show how this can be used to build expressive APIs, and to specify and verify the behaviour of interactive, stateful programs. I illustrate the technique using a file handling API, and an interactive game.

Keywords

Dependent Type Functional Programming Game State Game Rule Syntactic Sugar 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. 1.
    Aldrich, J., Sunshine, J., Saini, D., Sparks, Z.: Typestate-oriented programming. In: Proceedings of the 24th Conference on Object Oriented Programming Systems Languages and Applications, pp. 1015–1012 (2009)Google Scholar
  2. 2.
    Bauer, A., Pretnar, M.: Programming with Algebraic Effects and Handlers (2012). http://arxiv.org/abs/1203.1539
  3. 3.
    Brady, E.: Idris, a general-purpose dependently typed programming language: Design and implementation. Journal of Functional Programming 23, 552–593 (2013)CrossRefzbMATHMathSciNetGoogle Scholar
  4. 4.
    Brady, E.: Programming and reasoning with algebraic effects and dependent types. In: ICFP 2013: Proceedings of the 18th ACM SIGPLAN International Conference on Functional Programming. ACM (2013)Google Scholar
  5. 5.
    Brady, E., Hammond, K.: Correct-by-construction concurrency: Using dependent types to verify implementations of effectful resource usage protocols. Fundamenta Informaticae 102, 145–176 (2010)zbMATHMathSciNetGoogle Scholar
  6. 6.
    Fowler, S., Brady, E.: Dependent types for safe and secure web programming. In: Implementation and Application of Functional Languages (IFL) (2013)Google Scholar
  7. 7.
    Honda, K., Yoshida, N., Carbone, M.: Multiparty asynchronous session types. In: POPL, pp. 273–284 (2008)Google Scholar
  8. 8.
    Hyland, M., Plotkin, G., Power, J.: Combining effects: Sum and tensor. Theoretical Computer Science 357, 70–99 (2006)CrossRefzbMATHMathSciNetGoogle Scholar
  9. 9.
    Kammar, O., Lindley, S., Oury, N.: Handlers in action. In: Proceedings of the 18th International Conference on Functional Programming (ICFP 2013). ACM (2013)Google Scholar
  10. 10.
    Kiselyov, O., Sabry, A., Swords, C.: Extensible effects: an alternative to monad transformers. In: Proceedings of the 2013 ACM SIGPLAN Symposium on Haskell, Haskell 2013, pp. 59–70, New York. ACM (2013)Google Scholar
  11. 11.
    Leijen, D.: Koka: programming with row polymorphic effect types. In: Levy, P., Krishnaswami, N. (eds.) MSFP. EPTCS, vol. 153, pp. 100–126 (2014)Google Scholar
  12. 12.
    Levy, P.B.: Call-By-Push-Value. PhD thesis, Queen Mary and Westfield College, University of London (2001)Google Scholar
  13. 13.
    Lippmeier, B.: Witnessing purity, constancy and mutability. In: Hu, Z. (ed.) APLAS 2009. LNCS, vol. 5904, pp. 95–110. Springer, Heidelberg (2009)CrossRefGoogle Scholar
  14. 14.
    McBride, C.: Kleisli arrows of outrageous fortune (2011), (Draft)Google Scholar
  15. 15.
    Nanevski, A., Morrisett, G., Shinnar, A., Govereau, P., Birkedal, L.: Ynot: reasoning with the awkward squad. In: ICFP 2008: Proceeding of the 13th ACM SIGPLAN International Conference on Functional Programming, pp. 229–240, New York. ACM (2008)Google Scholar
  16. 16.
    Plotkin, G., Pretnar, M.: Handlers of algebraic effects. In: Castagna, G. (ed.) ESOP 2009. LNCS, vol. 5502, pp. 80–94. Springer, Heidelberg (2009)CrossRefGoogle Scholar
  17. 17.
    Pretnar, M.: The Logic and Handling of Algebraic Effects. PhD thesis, University of Edinburgh (2010)Google Scholar
  18. 18.
    Strom, R., Yemini, S.: Typestate: A programming language concept for enhancing software reliability. IEEE Transactions on Software Engineering SE–12(1), 157–171 (1986)CrossRefGoogle Scholar
  19. 19.
    Walker, D.: A type system for expressive security policies. In: Proceedings of the 27th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL 2000, pp. 254–267. ACM (2000)Google Scholar

Copyright information

© Springer International Publishing Switzerland 2015

Authors and Affiliations

  1. 1.University of St AndrewsSt AndrewsScotland, UK

Personalised recommendations