Why modify it instead of creating the new one and let the previous tree get 
garbage collected?

On Sep 9, 2012, at 12:46 PM, Milan Straka <f...@ucw.cz> wrote:

> Hi all,
> 
> is there any way to perform a destructive update on a plain ADT?
> Imagine I have a simple
>  data Tree a = Nil | Node a (Tree a) (Tree a)
> I would like to be able to modify right subtree of an existing tree.
> 
> I can do that for example when using IORefs by changing the datatype to
>  data Tree a = Nil | Node a (IORef (Tree a)) (IORef (Tree a))
> and use unsafePerformIO + writeIORef. But the IORefs cause additional
> complexity when working with the data type.
> 
> 
> At the moment I am interested in any GHC solution, be it non-portable or
> version specific. I would like just to run some benchmarks and see the
> results.
> 
> Cheers,
> Milan
> 
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe@haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe


_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to