GHC 6.8.1 RC debugger only breaking on first evaluation of a function

Olivier Boudry olivier.boudry at gmail.com
Tue Sep 18 15:20:49 EDT 2007


On 9/18/07, Pepe Iborra <mnislaih at gmail.com> wrote:
>
> Could you paste a ghci session demonstrating the problem?
>
>
Here is a very short and simple debug session showing the problem:

=======================================
*Main> :l debug68.hs
[1 of 1] Compiling Main             ( debug68.hs, interpreted )
Ok, modules loaded: Main.
*Main> :break qsort
Breakpoint 1 activated at debug68.hs:(1,0)-(3,55)
*Main> main
Stopped at debug68.hs:(1,0)-(3,55)
_result :: [a] = _
[debug68.hs:(1,0)-(3,55)] *Main> :delete *
[debug68.hs:(1,0)-(3,55)] *Main> :continue
[0,1,3,4,8,11,18,23]
*Main> :break qsort
Breakpoint 2 activated at debug68.hs:(1,0)-(3,55)
*Main> main
[0,1,3,4,8,11,18,23]
=======================================

The code:
=======================================
qsort [] = []
qsort (a:as) = qsort left ++ [a] ++ qsort right
  where (left,right) = (filter (<=a) as, filter (>a) as)

main = do
    print $ qsort [8, 4, 0, 3, 1, 23, 11, 18]
=======================================

The sequence is:
1: set a breakpoint at qsort
2: evaluate function main
3: execution stopped at qsort (as expected)
4: delete all breakpoints
5: set breakpoint at qsort again
6: evaluate function main
7: that lazy haskell show the result without stopping at the breakpoint

Just for fun I wrote an IO qsort function:

    qsortIO :: (Ord a) => [a] -> IO [a]
    qsortIO [] = return []
    qsortIO (a:as) = do
        l <- qsortIO left
        r <- qsortIO right
        return $ l ++ [a] ++ r
      where
        (left, right) = (filter (<=a) as, filter (>a) as)

and this one gets debugged on each run thanks to it's IO signature.

Hope this helps,

Best regards,

Olivier.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/glasgow-haskell-users/attachments/20070918/c7bb52e5/attachment.htm


More information about the Glasgow-haskell-users mailing list