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
