【发布时间】:2011-08-18 07:57:09
【问题描述】:
这是一个非常愚蠢的问题,但我有点迷路了。这是函数
f :: (Bool,Int) -> Int
f (True,n) = round (2 ** n)
f (False,n) = 0
这是我遇到的一个错误
No instance for (Floating Int)
arising from a use of `**'
Possible fix: add an instance declaration for (Floating Int)
In the first argument of `round', namely `(2 ** n)'
In the expression: round (2 ** n)
In an equation for `f': f (True, n) = round (2 ** n)
我应该添加什么才能使其正常工作?
【问题讨论】:
标签: haskell floating-point int typeclass