我正尝试在haskell中的一个类中执行main方法。当我运行命令runhaskell mod12PA.hs时,我得到一个错误,并且我不知道为什么。
代码如下:
-- The main program: read points from stdin, write an SVG file to stdout.
main :: IO ()
main = do
putStrLn "Enter points: "
points <- getLine
putStrLn ("Points: " ++ points)错误:
<interactive>:41:1: error:
Variable not in scope: runhaskell :: t0 -> b0 -> c
<interactive>:41:12: error: Variable not in scope: mod12PA
<interactive>:41:20: error: Variable not in scope: hs :: a -> b0发布于 2017-03-25 07:30:00
我知道我需要在ghci之外编译文件,然后运行可执行文件。我试图从ghci中执行该文件,但该文件不起作用。
Ran ghc --make mod12PA.hs
然后是mod12PA.exe
发布于 2017-03-25 08:09:03
虽然您确实需要在GHCi之外运行该命令,但runhaskell mod12PA.hs应该可以工作。(与ghc --make不同,runhaskell的用途不同:它运行代码而不编译代码。)
https://stackoverflow.com/questions/43010618
复制相似问题