Given:
λ: let x = 1 + 2
I run sprint
to print its value:
λ: :sprint x
x = _
As expected, it's unevaluated.
But, after evaluating x
:
λ: x
3
sprint
still outputs _
, i.e. unevaluated:
λ: :sprint x
x = _
Why is that?
It's because x
is polymorphic.
Compare with:
Prelude> let x = 1 + 2 :: Int
Prelude> :sprint x
x = _
Prelude> x
3
Prelude> :sprint x
x = 3
Prelude>
When x
is polymorphic GHCI cannot replace the thunk with a specific value since you might evaluate it later as a different type.