Marc van Dongen= writes:
> 
> I suspect the program included below is
> incorrect. Nevertheless it compiles fine under
> ghc-3.01 patchlevel 0.
> 
> > module Main( main ) where
> > import List( genericLength )
> > main = putStr (show integral) >>
> >        putStr "\n"            >>
> >        return ()
> >      where integral = genericLength []
> 
> The reason why I am having problems with this
> program is that I cannot infer whether integral
> should be an Int or an Integer.
> 

This is a legal Haskell program. The (ambiguous) type of `integral' is
(Num a => a), but Haskell disambiguates numeric expressions with the
help of `default' declarations. As per Haskell 1.4 (see section 4.3.4
of the report), this means resolving `integral' to be a value of type
Int.

> ghc-3.01 thinks integral is an Int (a big
> positive integral is sometimes shown as a
> negative number).

ghc's implementation of Ints doesn't do overflow checking, so this is
not too surprising. Disambiguate your program either by using type
annotations telling the compiler that `integral' really is an Integer
or use a `default' declaration.

--Sigbjorn

Reply via email to