✨ ARCANUM RUNE DIFFICULTY: Apprentice Creational

The Prototype of the Progenitor

Clone and modify ancient immutable grimoires.

✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Prototype
ARCANUM SCHOOL: Illusion // Replicative Form
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// CODEX INCANTATION //
type grimoire = {
  title: string,
  spells: string list,
  manaCost: int
}

val standardGrimoire : grimoire = {
  title = "Apprentice's Guide",
  spells = ["Light", "Mage Hand"],
  manaCost = 10
}

fun cloneWithModifications (g: grimoire) newTitle newSpells : grimoire =
  {
    title = newTitle,
    spells = #spells g @ newSpells,
    manaCost = #manaCost g + 5
  }

val advancedGrimoire = cloneWithModifications standardGrimoire "Adept's Guide" ["Fireball"]

When practicing the Prototype pattern in Standard ML, the ML Progenitor smiles upon immutability. You do not need deep or shallow copy semantics as seen in object-oriented realms; records are immutable. “Cloning” is fundamentally just creating a new record based on the values of the old one, applying any necessary augmentations along the way without corrupting the ancient original text.

Runic Tags: #immutability #records #cloning