Feature not evaluated in the GHCI

If I assign var maxBound:

let bInt = maxBound

      

pricing bInt

prints ()

but if i type bInt

bInt :: Int
prints : 9223372036854775807

      

Why bInt is not evaluated until I type

bInt (bInt :: Int) ?

      

+3


source to share


1 answer


maxBound

is a function of the class Bounded

. By default, GHCi appears to select the instance for ()

that returns ()

. You can force it to use a different instance by adding a type signature.



let bInt :: Int; bInt = maxBound
bInt -- 9223372036854775807

let x = maxBound
x :: () -- ()
x :: Bool -- True
x :: Char -- '\1114111'

      

+4


source







All Articles