✨ ARCANUM RUNE DIFFICULTY: Adept Structural

The Composite Hex

Treating individual derivations and compositions of derivations uniformly.

✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Composite
ARCANUM SCHOOL: Transmutation // Pure Environment Hexes
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// CODEX INCANTATION //
let
  # Leaf component
  mkMaterial = name: {
    type = "material";
    inherit name;
    evaluate = "Material: ''${name}";
  };

  # Composite component
  mkSpellbook = name: children: {
    type = "spellbook";
    inherit name children;
    evaluate = "Spellbook ''${name} containing: [" + 
      (builtins.concatStringsSep ", " (map (c: c.evaluate) children)) + "]";
  };

  # Usage
  manaPotion = mkMaterial "Mana Water";
  healingHerb = mkMaterial "Bloodweed";
  
  restorationKit = mkSpellbook "Restoration" [ manaPotion healingHerb ];
  masterCache = mkSpellbook "Archmage Stash" [ restorationKit (mkMaterial "Phoenix Feather") ];
in
masterCache.evaluate

The Composite pattern creates tree-like structures where leaves and branches implement the same interface. In Nix, this maps cleanly to nested derivation environments, module imports, or configuration trees that evaluate uniformly.

Runic Tags: #structural #composite #nix #trees