The Decorator of the Progenitor
Augment base spell effects through function composition.
✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Decorator
ARCANUM SCHOOL: Transmutation // Effect Augmentation
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// CODEX INCANTATION //
type spell = int -> string
fun baseDamage damage =
"Deals " ^ Int.toString damage ^ " damage."
fun empower (s: spell) (damage: int) =
s (damage * 2) ^ " (Empowered!)"
fun addBurn (s: spell) (damage: int) =
s damage ^ " Also applies burn for 3 seconds."
(* Composing the decorators *)
val ultimateFireball = addBurn (empower baseDamage)
val result = ultimateFireball 50
In the pure functional streams of the ML Progenitor, the Decorator pattern translates directly to higher-order functions. Rather than wrapping objects, an Archmage simply passes a function to another function that adds behavior before, after, or around the original invocation. This functional composition enables infinite, elegant spell augmentations without cumbersome inheritance hierarchies.
Runic Tags:
#higher-order functions
#composition
#wrappers