🐪 OCAML METAMAGIC DIFFICULTY: Apprentice Creational

The Factory Method

Delegating the manifestation of mystical entities to specific lineage functions.

✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Factory Method
ARCANUM SCHOOL: Conjuration // Entity Summoning
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// OCAML PATTERN //
type familiar = Raven | Toad | Cat

module type WITCH = sig
  val summon_familiar : unit -> familiar
end

module SwampWitch : WITCH = struct
  let summon_familiar () = Toad
end

module SkyWitch : WITCH = struct
  let summon_familiar () = Raven
end

The Factory Method manifests as specialized modules that dictate the exact lineage of familiar summoned, hidden behind an abstract signature.

Runic Tags: #Caml Metamagic #Abstract Types #OCaml