⚙️ ISABELLE RUNE DIFFICULTY: Adept Structural

The Bridge

Decouple an abstraction from its implementation so that the two can vary independently across logical dimensions.

✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Bridge
ARCANUM SCHOOL: Transmutation // Integration
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// ISABELLE PATTERN //
theory Bridge
  imports Main
begin

datatype element = Fire | Frost | Arcane

record spell_implementation =
  render_effect :: "element \<Rightarrow> string"

record spell_abstraction =
  impl :: spell_implementation
  cast :: "string"

definition mk_spell :: "spell_implementation \<Rightarrow> element \<Rightarrow> spell_abstraction" where
  "mk_spell i e = \<lparr> impl = i, cast = render_effect i e \<rparr>"

end
Runic Tags: #isabelle #hol #transmutation #design-patterns