The Chain of Magical Wardens
Passing a spell request through a chain of arcane wardens.
✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Chain of Responsibility
ARCANUM SCHOOL: Abjuration // Wardens
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// CODEX INCANTATION //
module ChainOfResponsibility
type request = { spell_level: nat }
type handler = request -> option string
let handle_apprentice : handler = fun r ->
if r.spell_level < 3 then Some "Apprentice handles" else None
let handle_adept : handler = fun r ->
if r.spell_level < 6 then Some "Adept handles" else None
let rec chain (handlers: list handler) (r: request) : option string =
match handlers with
| [] -> None
| h :: t ->
match h r with
| Some res -> Some res
| None -> chain t r
A functional chain of responsibility where a list of warden functions attempt to process a spell request in sequence.
Runic Tags:
#chain
#filtering
#wardens