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?
Thanks.