No, there's no way you can change the value of 'a' after the fact. Since 'a' is a constant the compiler has most likely inlined it wherever it has been used, the done constant folding etc. If you need an updateable variable, you need to tell the compiler, otherwise it will assume your code is pure.
-- Lennart On Tue, Aug 11, 2009 at 5:48 PM, Job Vranish<jvran...@gmail.com> wrote: > Does anybody know if there is some unsafe IO function that would let me do > destructive assignment? > Something like: > > a = 5 > main = do > veryUnsafeAndYouShouldNeverEveryCallThisFunction_DestructiveAssign a 8 > print a >> 8 > > and yes I am in fact insane... > > I'm also looking for a way to make actual copies of data. > so I could do something like this: > > a = Node 5 [Node 2 [], Node 5 [a]] > main = do > b <- makeCopy a > veryUnsafeAndYouShouldNeverEveryCallThisFunction_DestructiveAssign b (Node > 0 []) > -- 'a' is unchanged > > It would be even more fantastic, if the copy function was lazy. > I think the traverse function might actually make a copy, but I would be > happier with something more general (doesn't require membership in > traversable), and more explicit (was actually designed for making real > copies). > > Any ideas? > > Thanks, > > - Job > > > > _______________________________________________ > 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