[Haskell-cafe] How i use GHC.Word.Word8 wit Int ?

z_axis at 163.com z_axis at 163.com
Tue May 19 20:40:15 EDT 2009

Hi, friends

rollDice :: Word8 -> IO Word8
rollDice n = do
    bracket (openFile "/dev/random" ReadMode) (hClose)
        (\hd -> do v <-  fmap B.unpack (B.hGet hd 1)
                   let v1 =  Data.List.head v
                   return $ (v1 `mod` n) + 1)
blueIdx <- rollDice $ length [1..33]

Couldn't match expected type `Word8' against inferred type `Int'
    In the second argument of `($)', namely `length yesBlue

I know "length [1..33]" is Int not Word8, but Word8 is enough here.  


More information about the Haskell-Cafe mailing list