当我尝试
> 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
类型的函数,其中a
是Bounded
。但是,它不接受任何参数。 Int maxBound
意味着您正在尝试使用数据构造函数Int
和参数maxBound
创建某些内容。对于您的特定错误消息,您尝试使用
Int
(它是一种类型)作为值,从而导致出现错误。导入Data.Int
将无济于事。