🌐 REASONML PACT DIFFICULTY: Apprentice Structural

Decorator in ReasonML

Function composition to weave new enchantments.

✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Decorator
ARCANUM SCHOOL: Transmutation // Enhancement
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// REASON PATTERN //
let castSpell = (name) => "Casting " ++ name;
let withEcho = (spellFn, name) => spellFn(name) ++ " ... " ++ spellFn(name);

let echoingCast = withEcho(castSpell);

Higher-order functions wrap base operations, layering on additional magical effects without mutating the original spell.

Runic Tags: #reason #decorator #structural