Command in Dhall
Reify spells as data structures to be evaluated deterministically.
✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Command
ARCANUM SCHOOL: Enchantment // Reification
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// DHALL PATTERN //
let Command = < Cast : Text | Dispels : Text | Wait >
let execute = \(c : Command) ->
merge
{ Cast = \(s : Text) -> "Casting " ++ s
, Dispels = \(s : Text) -> "Dispelling " ++ s
, Wait = "Waiting..."
}
c
in execute (Command.Cast "Halting Fire")
The Command pattern is a core tenet of configuration-as-code languages like Dhall. Rather than imperatively running scripts, one declares union types that represent desired states or actions. The interpreter function safely exhausts all possibilities of the union, proving that no command goes unhandled.
Runic Tags:
#dhall
#halting
#runes
#configuration
#behavioral