λ HASKELL SIGILS DIFFICULTY: Adept Behavioral

The Visitor

Pattern matching over algebraic data types, cleanly separating operations from structures.

✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Visitor
ARCANUM SCHOOL: Divination // Examination
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// PURE FUNCTIONAL VOID SIGIL //
module Visitor where
data AST = Lit Int | Add AST AST
visitEval :: AST -> Int
visitEval (Lit n) = n
visitEval (Add a b) = visitEval a + visitEval b
Runic Tags: #visitor #pattern-matching #behavioral