Observer in Dhall
Distribute runic events to a list of expectant watcher functions.
✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Observer
ARCANUM SCHOOL: Divination // Scrying
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// DHALL PATTERN //
let Event = < RuneActivated : Text | RuneFaded : Text >
let Observer = Event -> Text
let archmageObserver : Observer =
\(e : Event) ->
merge
{ RuneActivated = \(r : Text) -> "Archmage notes activation of " ++ r
, RuneFaded = \(r : Text) -> "Archmage mourns fading of " ++ r
}
e
let trigger = \(e : Event) -> \(obs : List Observer) ->
-- Functional application would occur here
"Event triggered and logged."
in trigger (Event.RuneActivated "Halt") [ archmageObserver ]
While traditional event loops don’t exist in Dhall, the Observer pattern is modeled statically by passing event unions into lists of functions. This guarantees that when an event is constructed within the configuration domain, all observers resolve their reactions deterministically before the configuration is emitted.
Runic Tags:
#dhall
#halting
#runes
#configuration
#behavioral