[Haskell-cafe] Why this exception occurs ?
L.Guo
leaveye.guo at gmail.com
Fri May 25 03:49:34 EDT 2007
When I was tring manually truncate data to Word8 to fill into
ByteString, I got the exception.
Thanks. Now I understand the reason for that exception.
And I know it is no need to manually truncate data.
------------------
L.Guo
2007-05-25
-------------------------------------------------------------
From: Donald Bruce Stewart
At: 2007-05-25 15:33:46
Subject: Re: [Haskell-cafe] Why this exception occurs ?
dons:
> leaveye.guo:
> > Hi.
> >
> > In GHCi ver 6.6, why this happens ?
> >
> > Prelude Data.ByteString> Data.ByteString.pack $! Prelude.map (`rem` 256) $ [0..511]
> > "*** Exception: divide by zero
>
> It's the use of `rem` on Word8, by the way:
>
> Prelude> (0 `rem` 256) :: Data.Word.Word8
> *** Exception: divide by zero
>
Sorry, I should clarify, think about how to represent:
256 :: Word8
;-)
-- Don
More information about the Haskell-Cafe
mailing list