[Haskell-cafe] Question on proper use of Data.IORef
Max Rabkin
max.rabkin at gmail.com
Fri Jun 22 17:43:09 CEST 2012
On Fri, Jun 22, 2012 at 5:30 PM, Captain Freako <capn.freako at gmail.com> wrote:
> 12 main = do
> 13 let theValue = 1
> 14 print theValue
> 15 theValueRef <- newIORef theValue
> 16 bump theValueRef
> 17 return theValue
theValue is a plain old immutable Haskell variable. "newIORef" creates
an IORef whose initial value is equal to the argument; it doesn't
create a pointer to the value or something like that. Change "return
theValue" to "readIORef theValueRef" to extract the changed value in
the IORef.
--Max
More information about the Haskell-Cafe
mailing list