The Abstract Factory
A mathematical ward that constructs families of absolute enchantments without exposing their concrete proofs.
✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Abstract Factory
ARCANUM SCHOOL: Abjuration // Geometry
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// LEAN PATTERN //
namespace MathematicalWards
class WardFactory (A : Type) where
createShield : A → String
createSigil : A → String
structure AbsoluteWard where
power : Nat
instance : WardFactory AbsoluteWard where
createShield w := s!"Absolute Shield of power {w.power}"
createSigil w := s!"Absolute Sigil of power {w.power}"
def invokeWard {A : Type} [WardFactory A] (ward : A) : String × String :=
(WardFactory.createShield ward, WardFactory.createSigil ward)
end MathematicalWards
An abstract factory implemented via typeclasses in Lean 4. It ensures families of related magical objects are instantiated consistently according to mathematical truths.
Runic Tags:
#creational
#lean4
#abstract-factory
#wards