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

20 May
2009
20 May
'09
7:46 a.m.
While just writing 33 instead of length [1..33] saves an awful lot of bother, the function you'd probably want in similar circumstances is `fromIntegral` See the Prelude. Also, you can use Data.ByteString.head instead of unpack and then Data.List.head rollDice :: Word8 -> IO Word8 rollDice n = do bracket (openFile "/dev/random" ReadMode) hClose (\hd -> do v <- fmap B.head $ B.hGet hd 1 return $ (v `mod` n) + 1)
5846
Age (days ago)
5846
Last active (days ago)
0 comments
1 participants
participants (1)
-
spoon@killersmurf.com