如何修复默认使用以下约束进行类型.哈斯克尔



我有以下辅助方法

distance :: Segment -> Length
distance ((ax, ay), (bx, by)) = sqrt ((bx-ax)^2 + (by-ay)^2)

我收到警告

polycake.hs:115:46: Warning:
Defaulting the following constraint(s) to type ‘Integer’
  (Integral b0) arising from a use of ‘^’ at polycake.hs:115:46
  (Num b0) arising from the literal ‘2’ at polycake.hs:115:47
In the first argument of ‘(+)’, namely ‘(bx - ax) ^ 2’
In the first argument of ‘sqrt’, namely
  ‘((bx - ax) ^ 2 + (by - ay) ^ 2)’
In the expression: sqrt ((bx - ax) ^ 2 + (by - ay) ^ 2)

我也无法抑制警告,正在寻找一种将其显式转换为类型的方法。

注释

每个2,如

(bx-ax)^(2 :: Integer)

最新更新