GHCI breakpoint problems
Here is the toys function defined in the file, call it test.hs:
x a b c = do
putStrLn $ show a
return a
You can of course import it into GHCI and set a breakpoint:
λ :load test.hs
[1 of 1] Compiling Main ( test.hs, interpreted )
Ok, modules loaded: Main.
λ :break x
Breakpoint 3 activated at test2.hs:(1,1)-(3,12)
λ x 1 2 3
Stopped at test2.hs:(1,1)-(3,12)
_result :: IO b = _
However, there doesn't seem to be a way to test the b and c arguments.
Is there a way to get around this? I am running GHCi 7.8.4.
From the GHC User Guide :
GHCi provided bindings for free variables [6] of the expression on which the breakpoint was set ...
[6] We initially provided bindings for all variables in scope, rather than just free expression variables, but found that this is greatly reduced, hence the current restriction on just free variables.
I found a hacky workaround. If you redefine function x as follows:
x a b c = do
return a; return b; return c;
putStrLn $ show a
return a
Then you need to call: step and then check b and c:
λ :break x
Breakpoint 4 activated at test2.hs:(1,1)-(4,12)
λ x 1 2 3
Stopped at test2.hs:(1,1)-(4,12)
_result :: IO b = _
λ :step
Stopped at test2.hs:(1,11)-(4,12)
_result :: IO Integer = _
a :: Integer = 1
b :: Integer = 2
c :: Integer = 3
It would be nice if there was a way to do this without overriding the function.