[Haskell-beginners] Re: question about styles of recursion
7stud
bbxx789_05ss at yahoo.com
Fri Mar 27 05:12:46 EDT 2009
Daniel Fischer <daniel.is.fischer <at> web.de> writes:
>
> (/) in the first equation is at type Double -> Double -> Double.
>
Then why don't I get an error here:
Prelude> 2 / 4
0.5
Prelude> 2 / fromIntegral 4
0.5
And why does this happen:
Prelude> let x = 2
Prelude> :type x
x :: Integer
Prelude> x / fromIntegral 4
<interactive>:1:0:
No instance for (Fractional Integer)
arising from a use of `/' at <interactive>:1:0-17
Possible fix: add an instance declaration for (Fractional Integer)
In the expression: x / fromIntegral 4
In the definition of `it': it = x / fromIntegral 4
And how do I read this type:
Prelude> :type fromIntegral
fromIntegral :: (Num b, Integral a) => a -> b
What does the => mean?
More information about the Beginners
mailing list