Impressions on GHC debugger

Alexey Rodriguez Yakushev mrchebas at
Thu Apr 19 09:47:03 EDT 2007

Dear all,

Yesterday I darcs-got the GHC HEAD to play with the debugger and I  
have the following impressions/bug/suggestions:

* I would like to know whether I am debugging mode (i.e. in a  
breakpoint) or not. For example

 > *Main>  -- normal prompt

and, for example,

 > *Main:[1] >  -- in breakpoint 1

now, if I evaluate expression "e" via "seq e ()" and it happens to  
trigger breakpoint 2, I would like to see something like

 > *Main:[1]:[2] >

or some better notation, but you get my point.

* The notation for printing a list is non-Haskell, consider the  
following evaluated head but unevaluated tail:

 > *Main> :print xs
 > xs = [True | (_t2::[Bool])]

I would have expected "True : (_t2::[Bool])"

* Consider the following code:

 > mymap f [] = []
 > mymap f (x:xs) = f x:mymap f xs
 > main = mapM_ putStrLn $ mymap ('a':) ["hello","bye"]

First, I set a breakpoint on line two. When I invoke "main", the  
breakpoint is triggered two times before "main" is done evaluating.  
Afterwards, If I type "main" at the ghci prompt again, the breakpoint  
is not triggered anymore! Even though ":show breaks" lists it.

* Again considering the code above, if I break at line 2:

 > Stopped at FreeVar2.hs:2:17-19
 > x :: GHC.Base.Unknown
 > f :: t -> a
 > xs :: [GHC.Base.Unknown]

Now I type "f" and the following message appears:

 > *** Exception: No match in record selector Var.tcTyVarDetails

* I was wondering whether it would be nice to have a "break" function/ 
primitive, so that you can write:

 > mymap f [] = []
 > mymap f (x:xs) = (break (f x):mymap f xs)

with "break" having type "a -> a" and inserting a breakpoint around  
the argument expression. It is handy to not have to recalculate  
lines. However I am not so sure anymore. Using line numbers is not as  
bad as I thought.

The debugger is a nice addition to GHC, and I look forward to the  
debugger being integrated into the Emacs Haskell mode!



More information about the Glasgow-haskell-users mailing list