Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Function not evaluating in GHCI

Tags:

haskell

ghci

If I assign a var to maxBound :

let bInt = maxBound

evaluation of bInt prints ()

but if I type bInt

bInt :: Int
prints : 9223372036854775807

Why does bInt not evaluate until I type

bInt (bInt :: Int) ?
like image 483
blue-sky Avatar asked Aug 29 '26 10:08

blue-sky


1 Answers

maxBound is a function in the Bounded type class. By default, GHCi appears to choose the instance for (), which returns (). You can force it to use another instance by adding a type signature.

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

let x = maxBound
x :: () -- ()
x :: Bool -- True
x :: Char -- '\1114111'
like image 142
Taylor Fausak Avatar answered Aug 31 '26 23:08

Taylor Fausak