2
*> sin sin 0.5
<interactive>:10:1:
Non type-variable argument in the constraint: Floating (a -> a)
(Use FlexibleContexts to permit this)
When checking that ‘it’ has the inferred type
it :: forall a. (Floating a, Floating (a -> a)) => a
但是sin (sin 0.5)
有效。
我认为它们是相同的,我无法理解错误信息。
我想知道为什么?haskell中的“sin sin 0.5”和“sin(sin 0.5)”有什么区别?
它们不相同。函数应用程序是左关联的,因此“sin sin 0.5”实际上是“(sin sin)0.5”,这不是你的意思,并导致类型错误。 – duplode
[了解Haskell优先级规则如何与多个部分应用程序一起工作]的部分副本(http://stackoverflow.com/questions/17243075/understanding-how-haskell-precedence-rules-work-with-multiple-partial-applicatio) – duplode