The Composite: Fractal Spell Trees
Treating single enchantments and sprawling spell clusters uniformly.
✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Composite
ARCANUM SCHOOL: Conjuration // Fractal-Weaving
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// CODEX INCANTATION //
module Composite
-- The component
interface SpellComponent s where
evaluatePower : s -> Nat
-- Leaf
data BasicSpell = MkBasicSpell Nat
SpellComponent BasicSpell where
evaluatePower (MkBasicSpell p) = p
-- Composite
data SpellCluster : Type -> Type where
MkCluster : SpellComponent s => List s -> SpellCluster s
SpellComponent (SpellCluster s) where
evaluatePower (MkCluster xs) = sum (map evaluatePower xs)
By treating a lone BasicSpell and a vast SpellCluster interchangeably, the Composite pattern allows technomancers to manipulate fractal arrays of magic. Through Idris’s inductive data structures, the Theorem Proving Pacts guarantee that any traversal of the spell tree terminates safely, calculating the aggregate mana cost without fear of infinite cosmic loops.
Runic Tags:
#structural
#recursion
#inductive-types