The Factory Method
Defines an interface for creating absolute wards, deferring the exact instantiation to the mathematical structure of the subclass.
✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Factory Method
ARCANUM SCHOOL: Conjuration // Axiomatics
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// LEAN PATTERN //
namespace MathematicalWards
class WardCreator (T : Type) where
conjure : String → T
structure GeometryWard where
name : String
instance : WardCreator GeometryWard where
conjure n := ⟨n ++ " (Geometry)"⟩
structure ArithmeticWard where
name : String
instance : WardCreator ArithmeticWard where
conjure n := ⟨n ++ " (Arithmetic)"⟩
def manifestWard {T : Type} [WardCreator T] (name : String) : T :=
WardCreator.conjure name
end MathematicalWards
A factory method pattern expressed through Lean 4’s powerful typeclass resolution, mapping strings to precise geometric or arithmetic constructs.
Runic Tags:
#creational
#lean4
#factory-method
#wards