我是Haskell的新手,仍然无法弄清楚这些类型的问题。我收到以下函数的错误:
computeTriUp :: Point -> Float -> [Point]
computeTriUp center r = [(x + r*cos(pi/2.0), y+r*sin(pi/2.0)), (x+r*cos(5.0*pi/4.0), y+r*sin(5.0*pi/4.0)), (x+r*cos(7.0*pi/4.0), y+r*sin(7.0*pi/4.0))]
where x = fst center
y = snd center
我的错误是:
Couldn't match expected type `Int' with actual type `Float'
In the first argument of `(*)', namely `r'
In the second argument of `(+)', namely `r * cos (pi / 2.0)'
In the expression: x + r * cos (pi / 2.0)
有什么想法吗? 谢谢!
答案 0 :(得分:2)
假设Point是一对Ints,您可能想要更改x和y的定义以将它们转换为Floats ...
x = fromIntegral $ fst centre