Skip to content

Instantly share code, notes, and snippets.

@23Skidoo
Created May 19, 2011 18:51
Show Gist options
  • Save 23Skidoo/981441 to your computer and use it in GitHub Desktop.
Save 23Skidoo/981441 to your computer and use it in GitHub Desktop.
Experiments with unboxed mutable records
module Main
where
import Control.Monad
import Data.IORef
data SomeStruct = SomeStruct { someField :: {-# UNPACK #-} !Int,
someOtherField :: {-# UNPACK #-} !Int,
yetAnotherField :: {-# UNPACK #-} !Float }
main :: IO ()
main = do i <- newIORef $ SomeStruct 1 2 6.8
modifyIORef i (\s -> s { someOtherField = 23 })
f <- liftM someOtherField $ readIORef i
print f
return ()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment