⚙️ LEAN RUNE DIFFICULTY: Apprentice Structural

The Adapter

Translating incompatible magical interfaces into a uniform mathematical ward interface.

✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Adapter
ARCANUM SCHOOL: Transmutation // Formatting
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// LEAN PATTERN //
namespace MathematicalWards

class AbsoluteWard (W : Type) where
  deflect : W → String

structure LegacyShield where
  durability : Nat

def LegacyShield.block (s : LegacyShield) : String :=
  s!"Blocked with legacy durability {s.durability}"

instance : AbsoluteWard LegacyShield where
  deflect s := s.block

def castWard {W : Type} [AbsoluteWard W] (ward : W) : String :=
  AbsoluteWard.deflect ward

end MathematicalWards

Adapting a legacy magical construct to the AbsoluteWard interface using typeclass instances, transparently unifying old and new ward geometries.

Runic Tags: #structural #lean4 #adapter #wards