Memento in Dhall
Capture and store the immutable state of a runic matrix for later restoration.
✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Memento
ARCANUM SCHOOL: Abjuration // Preservation
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// DHALL PATTERN //
let State = { runesActive : Natural, energy : Natural }
let save = \(s : State) -> s
let restore = \(m : State) -> m
let initialState = { runesActive = 3, energy = 100 }
let memento = save initialState
let alteredState = initialState // { energy = 50 }
in restore memento
Due to Dhall’s immutability, the Memento pattern is almost trivial. Any captured state is fundamentally safe from mutation. By passing a record (Memento) as an argument, you can trivially roll back a complex configuration to a known-safe checkpoint without risking side-effects.
Runic Tags:
#dhall
#halting
#runes
#configuration
#behavioral