Hierarchical Free Monads and Software Design in Functional Programming

schedule Nov 16th 04:00 - 04:45 PM place Ball Room 2 people 65 Interested

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 4 months ago

Public Feedback

comment Suggest improvements to the Speaker

  • Liked Aaron W Hsu
    keyboard_arrow_down

    Aaron W Hsu - Programming Obesity: A Code Health Epidemic

    Aaron W Hsu
    Aaron W Hsu
    Computer Scientist
    Indiana University
    schedule 2 months ago
    Sold Out!
    45 Mins
    Keynote
    Beginner

    Programs are getting fat. They're becoming slow. They're taking up more computing resources. They're getting harder to maintain and more complex from the ground up. Layer upon layer of sophistication is causing us to lose our ability to predict what software will do. Where's that bug? Why is everything going so slowly? Am I even using the right data structures? Where's that important point in the documentation again?

    What's happened to us? In this meta-dive into the nature of our approach to programming, we will explore some of the dangers of our current approaches to programming and the how/why of our current programming obesity problem. We will look at real case studies and see just how bad the situation can be.

    But we will also explore how we can battle these sources of obesity. In this passionate plea for code that we can gain control over again, we will look at examples of how we can return to a state of high-performance on all levels, from code size to code scalability. We will look at the principles that can help us to reach leaner, more efficient, more usable, less buggy code. We will hopefully find some light at the end of the tunnel, and how we can change our outlook on programming to push ourselves towards code that benefits not only ourselves, but also those that will come after us.

  • Liked Andrea Leopardi
    keyboard_arrow_down

    Andrea Leopardi - BEAM Architecture Handbook

    Andrea Leopardi
    Andrea Leopardi
    Core Team Member
    Elixir Lang
    schedule 3 months ago
    Sold Out!
    45 Mins
    Talk
    Intermediate

    If you are writing a stateless web application backed up by a database, there is a good chance Elixir is a great fit. However, this is not where it shines. In this talk, we will discuss how to architect Elixir applications in order to leverage the features of the language and of its runtime.

    We will look at this both from a lower level, talking about the architecture of processes inside an Elixir application, as well as from a higher perspective of writing Elixir services and architecting systems to play to Elixir's strengths. We will see practical use cases and discuss design patterns.
  • Liked Allister Beharry
    keyboard_arrow_down

    Allister Beharry - Lightweight dependent types for scientific computing

    Allister Beharry
    Allister Beharry
    Software Developer
    Freelancer
    schedule 2 months ago
    Sold Out!
    20 Mins
    Demonstration
    Intermediate

    Sylvester is an F# DSL for scientific computing which implements an advanced type system where vector, matrix, tensor, neural-network and other types have numeric properties like dimension sizes, rank, layer node size, etc., encoded as part of the type. Type-level constraints for operations like matrix multiplication or network layer construction utilize the F# type checker as a type-checker for linear algebra and other mathematical domains which allows for type-level verification of mathematical operations and for Intellisense-enabled IDEs to provide immediate feedback that helps the user avoid errors in mathematical expressions..

  • Liked Nikhil More
    keyboard_arrow_down

    Nikhil More - Do you OOP in Elixir?

    Nikhil More
    Nikhil More
    Sr. Engineer
    Volansys
    schedule 2 months ago
    Sold Out!
    20 Mins
    Experience Report
    Beginner

    One of the strategies being adopted by RoR or Java software developers in adopting Elixir is they have not yet adapted themselves to unlearn the OOP in developing the web systems. This has caused OOP concepts to creep into full fledged Elixir systems. This presentation seeks to highlight these subtle points that need to be avoided to make the code more FP and less OOP.

  • Liked Tony Morris
    keyboard_arrow_down

    Tony Morris - An Intuition for List Folds

    45 Mins
    Talk
    Beginner

    In this talk, we go back to first principles, defining and examining the definition for a cons list, then take a look at the ubiquitous right and left fold functions on a list.

    The primary focus of this talk is to develop an intuition for how these functions work so that we can best decide when to apply them. Multiple programming languages will be used to help emphasise the independence of the gained intuition. This talk will generally be interactive with the audience as we solve problems and build confidence in our new knowledge.

    Knowing how to apply the various list fold functions is a common question by the student of FP. This talk aims to provide a solid, reliable answer to this question. No prior understanding of list folds is necessary.

  • Liked Tony Morris
    keyboard_arrow_down

    Tony Morris - Zippers

    45 Mins
    Talk
    Intermediate

    The term zipper is a colloquial used to describe n-hole (most often, 1-hole) contexts. That is, a data structure that has a _hole_ or _pointer_ focused on a specific element with the ability to efficiently traverse to its neighbouring elements, providing an elegant solution for the need to efficiently traverse and _modify_ immutable data structures.

    In this talk, we will look at examples of zippers for canonical data structures such as lists and other products and sums. We will then define comonads and see the relationship between zippers and comonads.

    Most of this talk will be spent on the practical application of zippers in everyday programming. We will solve some simple problems using zippers. We will then contrast why we might use a zipper, compared to a lens.

    Finally, for a fun and interesting observation, we will look at the algebraic structure of products and sums, then compute the derivative of these structures. Turns out, a derivative of a data structure is its zipper ("McBride, Conor, et al (2005). ∂ for Data: Differentiating Data Structures").

  • Liked Saurabh Nanda
    keyboard_arrow_down

    Saurabh Nanda - Getting property-based testing to work after struggling for 3 years

    Saurabh Nanda
    Saurabh Nanda
    Founder
    Vacation Labs
    schedule 2 months ago
    Sold Out!
    45 Mins
    Talk
    Intermediate

    I got excited about property-based testing after hearing John Hughes talk at Functional Conf 2016. I tried it that year with QuickCheck, but failed miserably (it almost derailed the entire project delivery). I cribbed about it in my talk at Functional Conf 2017. In 2018, Srihari's talk got me excited again. This time, I tried with Hedgehog, and got it to work!

    This talk is about this journey and its learnings. We'll talk about how Hedgehog was used to test [1]:

    • A Postgres backed task/job queue
    • A small Wai/Servant based webapp

    And no, we will not talk about the most common (and completely useless) example of reversing a list!

    [1] Both of these are part of an open-sourced task/job queue library.

  • Liked Harendra Kumar
    keyboard_arrow_down

    Harendra Kumar - Streamly: Declarative Concurrency and Dataflow Programming in Haskell

    Harendra Kumar
    Harendra Kumar
    Founder
    Composewell Technologies
    schedule 2 months ago
    Sold Out!
    45 Mins
    Talk
    Intermediate

    Overview: Streamly is a Haskell library for writing programs in a high level, declarative data flow programming paradigm. It provides a simple API, very close to standard Haskell lists. A program is expressed as a composition of data processing pipes, generally known as streams. Streams can be generated, merged, chained, mapped, zipped, and consumed concurrently – enabling a high level, declarative yet concurrent composition of programs. Programs can be concurrent or non-concurrent without any significant change. Concurrency is auto scaled based on consumption rate. Programmers do not have to be aware of threads, locking or synchronization to write scalable concurrent programs. Streamly provides C like performance, orders of magnitude better compared to existing streaming libraries.

    Motivation: Haskell has a beautiful abstraction capability. Haskell lists, several streaming and concurrency libraries are some examples of good programming abstractions. The problem is that concurrency is not handled elegantly and declaratively by these libraries. Moreover, the lack of good performance gives rise to special purpose performance centric libraries like text and bytestring creating more confusion. Streamly unifies, lists, streaming, concurrency, logic programming and reactive programming with unparalleled performance. We can finally have a unified string handling.

    Audience: Streamly is designed to express the full spectrum of programs. Do not think that if you are writing a small and simple program it may not be for you. It expresses a small program with the same efficiency, simplicity and elegance as a large scale concurrent application. It unifies many different aspects of special purpose libraries into a single yet simple framework. It is especially suitable for high performance and scalable backend data processing systems. If you use or plan to use any real time streaming or data flow programming frameworks including Apache Flink, Apache Spark or asynchronous/reactive programming frameworks like ReactiveX/RxJs then you may be interested in Streamly.

  • Liked Anupam Jain
    keyboard_arrow_down

    Anupam Jain - Supercharged Web Application development with Purescript

    45 Mins
    Workshop
    Beginner

    UPDATE: Please setup https://github.com/ajnsit/purescript-react-starter (follow the instructions in the README) on your laptops as a **prerequisite**.

    Purescript is a purely functional, strongly typed language, that compiles to Javascript.

    It provides several high quality libraries for frontend development, and comes with excellent tooling and editor support that makes writing code a snap!

    In this talk I will provide a quick introduction to some basics of Purescript, and then dive into an interactive demonstration of building a non-trivial web application from scratch. I will show how to interface with React bindings, and how to interface with some existing Javascript libraries (a React UI component lib).

    The presentation will be interactive and similar to an inpromptu talk I gave which is linked below. However, I will also demonstrate live coding of an actual purescript application which people can follow along.

    Bring your laptop to follow along.

  • Liked Morten Kromberg
    keyboard_arrow_down

    Morten Kromberg - Delivering your APLs

    Morten Kromberg
    Morten Kromberg
    CXO
    Dyalog
    schedule 2 months ago
    Sold Out!
    45 Mins
    Tutorial
    Beginner

    Most talks on APL at FunctionalConf have focused on the way array oriented programming allows you to quickly deliver concise and efficient solutions to problems with an analytical core. This talk will focus on the development environment, and follow the life of an APL code snippet from it's interactive discovery, via testing and debugging, through to delivery as a web service and a shared object, embedded into a solution implemented in Python.

  • Liked Tamizhvendan S
    keyboard_arrow_down

    Tamizhvendan S - Building an E-Commerce Marketplace Middleware in Clojure

    Tamizhvendan S
    Tamizhvendan S
    Lead Consultant
    Ajira
    schedule 2 months ago
    Sold Out!
    45 Mins
    Case Study
    Beginner

    Have you ever wondered how we can build a real-world, production-ready, end-to-end application using the functional programming principles? Immutability, Pure Functions and all other functional programming things sound good on paper but How can we build something useful by applying it?

    At Ajira, We recently built an e-commerce marketplace middleware in Clojure for a leading retail chain to sell their products on multiple e-commerce sites seamlessly. In this case study, we are going to build a minimal version of this project using which I will be sharing how we implemented it.

  • Liked Aaron W Hsu
    keyboard_arrow_down

    Aaron W Hsu - APL Training Wheels

    Aaron W Hsu
    Aaron W Hsu
    Computer Scientist
    Indiana University
    schedule 2 months ago
    Sold Out!
    45 Mins
    Tutorial
    Beginner

    APL is getting a lot of attention lately due to its potential for very high performance portability and suitability for both rapid prototyping of complex solutions as well as deployment of complex algorithms to high-speed, modern parallel hardware. It has the potential to vastly improve the speed, scalability, and size of your code bases. But APL has a reputation as an intimidating language to learn.

    In this back to the basics tutorial, we will explore the core of APL, and focus on those areas that usually trip up the beginner in learning APL. We will also walk you through how to approach an APL expression, how to reason about them, and how to read them efficiently. We will teach you the skills that the expert APLer has internalized, and how you can work through these skills externally and explicitly in a way that will help you to eventually internalize these critical skills in a way that makes you efficient at using APL on real world problems.

  • Liked Saurabh Nanda
    keyboard_arrow_down

    Saurabh Nanda - Why is Haskell so hard to learn? (and how to deal with it)

    Saurabh Nanda
    Saurabh Nanda
    Founder
    Vacation Labs
    schedule 2 months ago
    Sold Out!
    45 Mins
    Talk
    Beginner

    Haskell is notoriously hard to learn. I have struggled with the learning curve. I have seen others struggle with it. And I have seen developers struggling to wield the language effectively even after months of learning.

    We'll talk about five things that give Haskell this (understandably) bad rep, and how to effectively deal with them during your learning phase.

  • Liked Ravi Chandra Padmala
    keyboard_arrow_down

    Ravi Chandra Padmala - After the Crash

    Ravi Chandra Padmala
    Ravi Chandra Padmala
    Partner
    nilenso
    schedule 2 months ago
    Sold Out!
    45 Mins
    Talk
    Intermediate

    'Let it crash' gets thrown around a lot in the Erlang community. An experienced
    programmer (with understandably different experiences) on first encountering
    this idea in Erlang is often found asking what we let crash? And what happens
    after?

    I will attempt to answer this question.

    Erlang puts distributed systems programming ideas front and center. We'll also
    talk about this in the context of letting processes crash and how that affects the
    design of our software.


  • Liked Edward Kmett
    keyboard_arrow_down

    Edward Kmett / Tony Morris - Let's Lens

    Edward Kmett
    Edward Kmett
    Chair of the Haskell Core Libraries Committee, Research Engineer
    Machine Intelligence Research Institute
    Tony Morris
    Tony Morris
    Sr. Software Engineer
    Queensland FP Lab, Data61
    schedule 2 months ago
    Sold Out!
    480 Mins
    Workshop
    Intermediate

    Let's Lens presents a series of exercises, in a similar format to the Data61 functional programming course material. The subject of the exercises is around the concept of lenses, initially proposed by Foster et al., to solve the view-update problem of relational databases.

    The theories around lenses have been advanced significantly in recent years, resulting in a library, implemented in Haskell, called lens.

    This workshop will take you through the basic definition of the lens data structure and its related structures such as traversals and prisms. Following this we implement some of the low-level lens library, then go on to discuss and solve a practical problem that uses all of these structures.

  • Liked Sreenidhi Nair
    keyboard_arrow_down

    Sreenidhi Nair - Learnings from using haskell in production

    Sreenidhi Nair
    Sreenidhi Nair
    Senior Haskell Developer
    ByteAlly
    schedule 2 months ago
    Sold Out!
    20 Mins
    Experience Report
    Intermediate

    Over a period of 7 years, we have applied Haskell across Web apps, compilers, parsers for our customers across various industries. This is our report on how some of the unique features of Haskell have not only helped us create stable production environments but also break barriers. On the other hand, there is a high cost of on-boarding new developers and few other pain points. So, is Haskell worth the investment?

  • Liked Suvrat Apte
    keyboard_arrow_down

    Suvrat Apte - How debuggers work in Lispy languages

    Suvrat Apte
    Suvrat Apte
    Backend Engineer
    Helpshift
    schedule 2 months ago
    Sold Out!
    45 Mins
    Talk
    Intermediate

    Debuggers are one of the most essential tools for any kind of development.

    Debuggers in Lispy languages make use of Lisp's homoiconicity. They are a bit different from debuggers for languages like C or Java.

    This kind of information is usually not needed in day to day development and hence it remains hidden.

    In this talk, I will take Clojure's cider-debug as an example and explain how it uses homoiconicity. Along with cider-debug, I will also talk about REPLs and how REPL client-server communication happens (with nREPL as an example).

  • Liked Siddharth Bhat
    keyboard_arrow_down

    Siddharth Bhat - Monad-bayes: Probabilistic programming in haskell, tutorial & implementation

    Siddharth Bhat
    Siddharth Bhat
    Student
    IIIT Hyderabad
    schedule 2 months ago
    Sold Out!
    20 Mins
    Case Study
    Intermediate

    We take a dive into probabilistic programming, beginning with a high-level explanation of what probabilistic programming is. We then continue to see how to use the monad-bayes library for performing tasks such as regression in a bayesian formalism. We also look into the implementation of the library, which involves performing an interesting sampling method (markov-chain-monte-carlo) on a very unique space (the space of computational traces of the program). We finally end with next-steps for the haskell community to improve in the probablistic programming space, ala pyro for python

    Here is our tiny re-implementation of monad-bayes, boiled down to the essentials: https://github.com/bollu/shakuni

    Paper on which the talk is based on: http://mlg.eng.cam.ac.uk/pub/pdf/SciGhaGor15.pdf

  • Liked Anne Ogborn
    keyboard_arrow_down

    Anne Ogborn - Introduction to Logic Programming and SWI-Prolog

    Anne Ogborn
    Anne Ogborn
    Logic Programmer
    DataChemist.com
    schedule 2 months ago
    Sold Out!
    480 Mins
    Workshop
    Beginner

    As machine learning matures, it is becoming obvious that we need explainable solutions. As functional programming matures it becomes obvious that we need inference and nondeterminism. And linked open data demands reasoning. This all day workshop will introduce the logic programming paradigm, in which programs are expressed as a set of logical rules and executed by finding proofs of queries.

    SWI-Prolog is the most highly developed and widely used language for logic programming.

    The language, which has been in continuous use in academic research settings since it's invention in 1972, provides unparalleled power. Many problems which would be difficult to express in other languages are simple in SWI-Prolog. SWI-Prolog is a 'batteries included' modern language, ready for real world tasks like web development and process control.

    In this dynamic hands on workshop we'll learn the basics of SWI-Prolog, and look at some of the amazing things it can do.

  • Liked Mangala Kader
    keyboard_arrow_down

    Mangala Kader - Understanding the pitfalls in Erlang / Elixir and steering clear from them

    45 Mins
    Talk
    Beginner

    Erlang has been in production for more than 30 years and a highly battle-tested robust system, which is being used by everybody including Telecom systems that provides 99.99% uptime. Elixir has been built on top of Erlang overcoming the shortcomings of the language and also using meta-programming, it has opened a new paradigm of looking at the language itself. I want to show what Elixir is to the audience and minute nuances that every experienced or inexperienced developer should be aware of before jumping into the magical erlang and elixir world.