[Haskell-cafe] Functors and the Visitor Pattern

Daryoush Mehrtash dmehrtash at gmail.com
Wed Jun 3 13:32:40 EDT 2009

There was a google talk on Visitor pattern in Java and Common Lisp that you
might find interesting



On Wed, Jun 3, 2009 at 6:10 AM, Tom.Amundsen <tomamundsen at gmail.com> wrote:

> So, last night, I was having this problem with my Java code where I
> couldn't
> figure out for the life of me how to write a piece of code without a big if
> {} else if {} else if {} ... else {} structure. I was Googling "Java
> Reflection" to try to determine how to "cast to the most concerete subclass
> at runtime." Then it dawned on me that what I was trying to do has already
> been solved by using the Visitor design pattern.
> Then, after reading the Visitor design pattern page on Wiki, it said that
> the visitor pattern is essentially an implementation of a functor. Aha! It
> totally clicked. The Visitor pattern allows you to collect code for similar
> operations, while spreading apart code for similar objects. Now that really
> sounds like a functor!
> Although, now I'm second guessing myself, because I can't figure out how we
> could create some design pattern that simulates an applicative functor. I'm
> pretty sure the Visitor pattern doesn't take you this far (but I am willing
> to be corrected). So, is there a way to create applicative functors in
> non-functional languages? What would that pattern look like?
> - Tom
> --
> View this message in context:
> http://www.nabble.com/Functors-and-the-Visitor-Pattern-tp23851113p23851113.html
> Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090603/2e80164e/attachment.html

More information about the Haskell-Cafe mailing list