The Singleton of Web Runes
Ensure a single source of truth for the arcane matrix, accessed via Reader environment.
✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Singleton
ARCANUM SCHOOL: Abjuration // Leyline Anchoring
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// PURESCRIPT PATTERN //
module Arcane.Singleton where
import Prelude
import Control.Monad.Reader (Reader, ask, runReader)
type CoreCrystal = { frequency :: Number, resonance :: String }
-- The Single Instance
theOmegaCrystal :: CoreCrystal
theOmegaCrystal = { frequency: 432.0, resonance: "Aether" }
type SpellM = Reader CoreCrystal
castResonance :: SpellM String
castResonance = do
crystal <- ask
pure $ "Casting with resonance: " <> crystal.resonance
executeSpell :: String
executeSpell = runReader castResonance theOmegaCrystal
Runic Tags:
#creational
#singleton
#purescript
#runes