The visitor pattern

First we will discuss “visitor pattern” We might attempt to explain why the “visitor” pattern got its name, but we believe this would confuse more than clarify; it is easier to write it off as a misnomer.

and see some examples in Java, and then we will look at comparable code in Haskell. We will see that the Java code using visitors bears a strong resemblance to what we call sum types or tagged unions in Haskell.