命令“ ghc”返回变量不在范围内

Jon*_*eil -1 haskell ghc

我从Haskell开始,尝试在Haskell中编译.ghci文件时遇到此奇怪的错误消息。我有这个非常简单的代码,例如:

main = do
    putStrLn "Greetings! What is your name?"
    inpStr <- getLine
    putStrLn $ "Welcome to Haskell, " ++ inpStr ++ "!"
Run Code Online (Sandbox Code Playgroud)

我将代码保存在一个名为basicio.hs并尝试运行的文件中, ghc basicio.hs 而不是字符串,我收到以下消息

<interactive>:2:1: error:
    Variable not in scope: runghc :: t0 -> b0 -> c

<interactive>:2:8: error: Variable not in scope: basicio
Run Code Online (Sandbox Code Playgroud)

我不确定出什么问题,命令“:load”可以正常工作并找到我的文件。

K. *_*uhr 5

此错误消息看起来像是通过runghc basicio在GHCi提示符下键入“ ” 生成的:

GHCi, version 8.6.5: http://www.haskell.org/ghc/  :? for help
Loaded GHCi configuration from ...
> runghc basicio

<interactive>:3:1: error: Variable not in scope: runghc :: t0 -> t

<interactive>:3:8: error: Variable not in scope: basicio
>
Run Code Online (Sandbox Code Playgroud)

但是,该runghc命令和编译器命令ghc均应直接从命令行运行。