logo       

Re: Begginer question: msg#00058

lang.haskell.cafe

Subject: Re: Begginer question

Ketil Malde wrote:
Maurício <briqueabraque@xxxxxxxxx> 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


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise