Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
skip to main content
10.1145/3609025.3609477acmconferencesArticle/Chapter ViewAbstractPublication PagesicfpConference Proceedingsconference-collections
research-article
Open access

Typed Design Patterns for the Functional Era

Published: 31 August 2023 Publication History

Abstract

This paper explores how design patterns could be revisited in the era of mainstream functional programming languages. I discuss the kinds of knowledge that ought to be represented as functional design patterns: architectural concepts that are relatively self-contained, but whose entirety cannot be represented as a language-level abstraction. I present four concrete examples embodying this idea: the Witness, the State Machine, the Parallel Lists, and the Registry. Each pattern is implemented in Rust to demonstrate how careful use of a sophisticated type system can better model each domain construct and thereby catch user mistakes at compile-time.

References

[1]
2011. Where are all the functional programming design patterns? https://softwareengineering.stackexchange.com/q/89273
[2]
Jonathan Aldrich, Joshua Sunshine, Darpan Saini, and Zachary Sparks. 2009. Typestate-Oriented Programming. In Proceedings of the 24th ACM SIGPLAN Conference Companion on Object Oriented Programming Systems Languages and Applications (OOPSLA ’09). Association for Computing Machinery, New York, NY, USA. 1015–1022. isbn:9781605587684 https://doi.org/10.1145/1639950.1640073
[3]
Jean-Philippe Bernardy, Mathieu Boespflug, Ryan R. Newton, Simon Peyton Jones, and Arnaud Spiwack. 2017. Linear Haskell: Practical Linearity in a Higher-Order Polymorphic Language. Proc. ACM Program. Lang., 2, POPL (2017), Article 5, dec, 29 pages. https://doi.org/10.1145/3158093
[4]
Michael Bevilacqua-Linn. 2013. Functional Programming Patterns in Scala and Clojure. The Pragmatic Bookshelf.
[5]
Edwin Brady. 2017. Type-Driven Development with Idris. Manning, New York, USA.
[6]
José Duarte and António Ravara. 2021. Retrofitting Typestates into Rust. In Proceedings of the 25th Brazilian Symposium on Programming Languages (SBLP ’21). Association for Computing Machinery, New York, NY, USA. 83–91. isbn:9781450390620 https://doi.org/10.1145/3475061.3475082
[7]
Eric Evans. 2003. Domain-driven design. Addison-Wesley Educational, Boston, MA.
[8]
Matthias Felleisen, Robert Bruce Findler, Matthew Flatt, and Shriram Krishnamurthi. 2018. How to design programs: an introduction to programming and computing. MIT Press.
[9]
Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides. 1994. Design patterns. Addison Wesley, Boston, MA.
[10]
Jeremy Gibbons. 2006. Design Patterns as Higher-Order Datatype-Generic Programs. In Proceedings of the 2006 ACM SIGPLAN Workshop on Generic Programming (WGP ’06). Association for Computing Machinery, New York, NY, USA. 1–12. isbn:1595934928 https://doi.org/10.1145/1159861.1159863
[11]
Alexander Granin. 2020. Functional Design and Architecture. Leanpub.
[12]
John Hunt. 2013. Scala Design Patterns. Springer, Pennsylvania, USA.
[13]
Thomas Bracht Laumann Jespersen, Philip Munksgaard, and Ken Friis Larsen. 2015. Session Types for Rust. In Proceedings of the 11th ACM SIGPLAN Workshop on Generic Programming (WGP 2015). Association for Computing Machinery, New York, NY, USA. 13–22. isbn:9781450338103 https://doi.org/10.1145/2808098.2808100
[14]
Atul S. Khot. 2015. Scala Functional Programming Patterns. Packt Publishing, Birmingham, UK.
[15]
Oleg Kiselyov, Ralf Lämmel, and Keean Schupke. 2004. Strongly Typed Heterogeneous Collections. In Proceedings of the 2004 ACM SIGPLAN Workshop on Haskell (Haskell ’04). Association for Computing Machinery, New York, NY, USA. 96–107. isbn:1581138504 https://doi.org/10.1145/1017472.1017488
[16]
Ryan Lemmer. 2015. Haskell Design Patterns. Packt Publishing, Birmingham, UK.
[17]
Alp Mestanogullari, Sönke Hahn, Julian K. Arni, and Andres Löh. 2015. Type-Level Web APIs with Servant: An Exercise in Domain-Specific Generic Programming. In Proceedings of the 11th ACM SIGPLAN Workshop on Generic Programming (WGP 2015). Association for Computing Machinery, New York, NY, USA. 1–12. isbn:9781450338103 https://doi.org/10.1145/2808098.2808099
[18]
Nicholas Nethercote. 2020. The Rust Performance Book. https://nnethercote.github.io/perf-book/
[19]
Ivan Nikolov. 2016. Scala Design Patterns. Packt Publishing, Birmingham, UK.
[20]
Peter Norvig. 1998. Design Patterns in Dynamic Languages. https://www.norvig.com/design-patterns/
[21]
Riccardo Pucella and Jesse A. Tov. 2008. Haskell Session Types with (Almost) No Class. SIGPLAN Not., 44, 2 (2008), sep, 25–36. issn:0362-1340 https://doi.org/10.1145/1543134.1411290
[22]
David Rumelhart. 1980. Schemata: The building blocks of cognition. In Theoretical Issues in Reading Comprehension. Routledge.
[23]
Robert E. Strom and Shaula Yemini. 1986. Typestate: A programming language concept for enhancing software reliability. IEEE Transactions on Software Engineering, SE-12, 1 (1986), 157–171. https://doi.org/10.1109/TSE.1986.6312929
[24]
Scott Wlaschin. 2017. Domain Modeling made Functional. Tackle Software Complexity with Domain-Driven Design and F#. The Pragmatic Bookshelf. isbn:978-1-68050-254-1

Cited By

View all

Index Terms

  1. Typed Design Patterns for the Functional Era
    Index terms have been assigned to the content through auto-classification.

    Recommendations

    Comments

    Information & Contributors

    Information

    Published In

    cover image ACM Conferences
    FUNARCH 2023: Proceedings of the 1st ACM SIGPLAN International Workshop on Functional Software Architecture
    August 2023
    62 pages
    ISBN:9798400702976
    DOI:10.1145/3609025
    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: 31 August 2023

    Permissions

    Request permissions for this article.

    Check for updates

    Author Tags

    1. design patterns
    2. domain-driven design
    3. rust

    Qualifiers

    • Research-article

    Conference

    FUNARCH '23
    Sponsor:

    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

    • 0
      Total Citations
    • 1,003
      Total Downloads
    • Downloads (Last 12 months)907
    • Downloads (Last 6 weeks)38
    Reflects downloads up to 12 Nov 2024

    Other Metrics

    Citations

    Cited By

    View all

    View Options

    View options

    PDF

    View or Download as a PDF file.

    PDF

    eReader

    View online with eReader.

    eReader

    Get Access

    Login options

    Media

    Figures

    Other

    Tables

    Share

    Share

    Share this Publication link

    Share on social media