Skip to content

Instantly share code, notes, and snippets.

anonymous
anonymous / VisitorExample.hs
Created October 12, 2012 14:32
The Visitor pattern in Haskell
{-# LANGUAGE ExistentialQuantification #-}
-- This file is a direct translation of the example for the Visitor pattern from
-- Wikipedia [1] to Haskell
--
-- The Visitor pattern essentially tackles two dispatching problems:
--
-- 1. double dispatching
-- 2. dispatching subtypes
--
-- While double dispatching of static types could be solved in Haskell by using