Hierarchical Free Monads and Software Design in Functional Programming

Functional Programming is going through the same process of rethinking as Object Oriented Programming has passed already. FP today is not only something mystical, something barely applicable for day-to-day tasks, but rather a whole philosophy of building big, complex applications, with own tools, approaches and methodologies. We can see a lot of ideas about software design and architecture emerging from the FP community: talks, books, articles. We’re actively discussing Final Tagless, Free Monads, effect systems and other approaches, but it seems the theme not yet covered and we don’t know about possibilities we have.

In this talk, I’ll tell you about the power of Free Monads in building complex applications in Haskell and PureScript. These applications will be satisfying the requirements like maintainability, testability, simplicity. You’ll know how to create a safe concurrent application state, how to divide the application into layers and how to keep the code sane. In fact, you can do the same with Final Tagless or extensible effects, but the approach with hierarchical Free Monads has some specific properties making it the best tool to separate concerns and create a very interesting eDSLs with different semantics.

The talk is based on the ideas I’m describing in my book “Functional Design and Architecture”. I also gave several talks about this theme earlier (you can find all my talks here).

I’ve used these ideas to build software for different companies, including Juspay (Bengaluru), Restaumatic (Poland), Enecuum (Hong Kong). We’ve created several interesting technologies that were not possible to make without Free Monads. Some of them are open sourced.

 
 

Outline/Structure of the Talk

  1. Software Design in Functional Programming
    1. The main tasks of Software Design
    2. Inversion of Control: how, why, when
    3. Final Tagless vs Free Monads vs Effect systems vs Freer vs…
  2. Introduction into Software Design with Free Monads
    1. The key idea of Free Monads
    2. Layering the application
      1. Domain Model
      2. Business Logic Languages
      3. Scenarios
      4. Application State
      5. Database Model
      6. Implementation layer
      7. Runtime
  3. Sample program
  4. Testing of Free Monad
    1. Functional testing
    2. Integration testing
  5. Conclusion

Learning Outcome

The audience will learn about eDSLs design and semantics, about the ways of structuring of applications, about the importance of layering, about testing and other aspects of software design, - and all this based on the Hierarchical Free Monads approach.

Target Audience

Haskell, PureScript developers who wants to know more about software design in large in pure functional languages.

Prerequisites for Attendees

It's a nice idea to learn about why we need Final Tagless, Free Monads, Service Handle pattern.

The rough understanding of monads is preferred.

All the slides will be in Haskell / PureScript.

schedule Submitted 1 month ago

Public Feedback

comment Suggest improvements to the Speaker

  • Liked Harmeet Singh
    keyboard_arrow_down

    Harmeet Singh - Type System: The Beauty And The Beast

    45 Mins
    Talk
    Intermediate

    The type system plays an important role in building type-safe applications that reduce runtime exceptions and developer mistakes. This sophisticated system is leveraged by Scala’s most famous functional libraries, such as Scala-Cats and ScalaZ. This feature-rich system allows implementing pure functional programming on the JVM. It is a beast due to its complex syntax, as it prevents developers from exploring its beautiful aspects like partially applying types in Scala. In this talk, we will tame the beast and use its beauty to solve real-life issues faced during coding. Our examples will be based on generics, constraints, type lambdas, and the kind projector plugin.

    The following are the learning objectives of this talk:

    1. Practical use cases of the type system using real-life coding examples.

    2. Implementing custom higher kinded types and handling partially applied types via type lambdas and the kind projector plugin.