💠 F# SIGILS DIFFICULTY: Apprentice Creational

The Singleton Monolith

A singular, immutable locus of magical energy within the CLR.

✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Singleton
ARCANUM SCHOOL: Abjuration // Leylines
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// FSHARP PATTERN //
type LeylineNexus private () =
    static let instance = LeylineNexus()

    let mutable energyLevel = 1000

    static member Instance = instance

    member _.TapEnergy(amount) =
        if energyLevel >= amount then
            energyLevel <- energyLevel - amount
            printfn "Tapped %d energy. Remaining: %d" amount energyLevel
        else
            printfn "Nexus depleted!"

// Usage:
let nexus = LeylineNexus.Instance
nexus.TapEnergy(50)

F# modules provide a natural singleton. However, when object-oriented state must be strictly bounded to a single CLR instance, a static instance wrapped in a private constructor secures the nexus against multiple instantiations.

Runic Tags: #creational #singleton #fsharp #leylines