[Haskell-cafe] List comprehensions with Word8

Steve Schafer steve at fenestra.com
Thu May 16 23:26:02 CEST 2013


On Thu, 16 May 2013 23:15:33 +0200, you wrote:

>Hello everyone,
>
>I was playing with Word8 and list comprehensions and
>the following examples came up. I have to admit the
>behavior looks quite strange because it does not seem
>to be consistent. Can someone shed some light on reason
>behind some of these outputs?

When you say

 <some positive integer> :: [Word8]

what you're effectively saying is

 <some positive integer> `mod` 256

because that's what fits into a slot that's 8 bits wide.

So:

 1000 `mod` 256 = 232

 10000 `mod` 256 = 16

and so on.

-Steve Schafer



More information about the Haskell-Cafe mailing list