⚙️ PURESCRIPT RUNE DIFFICULTY: Adept Creational

The Abstract Factory of Web Runes

Conjure families of related strictly-typed web runes without specifying their concrete manifestations.

✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Abstract Factory
ARCANUM SCHOOL: Conjuration // Sigilcraft
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// PURESCRIPT PATTERN //
module Arcane.AbstractFactory where
import Prelude
import Effect (Effect)
import Effect.Console (log)

-- The Abstract Factory is a Record of functions
type WebRuneFactory =
  { forgeWard  :: String -> String
  , weaveGlyph :: String -> String
  }

fireRunes :: WebRuneFactory
fireRunes =
  { forgeWard: \intensity -> "<IgnisWard level='" <> intensity <> "' />"
  , weaveGlyph: \target -> "[FlameGlyph binds " <> target <> "]"
  }

voidRunes :: WebRuneFactory
voidRunes =
  { forgeWard: \intensity -> "<NullWard level='" <> intensity <> "' />"
  , weaveGlyph: \target -> "[AbyssGlyph consumes " <> target <> "]"
  }

invokeRitual :: WebRuneFactory -> Effect Unit
invokeRitual factory = do
  log $ factory.forgeWard "High"
  log $ factory.weaveGlyph "Demon"
Runic Tags: #creational #abstract-factory #purescript #runes