The Bridge
Decouple an arcane abstraction from its implementation, allowing both to vary independently.
✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Bridge
ARCANUM SCHOOL: Illusion // Metamagic
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// CODEX INCANTATION //
structural type ElementalCore = Fire | Ice | Lightning
structural type SpellForm = Bolt | Blast | Shield
castSpell : SpellForm -> ElementalCore -> Text
castSpell form core =
c = match core with
Fire -> "flaming"
Ice -> "freezing"
Lightning -> "sparking"
f = match form with
Bolt -> "bolt"
Blast -> "blast"
Shield -> "shield"
c ++ " " ++ f
The Bridge pattern in Unison leverages algebraic data types to cleanly separate orthogonal dimensions of a spell. Rather than defining a FireBolt or an IceShield, the magus defines ElementalCore and SpellForm independently. Functions then weave these separate lineages together, preventing an exponential explosion of spell variants within the namespace.
Runic Tags:
#structural
#bridge
#unison
#abstraction