⚙️ MIRANDA RUNE DIFFICULTY: Archmage Behavioral

The State of the Ancestral Monad

Altering pure behavior when internal state changes by transitioning to new monadic functions.

✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: State
ARCANUM SCHOOL: Enchantment // Ancestral Monad
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// MIRANDA PATTERN //
|| State transitions yield entirely new pure handlers.

state_fn == string -> (string, state_fn)

state_on :: state_fn
state_on "toggle" = ("Turning Off", state_off)
state_on _ = ("Staying On", state_on)

state_off :: state_fn
state_off "toggle" = ("Turning On", state_on)
state_off _ = ("Staying Off", state_off)

run_machine :: state_fn -> [string] -> [string]
run_machine _ [] = []
run_machine st (evt:evts) = out : run_machine next_st evts
                            where (out, next_st) = st evt
Runic Tags: #miranda #behavioral #state #ancestral-monad