[go: up one dir, main page]
More Web Proxy on the site http://driver.im/ skip to main content
10.1145/2500365.2500581acmconferencesArticle/Chapter ViewAbstractPublication PagesicfpConference Proceedingsconference-collections
research-article

Programming and reasoning with algebraic effects and dependent types

Published: 25 September 2013 Publication History

Abstract

One often cited benefit of pure functional programming is that pure code is easier to test and reason about, both formally and informally. However, real programs have side-effects including state management, exceptions and interactions with the outside world. Haskell solves this problem using monads to capture details of possibly side-effecting computations --- it provides monads for capturing state, I/O, exceptions, non-determinism, libraries for practical purposes such as CGI and parsing, and many others, as well as monad transformers for combining multiple effects.
Unfortunately, useful as monads are, they do not compose very well. Monad transformers can quickly become unwieldy when there are lots of effects to manage, leading to a temptation in larger programs to combine everything into one coarse-grained state and exception monad. In this paper I describe an alternative approach based on handling algebraic effects, implemented in the IDRIS programming language. I show how to describe side effecting computations, how to write programs which compose multiple fine-grained effects, and how, using dependent types, we can use this approach to reason about states in effectful programs.

References

[1]
J. Aldrich, J. Sunshine, D. Saini, and Z. Sparks. Typestate-oriented programming. In Proceedings of the 24th conference on Object Oriented Programming Systems Languages and Applications, pages 1015--1012, 2009.
[2]
L. Augustsson and M. Carlsson. An exercise in dependent types: A well-typed interpreter, 1999. In Workshop on Dependent Types in Programming, Gothenburg.
[3]
A. Bauer and M. Pretnar. Programming with Algebraic Effects and Handlers, 2012. Available from http://arxiv.org/abs/1203. 1539.
[4]
E. Brady. Idris, a General Purpose Programming Language: Design and Implementation, 2013. Draft.
[5]
E. Brady. Programming in Idris: a Tutorial, 2013. Available from http://idris-lang.org/tutorial.
[6]
newblock {An exercise in dependent types: A well-typed interpreter}, 1999E. Brady and K. Hammond. A verified staged interpreter is a verified compiler. In Generative Programming and Component Engineering (GPCE 2006). ACM, 2006.
[7]
E. Brady and K. Hammond. Correct-by-construction concurrency: Using dependent types to verify implementations of effectful resource usage protocols. Fundamenta Informaticae, 102:145--176, 2010.
[8]
E. Brady and K. Hammond. Scrapping your inefficient engine: Using partial evaluation to improve domain-specific language implementation. In Proceedings of the 15th International Conference on Functional Programming (ICFP '10), pages 297--308. ACM, 2010.
[9]
E. Brady and K. Hammond. Resource-safe Systems Programming with Embedded Domain Specific Languages. In Practical Applications of Declarative Languages, pages 242--257, 2012.
[10]
J. Carette, O. Kiselyov, and C.-C. Shan. Finally tagless, partially evaluated: Tagless staged interpreters for simpler typed languages. Journal of Functional Programming, 19(05):509--543.
[11]
D. Delahaye. A tactic language for the system Coq. In Logic for Programming and Automated Reasoning (LPAR), volume 1955 of LNAI, pages 85--95. Springer, 2000.
[12]
P. Hancock and A. Setzer. Interactive Programs in Dependent Type Theory. In Proceedings of the 14th Annual Conference of the EACSL on Computer Science Logic, pages 317--331, Aug. 2000.
[13]
M. Hyland, G. Plotkin, and J. Power. Combining effects: Sum and tensor. Theoretical Computer Science, 357:70--99, 2006.
[14]
M. Jaskelioff. Modular monad transformers. In ESOP 09: Proceedings of the 18th European Symposium on Programming Languages and Systems, LNCS, pages 64--79. Springer, 2009.
[15]
O. Kammar, S. Lindley, and N. Oury. Handlers in action. In Proceedings of the 18th International Conference on Functional Programming (ICFP '13). ACM, 2013.
[16]
P. B. Levy. Call-By-Push-Value. PhD thesis, Queen Mary and Westfield College, University of London, 2001.
[17]
S. Liang, P. Hudak, and M. Jones. Monad transformers and modular interpreters. In Proceedings of the 22nd ACM SIGPLAN-SIGACT symposium on Principles of Programming Languages, pages 333--343, New York, New York, USA, Jan. 1995. ACM Press.
[18]
B. Lippmeier. Witnessing Purity, Constancy and Mutability. In 7th Asian Symposium on Programming Languages and Systems (APLAS 2009), volume 5904 of LNCS, pages 95--110. Springer, 2009.
[19]
C. McBride. Kleisli arrows of outrageous fortune, 2011. Draft.
[20]
C. McBride and R. Paterson. Applicative programming with effects. Journal of functional programming, 18(1):1--13, 2008.
[21]
M. Michelbrink and A. Setzer. State dependent IO-monads in type theory. Electronic Notes in Theoretical Computer Science, 122:127--146, 2005.
[22]
A. Nanevski, G. Morrisett, and L. Birkedal. Hoare type theory, polymorphism and separation. Journal of Functional Programming, 18(5--6):865--911, Sept. 2008.
[23]
A. Nanevski, G. Morrisett, A. Shinnar, P. Govereau, and L. Birkedal. Ynot: Dependent types for imperative programs. In Proceedings of the 13th International Conference on Functional Programming (ICFP '08), pages 229--240. ACM, 2008.
[24]
M. Odersky, P. Altherr, V. Cremet, B. Emir, S. Maneth, S. Micheloud, N. Mihaylov, M. Schinz, E. Stenman, and M. Zenger. An overview of the Scala programming language. Technical report, 2004.
[25]
E. Pasalic, W. Taha, and T. Sheard. Tagless staged interpreters for typed languages. In Proceedings of the 7th International Conference on Functional Programming (ICFP '02), volume 37, pages 218--229. ACM, Sept. 2002.
[26]
S. Peyton Jones. Haskell 98 Language and Libraries: The Revised Report. Technical report, 2002.
[27]
G. Plotkin and M. Pretnar. Handlers of Algebraic Effects. In ESOP 09: Proceedings of the 18th European Symposium on Programming Languages and Systems, pages 80--94, 2009.
[28]
M. Pretnar. The Logic and Handling of Algebraic Effects. PhD thesis, University of Edinburgh, 2010.
[29]
R. Strom and S. Yemini. Typestate: A programming language concept for enhancing software reliability. IEEE Transactions on Software Engineering, SE-12(1):157--171, 1986.
[30]
W. Swierstra. Data types a la carte. Journal of functional programming, 18(4):423--436, 2008.
[31]
P. Wadler. Monads for functional programming. In J. Jeuring and E. Meijer, editors, Advanced Functional Programming, volume 925 of LNCS, pages 24--52. Springer, 1995.
[32]
D. Walker. A Type System for Expressive Security Policies. In Proceedings of the 27th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL '00, pages 254--267. ACM, 2000.
[33]
H. Xi. Imperative Programming with Dependent Types. In 15th Annual IEEE Symposium on Logic in Computer Science, pages 375--387, 2000.

Cited By

View all
  • (2024)Making a Curry Interpreter using Effects and HandlersProceedings of the 17th ACM SIGPLAN International Haskell Symposium10.1145/3677999.3678279(68-82)Online publication date: 29-Aug-2024
  • (2024)Associated Effects: Flexible Abstractions for Effectful ProgrammingProceedings of the ACM on Programming Languages10.1145/36563938:PLDI(394-416)Online publication date: 20-Jun-2024
  • (2024)Answer Refinement Modification: Refinement Type System for Algebraic Effects and HandlersProceedings of the ACM on Programming Languages10.1145/36332808:POPL(115-147)Online publication date: 5-Jan-2024
  • Show More Cited By

Index Terms

  1. Programming and reasoning with algebraic effects and dependent types

    Recommendations

    Comments

    Please enable JavaScript to view thecomments powered by Disqus.

    Information & Contributors

    Information

    Published In

    cover image ACM Conferences
    ICFP '13: Proceedings of the 18th ACM SIGPLAN international conference on Functional programming
    September 2013
    484 pages
    ISBN:9781450323260
    DOI:10.1145/2500365
    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].

    Sponsors

    Publisher

    Association for Computing Machinery

    New York, NY, United States

    Publication History

    Published: 25 September 2013

    Permissions

    Request permissions for this article.

    Check for updates

    Author Tags

    1. algebraic effects
    2. dependent types

    Qualifiers

    • Research-article

    Conference

    ICFP'13
    Sponsor:
    ICFP'13: ACM SIGPLAN International Conference on Functional Programming
    September 25 - 27, 2013
    Massachusetts, Boston, USA

    Acceptance Rates

    ICFP '13 Paper Acceptance Rate 40 of 133 submissions, 30%;
    Overall Acceptance Rate 333 of 1,064 submissions, 31%

    Upcoming Conference

    ICFP '25
    ACM SIGPLAN International Conference on Functional Programming
    October 12 - 18, 2025
    Singapore , Singapore

    Contributors

    Other Metrics

    Bibliometrics & Citations

    Bibliometrics

    Article Metrics

    • Downloads (Last 12 months)52
    • Downloads (Last 6 weeks)1
    Reflects downloads up to 12 Dec 2024

    Other Metrics

    Citations

    Cited By

    View all
    • (2024)Making a Curry Interpreter using Effects and HandlersProceedings of the 17th ACM SIGPLAN International Haskell Symposium10.1145/3677999.3678279(68-82)Online publication date: 29-Aug-2024
    • (2024)Associated Effects: Flexible Abstractions for Effectful ProgrammingProceedings of the ACM on Programming Languages10.1145/36563938:PLDI(394-416)Online publication date: 20-Jun-2024
    • (2024)Answer Refinement Modification: Refinement Type System for Algebraic Effects and HandlersProceedings of the ACM on Programming Languages10.1145/36332808:POPL(115-147)Online publication date: 5-Jan-2024
    • (2024) i C o L a +Journal of Systems and Software10.1016/j.jss.2024.111979211:COnline publication date: 2-Jul-2024
    • (2023)Fast and Efficient Boolean Unification for Hindley-Milner-Style Type and Effect SystemsProceedings of the ACM on Programming Languages10.1145/36228167:OOPSLA2(516-543)Online publication date: 16-Oct-2023
    • (2023)Hefty Algebras: Modular Elaboration of Higher-Order Algebraic EffectsProceedings of the ACM on Programming Languages10.1145/35712557:POPL(1801-1831)Online publication date: 11-Jan-2023
    • (2021)Reasoning about effect interaction by fusionProceedings of the ACM on Programming Languages10.1145/34735785:ICFP(1-29)Online publication date: 19-Aug-2021
    • (2020)Legodroid: A Type-Driven Library for Android and LEGO Mindstorms InteroperabilitySensors10.3390/s2007192620:7(1926)Online publication date: 30-Mar-2020
    • (2020)SteelCore: an extensible concurrent separation logic for effectful dependently typed programsProceedings of the ACM on Programming Languages10.1145/34090034:ICFP(1-30)Online publication date: 3-Aug-2020
    • (2020)Generalized monoidal effects and handlersJournal of Functional Programming10.1017/S095679682000010630Online publication date: 28-Jul-2020
    • Show More Cited By

    View Options

    Login options

    View options

    PDF

    View or Download as a PDF file.

    PDF

    eReader

    View online with eReader.

    eReader

    Media

    Figures

    Other

    Tables

    Share

    Share

    Share this Publication link

    Share on social media