> Evaluating sum [1..100000] (compiled with hbc)
> results in a wrong value.
> Haskell seems to assume Int to be the
> correct type. But Integer is needed.
Haskell assumes nothing at all.  Haskell uses its default rules for
ambiguous type resolution, and the normal setting of this is that Int
is choosen when there is an ambiguity (your example is not quite big
enough to see if there is one, but I assume there was).  You can
change this with a "default" declaration in your module, or by giving
the type explicitely.

> Why doesn't any error-message (like "overflow")
> occur during evaluation?
The behaviour of arithmetic overflow is undefined in Haskell.
HBC silently ignores overflow and you get just lets the result "wrap around".
This means that that the type Int (with its operations) is still a
commutative ring (but not an integral domain), which some prefer (like me)
over making all operations on it partial functions.

        -- Lennart

Reply via email to