Visitor in Dhall
Decouple operational logic from structural data by traversing runic variants.
✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Visitor
ARCANUM SCHOOL: Divination // Exploration
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// DHALL PATTERN //
let Shape = < Circle : Natural | Rectangle : { w : Natural, h : Natural } >
let Visitor =
{ visitCircle : Natural -> Text
, visitRectangle : { w : Natural, h : Natural } -> Text
}
let accept = \(s : Shape) -> \(v : Visitor) ->
merge
{ Circle = v.visitCircle
, Rectangle = v.visitRectangle
}
s
let descriptionVisitor : Visitor =
{ visitCircle = \(r : Natural) -> "Circle of radius rune"
, visitRectangle = \(dims : { w : Natural, h : Natural }) -> "Rectangular matrix"
}
in accept (Shape.Circle 5) descriptionVisitor
In a dynamically bound, functional paradigm, the Visitor pattern is realized natively through exhaustive pattern matching over sum types. By enforcing a merge expression that handles every possible variant of the configuration data, Dhall guarantees that no shape escapes the analytical gaze of the archmage, culminating in safe and halted execution.
Runic Tags:
#dhall
#halting
#runes
#configuration
#behavioral