[Haskell-cafe] Int vs Integer?
Daniel Carrera
dcarrera at digitaldistribution.com
Thu May 5 03:23:52 EDT 2005
Hello,
What's the difference between "Int" and "Integer"?
How can I tell Haskell which one I want? I'm having trouble with a function:
ints = 0 : map (1+) ints
prng = map iter ints
where iter 0 = [0,0]
iter n = [i,j]
where i = mod n 256
j = ints !! i
(eventually 'iter' will be more a more interesting function).
When I try to load this module in Hugs I get the error:
ERROR "./PRNG.hs":24 - Type error in list
*** Expression : [i,j]
*** Term : j
*** Type : Integer
*** Does not match : Int
Line 24 is the 'prng' line. I've spent all day trying to fix this, but
for the life of me I can't figure out why it happens or how to make it
stop. Haskell just doesn't seem to like the 'iter !! i' construct.
It's interesting that if you replace 'i' by (say) 3, Haskell runs the
program happily. But, if you replace 'i = mod n 256' by 'i=3' you get
the same error.
Any words of wisdom would be appreciated.
Cheers,
Daniel.
More information about the Haskell-Cafe
mailing list