The Memento Hex
Capturing and restoring the pure state of an arcane grimoire.
✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Memento
ARCANUM SCHOOL: Divination // Pure Environment Hexes
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// CODEX INCANTATION //
let
# Originator State
mkState = grimoire: mana: { inherit grimoire mana; };
# Save state (create Memento)
saveState = state: { _memento = state; };
# Restore state (restore from Memento)
restoreState = memento: memento._memento;
# Evolution of state
initial = mkState "Novice" 10;
memento1 = saveState initial;
evolved = mkState "Adept" 50;
memento2 = saveState evolved;
# Rolling back
rolledBack = restoreState memento1;
in
{
inherit evolved rolledBack;
}
Because Nix attributes are immutable, every bound state is effectively a Memento. However, structurally organizing previous generations or configuration snapshots allows for safe rollbacks. This is the exact philosophy behind NixOS generations.
Runic Tags:
#behavioral
#memento
#nix
#snapshots