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.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Preview
Unable to display preview. Download preview PDF.
References
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)
Bauer, A., Pretnar, M.: Programming with Algebraic Effects and Handlers (2012). http://arxiv.org/abs/1203.1539
Brady, E.: Idris, a general-purpose dependently typed programming language: Design and implementation. Journal of Functional Programming 23, 552–593 (2013)
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)
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)
Fowler, S., Brady, E.: Dependent types for safe and secure web programming. In: Implementation and Application of Functional Languages (IFL) (2013)
Honda, K., Yoshida, N., Carbone, M.: Multiparty asynchronous session types. In: POPL, pp. 273–284 (2008)
Hyland, M., Plotkin, G., Power, J.: Combining effects: Sum and tensor. Theoretical Computer Science 357, 70–99 (2006)
Kammar, O., Lindley, S., Oury, N.: Handlers in action. In: Proceedings of the 18th International Conference on Functional Programming (ICFP 2013). ACM (2013)
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)
Leijen, D.: Koka: programming with row polymorphic effect types. In: Levy, P., Krishnaswami, N. (eds.) MSFP. EPTCS, vol. 153, pp. 100–126 (2014)
Levy, P.B.: Call-By-Push-Value. PhD thesis, Queen Mary and Westfield College, University of London (2001)
Lippmeier, B.: Witnessing purity, constancy and mutability. In: Hu, Z. (ed.) APLAS 2009. LNCS, vol. 5904, pp. 95–110. Springer, Heidelberg (2009)
McBride, C.: Kleisli arrows of outrageous fortune (2011), (Draft)
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)
Plotkin, G., Pretnar, M.: Handlers of algebraic effects. In: Castagna, G. (ed.) ESOP 2009. LNCS, vol. 5502, pp. 80–94. Springer, Heidelberg (2009)
Pretnar, M.: The Logic and Handling of Algebraic Effects. PhD thesis, University of Edinburgh (2010)
Strom, R., Yemini, S.: Typestate: A programming language concept for enhancing software reliability. IEEE Transactions on Software Engineering SE–12(1), 157–171 (1986)
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)
Author information
Authors and Affiliations
Corresponding author
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2015 Springer International Publishing Switzerland
About this paper
Cite this paper
Brady, E. (2015). Resource-Dependent Algebraic Effects. In: Hage, J., McCarthy, J. (eds) Trends in Functional Programming. TFP 2014. Lecture Notes in Computer Science(), vol 8843. Springer, Cham. https://doi.org/10.1007/978-3-319-14675-1_2
Download citation
DOI: https://doi.org/10.1007/978-3-319-14675-1_2
Published:
Publisher Name: Springer, Cham
Print ISBN: 978-3-319-14674-4
Online ISBN: 978-3-319-14675-1
eBook Packages: Computer ScienceComputer Science (R0)