The Visitor of the Astral Plane
Performing new operations on a hierarchy of astral entities without altering their structures.
✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Visitor
ARCANUM SCHOOL: Necromancy // Astral Travel
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// CODEX INCANTATION //
module Visitor
type astral_entity =
| Spirit : name:string -> astral_entity
| Poltergeist : anger:nat -> astral_entity
type visitor 'a = {
visit_spirit : string -> 'a;
visit_poltergeist : nat -> 'a;
}
let accept (e: astral_entity) (v: visitor 'a) : 'a =
match e with
| Spirit n -> v.visit_spirit n
| Poltergeist a -> v.visit_poltergeist a
A generic Visitor interface leveraging pattern matching to deeply inspect and interact with the varied entities of the Astral Plane.
Runic Tags:
#visitor
#double-dispatch
#entities