Email the Author
You can use this page to email Alexander Granin about Functional Design and Architecture (Early Edition, 2020).
About the Book
Important: this is the Early Edition of the book self-published in 2020.
* Consider buying Functional Design and Architecture, significantly reworked and published by Manning in 2024.
* See also my new book Pragmatic Type-Level Design.
FDaA is a fundamental book about Software Design in Haskell and other functional languages. The main idea of this book is to provide a comprehensive source of knowledge, and a complete methodology for building real-world applications. Application architectures, best practices, design patterns, and approaches, - all the information you need to achieve a simple, maintainable, testable code with low complexity and low risks. By reading this book, you’ll learn many useful techniques: from the requirement analysis to the implementation of particular subsystems such as SQL and NoSQL databases, multithreading, and logging. You’ll learn about design principles, application layers, functional interfaces, Inversion of Control, and Dependency Injection.
The book has 9 chapters, 780K symbols, 120K words.
The book is very practical. It will be useful for software engineers who want to improve their software design skills with a strong relation to many advanced Haskell concepts.
The book requires a certain level of Haskell knowledge, up to intermediate.
The book covers a big gap in the Haskell ecosystem: the lack of resources for high-level application design. It’s also important that the ideas from the book were used in real production with great success. The book offers my own methodology - Functional Declarative Design, with Hierarchical Free Monads as a core technology. Using this methodology, I created several real-world frameworks, and they are driving a successful business in several companies.
There is a limited colored hardcover version of the book of the highest printing quality. This is what it looks like (video). Shipping is not possible at the moment.
Book topics:
- requirements analysis and architecture modeling;
- application layering;
- design principles, SOLID;
- Haskell-specific design patterns;
- Inversion of Control and Dependency Injection;
- domain modeling, embedded and external DSLs;
- functional interfaces, subsystems, and services;
- Free monads, ReaderT pattern, Service handle pattern;
- Final Tagless/mtl, GADTs
- multithreading and concurrency;
- state and stateful applications;
- design of business logic;
- interaction with impure subsystems;
- relational and key-value databases;
- error handling, exceptions, error domains;
- web servers, HTTP backends, CLI applications;
- property-based, functional, and integration testing;
- black box and white box testing.
The book is project-based. There are two showcase projects for it:
- Hydra, a full-fledged framework for building web services, multithreaded, and concurrent applications with SQL and KV DB support. Contains 3 engines: Final Tagless, Free Monad, and Church Encoded Free Monad, as well as several demo applications to compare these 3 approaches.
- Andromeda, a SCADA software for spaceship control.
I designed the following real-world frameworks using the ideas from the book (with the help of other people of course):
- EulerHS - a Haskell framework for web backends and console apps. Has many subsystems out of the box: SQL DBs support (Postgres, MySQL, SQLite), KV DBs support (Reddis), logging, concurrent flows, exception handling, automatic whitebox testing, typed options and other stuff.
- PureScript Presto - a PureScript framework for building mobile apps using a handy eDSL.
- PureScript Presto.Backend - a PureScript framework for web backends. It has the same design as Presto but also is empowered by some additional features like logging, HTTP APIs integration, KV DB, SQL DB subsystems, state handling, automatic whitebox testing, and other useful stuff.
All of these frameworks drive the business of an Indian financial company Juspay. Its mobile apps and financial backends have hundreds of thousands of lines of code, and these frameworks are really tested in production. This technology helped the company to grow and enabled wide adoption of PureScript and Haskell. Essentially, Juspay was the first company I used my ideas. We found that Hierarchical Free Monads hide all the complexity of implementation details behind convenient interfaces so that the code is understandable by not only developers but by managers as well. This helped us to easily reason about the domain, the logic, the business goals and the requirements. My approach also brought confidence that Haskell and PureScript are not only academic languages.
- Node - a full-fledged framework for building distributed, concurrent, multithreading apps, and blockchains initially, but not only. I designed this framework for Enecuum and then we successfully created our own blockchain using it. What's important, we managed to achieve our goals less than in 4 months with a team of 4 haskellers. The framework allowed us to write fast, complicated blockchain logic easily, quickly, without bugs and with maximum confidence due to the great testability of the HFM approach. You can read more about the framework in this my article: Building network actors with Node Framework.
About the Author
International speaker, researcher, author
Expert Haskell and C++ developer
Software architect, team lead
Haskell consultant
Author of the book "Functional Design and Architecture"