The Decorator: Layered Enchantments
Dynamically adding responsibilities and wards to an entity.
✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Decorator
ARCANUM SCHOOL: Abjuration // Warding
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// CODEX INCANTATION //
module Decorator
interface Enchantment e where
cast : e -> String
data BaseSpell = MkBaseSpell
Enchantment BaseSpell where
cast _ = "Fireball"
-- Decorators
data Empowered : Type -> Type where
MkEmpowered : Enchantment e => e -> Empowered e
Enchantment (Empowered e) where
cast (MkEmpowered inner) = cast inner ++ " (Empowered)"
data Echoing : Type -> Type where
MkEchoing : Enchantment e => e -> Echoing e
Enchantment (Echoing e) where
cast (MkEchoing inner) = cast inner ++ " " ++ cast inner
The Decorator pattern envelops a core spell within concentric layers of esoteric power. Rather than constructing a monolithic matrix for every possible spell variation, Idris utilizes type wrappers—Empowered or Echoing—to augment the fundamental magic. The Theorem Proving Pacts verify that these ethereal skins adhere to the Enchantment contract, wrapping safety around immense destructive potential.
Runic Tags:
#structural
#composition
#higher-kinded-types