2
考慮以下人爲的例子內的值:調試/檢查功能
module Main where
myadd3 first second third =
let result1 = first -- line 3
result2 = second -- line 4
result3 = third -- line 5
in result1 + result2 + result3 -- line 6
我想檢查的result1
值,result2
,和result3
由時間我到達線6然而,當我通過步驟代碼,在任何時候,做任何這些「計算」的出現可供查閱:
*Main> :break 3
Breakpoint 0 activated at Main4.hs:3:17-21
*Main> :break 4
Breakpoint 1 activated at Main4.hs:4:17-22
*Main> :break 5
Breakpoint 2 activated at Main4.hs:5:17-21
*Main> :break 6
Breakpoint 3 activated at Main4.hs:6:6-32
*Main> myadd3 2 3 4
Stopped at Main4.hs:6:6-32
_result :: a = _
result1 :: a = _
result2 :: a = _
result3 :: a = _
[Main4.hs:6:6-32] *Main> :step
Stopped at Main4.hs:6:6-22
_result :: a = _
result1 :: a = _
result2 :: a = _
[Main4.hs:6:6-22] *Main> :step
Stopped at Main4.hs:3:17-21
_result :: Integer = _
first :: Integer = 2
[Main4.hs:3:17-21] *Main> :step
Stopped at Main4.hs:4:17-22
_result :: Integer = _
second :: Integer = 3
[Main4.hs:4:17-22] *Main> :step
Stopped at Main4.hs:5:17-21
_result :: Integer = _
third :: Integer = 4
[Main4.hs:5:17-21] *Main> :step
9
也就是說我們有像result1 :: a = _
線,但沒有像result1 :: a = 2
。這是因爲哈斯克爾懶惰的本質嗎?如果是的話,是否有辦法檢查result1
,result2
和result3
當時值是綁定到他們?謝謝