[Haskell-cafe] Binding of an integer variable

Brandon Allbery allbery.b at gmail.com
Thu Jul 28 20:52:06 CEST 2011


On Thu, Jul 28, 2011 at 14:43, Paul Reiners <paul.reiners at gmail.com> wrote:

> I have a question about the following GHCi interaction:
>
> Prelude> let x = 23
> Prelude> :show bindings
> x :: Integer = _
>
> What is the meaning of the underscore in the third line?  Why doesn't it
> say this, instead?
>

The underscore indicates an unevaluated thunk.  In this case it's because
numeric literals are translated into function calls (in this case (fromInteger
23); even though GHCi has already applied defaulting to the type, it still
hasn't evaluated the *value* yet, and won't until it's needed due to
laziness.  If you do something like show x then the binding will be updated
to show the actual value.

-- 
brandon s allbery                                      allbery.b at gmail.com
wandering unix systems administrator (available)     (412) 475-9364 vm/sms
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20110728/987ab2a9/attachment.htm>


More information about the Haskell-Cafe mailing list