[Haskell-cafe] what is wrong w my IORef Word32 ?
Joerg Fritsch
fritsch at joerg.cc
Thu Jul 18 19:08:22 CEST 2013
All, what is wrong w the below code?
I get an type error related to the operation shiftL
import Data.Bits
import Data.Word
import Data.IORef
data Word32s = Word32s { x :: IORef Word32 }
bitfield :: Word32
bitfield = 0
mkbitfield :: Word32 -> IO Word32s
mkbitfield i = do the_bf <- newIORef i
return (Word32s the_bf)
sLbitfield :: Integer -> Word32s -> IO ()
sLbitfield i (Word32s bf) = do modifyIORef bf (shiftL i)
main::IO()
main = do
oper_bf <- mkbitfield bitfield
sLbitfield 2 oper_bf
bf_003.hs:15:48:
Couldn't match type `Int' with `Word32'
Expected type: Word32 -> Word32
Actual type: Int -> Word32
In the return type of a call of `shiftL'
In the second argument of `modifyIORef', namely `(shiftL i)'
In a stmt of a 'do' block: modifyIORef bf (shiftL i)
bf_003.hs:15:55:
Couldn't match expected type `Word32' with actual type `Integer'
In the first argument of `shiftL', namely `i'
In the second argument of `modifyIORef', namely `(shiftL i)'
In a stmt of a 'do' block: modifyIORef bf (shiftL i)
Thanks,
--Joerg
More information about the Haskell-Cafe
mailing list