why does not Int maxBound work?
EDIT: The official docs for the function are at http://www.haskell.org/ghc/docs/7.0.3/html/libraries/base-4.3.1.0/Prelude.html#v:maxBound
To begin with, you should be doing
Prelude> maxBound :: Int
9223372036854775807
Prelude>
If you look at the type signature of maxBound
:
Prelude> :t maxBound
maxBound :: (Bounded a) => a
Then maxBound
is a function that returns something of type a
, where a
is Bounded
. However, it does not accept any parameters. Int maxBound
means that you are trying to create something with data constructor Int
and parameter maxBound
.
For your specific error message, you are trying to use Int
- which is a type - as a value, resulting in the error you are getting. Importing Data.Int
won't help.
That's not valid Haskell.
maxBound
is a constant that defines the maximum element of types that are in the Bounded
class:
Prelude> :t maxBound
maxBound :: Bounded a => a
To get the bound for any particular type, you need to specialize it to a particular type. Type annotations are given by ::
syntax on expressions, like so:
Prelude> maxBound :: Int
9223372036854775807