⚙️ ISABELLE RUNE DIFFICULTY: Adept Creational

The Abstract Factory

Conjure families of related objects through higher-order logic interfaces without specifying their concrete theories.

✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Abstract Factory
ARCANUM SCHOOL: Conjuration // Abstraction
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// ISABELLE PATTERN //
theory AbstractFactory
  imports Main
begin

record ('a, 'b) abstract_factory =
  create_spell :: "unit \<Rightarrow> 'a"
  create_ward :: "unit \<Rightarrow> 'b"

definition fire_factory :: "(string, string) abstract_factory" where
  "fire_factory = \<lparr> 
    create_spell = (\<lambda>_. ''Fireball''), 
    create_ward = (\<lambda>_. ''Flame Shield'') 
  \<rparr>"

definition ice_factory :: "(string, string) abstract_factory" where
  "ice_factory = \<lparr> 
    create_spell = (\<lambda>_. ''Frost Nova''), 
    create_ward = (\<lambda>_. ''Ice Barrier'') 
  \<rparr>"

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