
13 Aug
2009
13 Aug
'09
1:02 p.m.
Job Vranish 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
Untested, just guessing: {-# NOILINE aRef , a #-} aRef = unsafePerformIO (newRef 0) a = unsafePerformIO aRef main = do use a -- 0 if you are lucky writeRef aRef 5 use a -- 5 if you are lucky However, I would not in the least be surprised if your program stops working whenever your cat purrs. And yes, I find the above "code" quite disgusting. Zun.