The Prototype of Web Runes
Clone and mutate existing mystical entities via pure functional record updates.
✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Prototype
ARCANUM SCHOOL: Illusion // Simulacrum
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// PURESCRIPT PATTERN //
module Arcane.Prototype where
import Prelude
-- In pure FP, cloning is just variable binding, but we can model a cloneable entity
type Familiar =
{ name :: String
, species :: String
, powerLevel :: Int
}
baseRaven :: Familiar
baseRaven = { name: "Corvus", species: "Shadow Raven", powerLevel: 10 }
-- 'Cloning' and mutating via record updates
cloneAndRename :: String -> Familiar -> Familiar
cloneAndRename newName f = f { name = newName }
empowerFamiliar :: Int -> Familiar -> Familiar
empowerFamiliar boost f = f { powerLevel = f.powerLevel + boost }
Runic Tags:
#creational
#prototype
#purescript
#runes