The Memento of Web Runes
Capture and restore the internal state of a mystical entity without violating encapsulation.
✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Memento
ARCANUM SCHOOL: Necromancy // Soul Anchoring
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// PURESCRIPT PATTERN //
module Arcane.Memento where
import Prelude
type SoulState = { sanity :: Int, mana :: Int }
newtype SoulStone = SoulStone SoulState -- The Memento
saveState :: SoulState -> SoulStone
saveState state = SoulStone state
restoreState :: SoulStone -> SoulState
restoreState (SoulStone state) = state
-- Usage
corrupt :: SoulState -> SoulState
corrupt s = s { sanity = s.sanity - 10 }
Runic Tags:
#behavioral
#memento
#purescript
#runes