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

2009-05-20 Thread spoon
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 =

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

2009-05-19 Thread z_a...@163.com
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]

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

2009-05-19 Thread Felipe Lessa
On Wed, May 20, 2009 at 08:40:15AM +0800, z_a...@163.com wrote: I know length [1..33] is Int not Word8, but Word8 is enough here. Just saying '33' is enough here. :) -- Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org

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

2009-05-19 Thread Bernie Pope
2009/5/20 z_a...@163.com z_a...@163.com: 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)

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

2009-05-19 Thread Johannes Laire
On Wed, May 20, 2009 at 3:40 AM, z_a...@163.com z_a...@163.com wrote: 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                  

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

2009-05-19 Thread Lee Duhem
2009/5/20 Bernie Pope florbit...@gmail.com: Oh right. I didn't see your proposal (did it get sent to the list?). Yes, I just push the Replay button, not the Sorry for the confusion. It's my fault, sorry. lee ___ Haskell-Cafe mailing list