
3 Oct
2006
3 Oct
'06
1:57 p.m.
On 10/3/06, Edward Ing
The source is below. Side is types as Float. My assumption was that Haskell would know how to convert the Int to a float and all would be well. I am I mistaken somewhere? The problem is with the last line.
Yes - Haskell does not automatically promote numeric types. In this case, the following code compiles: vertex :: Vertex -> Int -> Int -> Side -> Vertex vertex (a ,b) currentSide totalSides length = let angle = (360 / fromIntegral totalSides) * fromIntegral currentSide in ( a + ( length * (sin angle)), b + ( (*) (cos angle) length ) ) although I'm not sure it's exactly what you want. /g