Using "GHC as a library" with own functions makes runStmt return RunBreak

Hi I am trying to use "GHC as a library". From runStmt, I want to load and run functions from a home-grown module. Lets call my home-grown module HomeGrown.hs. I have tried to model my application after http://haskell.org/sitewiki/images/1/17/Interactive-6.8.hs / http://haskell.org/sitewiki/images/f/f9/MyPrelude.hs from http://haskell.org/haskellwiki/GHC/As_a_library . This library loads MyPrelude.hs and runs myPutStrLn & myGetLine + more. However, when I try to run code from HomeGrown.hs like: runStmt session "HomeGrown.foo" GHC.SingleStep runStmt keeps returning RunBreak (of type RunResult). From what I can read of the WWW, RunBreak is related to some debugger and indicate that GHC encountered some breakpoint. However, I did not set any break points. Comparing Interactive-6.8 and MyPrelude.hs to my own code, the largest difference seemed to be that Interactive-6.8 do not only use MyPrelude.hs by calling `addTarget` and `setContext`, it also imports MyPrelude.hs as a regular Haskell import (import MyPrelude). Thus I tried to remove this import to see what would happen. Interactive-6.8 compiled and started just fine. However, whenever it needed to use any functions in MyPrelude, runStmt also returned RunBreak. So is it only possible to load home-grown/non-standard modules when also doing a regular import? Greetings, Mads Lindstrøm

Mads Lindstrøm
So is it only possible to load home-grown/non-standard modules when also doing a regular import?
Here I really mean: So is it only possible to load home-grown/non-standard modules _without_ also doing a regular import? I could also pose my question differently as: If I remove this line in Interactive-6.8.hs: import MyPrelude then how would I change Interactive-6.8.hs and/or MyPrelude.hs, so that it was still possible to use the functions in MyPrelude.hs. It seems to me that the import should not be necessary. If it is necessary, then how is one to make use of modules not know at compile-time (of Interactive-6.8.hs or similar)? Note that Interactive-6.8.hs compiles and starts without trouble, even though "import MyPrelude" is removed. The trouble only arises when runStmt calls the functions inside of MyPrelude. For those who cares, I have tested my code on both GHC 6.8.1 and 6.8.2. Also I am using Debian Linux. Greetings, Mads Lindstrøm

Mads Lindstrøm
Hi
I am trying to use "GHC as a library". From runStmt, I want to load and run functions from a home-grown module. Lets call my home-grown module HomeGrown.hs.
I have tried to model my application after http://haskell.org/sitewiki/images/1/17/Interactive-6.8.hs / http://haskell.org/sitewiki/images/f/f9/MyPrelude.hs from http://haskell.org/haskellwiki/GHC/As_a_library . This library loads MyPrelude.hs and runs myPutStrLn & myGetLine + more.
However, when I try to run code from HomeGrown.hs like:
runStmt session "HomeGrown.foo" GHC.SingleStep
runStmt keeps returning RunBreak (of type RunResult). From what I can read of the WWW, RunBreak is related to some debugger and indicate that GHC encountered some breakpoint. However, I did not set any break points.
For those interested I figured out how to avoid the RunBreak -returns. Use RunToCompletion in stead of SingleStep in the application of runStmt. I guess Interactive-6.8.hs should also use SingleStep. Greetings, Mads Lindstrøm

Mads Lindstrøm wrote:
For those interested I figured out how to avoid the RunBreak -returns. Use RunToCompletion in stead of SingleStep in the application of runStmt. I guess Interactive-6.8.hs should also use SingleStep.
SingleStep is what GHCi uses to implement :step - that is, it runs until the next breakpoint location and then stops, returning RunBreak to the caller of runStmt. To run the whole statement, what you want is RunToCompletion, as you discovered. Cheers, Simon
participants (2)
-
Mads Lindstrøm
-
Simon Marlow