我试图定义一个像“Int”这样的特定类型的值,但似乎Prelude不支持它?如何在Haskell的“let”表达式中使用“type”定义值?
Prelude> let c::Int = 4
Prelude|
<interactive>:49:8:
Illegal type signature: ‘Int’
Perhaps you intended to use ScopedTypeVariables
In a pattern type-signature
Prelude> let [Int]c=4
Prelude|
<interactive>:51:5: Parse error in pattern: [Int]
如何纠正它?
类型签名可以出现在自己的行上(在let,where或top level声明中)或表达式中。类型签名不适用于绑定的左侧。 –
[GHCi中的多行命令]可能重复(http://stackoverflow.com/questions/8443035/multi-line-commands-in-ghci) –
“如何更正它?” - 错误说明 - “也许你打算使用ScopedTypeVariables”。用':set -XScopedTypeVariables'在ghci中启用ScopedTypeVariables。也就是说,如果你想使用这个特定的语法。 – user2407038