[Haskell-beginners] Question about data structures

Russ Abbott russ.abbott at gmail.com
Wed Nov 24 14:40:02 EST 2010

I would appreciate some advice about the best way to manipulate data
structures in Haskell.

Let's assume I have what in an OO language would be a class with a number of
instance variables.  When I want to change one of the values of one of those
instance variables in Haskell I must rebuild the entire structure.  Even
worse, if one of those instance variables is a reference to another data
structure, then when I change that referenced data structure, I am forced to
rebuild my top level variable.  For example.

data Struct1  =  Struct1  {var1  :: Struct11, var2 :: Struct1, ... }
data Struct11 = Struct11 {var11 :: ... }

Let's assume I have x :: Struct1 and that I change the value of var11 . var1
$ x.  Doesn't that require that I rebuild x?

Is there a better way?

-- Russ*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/beginners/attachments/20101124/4603d844/attachment.html

More information about the Beginners mailing list