Search Results

Search found 1 results on 1 pages for 'redxaxder'.

Page 1/1 | 1 

  • How do record updates behave internally?

    - by redxaxder
    data Thing = Thing {a :: Int, b :: Int, c :: Int, (...) , z :: Int} deriving Show foo = Thing 1 2 3 4 5 (...) 26 mkBar x = x { c = 30 } main = do print $ mkBar foo What is copied over when I mutate foo in this way? As opposed to mutating part of a structure directly. Data Thing = Thing {a :: IORef Int, b :: IORef Int, (...) , z :: IORef Int} instance Show Thing where (...something something unsafePerformIO...) mkFoo = do a <- newIORef 1 (...) z <- newIORef 26 return Thing a b (...) z mkBar x = writeIORef (c x) 30 main = do foo <- mkFoo mkBar foo print foo Does compiling with optimizations change this behavior?

    Read the article

1