[Haskell-cafe] Re: Begginer question

Maurício briqueabraque at yahoo.com
Thu Jan 6 09:06:58 EST 2005


Ketil Malde wrote:
> Maurício <briqueabraque at yahoo.com> writes:
> 
>  > (...)
> 
>>Couldn't match `Float' against `Complex Float'
>>         Expected type: Float
>>         Inferred type: Complex Float
>>     In the second argument of `(+)', namely `sqr_delta'
>>     In the definition of `x1': x1 = (b + sqr_delta)
> 
> 
> The error message says it all, really.
> 
> > (...)
> 
> Note that Haskell doesn't automatically convert arguments for you --
> this is a feature.  
> 
> -kzm

   When I type this:

*****
import Complex;
a = 3 :+ 4;
*****

and load it into ghci, "a + 4" gives me "7.0 :+ 4.0", although "a + 
(4::Float)" gives me that error again. Why Haskell converts "4" to 
Complex but not a Float?

   Maurício




More information about the Haskell-Cafe mailing list