On 9/18/07, <b class="gmail_sendername">Pepe Iborra</b> <<a href="mailto:mnislaih@gmail.com">mnislaih@gmail.com</a>> wrote:<div><span class="gmail_quote"></span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Could you paste a ghci session demonstrating the problem?<br><br></blockquote></div><br>Here is a very short and simple debug session showing the problem:<br>
<br>
=======================================<br>
*Main> :l debug68.hs<br>
[1 of 1] Compiling Main ( debug68.hs, interpreted )<br>
Ok, modules loaded: Main.<br>
*Main> :break qsort<br>
Breakpoint 1 activated at debug68.hs:(1,0)-(3,55)<br>
*Main> main<br>
Stopped at debug68.hs:(1,0)-(3,55)<br>
_result :: [a] = _<br>
[debug68.hs:(1,0)-(3,55)] *Main> :delete *<br>
[debug68.hs:(1,0)-(3,55)] *Main> :continue<br>
[0,1,3,4,8,11,18,23]<br>
*Main> :break qsort<br>
Breakpoint 2 activated at debug68.hs:(1,0)-(3,55)<br>
*Main> main<br>
[0,1,3,4,8,11,18,23]<br>
=======================================<br>
<br>
The code:<br>
=======================================<br>
qsort [] = [] <br>
qsort (a:as) = qsort left ++ [a] ++ qsort right<br>
where (left,right) = (filter (<=a) as, filter (>a) as)<br>
<br>
main = do<br>
print $ qsort [8, 4, 0, 3, 1, 23, 11, 18]<br>
=======================================<br><br><span class="gmail_quote"></span>The sequence is:<br>1: set a breakpoint at qsort<br>2: evaluate function main<br>3: execution stopped at qsort (as expected)<br>4: delete all breakpoints
<br>5: set breakpoint at qsort again<br>6: evaluate function main<br>7: that lazy haskell show the result without stopping at the breakpoint<br><br>Just for fun I wrote an IO qsort function:<br><br> qsortIO :: (Ord a) => [a] -> IO [a]
<br> qsortIO [] = return []<br> qsortIO (a:as) = do<br> l <- qsortIO left<br> r <- qsortIO right<br> return $ l ++ [a] ++ r<br> where<br> (left, right) = (filter (<=a) as, filter (>a) as)
<br><br>and this one gets debugged on each run thanks to it's IO signature.<br><br>Hope this helps,<br><br>Best regards,<br><br>Olivier.<br>