liveBook · Manning

Declarative definition

As explained in Functional Design and Architecture: Examples in Haskell

A declarative definition specifies the structure or intended result of an artifact without describing its execution procedure.

An imperative application script can become a declarative definition when it describes intended processes and logic instead of directly executing them. Rather than forking a process or evaluating a scenario immediately, the program defines those actions for a later interpreter. This separation creates room to redesign the implementation while preserving the application’s intent. section 9.1.3

A practical design sequence is:

  • Imagine the embedded language from its usage point of view, even before the design compiles. section 9.1.3
  • Use the proposed language to express business logic and assess whether the developer experience feels right. section 9.1.3
  • Make the design compile, then make its definitions work through suitable interpreters. section 9.1.3

Defining process structure

Aliases such as process = forkProcess and scenario = evalLang make an application read as a declaration: process (forever (astronomer ch)) and scenario (forever (trackingCenter ch)). The application specifies concurrent responsibilities without exposing their execution directly.

How Functional Design and Architecture: Examples in Haskell covers it

How deep it goes
Contrasts imperative execution with declarative intent and outlines an eDSL design workflow, but defers interpreter implementation details.
Examples
Uses process and scenario aliases around astronomer and trackingCenter to express concurrent application behavior.
What it assumes
Assumes familiarity with application scripts and concurrent behavior while introducing declarative thinking through process and scenario abstractions.
What you can do after
Design eDSL usage around business intent, then refine it toward compilation and working interpreters.
How it connects
Links declarative definitions to embedded domain-specific languages, free monads, interpreters, processes, and concurrency.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Functional Design and Architecture: Examples in Haskell. The section links point to the parts of the book it draws on.