当我尝试

> Int maxBound

在ghci中,我得到了
Not in scope: data constructor 'Int'

即使我import Data.Int,问题仍然存在。这里发生了什么?

最佳答案

编辑:该功能的官方文档位于http://www.haskell.org/ghc/docs/7.0.3/html/libraries/base-4.3.1.0/Prelude.html#v:maxBound

首先,您应该在做

Prelude> maxBound :: Int
9223372036854775807
Prelude>

如果您查看maxBound的类型签名:
Prelude> :t maxBound
maxBound :: (Bounded a) => a

然后maxBound是一个返回a类型的函数,其中aBounded。但是,它不接受任何参数。 Int maxBound意味着您正在尝试使用数据构造函数Int和参数maxBound创建某些内容。

对于您的特定错误消息,您尝试使用Int(它是一种类型)作为值,从而导致出现错误。导入Data.Int将无济于事。

10-07 19:20
查看更多