🐪 OCAML METAMAGIC DIFFICULTY: Adept Structural

The Bridge

Decoupling the ethereal essence of a spell from its physical manifestation.

✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Bridge
ARCANUM SCHOOL: Transmutation // Essence Separation
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// OCAML PATTERN //
module type CATALYST = sig
  val trigger : string -> unit
end

module FireCatalyst : CATALYST = struct
  let trigger name = Printf.printf "%s bursts into flames!\n" name
end

module Spell (C : CATALYST) = struct
  let incant name = 
    Printf.printf "Chanting...\n";
    C.trigger name
end

module Fireball = Spell(FireCatalyst)

The Bridge pattern relies on OCaml Functors to separate the catalyst mechanism from the magical invocation, forging powerful composite spells.

Runic Tags: #Caml Metamagic #Functors #OCaml