🌐 REASONML PACT DIFFICULTY: Apprentice Creational

Builder in ReasonML

Step-by-step construction of complex arcane records.

✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Builder
ARCANUM SCHOOL: Transmutation // Synthesis
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// REASON PATTERN //
type potion = { mana: int, health: int, name: string };
let defaultPotion = { mana: 0, health: 0, name: "Empty Vial" };
let withMana = (m, p) => { ...p, mana: m };
let withHealth = (h, p) => { ...p, health: h };
let brew = (p) => p;

let myPotion = defaultPotion |> withMana(50) |> withHealth(100) |> brew;

Using pipeline operators, the Builder pattern in ReasonML transposes into a sequence of partial mutations, weaving attributes into a final immutable potion.

Runic Tags: #reason #builder #creational