【发布时间】:2015-10-24 04:20:05
【问题描述】:
我正在尝试将 RealFrac 类型的数字提升到另一个数字的幂,同样是 RealFrac 类型。 This question on exponentiation 有助于解释 Haskell 中的各种幂函数,我相信我需要使用 (^) 来保留任何非整数值。但是我该如何处理这些类型呢?我不断遇到这样的错误:
Could not deduce (Integral a) arising from a use of ‘^’
from the context (RealFrac a)
bound by the type signature for
splitFunc :: RealFrac a => a -> a -> a
at Procedural/City.hs:41:16-42
Possible fix:
add (Integral a) to the context of
the type signature for splitFunc :: RealFrac a => a -> a -> a
In the expression: r ^ l
In an equation for ‘splitFunc’: splitFunc r l = r ^ l
【问题讨论】:
标签: haskell types exponentiation