Functional Design and Architecture
Functional Design and Architecture (The Book + 6 Educational Videos + Code Samples)
$60.00
Minimum price
$80.00
Suggested price
Functional Design and Architecture

This book is 99% complete

Last updated on 2020-07-04

About the Book

The book is focusing on the design patterns, best practices and approaches to create applications using pure functional language such as Haskell. It aims to consolidate all the knowledge about how to create big applications in pure functional manner. The book builds a complete methodology based on Hierarchical Free Monads step-by-step. The material contains several original ideas on structuring applications, using monads, building DSLs. These ideas are very practical and proven to be working in real production. The book is practice-oriented, project-based. It's a fundamental source of knowledge on Software Engineering in Haskell.

The book will be useful for those who wants to learn Software Engineering, Design and Architecture in Functional Programming and Haskell. A certain level of Haskell is required (up to Intermediate). Useful for Senior Software Engineers and Software Architects.

The book is finished in its draft. It has 9 chapters, 732K symbols, 113K words. Now I'm working on it to make the book solid. I need to fill the gaps, edit the chapters, restyle and reformat the text.

I have a plan to print the book in paper. Once it's done, all the buyers will get a copy for free.

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.

Topics:

  • Architecture modelling, requirements analysis, subsystems design from the FP point of view
  • Layering
  • Embedded and external DSLs and domain modelling
  • Subsystems and services
  • Free Monads as functional interfaces
  • Other types of functional interfaces: Final Tagless, ReaderT pattern, Service Handle Pattern, GADTs
  • Hierarchical Free Monads as a basis for effects
  • Frameworks
  • Inversion of Control and Dependency Injection in FP
  • Applicability of the mainstream techniques and principles such as UML, SOLID, GRASP
  • Interaction with impure subsystems
  • Project structuring
  • Incorporation of SQL DBs, KV DBs
  • Design of business logic
  • Design of web services and console applications
  • And many other high-level topics
  • Share this book

  • Feedback

    You must own a copy of this Book to access the forums

    Email the Author(s)

About the Author

Alexander Granin
Alexander Granin

Haskeller, speaker, researcher, author.

Haskell consultant

Author of the book "Functional Design and Architecture"

Proficient C++ Developer

Functional C++ Advocate

Table of Contents

  • 1 What is software design?
  • 1.1 Software design
  • 1.1.1 Requirements, goals, simplicity
  • 1.1.2 Defining software design
  • 1.1.3 Low coupling, high cohesion
  • 1.1.4 Interfaces, Inversion of Control and Modularity
  • 1.2 Imperative Design
  • 1.3 Object-Oriented Design
  • 1.3.1 Object-oriented design patterns
  • 1.3.2 Object-oriented design principles
  • 1.3.3 Shifting to functional programming
  • 1.4 Functional Declarative Design
  • 1.4.1 Immutability, purity and determinism in FDD
  • 1.4.2 Strong static type systems in FDD
  • 1.4.3 Functional patterns, idioms and thinking
  • 1.5 Summary
  • 2 Architecture of the application
  • 2.1 Defining software architecture
  • 2.1.1 Software architecture in FDD
  • 2.1.2 Top-down development process
  • 2.1.3 Collecting requirements
  • 2.1.4 Requirements in mind maps
  • 2.2 Architecture layering and modularization
  • 2.2.1 Architecture layers
  • 2.2.2 Modularization of applications
  • 2.3 Modeling the architecture
  • 2.3.1 Defining architecture components
  • 2.3.2 Defining modules, subsystems and relations
  • 2.3.3 Defining architecture
  • 2.4 Summary
  • 3 Subsystems and services
  • 3.1 Functional subsystems
  • 3.1.1 Modules and libraries
  • 3.1.2 Monads as subsystems
  • 3.1.3 Layering subsystems with the monad stack
  • 3.2 Designing the Hardware subsystem
  • 3.2.1 Requirements
  • 3.2.2 Algebraic data type interface to HDL
  • 3.2.3 Functional interface to Hardware subsystem
  • 3.2.4 Free monad interface to HDL
  • 3.2.5 Interpreter for monadic HDL
  • 3.2.6 Advantages and disadvantages of a Free language
  • 3.3 Functional services
  • 3.3.1 Pure service
  • 3.3.2 Impure service
  • 3.3.3 The MVar request-response pattern
  • 3.3.4 Remote impure service
  • 3.4 Summary
  • 4 Domain model design
  • 4.1 Defining the domain model and requirements
  • 4.2 Simple embedded DSLs
  • 4.2.1 Domain model eDSL using functions and primitive types
  • 4.2.2 Domain model eDSL using ADT
  • 4.3 Combinatorial embedded DSLs
  • 4.3.1 Mnemonic domain analysis
  • 4.3.2 Monadic Free eDSL
  • 4.3.3 The abstract interpreter pattern
  • 4.3.4 Free language of Free languages
  • 4.3.5 Arrows for eDSLs
  • 4.3.6 Arrowized eDSL over Free eDSLs
  • 4.4 External DSL
  • 4.4.1 External DSL description
  • 4.4.2 Parsing to the abstract syntax tree
  • 4.4.3 The translation subsystem
  • 4.5 Summary
  • 5 Application state
  • 5.1 Architecture of the stateful application
  • 5.1.1 State in functional programming
  • 5.1.2 Minimum viable product
  • 5.1.3 Hardware network definition language
  • 5.1.4 Architecture of the simulator
  • 5.2 Pure state
  • 5.2.1 Argument-passing state
  • 5.2.2 State monad
  • 5.3 Impure state
  • 5.3.1 Impure state with IORef
  • 5.3.2 Impure state with State and IO monads
  • 5.4 Summary
  • 6 Multithreading and Concurrency
  • 6.1 Multithreaded applications
  • 6.1.1 Why is multithreading hard?
  • 6.1.2 Bare threads
  • 6.1.3 Separating and abstracting the threads
  • 6.1.4 Threads bookkeeping
  • 6.2 Software Transactional Memory
  • 6.2.1 Why STM is important
  • 6.2.2 Reducing complexity with STM
  • 6.2.3 Abstracting over STM
  • 6.3 Useful patterns
  • 6.3.1 Logging and STM
  • 6.3.2 Reactive programming with processes
  • 6.3.3 Custom concurrent data types (todo)
  • 6.5 Summary
  • 7 Persistence
  • 7.1 Persistence in FP
  • 7.2 Basics of DB Support
  • 7.2.1 Domain Model and DB Model
  • 7.2.2 Designing Untyped KV DB Subsystem
  • 7.2.3 Abstracted Logic vs Bare IO Logic
  • 7.2.4 Designing SQL DB Model
  • 7.2.5 Designing SQL DB Subsystem
  • 7.3 Advanced DB Design
  • 7.3.1 Advanced SQL DB Subsystem
  • 7.3.2 Typed KV DB Model
  • 7.3.3 Transactions (todo)
  • 7.3.4 Pools (todo)
  • 7.3.5 STM as in-place in-memory DB (todo)
  • 7.4 Summary
  • 8 Business logic design
  • 8.1 Business logic layering
  • 8.1.1 Explicit and implicit business logic
  • 8.2 A CLI tool for reporting astronomical objects
  • 8.2.1 API types and command-line interaction
  • 8.2.2 HTTP and TCP client functionality
  • 8.3 Functional interfaces and Dependency Injection
  • 8.3.1 Service Handle Pattern
  • 8.3.2 ReaderT Pattern
  • 8.3.3 Additional Free monad language
  • 8.3.4 GADT
  • 8.3.5 Final Tagless / mtl
  • 8.3.6 And what about effect systems? (todo)
  • 8.4 Designing web services
  • 8.4.1 REST API and API types
  • 8.4.2 Using framework for business logic
  • 8.4.3 Web server with Servant
  • 8.4.4 Validation
  • 8.4.5 DB Layer and project layout (todo)
  • 8.4.6 Configuration management (todo)
  • 8.5 Summary
  • 9 Testing
  • 9.1 Testing and Functional Programming
  • 9.1.1 Test Driven Development in FP
  • 9.1.2 Property-based testing
  • 9.1.3 Property-based testing of a Free monadic scenario
  • 9.1.4 Integration testing
  • 9.1.5 Acceptance testing
  • 9.2 Advanced testing techniques
  • 9.2.1 Mocking
  • 9.2.2 Functional and unit testing
  • 9.2.3 Automatic whitebox testing
  • 9.3 Testability of different approaches
  • 9.4 Summary

Authors have earned$9,108,966writing, publishing and selling on Leanpub,
earning 80% royalties while saving up to 25 million pounds of CO2 and up to 46,000 trees.

Learn more about writing on Leanpub

The Leanpub 45-day 100% Happiness Guarantee

Within 45 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

See full terms

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers), EPUB (for phones and tablets) and MOBI (for Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses! Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks. Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. It really is that easy.

Learn more about writing on Leanpub