liveBook · Manning

HdlMethod

As explained in Functional Design and Architecture: Examples in Haskell

HdlMethod is a book-specific operation that combines device definition, device interaction, and reporting responsibilities in the Hdl-based control design.

HdlMethod is the algebraic data type behind the Hdl embedded language for defining devices. Its constructors describe controller setup and component registration while carrying continuations for later steps. section 6.4.1 section 5.2.3

The two operations divide device definition into:

  • SetupController, which records a device name, controller name, component passport, and a continuation receiving the created Controller. section 6.4.1
  • RegisterComponent, which records a Controller, component index, component passport, and a unit continuation for its imperative-like operation. section 6.4.1
  • Functor mapping, which transforms and repackages both constructors’ continuations without changing their other arguments. section 6.4.1

Parameterized HdlMethod separates the device-definition language from the language that nests it. LogicControl can choose Hdl LogicControl as its continuation context, reducing cyclic coupling while preserving the scripting model. section 5.2.4

Creating two boosters

A free-monad script sets up left and right booster controllers, registers temperature and pressure components on each, and returns both controllers. Smart constructors hide the underlying HdlMethod and Free constructors. section 6.4.1

Listing 6.8 The Hdl algebra
data HdlMethod next
  
  = SetupController
       DeviceName             #1
       ControllerName         #2
       ComponentPassport      #3
       (Controller -> next)   #4
   
  | RegisterComponent
       Controller
       ComponentIndex
       ComponentPassport
       (() -> next)           #5

Inspect the complete HdlMethod algebra, including the continuation-bearing SetupController and unit-continuation RegisterComponent constructors. section 6.4.1

How Functional Design and Architecture: Examples in Haskell covers it

How deep it goes
Defines two constructors, continuation mapping, parameterization, and smart-constructor wrapping, while deferring device interaction and reporting.
Examples
Uses booster controllers, temperature and pressure components, and a single-device thermometer script as concrete Hdl definitions.
What you can do after
Apply it via Hdl smart constructors to write readable, loosely coupled device-definition scripts.
How it connects
Connects to free monads, continuations, functors, smart constructors, and parameterized algebraic data types.

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.