[Haskell-cafe] Functors and the Visitor Pattern

2009-06-03 Thread Tom.Amundsen
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

Re: [Haskell-cafe] Functors and the Visitor Pattern

2009-06-03 Thread Andres Loeh
> 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 func

Re: [Haskell-cafe] Functors and the Visitor Pattern

2009-06-03 Thread Edward Kmett
The concepts are fairly closely related but each entails something the other does not. Functor entails parametric polymorphism with respect to the contents of the container. And a visitor can extract a result from the traversal. As a result you may want to think in terms of a Traversable or Foldab

Re: [Haskell-cafe] Functors and the Visitor Pattern

2009-06-03 Thread Daryoush Mehrtash
There was a google talk on Visitor pattern in Java and Common Lisp that you might find interesting http://www.youtube.com/watch?v=VeAdryYZ7ak Daryoush On Wed, Jun 3, 2009 at 6:10 AM, Tom.Amundsen wrote: > > So, last night, I was having this problem with my Java code where I > couldn't > figure

Re: [Haskell-cafe] Functors and the Visitor Pattern

2009-06-04 Thread wren ng thornton
Tom.Amundsen 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 mos

Re: [Haskell-cafe] Functors and the Visitor Pattern

2009-06-04 Thread Johan Tibell
On Thu, Jun 4, 2009 at 9:13 AM, wren ng thornton wrote: > The Visitor pattern isn't a functor, it's a collection of things. The type > being visited is the functor[1], the set of methods on that type for > accepting a visitor is a catamorphism[2], and the visitor itself is an > algebra for the f

Re: [Haskell-cafe] Functors and the Visitor Pattern

2009-06-04 Thread wren ng thornton
Johan Tibell wrote: wren ng thornton wrote: > [2] For the recursive Visitor pattern I use most often, that is. For the > non-recursive version it's usually fmap. This is the part where the pattern > gets a bit shaky because there are actually many different patterns all > called "Visitor". The ma

Re: [Haskell-cafe] Functors and the Visitor Pattern

2009-06-05 Thread Johan Tibell
On Fri, Jun 5, 2009 at 4:45 AM, wren ng thornton wrote: > Johan Tibell wrote: >> >> Could you be so kind to give an example for each? >> > > In OOP you mean? > This cleared things up for me. Thanks! -- Johan ___ Haskell-Cafe mailing list Haskell-Cafe@