[Haskell-cafe] Dividing integers?
matiash at artech.com.uy
Thu Mar 18 10:55:53 EST 2004
Although you might not believe it since I'm going to ask a very very very basic question, I have been using Haskell for educational purposes for a couple semesters now. Nevertheless, I don't think I have ever worked with non-Int number types! :)
I don't understand why I get this error. I mean, apparently "/" is not defined for integers but I don't know how to "cast" the result of the length function into a Double...
Prelude> (length [1,2]) / 3
No instance for (Fractional Int)
arising from use of `/' at <interactive>:1
In the definition of `it': it = (length [1, 2]) / 3
Besides, a simple integer division works:
Prelude> 2 / 3
But I would guess that's because '2' and '3' are parsed as Floats because they are used in a divide function.
Any help will be appreciated!
More information about the Haskell-Cafe