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

Modular effects in Haskell through effect polymorphism and explicit dictionary applications: a new approach and the μVeriFast verifier as a case study

Published: 08 August 2019 Publication History

Abstract

In applications with a complex structure of side effects, effects should be dealt with modularly: components should be programmed against abstract effect interfaces that other components can instantiate as required, and reusable effect patterns should be factored out from the rest of the application. In this paper, we study a new, general approach to achieve this in Haskell by combining effect polymorphism and the recently proposed coherent explicit dictionary applications. We demonstrate the elegance and generality of our approach in μVeriFast: a Haskell-based reimplementation of the semi-automatic separation-logic-based verification tool VeriFast. This implementation features a complex interplay of advanced side effects: a backtracking search of program paths with angelic and demonic non-determinism, interaction with an underlying off-the-shelf SMT solver, and mutable state that is either backtracked or not during the search. Our use of effect polymorphism improves over the current non-modular implementation of VeriFast, allows us to nicely factor out the backtracking search pattern as a new AssumeAssert monad, and enables advanced features involving effects, such as the non-intrusive addition of a graphical symbolic debugger based on delimited continuations.

References

[1]
Aaron Levin. 2016. Extensible Effects in the van Laarhoven Free Monad. (Jan. 2016). http://aaronlevin.ca/post/136494428283/extensible-effectsin-the-van-laarhoven-free-monad
[2]
Andreas Hartmann. 2018. Structuring Functional Programs with Tagless Final. (June 2018). https://www.becompany.ch/en/blog/2018/06/ 21/tagless-final
[3]
Andrej Bauer and Matija Pretnar. 2015. Programming with Algebraic Effects and Handlers. Journal of Logical and Algebraic Methods in Programming 84, 1 (2015).
[4]
Dariusz Biernacki, Maciej Piróg, Piotr Polesiuk, and Filip Sieczkowski. 2019. Abstracting Algebraic Effects. Proc. ACM Program. Lang. 3, POPL (Jan. 2019), 6:1–6:28.
[5]
Baldur Blöndal, Andres Löh, and Ryan Scott. 2018. Deriving via: Or, How to Turn Hand-Written Instances into an Anti-Pattern. In Proceedings of the 11th ACM SIGPLAN International Symposium on Haskell (Haskell 2018). ACM, New York, NY, USA, 55–67.
[6]
Gert-Jan Bottu, Georgios Karachalias, Tom Schrijvers, Bruno C. d. S. Oliveira, and Philip Wadler. 2017. Quantified Class Constraints. In Proceedings of the 10th ACM SIGPLAN International Symposium on Haskell (Haskell 2017). ACM, New York, NY, USA, 148–161.
[7]
Joachim Breitner, Richard A. Eisenberg, Simon Peyton Jones, and Stephanie Weirich. 2014. Safe Zero-Cost Coercions for Haskell. In Proceedings of the 19th ACM SIGPLAN International Conference on Functional Programming (ICFP ’14). ACM, New York, NY, USA, 189– 202.
[8]
Jacques Carette, Oleg Kiselyov, and Chung-Chieh Shan. 2009. Finally Tagless, Partially Evaluated: Tagless Staged Interpreters for Simpler Typed Languages. Journal of Functional Programming 19, 5 (Sept. 2009), 509–543.
[9]
John A. De Goes. 2018. No More Transformers: High-Performance Effects in Scalaz 8. (May 2018). http://degoes.net/articles/effectswithout-transformers
[10]
Leonardo de Moura and Nikolaj Bjørner. 2008. Z3: An Efficient SMT Solver. In Tools and Algorithms for the Construction and Analysis of Systems (Lecture Notes in Computer Science), C. R. Ramakrishnan and Jakob Rehof (Eds.). Springer Berlin Heidelberg, 337–340.
[11]
Dominique Devriese, Lars Birkedal, and Frank Piessens. 2016. Reasoning about Object Capabilities Using Logical Relations and Effect Parametricity. In European Symposium on Security and Privacy. IEEE.
[12]
Sander Evers, Peter Achten, and Jan Kuper. 2005. A Functional Programming Technique for Forms in Graphical User Interfaces. In Implementation and Application of Functional Languages (Lecture Notes in Computer Science), Clemens Grelck, Frank Huch, Greg J. Michaelson, and Phil Trinder (Eds.). Springer Berlin Heidelberg, 35–51.
[13]
Mattias Felleisen. 1988. The Theory and Practice of First-Class Prompts. In Principles of Programming Languages (POPL ’88). ACM.
[14]
Andreas Herrmann and Arnaud Spiwack. 2018. Capability: The {ReaderT} Pattern without Boilerplate. (Oct. 2018). https://www.tweag. io/posts/2018-10-04-capability.html
[15]
Bart Jacobs, Jan Smans, and Frank Piessens. 2010. A Quick Tour of the VeriFast Program Verifier. In Programming Languages and Systems. Lecture Notes in Computer Science, Vol. 6461. Springer Berlin Heidelberg, 304–311.
[16]
Bart Jacobs, Frédéric Vogels, and Frank Piessens. 2015. Featherweight VeriFast. Logical Methods in Computer Science Volume 11, Issue 3 (Sept. 2015). https://lmcs.episciences.org/1595/pdf
[17]
Mauro Jaskelioff. 2009. Modular Monad Transformers. In Programming Languages and Systems (Lecture Notes in Computer Science), Giuseppe Castagna (Ed.). Springer Berlin Heidelberg, 64–79.
[18]
Mauro Jaskelioff. 2011. Monatron: An Extensible Monad Transformer Library. In Implementation and Application of Functional Languages (Lecture Notes in Computer Science), Sven-Bodo Scholz and Olaf Chitil (Eds.). Springer Berlin Heidelberg, 233–248.
[19]
Ohad Kammar, Sam Lindley, and Nicolas Oury. 2013. Handlers in Action. In ICFP. ACM.
[20]
Oleg Kiselyov and Hiromi Ishii. 2015. Freer Monads, More Extensible Effects. In Proceedings of the 2015 ACM SIGPLAN Symposium on Haskell (Haskell ’15). ACM, New York, NY, USA, 94–105.
[21]
Oleg Kiselyov, Amr Sabry, and Cameron Swords. 2013. Extensible Effects: An Alternative to Monad Transformers. In Haskell Symposium.
[22]
Oleg Kiselyov and Chung-chieh Shan. 2004. Functional Pearl: Implicit Configurations–or, Type Classes Reflect the Values of Types. In Haskell Workshop. ACM, 33–44.
[23]
John Launchbury and Simon L. Peyton Jones. 1994. Lazy Functional State Threads. In Programming Languages Design and Implementation. ACM, 24–35.
[24]
Sheng Liang, Paul Hudak, and Mark Jones. 1995. Monad Transformers and Modular Interpreters. In Principles of Programming Languages. ACM.
[25]
Mark S. Miller. 2006. Robust Composition: Towards a Unified Approach to Access Control and Concurrency Control. Ph.D. Dissertation. Johns Hopkins University.
[26]
Gordon Plotkin and Matija Pretnar. 2009. Handlers of Algebraic Effects. In Programming Languages and Systems. Lecture Notes in Computer Science, Vol. 5502. Springer Berlin Heidelberg, 80–94.
[27]
Russell O’Connor. 2014. Van Laarhoven Free Monad. (Feb. 2014). http://r6.ca/blog/20140210T181244Z.html
[28]
Tom Schrijvers and Bruno C.d.S. Oliveira. 2011. Monads, Zippers and Views: Virtualizing the Monad Stack. In International Conference on Functional Programming. ACM, 32–44.
[29]
Ryan Scott. 2018. How QuantifiedConstraints Can Let Us Put Join Back in Monad. (March 2018). https://ryanglscott.github.io/2018/03/04/howquantifiedconstraints-can-let-us-put-join-back-in-monad/
[30]
Austin Seipp. 2013. Reflecting Values to Types and Back. School of Haskell (Aug. 2013). https://www.schoolofhaskell.com/user/ thoughtpolice/using-reflection
[31]
Michael Snoyman. 2017. The ReaderT Design Pattern. (June 2017). https://www.fpcomplete.com/blog/2017/06/readert-design-pattern
[32]
Henning Thielemann. 2013. Mutable Variable. (June 2013). https: //wiki.haskell.org/Mutable_variable
[33]
Twan van Laarhoven. 2009. CPS Based Functional References. (July 2009). https://www.twanvl.nl/blog/haskell/cps-functional-references
[34]
Vasiliy Kevroletin. 2018. Introduction to Tagless Final. (Dec. 2018). https://serokell.io/blog/2018/12/07/tagless-final
[35]
Frédéric Vogels. 2012. Formalisation and Soundness of Static Verification Algorithms for Imperative Programs (Formalisatie en correctheid van statische verificatiealgoritmes voor imperatieve programma’s). Ph.D. Dissertation. https://lirias.kuleuven.be/retrieve/204848
[36]
Janis Voigtländer. 2009. Free Theorems Involving Type Constructor Classes: Functional Pearl. In International Conference on Functional Programming. ACM, 173–184.
[37]
Philip Wadler. 1989. Theorems for Free!. In Functional Programming Languages and Computer Architecture. ACM, 347–359.
[38]
Thomas Winant and Dominique Devriese. 2018. Coherent Explicit Dictionary Application for Haskell. In Haskell Symposium.
[39]
Nicolas Wu and Tom Schrijvers. 2015. Fusion for Free. In Mathematics of Program Construction.
[40]
Yizhou Zhang and Andrew C. Myers. 2019. Abstraction-Safe Effect Handlers via Tunneling. Proc. ACM Program. Lang. 3, POPL (Jan. 2019), 5:1–5:29.

Cited By

View all
  • (2023)From Capabilities to Regions: Enabling Efficient Compilation of Lexical Effect HandlersProceedings of the ACM on Programming Languages10.1145/36228317:OOPSLA2(941-970)Online publication date: 16-Oct-2023
  • (2022)Verified symbolic execution with Kripke specification monads (and no meta-programming)Proceedings of the ACM on Programming Languages10.1145/35476286:ICFP(194-224)Online publication date: 31-Aug-2022
  • (2019)Binders by day, labels by night: effect instances via lexically scoped handlersProceedings of the ACM on Programming Languages10.1145/33711164:POPL(1-29)Online publication date: 20-Dec-2019

Index Terms

  1. Modular effects in Haskell through effect polymorphism and explicit dictionary applications: a new approach and the μVeriFast verifier as a case study

        Recommendations

        Comments

        Information & Contributors

        Information

        Published In

        cover image ACM Conferences
        Haskell 2019: Proceedings of the 12th ACM SIGPLAN International Symposium on Haskell
        August 2019
        175 pages
        ISBN:9781450368131
        DOI:10.1145/3331545
        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 ACM 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: 08 August 2019

        Permissions

        Request permissions for this article.

        Check for updates

        Author Tags

        1. Haskell
        2. backtracking search
        3. effect polymorphism
        4. modular effects
        5. monads
        6. separation logic
        7. symbolic execution

        Qualifiers

        • Research-article

        Conference

        ICFP '19
        Sponsor:

        Acceptance Rates

        Overall Acceptance Rate 57 of 143 submissions, 40%

        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)9
        • Downloads (Last 6 weeks)1
        Reflects downloads up to 22 Oct 2024

        Other Metrics

        Citations

        Cited By

        View all
        • (2023)From Capabilities to Regions: Enabling Efficient Compilation of Lexical Effect HandlersProceedings of the ACM on Programming Languages10.1145/36228317:OOPSLA2(941-970)Online publication date: 16-Oct-2023
        • (2022)Verified symbolic execution with Kripke specification monads (and no meta-programming)Proceedings of the ACM on Programming Languages10.1145/35476286:ICFP(194-224)Online publication date: 31-Aug-2022
        • (2019)Binders by day, labels by night: effect instances via lexically scoped handlersProceedings of the ACM on Programming Languages10.1145/33711164:POPL(1-29)Online publication date: 20-Dec-2019

        View Options

        Get Access

        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