Decorator in Dhall
Dynamically augment the power of a rune via record merging.
✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Decorator
ARCANUM SCHOOL: Enchantment // Augmentation
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// DHALL PATTERN //
let Rune = { power : Natural, description : Text }
let baseRune : Rune = { power = 10, description = "Basic Halt" }
let empower =
\(r : Rune) ->
r // { power = r.power * 2, description = "Empowered " ++ r.description }
in empower baseRune
In the functional realms of Dhall, the Decorator pattern maps seamlessly to pure function application and record manipulation. An archmage passes a base spell into a decorator function, which safely overwrites specific fields with enhanced values, retaining the original type signature and preserving the total functional purity.
Runic Tags:
#dhall
#halting
#runes
#configuration
#structural