Marco,
I have heard this referred to as the "dreaded monomorphism
restriction". It's a "feature" of the Haskell language, not a bug in
hugs. GHC might have an extension that (partially) eliminates the
restriction. Unfortunately, I don't quite remember what the restriction
is. I'm sure many others on this list will be able to explain it.
Thanks,
Matt Harden
Marco Lombardi wrote:
>
> Dear Sir,
>
> playing with Hugs I have found a strange behavior that could be the
> symptom of a bug. Please note that I am using the last version of Hugs
> (February 2000) with the type checker fix suggested in the bug page.
>
> If I define the function
>
> f x = x + x
>
> and then ask Hugs to report the type, I get a very reasonable answer:
>
> f :: Num a => a -> a
>
> The same happens if I directly ask the type of the lambda abstraction
> \x -> x + x. In other words, the command
>
> > :type \x -> x + x
>
> gives the answer
>
> \x -> x + x :: Num a => a -> a
>
> If now I define
>
> g = \x -> x + x
>
> I get the surprising type
>
> g :: Integer -> Integer
>
> Analogously, using "g 2.5" produces the error
>
> *** Expression : g 2.5
> *** Type : Fractional Integer => Integer
>
> Is this normal or is really a bug? Please note that the Glasgow
> Haskell Compiler seems to identify the correct type for both f and g.
>
> Best regards,
>
> Marco Lombardi
>
> _____________________________________________________________________
>
> Marco Lombardi
>
> Scuola Normale Superiore European Southern Observatory
> P.zza dei Cavalieri 7 Karl-Schwarzschild-Str. 2
> I-56100, Pisa, Italy D-85748, Garching, Germany
> tel.: +39-050-509111 tel.: +49-(0)89-32006362
> fax: +39-050-563513 fax: +49-(0)89-3202362
> e-mail: [EMAIL PROTECTED] e-mail: [EMAIL PROTECTED]
> _____________________________________________________________________