Re: [Haskell-cafe] I just don't get it (data structures and OO)

2007-06-03 Thread Donald Bruce Stewart
Phlex: Hello all, I'm coming from the OO world, and there's something i don't quite understand in the way haskellers manipulate data (as all functional programmers i guess). Let's say i have a deep nested data structure. Universe containing galaxies, containing solar systems,

Re: [Haskell-cafe] I just don't get it (data structures and OO)

2007-06-03 Thread Phlex
Donald Bruce Stewart wrote: Phlex: On the other side, using the functional paradigm, it seems to me that the function i use in order to create a _new_ inhabitant with a different age will need to have knowledge of the country over it, the planet ..and so on up to the universe...as i need

Re: [Haskell-cafe] I just don't get it (data structures and OO)

2007-06-03 Thread Phlex
Bulat Ziganshin wrote: Hello Phlex, Sunday, June 3, 2007, 11:41:29 AM, you wrote: That's precisely the thing i don't understand. In order to update node 3 with a new pointer, i need to mutate it, so i need to recreate it, and so on up to node 1. yes, that's true Now in this

Re: [Haskell-cafe] I just don't get it (data structures and OO)

2007-06-03 Thread Malcolm Wallace
Phlex [EMAIL PROTECTED] writes: The thing is, now that i have my planet p... i want to change it's age ... and get back the new state of the universe... It is true, there is often a significant amount of boilerplate code needed to wrap a simple planet-change nested deep within a universe

Re: [Haskell-cafe] I just don't get it (data structures and OO)

2007-06-03 Thread Tillmann Rendel
Hello, Phlex wrote: changePlanetAge universe galaxy planet age = ...lots of code, returning a new universe And the same code for all functions updating any of the properties of my planet ... And the same code for all functions updating properties of a country on this planet... In functional

Re: [Haskell-cafe] I just don't get it (data structures and OO)

2007-06-03 Thread Phlex
Tillmann Rendel wrote: Hello, Phlex wrote: changePlanetAge universe galaxy planet age = ...lots of code, returning a new universe And the same code for all functions updating any of the properties of my planet ... And the same code for all functions updating properties of a country on this

Re: [Haskell-cafe] I just don't get it (data structures and OO)

2007-06-03 Thread Claus Reinke
hi there, Let's say i have a deep nested data structure. Universe containing galaxies, containing solar systems, containing planets, containing countries, containing inhabitants, containing ...whatever. Using the OO paradigm, once i get a reference to an inhabitant, i can update it quite

Re: [Haskell-cafe] I just don't get it (data structures and OO)

2007-06-03 Thread Felipe Almeida Lessa
On 6/3/07, Tillmann Rendel [EMAIL PROTECTED] wrote: In functional programming, problems of the kind and the same code for all functions doing something related are most often solved by introducing higher order functions. Let's try to decompose the problem as follows: [snip] Now I've got one

Re: [Haskell-cafe] I just don't get it (data structures and OO)

2007-06-03 Thread Vincent Kraeutler
Phlex wrote: This is very informative, and easier to grasp for such a newbie as me. So the idea is to take the changing function down the chain, i knew this couldn't be that hard ! Still this requires indeed to think different, I guess i'm up for quite a few exercises in order to wrap my mind

Re: [Haskell-cafe] I just don't get it (data structures and OO)

2007-06-03 Thread Ketil Malde
On Sun, 2007-06-03 at 09:02 -0300, Felipe Almeida Lessa wrote: On 6/3/07, Tillmann Rendel [EMAIL PROTECTED] wrote: In functional programming, problems of the kind and the same code for all functions doing something related are most often solved by introducing higher order functions. Let's