Re: Odd side effect of using chr
Malcolm Wallace <[email protected]>
| Newsgroups | gmane.comp.lang.haskell.hugs.bugs |
|---|---|
| Organization | Dept of Computer Science, University of York |
| Message-ID | <[email protected]> |
Gavin Lowe <[email protected]> writes: > I think this is a hugs bug. It isn't. You will get the same behaviour in nhc98 and ghc. > Prelude> let g n = n^25 `mod` 18721 in g 4 > 17173 > > Prelude> let f n = snd( chr n, n^25 `mod` 18721 ) in f 4 > 0 The problem is with type-defaults for overloaded numbers. In the first example, n is inferred to be of type n :: Integral a => a which is defaulted to Integer. In the second example, because the type of chr is chr :: Int -> Char the type of n is inferred as Int, which cannot represent the value 4^25. Regards, Malcolm