The Proxy
Provide a surrogate or placeholder for another arcane entity to control access to it.
✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Proxy
ARCANUM SCHOOL: Abjuration // Warding
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// CODEX INCANTATION //
ability ForbiddenKnowledge where
readScroll : Text -> Text
-- The Proxy is a handler that checks authorization before delegating.
guardedVault : Boolean -> '{ForbiddenKnowledge} a -> Optional a
guardedVault isArchmage comp =
h : Request ForbiddenKnowledge a -> Optional a
h = cases
{ForbiddenKnowledge.readScroll t -> resume} ->
if isArchmage then handle resume (t ++ " - true text") with h
else None
{a} -> Some a
handle !comp with h
In Unison, a Proxy is elegantly implemented using Abilities. A spell that requires access to a restricted scroll simply requests the readScroll ability. The Proxy takes the form of an effect handler (guardedVault) that intercepts this request, verifies the caster’s credentials, and either fulfills the request by consulting the true text, or denies it by aborting the evaluation.
Runic Tags:
#structural
#proxy
#unison
#abilities
#authorization