2014-02-28 3 views
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 

가 나는 단계별 그러나 때 라인 (6)에 도달 result1의 값을 검사 할 때에는 result2result3 싶습니다에게 코드가, 어떤 점에서이 "계산"중 하나를 수행 검사를 위해 사용할 수 표시 : 우리가 result1 :: a = _ 같은 라인이 아닌 result1 :: a = 2 같은 것을 가지고있다

*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, result2result3을 검사 할 수있는 방법이 있습니까? 감사합니다

답변

3

당신은 행동이 게으름으로 인한 것이라는 사실을 알고 있습니다. 평가를 수행하려면 다음을 수행하십시오.

[debug.hs:6:6-32] *Main> :print result1 
result1 = (_t1::a) 
[debug.hs:6:6-32] *Main> :force result1 
*** Ignoring breakpoint 
result1 = 2 
[debug.hs:6:6-32] *Main> :step 
Stopped at debug.hs:6:6-22 
_result :: Integer = _ 
result1 :: Integer = 2 
result2 :: Integer = _