ComponentDef is a declarative Hdl definition: a blueprint that pairs a component index with its ComponentPassport. An Hdl specification is a list of these definitions. section 4.1.3
The initial design used separate Sensor and Controller constructors and repeated classification data in both ComponentDef and ComponentPassport. That duplication allowed contradictory values, such as a sensor passport attached to a controller definition. section 3.3.2 section 4.1.2
The refactored representation keeps responsibilities separate:
- ComponentPassport describes what a vendor component is, including its class, name, GUID, and vendor. section 3.3.2
- ComponentDef describes where that component belongs in the Hdl specification by storing its ComponentIndex and passport. section 4.1.3
- ComponentClass carries sensor-specific information such as Temperature or Pressure, removing the need for specialized ComponentDef constructors. section 4.1.2 section 4.1.3
A booster definition
A booster Hdl specification can declare entries such as ComponentDef "nozzle1-t" aaaTemperature25Passport and ComponentDef "controller" aaaController86Passport. Later, makeDevice validates each passport against available VendorComponents before inserting the resulting DevicePart under its index. section 4.1.3
Listing 3.9 HDL for device definitions
module Andromeda.Hardware.Common where #1
type PhysicalGuid = String #2
type ComponentName = String #3
data Parameter = Temperature | Pressure
data ComponentClass = Sensors | Controllers
type Vendor = String
data ComponentPassport = ComponentPassport
{ componentClass :: ComponentClass
, componentName :: ComponentName
, componentGuid :: PhysicalGuid
, componentVendor :: Vendor
}
module Andromeda.Hardware.Hdl where #4
import Andromeda.Hardware.Common #5
type ComponentIndex = String
data ComponentDef
= Sensor ComponentPassport ComponentIndex Parameter
| Controller ComponentPassport ComponentIndex
type Hdl = [ComponentDef] #6
The listing shows the original algebraic design, including ComponentPassport, ComponentDef constructors, and Hdl as a list of component definitions. section 3.3.2
