Flyweight in ReasonML
Sharing immutable state vectors.
✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Flyweight
ARCANUM SCHOOL: Conjuration // Creation
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// REASON PATTERN //
module ParticleType = {
type t = { color: string, sprite: string };
let fire = { color: "red", sprite: "fire.png" };
};
type particle = { x: int, y: int, pType: ParticleType.t };
let spawnFire = (x, y) => { x, y, pType: ParticleType.fire };
Immutable bindings allow vast swarms of particles to reference a single shared configuration object, minimizing memory corruption.
Runic Tags:
#reason
#flyweight
#structural