[Haskell-beginners] 2 Questions: mutable data and copying results

Daniel Fischer daniel.is.fischer at web.de
Tue Aug 17 10:26:12 EDT 2010

On Tuesday 17 August 2010 16:08:49, C Gosch wrote:
> >
> > Since the graph is immutable most of the nodes in the new graph are
> > shared with nodes in the old graph. This is know as path copying and
> > is everywhere persistent ("immutable") data structures are used.
> > Updating a data structure (e.g. a tree) typically requires O(log n)
> > nodes to be copied.
> So that means the compiler figures this out for my own data structures,
> or do I have to take care that copying is done this way?
> Sorry for my ignorance, I'm still learning :)

It's done automatically (and, if your nodes contain huge data, you'll be 
happy to learn tha the data isn't copied at all, only the pointers to it).

More information about the Beginners mailing list