liveBook · Manning

AppL

As explained in Functional Design and Architecture: Examples in Haskell

AppL is a book-specific free-monadic language for declaring application initialization, process structure, configuration, and related orchestration logic.

An application needs to initialize shared state and start processes, but letting every process fork more threads can produce an uncontrolled number of them. AppL separates application orchestration from the logic run inside each process. section 9.1.3

AppL is a free-monadic language for initializing application state, declaring processes and their relationships, and managing configuration. It can run LangL scripts directly or fork them as processes. LangL holds the process logic—such as reading shared state, getting random values, and delaying—without an operation for forking child processes. AppL can contain domain logic, but keeping that logic in LangL preserves the separation. section 9.1.3

process :: LangL () -> AppL ()
process = forkProcess
 
scenario :: LangL a -> AppL a
scenario = evalLang
 
app :: AppL ()
app = do
 ch <- evalLang (newVar [])
 process (forever (astronomer ch))
 scenario (forever (trackingCenter ch))

In the application declaration, evalLang creates a shared variable, process forks an astronomer script, and scenario runs a tracking script. The scripts passed to process are LangL actions, not AppL actions. section 9.1.3

AppL also hosts broader initialization scenarios. A game-loading action can fetch a labyrinth and player position, create state variables, and return the resulting game state. Such actions can use throwException for domain-level failure and runSafely to return a failure as an Either value. section 15.2.3

White-box tests depend on the shape of an AppL action. Wrapping loading actions in runSafely moves their chains inside that operation, so mocks matched to the old sequence no longer reach the intended calls. The updated test uses a real runtime for selected operations and mocks the calls below them. section 15.2.3

How Functional Design and Architecture: Examples in Haskell covers it

How deep it goes
Explains the AppL–LangL boundary through process declarations and follows an AppL scenario through exception-handling and test refactoring.
Examples
Uses an astronomer and tracking-center application, then a game-loading scenario with mocked database failures.
What it assumes
Assumes familiarity with Haskell monadic actions and IORef while illustrating the AppL–LangL split through examples.
What you can do after
Evaluate/understand AppL process boundaries and diagnose white-box mock mismatches after runSafely refactoring.
How it connects
Connects free monads, LangL, process forking, shared state, domain-level exceptions, and white-box testing.

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.