✨ ARCANUM RUNE DIFFICULTY: Adept Structural

The Flyweight Dust

Sharing massive amounts of fine-grained objects to save memory.

✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Flyweight
ARCANUM SCHOOL: Transmutation // Mass Optimization
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// CODEX INCANTATION //
module FlyweightPattern where

open import Data.String

record SharedRune : Set where
  field glyph : String
  
record Particle : Set where
  field
    x y : String
    base : SharedRune

The Flyweight Dust

When rendering millions of glowing cyber-particles in a holographic blast, storing the full matrix per particle causes immediate RAM overflow. The Flyweight Dust shares common intrinsic state among all instances.

The Dependent Runes

By separating the SharedRune (intrinsic state) from the extrinsic state (x, y positions), we create efficient arrays of pointers. In pure Agda, this naturally flows from structural sharing in functional data structures.

Runic Tags: #agda #flyweight #optimization