How do I force interpretation mode in Hint (Language.Haskell.Interpreter)?
I have this code:
module Main where
import Language.Haskell.Interpreter
import Control.Monad
main = do
res <- runInterpreter (test "test")
case res of
Left e -> putStrLn (show e)
Right t -> putStrLn (show t)
return ()
test :: String -> Interpreter ()
test mname =
do
loadModules [mname ++ ".hs"]
setTopLevelModules ["Main"]
Will result in (based on the answers from here):
NotAllowed "These modules are not interpreted:\nMain\n"
only if GHC finds test.o!
I've tried
unsafeSetGhcOption ("-fbyte-code")
Using the
-fforce-recomp
option seems to force interpretation when used from GHCi/Hint.Although I could not find any documentation to verify this, it seems reasonable that GHCi/Hint would reuse the recompilation checking from GHC.
UPDATE: Digging around a bit more I found GHC ticket #2542, where it is stated that prefixing the module name with an asterisk will force interpretation in GHCi. This is also confirmed in the documentation.
This appears to carry over to Hint as well, so this also works: