✨ GLEAM ALCHEMY DIFFICULTY: Apprentice Behavioral

The Memento

Capturing temporal snapshots of state.

✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Memento
ARCANUM SCHOOL: Chronomancy // Time Anchors
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// GLEAM PATTERN //
pub type WorldState {
  WorldState(hp: Int, gold: Int)
}

pub type Memento {
  Memento(state: WorldState)
}

pub fn save_state(state: WorldState) -> Memento {
  Memento(state)
}

pub fn restore_state(memento: Memento) -> WorldState {
  memento.state
}

The Memento

In a pure language, every piece of data is an immutable snapshot. The Memento is just the data itself, safely preserved from the river of time.

Runic Tags: #chronomancy #memento #gleam