Dan*_*l O 2 haskell hint ghc ghc-api
为什么不能在提示(Language.Haskell.Interpreter)中将顶级模块设置为"Main"?
请允许我证明:
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"]
Run Code Online (Sandbox Code Playgroud)
将导致:
NotAllowed "These modules are not interpreted:\nMain\n"
Run Code Online (Sandbox Code Playgroud)